From e999d4d443a1f24d1cfdc8eda4e8fb6e152e98d0 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Fri, 22 May 2026 23:04:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(system):=20=E6=B7=BB=E5=8A=A0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=89=88=E6=9C=AC=E6=9F=A5=E8=AF=A2=E5=92=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=BF=81=E7=A7=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 license-service 中 DeviceEntity 的 device_id 唯一约束注解 - 添加 /api/system/version 接口用于查询当前部署版本 - 实现数据库 schema 版本化迁移机制 - 添加自动执行数据库迁移的功能 - 在前端安全中心界面显示当前版本和迁移状态 - 优化配置文件修复逻辑和代码结构 --- tenant-platform/src/api/system.ts | 10 +++++++ .../src/views/security/SecurityCenterView.vue | 28 +++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/tenant-platform/src/api/system.ts b/tenant-platform/src/api/system.ts index c795b50..de2ccfa 100644 --- a/tenant-platform/src/api/system.ts +++ b/tenant-platform/src/api/system.ts @@ -43,6 +43,16 @@ async function streamOperation( if (buf) onLine(buf) } +export async function getSystemVersion(): Promise<{ currentVersion: string }> { + const token = localStorage.getItem('token') ?? '' + const res = await fetch(`${BASE}/system/version`, { + headers: { Authorization: `Bearer ${token}` }, + }) + if (!res.ok) throw new Error(`HTTP ${res.status}`) + const json = await res.json() + return json.data as { currentVersion: string } +} + export function streamSystemUpdate(onLine: (line: string) => void, signal?: AbortSignal) { return streamOperation('/system/update', onLine, signal) } diff --git a/tenant-platform/src/views/security/SecurityCenterView.vue b/tenant-platform/src/views/security/SecurityCenterView.vue index 8587100..f0e3729 100644 --- a/tenant-platform/src/views/security/SecurityCenterView.vue +++ b/tenant-platform/src/views/security/SecurityCenterView.vue @@ -213,7 +213,15 @@

将拉取最新镜像并重建所有运行中的服务容器,用于升级到新版本。

将用当前本地镜像重建所有运行中的服务容器,无需下载新镜像,适合修复异常服务。

- + + + + {{ currentVersion }} + + + 自动执行,新版本启动时应用变更 + + @@ -258,7 +266,7 @@ import { Loading } from '@element-plus/icons-vue' import { accountApi } from '@/api/account' import { appApi, type App } from '@/api/app' import { migrateApi } from '@/api/migrate' -import { getDeploymentStatus, streamSystemUpdate, streamSystemReset } from '@/api/system' +import { getDeploymentStatus, getSystemVersion, streamSystemUpdate, streamSystemReset } from '@/api/system' import { useAuthStore } from '@/stores/auth' import { formatTime } from '@/utils/date' @@ -451,10 +459,23 @@ const updateError = ref('') const selfRestarting = ref(false) const updateLog = ref([]) const logEl = ref(null) +const currentVersion = ref('') +const versionLoading = ref(false) -function openOperationDialog(type: 'update' | 'reset') { +async function openOperationDialog(type: 'update' | 'reset') { operationType.value = type showUpdateDialog.value = true + if (type === 'update' && !currentVersion.value) { + versionLoading.value = true + try { + const info = await getSystemVersion() + currentVersion.value = info.currentVersion + } catch { + currentVersion.value = '' + } finally { + versionLoading.value = false + } + } } function resetUpdateDialog() { @@ -463,6 +484,7 @@ function resetUpdateDialog() { updateDone.value = false updateError.value = '' selfRestarting.value = false + currentVersion.value = '' } async function startOperation() {