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() {