Initial commit
This commit is contained in:
214
ruoyi-ui/src/views/monitor/version/index.vue
Normal file
214
ruoyi-ui/src/views/monitor/version/index.vue
Normal file
@@ -0,0 +1,214 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="getVersionInfo">刷新版本信息</el-button>
|
||||
<el-button type="success" icon="el-icon-upload" size="mini" @click="handleUpload" v-hasPermi="['system:version:upload']">上传新版本</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 版本信息卡片 -->
|
||||
<el-row class="mb8">
|
||||
<el-col s>
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>当前版本信息</span>
|
||||
</div>
|
||||
<div class="version-info">
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="当前版本">
|
||||
<el-tag type="primary" size="medium">{{ versionInfo.currentVersion }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">
|
||||
{{ parseTime(versionInfo.updateTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="下载链接" v-if="versionInfo.downloadUrl">
|
||||
<el-link :href="versionInfo.downloadUrl" target="_blank" type="primary">
|
||||
{{ versionInfo.downloadUrl }}
|
||||
</el-link>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 上传对话框 -->
|
||||
<el-dialog title="上传新版本" :visible.sync="uploadVisible" width="500px" append-to-body>
|
||||
<el-form ref="uploadForm" :model="uploadForm" :rules="uploadRules" label-width="80px">
|
||||
<el-form-item label="版本号" prop="version">
|
||||
<el-input v-model="uploadForm.version" placeholder="请输入版本号,如:2.1.0"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="版本文件" prop="file">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
action="#"
|
||||
:limit="1"
|
||||
accept=".exe"
|
||||
:on-exceed="handleExceed"
|
||||
:file-list="fileList"
|
||||
:auto-upload="false"
|
||||
:on-change="handleFileChange"
|
||||
:on-remove="handleFileRemove">
|
||||
<el-button slot="trigger" size="small" type="primary">选择文件</el-button>
|
||||
<div slot="tip" class="el-upload__tip">只能上传exe文件,且不超过800MB</div>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="uploadVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submitUpload" :loading="uploadLoading">{{ uploadLoading ? '上传中...' : '确 定' }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getVersionInfo, uploadFile, updateVersion } from "@/api/monitor/version"
|
||||
|
||||
export default {
|
||||
name: "Version",
|
||||
data() {
|
||||
return {
|
||||
// 查询参数
|
||||
queryParams: {},
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 版本信息
|
||||
versionInfo: {
|
||||
currentVersion: '2.0.0',
|
||||
updateTime: null,
|
||||
downloadUrl: null
|
||||
},
|
||||
// 版本检查表单
|
||||
checkForm: {
|
||||
testVersion: '1.0.0'
|
||||
},
|
||||
// 检查结果
|
||||
checkResult: null,
|
||||
// 检查加载状态
|
||||
checkLoading: false,
|
||||
// 上传对话框
|
||||
uploadVisible: false,
|
||||
// 上传表单
|
||||
uploadForm: {
|
||||
version: '',
|
||||
file: null
|
||||
},
|
||||
// 上传规则
|
||||
uploadRules: {
|
||||
version: [
|
||||
{ required: true, message: "版本号不能为空", trigger: "blur" },
|
||||
{ pattern: /^\d+\.\d+\.\d+$/, message: "版本号格式不正确,应为x.y.z格式", trigger: "blur" }
|
||||
],
|
||||
file: [
|
||||
{ required: true, message: "请选择要上传的文件", trigger: "change" }
|
||||
]
|
||||
},
|
||||
// 文件列表
|
||||
fileList: [],
|
||||
// 上传加载状态
|
||||
uploadLoading: false,
|
||||
// 上传进度
|
||||
uploadProgress: 0
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getVersionInfo();
|
||||
},
|
||||
methods: {
|
||||
/** 查询版本信息 */
|
||||
getVersionInfo() {
|
||||
getVersionInfo().then(response => {
|
||||
this.versionInfo = response.data;
|
||||
});
|
||||
},
|
||||
|
||||
/** 处理上传 */
|
||||
handleUpload() {
|
||||
this.uploadVisible = true;
|
||||
this.resetUploadForm();
|
||||
},
|
||||
/** 重置上传表单 */
|
||||
resetUploadForm() {
|
||||
this.uploadForm = {
|
||||
version: '',
|
||||
file: null
|
||||
};
|
||||
this.fileList = [];
|
||||
this.uploadProgress = 0;
|
||||
if (this.$refs.uploadForm) {
|
||||
this.$refs.uploadForm.resetFields();
|
||||
}
|
||||
},
|
||||
/** 文件超出限制 */
|
||||
handleExceed() {
|
||||
this.$modal.msgError("只能选择一个文件");
|
||||
},
|
||||
/** 文件改变 */
|
||||
handleFileChange(file, fileList) {
|
||||
this.uploadForm.file = file.raw;
|
||||
this.fileList = fileList;
|
||||
},
|
||||
/** 文件移除 */
|
||||
handleFileRemove() {
|
||||
this.uploadForm.file = null;
|
||||
this.fileList = [];
|
||||
},
|
||||
/** 提交上传 */
|
||||
submitUpload() {
|
||||
this.$refs.uploadForm.validate(valid => {
|
||||
if (valid) {
|
||||
if (!this.uploadForm.file) {
|
||||
this.$modal.msgError("请选择要上传的文件");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.uploadForm.file.size > 800 * 1024 * 1024) {
|
||||
this.$modal.msgError("文件大小不能超过800MB");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.uploadForm.file.name.endsWith('.exe')) {
|
||||
this.$modal.msgError("只支持上传.exe文件");
|
||||
return;
|
||||
}
|
||||
|
||||
this.uploadLoading = true;
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('files', this.uploadForm.file);
|
||||
|
||||
uploadFile(formData).then(response => {
|
||||
if (response && response.data[0]) {
|
||||
const fileInfo = response.data[0];
|
||||
const downloadUrl = fileInfo.fileUrl || fileInfo.url;
|
||||
updateVersion({
|
||||
version: this.uploadForm.version,
|
||||
downloadUrl: downloadUrl
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess("版本文件上传成功");
|
||||
this.uploadVisible = false;
|
||||
this.uploadLoading = false;
|
||||
this.getVersionInfo();
|
||||
});
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$modal.msgError("文件上传失败");
|
||||
this.uploadLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.version-info {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.box-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user