From 292936a2bdad37ab165444aaae13b3b0fe06add3 Mon Sep 17 00:00:00 2001
From: mapxn <16299874+mapxn@users.noreply.github.com>
Date: Mon, 26 Oct 2026 00:09:43 +0800
Subject: [PATCH] =?UTF-8?q?feat(web):=20eNotify=20=E5=AF=BC=E5=87=BA/?=
=?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=89=8D=E7=AB=AF=E4=B8=A4=E6=A1=A3=20UI?=
=?UTF-8?q?=EF=BC=88=E8=AE=BE=E7=BD=AE=E5=8C=BA=E4=B8=AA=E4=BA=BA=E6=A1=A3?=
=?UTF-8?q?=20+=20admin=20=E5=85=A8=E7=AB=99=EF=BC=89(ONE-360)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 新增 web/src/lib/backup.ts:六个接口的客户端(导出取 blob + 服务端文件名,
导入以文件原文上传),限制/类型按 CONTRACT.md 对齐。
- 新增 web/src/components/backup/*:共用导出/导入闭环(导出:加密默认开启 +
含历史开关;导入:选文件 → 预检 → 确认 → 结果),zh/en 文案齐全。
- 设置 → 备份与恢复(个人档,merge 固定);admin → 备份与恢复(全站,默认
restore,可切 merge)。
- api.ts 抽出 requestResponse 供下载接口复用会话刷新与 {error,code,details}
错误体;ApiError 增加 code/details。
- 三处必写提示:主钥匙包(导出按钮旁)、API Key 不导出、导入后需重新登录。
基于后端分支 agent/daniel/de6bc0b6a48a(PR #146,未合并)。
---
web/src/App.tsx | 6 +
.../components/backup/BackupCountsTable.tsx | 62 ++
.../components/backup/BackupExportPanel.tsx | 195 ++++++
.../components/backup/BackupImportPanel.tsx | 594 ++++++++++++++++++
web/src/components/backup/BackupSection.tsx | 31 +
.../components/backup/describeBackupError.ts | 47 ++
web/src/lib/api.ts | 43 +-
web/src/lib/backup.ts | 167 +++++
web/src/locales/en.json | 120 +++-
web/src/locales/zh.json | 120 +++-
web/src/pages/admin/AdminBackupPage.tsx | 10 +
web/src/pages/admin/AdminPage.tsx | 10 +-
web/src/pages/settings/SettingsPage.tsx | 22 +-
13 files changed, 1415 insertions(+), 12 deletions(-)
create mode 100644 web/src/components/backup/BackupCountsTable.tsx
create mode 100644 web/src/components/backup/BackupExportPanel.tsx
create mode 100644 web/src/components/backup/BackupImportPanel.tsx
create mode 100644 web/src/components/backup/BackupSection.tsx
create mode 100644 web/src/components/backup/describeBackupError.ts
create mode 100644 web/src/lib/backup.ts
create mode 100644 web/src/pages/admin/AdminBackupPage.tsx
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 50bb800..43b5c62 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -74,6 +74,11 @@ const AdminSecurityPage = lazy(() =>
default: m.AdminSecurityPage,
})),
);
+const AdminBackupPage = lazy(() =>
+ import("@/pages/admin/AdminBackupPage").then((m) => ({
+ default: m.AdminBackupPage,
+ })),
+);
const AboutPage = lazy(() =>
import("@/pages/about/AboutPage").then((m) => ({ default: m.AboutPage })),
);
@@ -172,6 +177,7 @@ export function App() {
| + {t("backup.tableLabel")} + | ++ {countLabel ?? t("backup.countLabel")} + | + {secondary && ( ++ {t("backup.writeLabel")} + | + )} +
|---|---|---|
| + {t(`backup.tables.${table}`)} + + {table} + + | ++ {counts?.[table] ?? 0} + | + {secondary && ( ++ {secondary[table] ?? 0} + | + )} +
+ {t("backup.importDescription")} +
++ {t("backup.resultTitle")} +
++ {t("backup.resultTotal", { count: result.total_written })} ·{" "} + {t( + result.mode === "restore" + ? "backup.modeRestoreShort" + : "backup.modeMergeShort", + )} +
+{t("backup.reloginNotice")}
+ {result.mode === "restore" &&{t("backup.apiKeyNotice")}
} ++ {t("backup.warningsTitle")} +
++ {file + ? t("backup.selectedFile", { + name: file.name, + size: formatBytes(file.size), + }) + : t("backup.fileHint", { max: formatBytes(MAX_BACKUP_BYTES) })} +
++ {t("backup.filePassphraseHint")} +
++ {t( + mode === "restore" + ? "backup.modeRestoreHint" + : "backup.modeMergeHint", + )} +
++ {t("backup.modeFixedMerge")} +
+{t("backup.reloginNotice")}
+{t("backup.apiKeyNotice")}
++ {error} +
+ )} + + {!preview && ( + + )} + + {preview && ( +{t("backup.previewTitle")}
+ + {preview.can_execute + ? t("backup.canExecute") + : t("backup.cannotExecute")} + ++ {t("backup.previewSummary", { + version: preview.format_version, + scope: t( + preview.scope === "instance" + ? "backup.scopeInstance" + : "backup.scopeUser", + ), + mode: t( + preview.mode === "restore" + ? "backup.modeRestoreShort" + : "backup.modeMergeShort", + ), + encryption: t( + preview.encrypted + ? "backup.encryptedYes" + : "backup.encryptedNo", + ), + date: new Date(preview.exported_at).toLocaleString(), + })} +
+ ++ {t("backup.usersTitle")} +
+ {preview.users.length === 0 ? ( ++ {t("backup.usersEmpty")} +
+ ) : ( ++ {t("backup.conflictsTitle")} +
+ {conflictRows.length === 0 ? ( ++ {t("backup.noConflicts")} +
+ ) : ( ++ {t("backup.ignoredTablesTitle")} +
++ {t("backup.blockersTitle")} +
++ {t("backup.warningsTitle")} +
++ {error} +
+ )} + ++ {t( + scope === "instance" + ? "backup.instanceDescription" + : "backup.userDescription", + )} +
+