From ef0876fc5dee05e90f362064ed7b342ba55d6121 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Thu, 21 May 2026 14:47:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(security):=20=E4=B8=80=E9=94=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20UI=20+=20=E7=A7=81=E6=9C=89/=E5=85=AC=E6=9C=89?= =?UTF-8?q?=E5=8C=96=E6=9D=A1=E4=BB=B6=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 安全中心按部署模式条件显示:PRIVATE 显示更新卡片,PUBLIC 显示迁移卡片 - 新增 api/system.ts:getDeploymentStatus + streamSystemUpdate(流式日志) - 更新进度用暗色终端风格日志框展示,自动滚动到底部 - RESTART_SELF 事件后轮询服务恢复,最长等待 90s Co-Authored-By: Claude Sonnet 4.6 --- tenant-platform/src/api/system.ts | 43 ++++ .../src/views/security/SecurityCenterView.vue | 190 ++++++++++++++++-- 2 files changed, 219 insertions(+), 14 deletions(-) create mode 100644 tenant-platform/src/api/system.ts diff --git a/tenant-platform/src/api/system.ts b/tenant-platform/src/api/system.ts new file mode 100644 index 0000000..011b13f --- /dev/null +++ b/tenant-platform/src/api/system.ts @@ -0,0 +1,43 @@ +const BASE = import.meta.env.VITE_API_BASE_URL ?? '/api' + +export interface DeploymentStatus { + mode: 'PUBLIC' | 'PRIVATE' + tenantRegisterEnabled: boolean + services: Record +} + +export async function getDeploymentStatus(): Promise { + const res = await fetch(`${BASE}/private/deployment/status`) + const json = await res.json() + return json.data as DeploymentStatus +} + +export async function streamSystemUpdate( + onLine: (line: string) => void, + signal?: AbortSignal, +): Promise { + const token = localStorage.getItem('token') ?? '' + const res = await fetch(`${BASE}/system/update`, { + method: 'POST', + headers: { Authorization: `Bearer ${token}` }, + signal, + }) + if (!res.ok) { + const text = await res.text() + throw new Error(text || `HTTP ${res.status}`) + } + const reader = res.body!.getReader() + const decoder = new TextDecoder() + let buf = '' + while (true) { + const { done, value } = await reader.read() + if (done) break + buf += decoder.decode(value, { stream: true }) + const lines = buf.split('\n') + buf = lines.pop() ?? '' + for (const line of lines) { + onLine(line) + } + } + if (buf) onLine(buf) +} diff --git a/tenant-platform/src/views/security/SecurityCenterView.vue b/tenant-platform/src/views/security/SecurityCenterView.vue index bd13d59..90162bd 100644 --- a/tenant-platform/src/views/security/SecurityCenterView.vue +++ b/tenant-platform/src/views/security/SecurityCenterView.vue @@ -38,7 +38,8 @@ 重置当前账号密码 - + +

将当前账号及应用数据迁移至私有化部署环境。迁移密钥仅在生成时显示一次,请及时保存。 @@ -46,6 +47,20 @@ 生成迁移密钥 + + + +

+ 拉取最新镜像并逐一重启各服务容器,全程无需手动操作。tenant-service 重启时页面连接会短暂中断,更新后自动恢复。 +

+ 立即更新 +
+ @@ -64,6 +79,7 @@ + - +

点击发送验证码,系统将向您的注册邮箱发送一次性验证码,验证通过后生成迁移密钥。

@@ -108,7 +124,6 @@ - + @@ -141,21 +157,71 @@ 知道了 + + + +
+

将拉取最新镜像并重启所有运行中的服务容器。

+ + + + +
+ +
+
{{ updateLog.join('\n') }}
+
+ +
+ + 正在等待服务重启... +
+ +
+ +
+
+ +
+ + +