Repository navigation
feat(web): eNotify 导出/导入前端两档 UI(设置区个人档 + admin 全站)(ONE-360) - #147
Merged
Merged
Conversation
- 新增 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,未合并)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ONE-360 前端子单(父单 ONE-358)
eNotify 一键导出/导入的前端实现:设置区个人档 + admin 区全站档,两处都是「导出 / 导入」完整闭环。
基线:本 PR 基于后端分支
agent/daniel/de6bc0b6a48a(PR #146,ONE-359,尚未合并),base 也指向该分支,因此 diff 只含前端改动。后端合并后本分支可改基到main。① 两处入口落点
/settings?tab=backup/admin/backup② 改了哪些文件
web/src/lib/backup.ts(新)— 六个接口的客户端:导出取 blob + 解析服务端Content-Disposition文件名;导入把File.text()原文放进file;MAX_BACKUP_BYTES10 MB 前端预检;downloadBlob。web/src/components/backup/*(新)—BackupSection(两档共用容器)、BackupExportPanel、BackupImportPanel、BackupCountsTable(预检/结果两张表)、describeBackupError({error,code,details}→ 本地化文案,未知码回落服务端文案)。web/src/pages/admin/AdminBackupPage.tsx(新)+AdminPage增加 tab +App.tsx路由。web/src/pages/settings/SettingsPage.tsx— 新增backup标签页(桌面 tab 栏与移动端菜单都接上)。web/src/lib/api.ts— 抽出requestResponse()复用会话/401 刷新逻辑并暴露api.postRaw(导出响应体是文件,不能按 JSON 解析);ApiError增加code/details,用于错误码映射。web/src/locales/{zh,en}.json— 新增backup.*命名空间(约 90 key/语言)+settings.backup/admin.backup。③ 三处必写提示(父单「不在导出范围」节)
backup.masterKeyWarning— 文件含渠道 token / SMTP 密码 / TOTP 密钥,等同主钥匙包,不要经聊天、邮件、网盘链接传输。backup.apiKeyNotice— 服务端只存哈希,恢复后需重新签发。backup.reloginNotice。④ 组件使用情况(无手搓组件)
@/components/ui/switch(Radix Switch 原生件)。@/components/ui/input(原生<input>,type="file"用组件自带的file:样式;文件选择本身是浏览器原生控件,没有自造 dropzone)。@/components/ui/label(Radix Label,与 Switch id 关联)。@/components/ConfirmDialog(restore 用 danger、merge 用 primary)。<select>,与仓库既有页面(API Key 有效期、时区)完全一致。BackupCountsTable只是表格布局(原生<table>),不涉及交互语义。⑤ 契约对接要点(按 CONTRACT.md)
{encrypted, passphrase?, include_history},encrypted默认 true;响应体当 blob 下载并采用服务端文件名。{file: <文件原文>, passphrase?, mode?}(个人档不传mode,全站档 restore 默认 / 可切 merge)。counts/will_write、users邮箱清单、conflicts(含 merge 覆盖 config 明示、restore 目标用户数、被覆盖 settings 键、各类跳过条数)、ignored_tables、blockers、warnings;can_execute:false时「确认导入」禁用。written+total_written,notices原样展示(restore 的「API Key 需重新签发,所有用户需要重新登录」)。PASSPHRASE_REQUIRED/DECRYPT_FAILED/UNSUPPORTED_FORMAT_VERSION/RESTORE_TARGET_NOT_EMPTY/MERGE_SOURCE_NOT_FOUND/MODE_NOT_ALLOWED/PAYLOAD_TOO_LARGE/STALE_PREVIEW/WRITE_FAILED等,未知码回落服务端消息。⑥ 自测
pnpm typecheck/pnpm lint(仅存量worker/src/routes/items.ts未使用导入告警)/pnpm format:check/pnpm build/pnpm test(15 files / 187 tests)全绿。wrangler dev+vite起真实实例,用 Chromium 走通两档闭环(导出→下载→选文件→预检→确认→结果),并核对了三处提示、加密默认开启、can_execute:false禁用、zh/en 两套文案。