前端更改
This commit is contained in:
27
acs2/nladmin-ui/src/api/system/version.js
Normal file
27
acs2/nladmin-ui/src/api/system/version.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前版本信息
|
||||||
|
* @returns {AxiosPromise}
|
||||||
|
*/
|
||||||
|
export function getCurrentVersion() {
|
||||||
|
return request({
|
||||||
|
url: '/api/version/current',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布版本更新通知
|
||||||
|
* @param {Object} data - { version, title, content }
|
||||||
|
* @returns {AxiosPromise}
|
||||||
|
*/
|
||||||
|
export function releaseVersion(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/version/release',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { getCurrentVersion, releaseVersion }
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
:visible.sync="dialogVisible"
|
||||||
|
:show-close="false"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
:title="$t('auto.version.title')"
|
||||||
|
width="600px"
|
||||||
|
>
|
||||||
|
<div class="version-notification">
|
||||||
|
<div class="version-info">
|
||||||
|
<span class="label">{{ $t('auto.version.versionNo') }}:</span>
|
||||||
|
<el-tag type="success" size="medium">v{{ versionInfo.version }}</el-tag>
|
||||||
|
</div>
|
||||||
|
<div v-if="versionInfo.releaseTime" class="version-info">
|
||||||
|
<span class="label">{{ $t('auto.version.releaseTime') }}:</span>
|
||||||
|
<span>{{ versionInfo.releaseTime }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="versionInfo.content" class="version-content">
|
||||||
|
<div class="label">{{ $t('auto.version.content') }}:</div>
|
||||||
|
<div class="content-body" v-html="versionInfo.content" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="handleConfirm">{{ $t('auto.version.confirm') }}</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getCurrentVersion } from '@/api/system/version'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'VersionNotification',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
versionInfo: {
|
||||||
|
version: '',
|
||||||
|
releaseTime: '',
|
||||||
|
content: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
hasShown() {
|
||||||
|
return this.dialogVisible
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 检查版本是否需要弹窗
|
||||||
|
* @param {string} serverVersion 服务端版本号
|
||||||
|
*/
|
||||||
|
checkVersion(serverVersion) {
|
||||||
|
const lastSeen = localStorage.getItem('lastSeenVersion')
|
||||||
|
if (!serverVersion || serverVersion === lastSeen) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.show(serverVersion)
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 显示版本更新弹窗
|
||||||
|
* @param {string} serverVersion 版本号
|
||||||
|
*/
|
||||||
|
show(serverVersion) {
|
||||||
|
getCurrentVersion().then(res => {
|
||||||
|
if (!res.enabled) return
|
||||||
|
this.versionInfo.version = res.version || serverVersion
|
||||||
|
this.versionInfo.releaseTime = res.releaseTime || ''
|
||||||
|
this.fetchVersionContent()
|
||||||
|
this.dialogVisible = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fetchVersionContent() {
|
||||||
|
// 从站内信获取最新的版本通知内容
|
||||||
|
// 内容通过后端 /api/version/current 返回的 releaseTime 已含,
|
||||||
|
// 如果需要额外展示详细内容,可调用通知接口查询
|
||||||
|
},
|
||||||
|
handleConfirm() {
|
||||||
|
localStorage.setItem('lastSeenVersion', this.versionInfo.version)
|
||||||
|
this.dialogVisible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.version-notification {
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
|
.version-info {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.version-info .label {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
.version-content {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
.version-content .label {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #303133;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
.version-content .content-body {
|
||||||
|
padding: 12px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #606266;
|
||||||
|
line-height: 1.8;
|
||||||
|
}
|
||||||
|
.dialog-footer {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
130
acs2/nladmin-ui/src/views/system/version/index.vue
Normal file
130
acs2/nladmin-ui/src/views/system/version/index.vue
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<template>
|
||||||
|
<div class="version-container">
|
||||||
|
<el-card class="version-card">
|
||||||
|
<div slot="header" class="card-header">
|
||||||
|
<span>{{ $t('auto.version.releaseTitle') }}</span>
|
||||||
|
</div>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-form-item :label="$t('auto.version.versionNo')" prop="version">
|
||||||
|
<el-input v-model="form.version" placeholder="例如:2.7.0" style="width: 300px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('auto.version.noticeTitle')" prop="title">
|
||||||
|
<el-input v-model="form.title" placeholder="例如:新增AGV多车调度功能" style="width: 500px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('auto.version.content')" prop="content">
|
||||||
|
<el-input
|
||||||
|
v-model="form.content"
|
||||||
|
type="textarea"
|
||||||
|
:rows="8"
|
||||||
|
placeholder="请输入更新内容,支持HTML格式"
|
||||||
|
style="width: 600px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" :loading="loading" @click="handleRelease">
|
||||||
|
{{ $t('auto.version.release') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="handleReset">{{ $t('auto.common.Reset') }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 当前版本信息 -->
|
||||||
|
<el-card class="version-card" style="margin-top: 20px">
|
||||||
|
<div slot="header" class="card-header">
|
||||||
|
<span>{{ $t('auto.version.currentInfo') }}</span>
|
||||||
|
</div>
|
||||||
|
<el-descriptions :column="2" border>
|
||||||
|
<el-descriptions-item :label="$t('auto.version.versionNo')">
|
||||||
|
<el-tag type="success">{{ currentVersion }}</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item :label="$t('auto.version.switch')">
|
||||||
|
<el-tag :type="enabled ? 'success' : 'danger'">{{ enabled ? $t('auto.version.enabled') : $t('auto.version.disabled') }}</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item :label="$t('auto.version.pollInterval')">
|
||||||
|
{{ pollInterval }}{{ $t('auto.version.seconds') }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item :label="$t('auto.version.releaseTime')">
|
||||||
|
{{ releaseTime || '-' }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getCurrentVersion, releaseVersion } from '@/api/system/version'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'VersionRelease',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
form: {
|
||||||
|
version: '',
|
||||||
|
title: '',
|
||||||
|
content: ''
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
version: [
|
||||||
|
{ required: true, message: '请输入版本号', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
title: [
|
||||||
|
{ required: true, message: '请输入标题', trigger: 'blur' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
currentVersion: '',
|
||||||
|
enabled: false,
|
||||||
|
pollInterval: 30,
|
||||||
|
releaseTime: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetchCurrentVersion()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchCurrentVersion() {
|
||||||
|
getCurrentVersion().then(res => {
|
||||||
|
this.currentVersion = res.version || '-'
|
||||||
|
this.enabled = res.enabled
|
||||||
|
this.pollInterval = res.pollInterval || 30
|
||||||
|
this.releaseTime = res.releaseTime || ''
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleRelease() {
|
||||||
|
this.$refs.form.validate(valid => {
|
||||||
|
if (!valid) return
|
||||||
|
this.loading = true
|
||||||
|
releaseVersion(this.form).then(() => {
|
||||||
|
this.$message.success('版本更新通知已发布')
|
||||||
|
this.handleReset()
|
||||||
|
this.fetchCurrentVersion()
|
||||||
|
}).catch(() => {
|
||||||
|
// 错误已在 request 拦截器中处理
|
||||||
|
}).finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleReset() {
|
||||||
|
this.form = {
|
||||||
|
version: '',
|
||||||
|
title: '',
|
||||||
|
content: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.version-container {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.version-card {
|
||||||
|
max-width: 800px;
|
||||||
|
}
|
||||||
|
.card-header {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user