diff --git a/README.en.md b/README.en.md
index 9b60cb4..f1b2c11 100644
--- a/README.en.md
+++ b/README.en.md
@@ -2,7 +2,7 @@
[简体中文](README.md) | **English**
-Track backup times, locations, and notes for files and folders. Supports batch entry, backup history, private folders, and data recovery.
+Track backup times, locations, and notes for files and folders. Supports batch entry, backup history, and private folders.
## Deploy with Docker
@@ -40,7 +40,7 @@ To connect an existing MongoDB instance, see [Database configuration](docs/docke
- **Batch entry:** Enter batch mode and select items, or paste a table. Each batch supports up to 20 records.
- **Find and edit records:** Open backup history → filter by item, location, or date → edit or delete records.
- **Private folders:** Click DataBack in the upper-left corner and enter your privacy password. Click it again to hide private folders.
-- **Undo deletion:** Use Undo in the deletion notification, or restore items from the recycle bin in data management within 30 days.
+- **Undo deletion:** Click Undo in the deletion notification.
## Update
@@ -85,13 +85,11 @@ Set the `DATABACK_PRIVACY_PASSWORD` environment variable before using private fo
## Back up and restore data
-- **Export:** Unlock private folders → open data management → export JSON to save the complete ledger.
-- **Automatic backups:** Open automatic backups in data management. DataBack keeps one backup per day and retains the latest 30. You can download a backup or create one immediately.
-- **Restore:** Select a backup → review its contents → confirm. DataBack saves the current ledger before replacing it.
+- **Automatic backups:** The server saves one ledger snapshot per day and retains the latest 30. Docker stores these in the `databack_snapshots` volume by default.
- **Full local backup:** Stop the app, then copy `data/`.
- **Full Docker backup:** Stop the service and back up its data volumes and `.env`. See [Full backup](docs/docker.en.md#full-backup) for commands.
-Ledger JSON contains folders and backup records. Save actual files, recycle-bin contents, and deployment credentials separately.
+The ledger records folders and backup information. Save actual files and deployment credentials separately.
## Layout
diff --git a/README.md b/README.md
index e9c38b9..25c81fa 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
**简体中文** | [English](README.en.md)
-记录文件和文件夹的备份时间、位置与说明,支持批量登记、历史查询、隐私目录和数据恢复。
+记录文件和文件夹的备份时间、位置与说明,支持批量登记、历史查询和隐私目录。
## Docker 部署
@@ -40,7 +40,7 @@ DATABACK_ALLOWED_HOSTS=backup.example.com,127.0.0.1:8767,localhost:8767
- **批量登记:** 点击批量登记后勾选项目,或粘贴表格,每批最多 20 条。
- **查询与修改:** 历史记录 → 筛选资料、位置、日期 → 编辑或删除记录。
- **隐私目录:** 点击左上角 DataBack → 输入隐私密码;再次点击收起。
-- **撤销删除:** 删除提示中点击撤销,或到数据管理的回收站恢复,保留 30 天。
+- **撤销删除:** 在删除后的提示中点击撤销。
## 更新
@@ -85,13 +85,11 @@ Windows 构建 `web/` 后,双击 `desktop/启动.cmd`;关闭时双击 `deskt
## 数据备份与恢复
-- **导出:** 解锁隐私目录 → 数据管理 → 导出 JSON,保存完整台账。
-- **自动备份:** 数据管理 → 自动备份,每天一份、保留最新 30 份,可下载或立即备份。
-- **恢复:** 选择备份 → 核对内容 → 确认恢复;替换前自动保存当前台账。
+- **自动备份:** 服务端每天保存一份台账快照,保留最新 30 份;Docker 默认保存在 `databack_snapshots` 数据卷。
- **本机完整备份:** 关闭程序后复制 `data/`。
- **Docker 完整备份:** 停止服务后备份数据卷和 `.env`,命令见 [数据备份](docs/docker.md#完整备份)。
-台账 JSON 包含目录和备份记录,实际文件、回收站内容和部署密码另行保存。
+台账只记录目录和备份信息,实际文件和部署密码另行保存。
## 目录
diff --git a/docs/docker.en.md b/docs/docker.en.md
index 06333b0..047aa07 100644
--- a/docs/docker.en.md
+++ b/docs/docker.en.md
@@ -46,7 +46,7 @@ Merge these fields into the existing application configuration. For a separate c
For existing deployments, keep the database directory, users, passwords, replica set, and volume mounts. Replace only the application image. The original `deploy.nas.app_health` Compose health-check entry point remains supported.
-To move between storage backends, export ledger JSON through the interface and import it into the destination. The migration CLI is at `web/scripts/migrate_to_mongo.py`; run it with `--help` for options.
+To migrate an existing schema-3 ledger JSON file to MongoDB, use `web/scripts/migrate_to_mongo.py`; run it with `--help` for options.
## Full backup
diff --git a/docs/docker.md b/docs/docker.md
index 95fa572..a13ffea 100644
--- a/docs/docker.md
+++ b/docs/docker.md
@@ -46,7 +46,7 @@ networks:
沿用已有部署时,保留原数据库目录、用户、密码、副本集和挂载配置,仅替换应用镜像。原 Compose 的 `deploy.nas.app_health` 健康检查入口仍可使用。
-台账可通过界面导出 JSON,在另一存储后端导入。迁移工具位于 `web/scripts/migrate_to_mongo.py`,运行 `--help` 查看参数。
+将已有 schema-3 台账 JSON 迁移到 MongoDB 时,使用 `web/scripts/migrate_to_mongo.py`,运行 `--help` 查看参数。
## 完整备份
diff --git a/web/src/App.tsx b/web/src/App.tsx
index d68a7ad..dc07b68 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -18,7 +18,6 @@ import type { DeleteTarget, EntityForm } from './components/EntityForms';
import { Overview } from './features/Overview';
import { AssetDetail } from './features/AssetDetail';
import { History } from './features/History';
-import { DataManagement } from './features/DataManagement';
export default function App() {
const session = useSession();
@@ -83,7 +82,7 @@ function LedgerApp({session, onLogout,privacyOpen,onTogglePrivacy,onSetPrivate}:
finally { markPending.current = false; setMarking(false); }
};
const saved = async () => { await ledger.refresh({throwOnError: true}); setNotice('备份记录已保存。'); };
- const deleted = async (trashId?: string) => { await ledger.refresh({throwOnError: true}); setNotice('已移入回收站。', trashId); };
+ const deleted = async (trashId?: string) => { await ledger.refresh({throwOnError: true}); setNotice('已删除。', trashId); };
const state = ledger.state;
const detail = state?.assets.find(asset => asset.id === detailId);
const directRecords = state && route.folderId && state.assets.some(asset => asset.id === route.folderId && asset.backup_target === true) && buildHierarchy(state.assets).isLeaf(route.folderId);
@@ -96,7 +95,6 @@ function LedgerApp({session, onLogout,privacyOpen,onTogglePrivacy,onSetPrivate}:
{!state ?
DataBack {ledger.loading ? `正在读取${nas ? '' : '本机'}台账…` : '恢复连接后即可继续查看和登记资料。'}
: <>
{route.page === 'overview' ? setEntity({kind: 'assets', entry})} onMark={markAsset} marking={marking} onAssetDelete={asset => setDeletion({collection: 'assets', id: asset.id, name: asset.name})} onRegister={assetId => setBackup({assetId})} onDetail={setDetailId} onLocateAsset={locateAsset} onEditRecords={assetId => setRecordEditor({assetId, mode: 'edit'})} onAddRecord={assetId => setRecordEditor({assetId, mode: 'new'})} onReorder={ledger.reorder} onRefresh={ledger.refresh} onBulk={assetIds=>setBulk({assetIds,mode:'selection'})} onPaste={()=>setBulk({mode:'paste'})} onPrivacy={onSetPrivate}/> : null}
{route.page === 'history' ? setBackup({})} onBulk={()=>setBulk({mode:'selection'})} onBulkEdit={setBulkRecordIds} onEdit={setRecord} onDelete={entry => setDeletion({collection: 'records', id: entry.id, name: '备份记录'})} /> : null}
- {route.page === 'data' ? ledger.refresh({throwOnError:true})} privacyOpen={privacyOpen} onUnlockPrivacy={onTogglePrivacy} /> : null}
{detail && route.page === 'overview' && !directRecords ? setDetailId('')} onEditRecords={() => setRecordEditor({assetId: detail.id, mode: 'edit'})} onAddRecord={buildHierarchy(state.assets).isLeaf(detail.id) ? () => setRecordEditor({assetId: detail.id, mode: 'new'}) : undefined} /> : null}
{recordInfo && recordEditor ? setRecordEditor(null)} onSaved={saved} onDeleted={deleted} /> : null}
{backup ? setBackup(null)} onSaved={saved} onChooseTargets={() => { setBackup(null); openFolder(null); }} /> : null}
@@ -109,6 +107,6 @@ function LedgerApp({session, onLogout,privacyOpen,onTogglePrivacy,onSetPrivate}:
setNotice(nas ? '已保存。' : '已保存到本机台账。');
}} /> : null}
>}
- {deletion ? setDeletion(null)} onRemove={async (collection, id) => { const receipt = await ledger.remove(collection, id); setNotice('已移入回收站。', receipt.trash_id); }} /> : null}
+ {deletion ? setDeletion(null)} onRemove={async (collection, id) => { const receipt = await ledger.remove(collection, id); setNotice('已删除。', receipt.trash_id); }} /> : null}
;
}
diff --git a/web/src/components/AssetForm.tsx b/web/src/components/AssetForm.tsx
index 5003958..51df82b 100644
--- a/web/src/components/AssetForm.tsx
+++ b/web/src/components/AssetForm.tsx
@@ -45,7 +45,7 @@ export function AssetDialog({ state, entry, initialKind = 'folder', parentId = n
{!entry ? { setMode('single'); setError(''); }}>单个 { setMode('batch'); setError(''); }}>批量
: null}
{!batch ? update('name', e.target.value)} /> : null}
update('kind', e.target.value as Asset['kind'])}>文件夹 文件
- update('parent_id', e.target.value)}>全部资料(根目录) {tree.moveOptions(entry?.id).map(asset => {tree.path(asset.id)} )}
+ update('parent_id', e.target.value)}>全部(根目录) {tree.moveOptions(entry?.id).map(asset => {tree.path(asset.id)} )}
{batch ? <>
{preview.valid ? 新增 {preview.created} 项 · 已有跳过 {preview.skipped} 项
名称 类型 处理 {preview.rows.map((row, index) => {row.path} {row.kind === 'file' ? '文件' : '文件夹'} {row.status === 'create' ? '新增' : '跳过'} )}
: null}
取消 {busy ? '正在保存…' : submitted.current ? '重试读取' : '确认添加'}
> : }
diff --git a/web/src/components/EntityForms.tsx b/web/src/components/EntityForms.tsx
index 759021c..da935fd 100644
--- a/web/src/components/EntityForms.tsx
+++ b/web/src/components/EntityForms.tsx
@@ -42,5 +42,5 @@ export function DeleteDialog({ target, onClose, onRemove }: { target: DeleteTarg
catch (reason) { setError(reason instanceof Error ? reason.message : '删除失败,请重试。'); }
finally { setBusy(false); }
}
- return ;
+ return ;
}
diff --git a/web/src/components/RecoveryPanels.tsx b/web/src/components/RecoveryPanels.tsx
deleted file mode 100644
index 77f854c..0000000
--- a/web/src/components/RecoveryPanels.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import {useEffect, useRef, useState} from 'react';
-import {Download, RotateCcw, Save} from 'lucide-react';
-import {request} from '../api';
-import {formatTime} from '../selectors';
-import {createRefreshSafeAction} from '../recoveryActions';
-import {FormError, Modal} from './ui';
-
-interface TrashEntry {id: string; collection: string; name: string; deleted_at: string; expires_at: string}
-interface Snapshot {id: string; created_at: string; reason: string; counts: {assets: number; records: number}}
-interface SnapshotList {items: Snapshot[]; enabled: boolean; error?: string}
-const reasonLabels: Record = {automatic: '自动', daily: '自动', startup: '自动', manual: '手动', pre_restore: '恢复前', before_restore: '恢复前'};
-type RecoveryAction = ReturnType>;
-type PendingAction = {label: string; action: RecoveryAction; refresh: () => Promise};
-
-function downloadJson(data: unknown, filename: string) {
- const url = URL.createObjectURL(new Blob([JSON.stringify(data, null, 2)], {type: 'application/json'}));
- const anchor = document.createElement('a'); anchor.href = url; anchor.download = filename; anchor.click();
- setTimeout(() => URL.revokeObjectURL(url), 1000);
-}
-
-export function RecoveryPanels({privacyOpen = false, onUnlockPrivacy, onRefresh}: {
- privacyOpen?: boolean; onUnlockPrivacy?: () => void; onRefresh: () => Promise;
-}) {
- const [trashOpen, setTrashOpen] = useState(false);
- const [snapshotsOpen, setSnapshotsOpen] = useState(false);
- const [trash, setTrash] = useState([]);
- const [snapshots, setSnapshots] = useState({items: [], enabled: true});
- const [trashLoaded, setTrashLoaded] = useState(false);
- const [snapshotsLoaded, setSnapshotsLoaded] = useState(false);
- const [loadingTrash, setLoadingTrash] = useState(false);
- const [loadingSnapshots, setLoadingSnapshots] = useState(false);
- const [busy, setBusy] = useState(false);
- const [error, setError] = useState('');
- const [message, setMessage] = useState('');
- const [restore, setRestore] = useState(null);
- const [retry, setRetry] = useState(null);
- const inFlight = useRef(false);
- const mounted = useRef(true);
- useEffect(() => {mounted.current = true; return () => {mounted.current = false;};}, []);
- async function loadTrash() {
- setLoadingTrash(true);
- try {
- const result = await request<{items: TrashEntry[]}>('trash');
- if (mounted.current) {setTrash(result.items); setTrashLoaded(true);}
- } finally {if (mounted.current) setLoadingTrash(false);}
- }
- async function loadSnapshots() {
- if (!privacyOpen) return;
- setLoadingSnapshots(true);
- try {
- const result = await request('snapshots');
- if (mounted.current) {setSnapshots(result);setSnapshotsLoaded(true);}
- } finally {if (mounted.current) setLoadingSnapshots(false);}
- }
- useEffect(() => {
- if (trashOpen && !trashLoaded) void loadTrash().catch(reason => {if(mounted.current)setError(reason instanceof Error ? reason.message : '读取回收站失败。');});
- }, [trashOpen, trashLoaded]);
- useEffect(() => {
- if (snapshotsOpen && privacyOpen && !snapshotsLoaded) void loadSnapshots().catch(reason => {if(mounted.current)setError(reason instanceof Error ? reason.message : '读取备份失败。');});
- }, [snapshotsOpen, privacyOpen, snapshotsLoaded]);
- async function perform(job: PendingAction) {
- if (inFlight.current) return;
- inFlight.current = true;setBusy(true);setError('');setMessage('');
- try {
- await job.action.run(job.refresh);
- if (mounted.current) {setRetry(null);setRestore(null);setMessage(job.label);}
- } catch (reason) {
- if (mounted.current) {
- setRetry(job.action.committed() ? job : null);
- setError(job.action.committed() ? '操作已完成,读取结果失败,请重试读取。' : reason instanceof Error ? reason.message : '操作失败,请重试。');
- }
- } finally {inFlight.current = false;if(mounted.current)setBusy(false);}
- }
- const unavailable = busy || Boolean(retry);
- const refreshAll = async () => {await loadSnapshots();await loadTrash();await onRefresh();};
- async function download(snapshot: Snapshot) {
- if (inFlight.current) return;
- inFlight.current = true;setBusy(true);setError('');setMessage('');
- try {const data = await request(`snapshots/${encodeURIComponent(snapshot.id)}`); if(mounted.current) downloadJson(data, `databack-${snapshot.created_at.replace(/[^0-9T]/g, '-').slice(0,19)}.json`);}
- catch (reason) {if(mounted.current)setError(reason instanceof Error ? reason.message : '下载失败,请重试。');}
- finally {inFlight.current=false;if(mounted.current)setBusy(false);}
- }
- return {message ? {message}
: null}
- {retry && !restore ? void perform(retry)}>重试读取 : null}
-
- setTrashOpen(current => !current)}>回收站 保留 30 天
- {trashOpen ?
- {loadingTrash ?
正在读取…
: !trashLoaded ?
void loadTrash().catch(reason => setError(reason instanceof Error ? reason.message : '读取失败。'))}>重试读取 : !trash.length ?
回收站为空
:
名称 删除时间 保留至 操作 {trash.map(item => {item.name} {formatTime(item.deleted_at)} {formatTime(item.expires_at)} void perform({label: '已恢复', action: createRefreshSafeAction(() => request(`trash/${encodeURIComponent(item.id)}/restore`, 'POST', {})), refresh: async () => {await loadTrash();await onRefresh();}})}>恢复 )}
}
-
: null}
-
-
- setSnapshotsOpen(current => !current)}>自动备份 每天一份 · 保留 30 份
- {snapshotsOpen && !privacyOpen ? 输入隐私密码 : snapshotsOpen && privacyOpen ?
- {snapshots.error ?
: null} void perform({label: '备份已保存', action: createRefreshSafeAction(() => request('snapshots', 'POST', {})), refresh: loadSnapshots})}>立即备份
- {loadingSnapshots ? 正在读取…
: !snapshotsLoaded ? void loadSnapshots().catch(reason => setError(reason instanceof Error ? reason.message : '读取失败。'))}>重试读取 : !snapshots.items.length ? 暂无备份
: 备份时间 来源 资料 记录 操作 {snapshots.items.map(item => {formatTime(item.created_at)} {reasonLabels[item.reason] ?? '备份'} {item.counts.assets} {item.counts.records} void download(item)}> {setRestore(item);setError('');}}>恢复
)}
}
- : null}
-
- {restore && privacyOpen ? {setRestore(null);setError('');}} busy={busy}>
-
{formatTime(restore.created_at)} · {restore.counts.assets} 份资料 · {restore.counts.records} 条记录
将替换当前台账,恢复前会自动保存一份备份。
- setRestore(null)}>取消 void perform(retry ?? {label: '台账已恢复', action: createRefreshSafeAction(() => request(`snapshots/${encodeURIComponent(restore.id)}/restore`, 'POST', {})), refresh: refreshAll})}>{busy ? '正在恢复…' : retry ? '重试读取' : '确认替换并恢复'}
- : null}
- ;
-}
diff --git a/web/src/components/Shell.tsx b/web/src/components/Shell.tsx
index 84272a4..8c44116 100644
--- a/web/src/components/Shell.tsx
+++ b/web/src/components/Shell.tsx
@@ -1,4 +1,4 @@
-import { Database, Folder, History, Plus } from 'lucide-react';
+import { Folder, History, Plus } from 'lucide-react';
import type { ReactNode } from 'react';
import type { Page } from '../types';
import { BrandIcon } from './BrandIcon';
@@ -6,7 +6,6 @@ import { BrandIcon } from './BrandIcon';
const navigation = [
{ id: 'overview', label: '资料目录', Icon: Folder },
{ id: 'history', label: '历史记录', Icon: History },
- { id: 'data', label: '数据管理', Icon: Database },
] as const;
export function Shell({ page, onNavigate, children, privacyOpen=false, onTogglePrivacy }: { page: Page; onNavigate: (page: Page) => void; children?: ReactNode; authRequired?: boolean; onLogout?: () => void; privacyOpen?:boolean; onTogglePrivacy?:()=>void }) {
return DataBack
diff --git a/web/src/features/DataManagement.tsx b/web/src/features/DataManagement.tsx
deleted file mode 100644
index 675a3de..0000000
--- a/web/src/features/DataManagement.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { useRef, useState } from 'react';
-import { Download, Upload } from 'lucide-react';
-import { request } from '../api';
-import { toDatetimeLocal } from '../selectors';
-import type { LedgerState } from '../types';
-import { createLatestImportReader } from '../importData';
-import type { ExportData } from '../importData';
-import { FormError, PageHeading } from '../components/ui';
-import { RecoveryPanels } from '../components/RecoveryPanels';
-
-export function DataManagement({ onRefresh, privacyOpen = false, onUnlockPrivacy }: { state: LedgerState; onRefresh: () => Promise; privacyOpen?: boolean; onUnlockPrivacy?: () => void }) {
- const [readLatest] = useState>(() => createLatestImportReader());
- const selectionId = useRef(0);
- const [preview, setPreview] = useState(null); const [filename, setFilename] = useState('');
- const [busy, setBusy] = useState(false); const [error, setError] = useState(''); const [message, setMessage] = useState('');
- async function exportFile() {
- setBusy(true); setError(''); setMessage('');
- try {
- const data = await request('export');
- const url = URL.createObjectURL(new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }));
- const anchor = document.createElement('a'); anchor.href = url; anchor.download = `databack-${toDatetimeLocal().slice(0, 10)}.json`; anchor.click();
- setTimeout(() => URL.revokeObjectURL(url), 1000); setMessage('台账 JSON 已导出。');
- } catch (reason) { setError(reason instanceof Error ? reason.message : '导出失败,请重试。'); }
- finally { setBusy(false); }
- }
- async function readFile(file?: File) {
- if (!file) return;
- const currentId = ++selectionId.current;
- setError(''); setMessage(''); setPreview(null); setFilename(file.name);
- try {
- const data = await readLatest(file);
- if (currentId === selectionId.current && data) setPreview(data);
- } catch (reason) { if (currentId === selectionId.current) setError(reason instanceof Error ? reason.message : '读取文件失败。'); }
- }
- async function importFile() {
- if (!preview) return;
- setBusy(true); setError(''); setMessage('');
- try { const result = await request<{ added: Record }>('import', 'POST', preview); setPreview(null); setMessage(`导入完成:新增 ${result.added.assets} 份资料、${result.added.locations} 个位置、${result.added.records} 条备份记录。`); await onRefresh(); }
- catch (reason) { setError(reason instanceof Error ? reason.message : '导入失败,数据未写入。'); }
- finally { setBusy(false); }
- }
- return <> {message ? {message}
: null}
- 导出台账 void exportFile()}> 导出 JSON
-
- {preview ? 导入预览 {filename}
资料 位置 备份记录 {preview.assets.length} {preview.locations.length} {preview.records.length}
setPreview(null)}>取消导入 void importFile()}>{busy ? '正在导入…' : '确认合并导入'}
: null}
-
- >;
-}
diff --git a/web/src/features/Overview.tsx b/web/src/features/Overview.tsx
index ab05e03..0e5b527 100644
--- a/web/src/features/Overview.tsx
+++ b/web/src/features/Overview.tsx
@@ -44,7 +44,7 @@ export function Overview(actions: OverviewActions) {
const {state, folderId} = actions;
const tree = useMemo(() => buildHierarchy(state.assets), [state.assets]);
const [keyword, setKeyword] = useState('');
- const [searchScope, setSearchScope] = useState('current');
+ const [searchScope, setSearchScope] = useState('all');
const [sort, setSort] = useState('manual');
const [selected,setSelected]=useState([]);
const [bulkSelecting,setBulkSelecting]=useState(false);
@@ -65,7 +65,7 @@ export function Overview(actions: OverviewActions) {
return () => { document.removeEventListener('keydown', escape); window.removeEventListener('blur', cancelDrag); cancelDrag(); };
}, []);
useEffect(() => { cancelDrag(); }, [sort, keyword, searchScope, pending]);
- useEffect(() => { setKeyword(''); setSearchScope('current'); setSelected([]); setBulkSelecting(false); cancelDrag(); }, [folderId]);
+ useEffect(() => { setKeyword(''); setSearchScope('all'); setSelected([]); setBulkSelecting(false); cancelDrag(); }, [folderId]);
const saving = useRef(false);
const folder = folderId ? tree.byId.get(folderId) : undefined;
const showingRecords = folder?.backup_target === true && tree.isLeaf(folder.id);
@@ -94,12 +94,12 @@ export function Overview(actions: OverviewActions) {
const openEntry = (asset: Asset, marked: boolean) => {
const target = directoryNavigation(asset, marked, searchingAll);
if ('folderId' in target && target.detailId && actions.onLocateAsset) {
- setKeyword(''); setSearchScope('current'); cancelSelection();
+ setKeyword(''); setSearchScope('all'); cancelSelection();
actions.onLocateAsset(asset);
return;
}
if ('folderId' in target) {
- setKeyword(''); setSearchScope('current'); cancelSelection();
+ setKeyword(''); setSearchScope('all'); cancelSelection();
actions.onFolder(target.folderId ?? null);
}
if (target.detailId) actions.onDetail(target.detailId);
@@ -114,8 +114,8 @@ export function Overview(actions: OverviewActions) {
finally { saving.current = false; setPending(false); }
};
return <>{actions.onBulk&&!showingRecords?bulkSelecting?<>{selectedVisible.length?`登记所选(${selectedVisible.length})`:'登记所选'} {actions.onPaste?{cancelSelection();actions.onPaste!();}}>粘贴表格 :null}取消 >:{cancelDrag();setSelected([]);setBulkSelecting(true);}}>批量登记 :null}{!bulkSelecting?<> actions.onCreate('file', folderId)}> 添加文件 actions.onCreate('folder', folderId)}> 新建文件夹 >:null} : undefined} />
- {folder ? actions.onFolder(folder.parent_id ?? null)}> : null} actions.onFolder(null)}>全部资料 {[...ancestors, ...(folder ? [folder] : [])].map((entry, index, all) => {index === all.length - 1 ? {entry.name} : actions.onFolder(entry.id)}>{entry.name} } )}
- {showingRecords ? null :
}
+ {folder ? actions.onFolder(folder.parent_id ?? null)}> : null} actions.onFolder(null)}>全部 {[...ancestors, ...(folder ? [folder] : [])].map((entry, index, all) => {index === all.length - 1 ? {entry.name} : actions.onFolder(entry.id)}>{entry.name} } )}
+ {showingRecords ? null :
}
{orderError ? {orderError} void actions.onRefresh().then(()=>setOrderError(''))}>刷新目录
: null}
{showingRecords ? actions.onEditRecords(folder.id)} onAddRecord={() => actions.onAddRecord(folder.id)} /> : {!rows.length ? keyword ? { setKeyword(''); setSelected([]); }}>清除搜索} /> : actions.onDetail(folder.id)}>备份信息 actions.onMark(folder)}>设为备份对象
: undefined} /> :
diff --git a/web/src/importData.ts b/web/src/importData.ts
deleted file mode 100644
index eb92547..0000000
--- a/web/src/importData.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { LedgerState } from './types';
-export interface ExportData extends LedgerState { format: string; schema_version: number; exported_at: string }
-export interface ImportFile { size: number; text: () => Promise }
-export function createLatestImportReader() {
- let selectionId = 0;
- return async (file: ImportFile): Promise => {
- const currentId = ++selectionId;
- try {
- if (file.size > 10 * 1024 * 1024) throw new Error('文件超过 10 MiB,请选择更小的台账 JSON 文件。');
- const text = await file.text();
- if (currentId !== selectionId) return undefined;
- return parseImportPreview(text);
- } catch (reason) {
- if (currentId !== selectionId) return undefined;
- throw reason;
- }
- };
-}
-export function parseImportPreview(text: string): ExportData {
- let data: unknown;
- try { data = JSON.parse(text); }
- catch { throw new Error('JSON 内容无法解析,尚未写入任何数据。'); }
- if (!data || typeof data !== 'object') throw new Error('文件不是支持的备份台账格式。请选择本应用导出的 JSON。');
- const candidate = data as ExportData;
- if (candidate.format !== 'filebackup-ledger' || ![1, 2, 3].includes(candidate.schema_version) || !['assets', 'versions', 'locations', 'records'].every(key => Array.isArray(candidate[key as keyof LedgerState]))) throw new Error('文件不是支持的备份台账格式。请选择本应用导出的 JSON。');
- for (const asset of candidate.assets) {
- if (asset && Object.hasOwn(asset, 'manual_order') && (!Number.isInteger(asset.manual_order) || typeof asset.manual_order !== 'number' || asset.manual_order < 0 || asset.manual_order > 2147483647)) throw new Error('手动排序须为 0 到 2147483647 之间的整数。');
- }
- return candidate;
-}
diff --git a/web/src/navigation.ts b/web/src/navigation.ts
index de852f6..4bc39b2 100644
--- a/web/src/navigation.ts
+++ b/web/src/navigation.ts
@@ -8,7 +8,7 @@ export function parseRoute(hash: string): Route {
catch { return {...root}; }
}
const page = hash.slice(2);
- return ['history', 'data'].includes(page) ? { page: page as Page, folderId: null } : {...root};
+ return page === 'history' ? { page, folderId: null } : {...root};
}
export function routeHash(route: Route): string {
return route.page === 'overview' ? route.folderId ? `#/folder/${encodeURIComponent(route.folderId)}` : '#/' : `#/${route.page}`;
diff --git a/web/src/recoveryActions.ts b/web/src/recoveryActions.ts
deleted file mode 100644
index 119c1bc..0000000
--- a/web/src/recoveryActions.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-// A successful write must not be repeated merely because the following refresh failed.
-export function createRefreshSafeAction(mutate: () => Promise) {
- let committed = false;
- let result: T;
- let pending: Promise | undefined;
- return {
- committed: () => committed,
- run(refresh: () => Promise): Promise {
- if (pending) return pending;
- pending = (async () => {
- if (!committed) { result = await mutate(); committed = true; }
- await refresh();
- return result;
- })().finally(() => { pending = undefined; });
- return pending;
- },
- };
-}
diff --git a/web/src/styles.css b/web/src/styles.css
index d1e976d..968e645 100644
--- a/web/src/styles.css
+++ b/web/src/styles.css
@@ -16,7 +16,7 @@
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; font-size: 13px; }
button, input, select, textarea { font: inherit; }
-button, label.file-picker, summary { -webkit-tap-highlight-color: transparent; }
+button, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; }
button:disabled, input:disabled, select:disabled, .disabled { cursor: not-allowed; opacity: .55; }
button, input, select, textarea { outline-offset: 3px; }
@@ -169,15 +169,6 @@ tbody tr:hover { background: #fcfdff; }
.history-table { min-width: 830px; }
.history-table td:nth-child(3) { white-space: nowrap; }
.history-table td:nth-child(4) { max-width: 260px; }
-.data-section { padding: 22px 24px; margin-bottom: 16px; display: flex; gap: 24px; justify-content: space-between; align-items: center; }
-.data-section h2 { margin-bottom: 0; }
-.data-section > div > h2 { margin-bottom: 12px; }
-.file-picker { position: relative; cursor: pointer; }
-.file-picker input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; padding: 0; cursor: pointer; }
-.file-picker:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
-.import-preview { padding: 24px; }
-.import-preview > p { font-size: 13px; margin: 12px 0; }
-.import-preview table { border: 1px solid var(--border); }
.modal { width: min(540px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 12px; padding: 0; color: #172b4d; background: #fff; max-height: calc(100dvh - 48px); box-shadow: 0 24px 80px #172b4d29; overflow: auto; }
.modal-wide { width: min(820px, calc(100vw - 32px)); }
.modal::backdrop { background: #172b4d66; backdrop-filter: blur(2px); }
@@ -281,9 +272,6 @@ tbody tr:hover { background: #fcfdff; }
.detail-footer { flex-wrap: wrap; }
.history-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 13px; gap: 12px 9px; }
.history-filters .search-field { grid-column: 1 / -1; }
- .data-section { flex-direction: column; align-items: flex-start; padding: 20px; gap: 12px; }
- .import-preview { padding: 16px; }
- .import-preview th, .import-preview td { padding: 10px 6px; font-size: 12px; }
.form-grid { grid-template-columns: 1fr; }
.modal { max-height: calc(100dvh - 26px); width: calc(100vw - 20px); }
.modal-header { padding: 15px 17px; }
@@ -309,9 +297,17 @@ tbody tr:hover { background: #fcfdff; }
.action-menu-options button.danger { color: #ba3a3a; }
.drag-handle { border: 0; background: transparent; color: #8f9bad; padding: 3px; display: flex; flex-shrink: 0; cursor: grab; }
.drag-handle:disabled { opacity: .3; cursor: default; }
-.explorer-table .directory-time-column { width: 160px; }
-.explorer-table .directory-actions-column { width: 88px; }
-.explorer-table.with-backup-notes .directory-name-column { width: 52%; }
+@media (min-width: 1001px) {
+ .explorer-table col { width: 33.333333%; }
+ .explorer-table.with-backup-notes .directory-name-column { width: 40%; }
+ .explorer-table.with-backup-notes .directory-time-column { width: 22%; }
+ .explorer-table.with-backup-notes .directory-notes-column { width: 26%; }
+ .explorer-table.with-backup-notes .directory-actions-column { width: 12%; }
+ .explorer-table th { padding: 8px 12px; }
+ .explorer-table td { padding: 6px 12px; height: 40px; }
+ .explorer-identity { gap: 10px; }
+ .explorer-identity > svg { width: 24px; height: 24px; }
+}
.directory-backup-notes { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.record-table-scroll { margin-top: 12px; }
.record-detail-table { min-width: 0; table-layout: fixed; width: 100%; }
@@ -357,20 +353,6 @@ tbody tr:hover { background: #fcfdff; }
.bulk-record-edit .record-entry-fields { gap: 14px; }
.bulk-record-edit .field + .checkbox-row { margin-top: 8px; }
.history-table th.history-select-cell, .history-table td.history-select-cell { width: 44px; min-width: 44px; padding-left: 12px; padding-right: 12px; }
-.recovery-panels { display: grid; gap: 16px; }
-.data-section.recovery-section { display: block; margin: 0; }
-.recovery-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
-.section-toggle { padding: 0; color: var(--text); gap: 10px; }
-.section-toggle h2 { margin: 0; }
-.section-toggle::after { content: '⌄'; font-size: 16px; color: var(--muted); }
-.section-toggle[aria-expanded="true"]::after { content: '⌃'; }
-.recovery-heading small { font-size: 12px; }
-.recovery-content { margin-top: 18px; }
-.recovery-toolbar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
-.recovery-table { width: 100%; min-width: 540px; table-layout: fixed; }
-.recovery-table th, .recovery-table td { text-align: center; font-size: 12px; overflow-wrap: anywhere; }
-.recovery-table .row-actions { justify-content: center; }
-.recovery-retry { width: fit-content; }
@media (max-width: 1000px) {
.directory-search { width: 100%; }
.directory-search .search-field { flex: 1; width: auto; }
@@ -411,10 +393,10 @@ tbody tr:hover { background: #fcfdff; }
@media (max-width:1000px) {
.heading-actions { flex-wrap:wrap; }
.heading-actions .button { flex:1 1 auto; }
- .explorer-toolbar, .directory-search, .data-section > div { min-width: 0; max-width: 100%; }
+ .explorer-toolbar, .directory-search { min-width: 0; max-width: 100%; }
.directory-search .search-field { min-width: 0; }
.directory-search select { width: 128px; }
- .toolbar, .recovery-toolbar { flex-wrap: wrap; }
+ .toolbar { flex-wrap: wrap; }
}
/* Keep focused controls at the readable size that avoids iOS input zoom. */
diff --git a/web/src/types.ts b/web/src/types.ts
index e5371a3..af75493 100644
--- a/web/src/types.ts
+++ b/web/src/types.ts
@@ -52,7 +52,7 @@ export interface RecordFilters {
dateFrom?: string;
dateTo?: string;
}
-export type Page = 'overview' | 'history' | 'data';
+export type Page = 'overview' | 'history';
export interface SessionInfo {
authenticated: boolean;
auth_required: boolean;
diff --git a/web/tests/directory-order.test.mjs b/web/tests/directory-order.test.mjs
index 8553db6..e6d7fd8 100644
--- a/web/tests/directory-order.test.mjs
+++ b/web/tests/directory-order.test.mjs
@@ -45,14 +45,6 @@ test('backup time sorting matches parent rows that display the latest marked des
});
test('move produces complete sibling order without mutating input and rejects foreign ids',()=>{assert.equal(typeof order.moveDirectoryAsset,'function');const ids=['a','b','c'];assert.deepEqual(order.moveDirectoryAsset(ids,'c','a'),['c','a','b']);assert.deepEqual(ids,['a','b','c']);assert.equal(order.moveDirectoryAsset(ids,'foreign','a'),null);assert.equal(order.moveDirectoryAsset(ids,'a','a'),null);});
-const {parseImportPreview}=await import('../src/importData.ts');
-test('import preview validates optional bounded manual order without requiring legacy field',()=>{
- const payload={format:'filebackup-ledger',schema_version:3,...state};
- assert.equal(parseImportPreview(JSON.stringify(payload)).assets.length,3);
- for(const value of [-1,true,1.5,'1',null,2147483648])assert.throws(()=>parseImportPreview(JSON.stringify({...payload,assets:[{...a,manual_order:value}]})),/手动排序/);
- assert.equal(parseImportPreview(JSON.stringify({...payload,assets:[{...a,manual_order:2147483647}]})).assets[0].manual_order,2147483647);
-});
-
test('never-backed-up items precede even pre-epoch actual backups in oldest mode',()=>{
const oldState={...state,records:[{id:'ancient',version_id:'v-old',backed_up_at:'1960-01-01T00:00:00Z'}]};
assert.deepEqual(order.sortDirectoryAssets(oldState,[a,c],'oldest').map(x=>x.id),['c','a']);
diff --git a/web/tests/frontend-targets.test.mjs b/web/tests/frontend-targets.test.mjs
index ac85718..85ef206 100644
--- a/web/tests/frontend-targets.test.mjs
+++ b/web/tests/frontend-targets.test.mjs
@@ -138,7 +138,8 @@ test('legacy edit inputs present forward slashes without mutating their state',
test('databack shell retains navigation without storage footer or visible logout', () => {
const nasHtml=render(Shell,{page:'overview',onNavigate:noop,storage:'mongodb',authRequired:true,onLogout:noop});
assert.match(nasHtml,/>DataBack);
- for (const label of ['资料目录','历史记录','数据管理']) assert.ok(nasHtml.includes(label));
+ for (const label of ['资料目录','历史记录']) assert.ok(nasHtml.includes(label));
+ assert.doesNotMatch(nasHtml,/数据管理|导出台账|导入台账|回收站|自动备份/);
assert.doesNotMatch(nasHtml,/待备份|到期/);
assert.doesNotMatch(nasHtml,/备份位置/);
assert.doesNotMatch(nasHtml,/NAS 保存|退出登录/);
diff --git a/web/tests/hierarchy-reminders.test.mjs b/web/tests/hierarchy-reminders.test.mjs
index 811cc70..3107414 100644
--- a/web/tests/hierarchy-reminders.test.mjs
+++ b/web/tests/hierarchy-reminders.test.mjs
@@ -2,7 +2,6 @@ import test from 'node:test';
import assert from 'node:assert/strict';
import * as hierarchy from '../src/hierarchy.ts';
import * as reminders from '../src/reminders.ts';
-import { parseImportPreview } from '../src/importData.ts';
const asset = (id, name, parent_id = null, kind = 'folder', extra = {}) => ({ id, name, parent_id, kind, source_path: '', backup_target: true, backup_enabled: true, backup_interval_days: 30, target_location_ids: [], notes: '', created_at: '', ...extra });
const assets = [asset('emotion', 'Emotion'), asset('letter', 'Letter', 'emotion'), asset('photos', 'Photos'), asset('me', 'Me', 'photos'), asset('year', '2025', 'me'), asset('file', 'note.txt', 'me', 'file')];
@@ -85,11 +84,6 @@ test('overall deadline ignores older target copies when another copy is newer',
assert.equal(result.status, 'current');
});
-test('schema 1, 2 and 3 import previews are accepted and schema 4 rejected', () => {
- for (const schema_version of [1, 2, 3]) assert.equal(parseImportPreview(JSON.stringify({format: 'filebackup-ledger', schema_version, ...state})).schema_version, schema_version);
- assert.throws(() => parseImportPreview(JSON.stringify({format: 'filebackup-ledger', schema_version: 4, ...state})), /支持的备份台账格式/);
-});
-
test('the backup-target flag is the only reminder switch even for legacy reminder-off leaves', () => {
const leaf = {...assets.find(a => a.id === 'year'), backup_interval_days: 5, backup_enabled: false};
const result = reminders.leafReminder(state, leaf, now);
diff --git a/web/tests/navigation-draft.test.mjs b/web/tests/navigation-draft.test.mjs
index a3cac52..4d54e9b 100644
--- a/web/tests/navigation-draft.test.mjs
+++ b/web/tests/navigation-draft.test.mjs
@@ -14,6 +14,13 @@ test('folder hashes preserve exact IDs, pages and invalid or deleted folders fal
assert.deepEqual(navigation.parseRoute('#/due'), {page: 'overview', folderId: null});
});
+test('removed data-management links resolve to the directory without reviving a retired page', () => {
+ const route = navigation.parseRoute('#/data');
+ assert.deepEqual(route, {page: 'overview', folderId: null});
+ assert.equal(navigation.routeHash(route), '#/');
+ assert.deepEqual(navigation.parseRoute('#/history'), {page: 'history', folderId: null});
+});
+
test('marked terminal file routes resolve to their own record page', () => {
const route={page:'overview',folderId:'file'};
assert.deepEqual(navigation.resolveRoute(route,[{id:'file',kind:'file',backup_target:true}]),route);
diff --git a/web/tests/record-recovery.test.mjs b/web/tests/record-recovery.test.mjs
index df778a3..7e2dd29 100644
--- a/web/tests/record-recovery.test.mjs
+++ b/web/tests/record-recovery.test.mjs
@@ -30,18 +30,6 @@ test('bulk changes include only selected fields and allow deliberate clearing of
assert.throws(()=>buildBulkRecordChanges({time:false,location:true,notes:false},{time:'',location:' ',notes:''}),/位置/);
assert.throws(()=>buildBulkRecordChanges({time:false,location:false,notes:true},{time:'',location:'',notes:'x'.repeat(2001)}),/2000/);
});
-test('refresh retry after committed recovery does not repeat mutation',async()=>{
- const {createRefreshSafeAction}=await import('../src/recoveryActions.ts');let writes=0;let reads=0;
- const action=createRefreshSafeAction(async()=>{writes++;return {restored:true};});
- await assert.rejects(action.run(async()=>{reads++;throw new Error('refresh unavailable');}),/refresh unavailable/);
- assert.equal(action.committed(),true);await action.run(async()=>{reads++;});assert.equal(writes,1);assert.equal(reads,2);
-});
-test('failed recovery mutation remains retryable and parallel clicks share the attempt',async()=>{
- const {createRefreshSafeAction}=await import('../src/recoveryActions.ts');let writes=0;let release;
- const action=createRefreshSafeAction(async()=>{writes++;if(writes===1)throw new Error('collision');return new Promise(resolve=>{release=resolve;});});
- await assert.rejects(action.run(async()=>{}),/collision/);assert.equal(action.committed(),false);
- const first=action.run(async()=>{});const second=action.run(async()=>{});await Promise.resolve();release({restored:true});await Promise.all([first,second]);assert.equal(writes,2);
-});
const render=(component,props)=>renderToStaticMarkup(createElement(component,props));const noop=()=>{};
test('reuse-last is explicit in new-record dialogs and absent when editing historical records',async()=>{
const {BackupDialog}=await import('../src/components/BackupForms.tsx');const {BackupInfoDialog}=await import('../src/components/BackupInfoDialog.tsx');
@@ -57,7 +45,3 @@ test('bulk edit dialog requires explicit field selection and labels intentional
const {RecordBulkEditDialog}=await import('../src/components/RecordBulkEditDialog.tsx');const html=render(RecordBulkEditDialog,{state,ids:['r1','r2'],onClose:noop,onSaved:noop});
assert.match(html,/修改备份时间/);assert.match(html,/修改备份位置/);assert.match(html,/修改备注/);assert.match(html,/留空将清除所选记录的备注/);assert.match(html,/]*type="submit"[^>]*disabled/);
});
-test('collapsed recovery panel shows no privacy input or snapshot actions',async()=>{
- const {RecoveryPanels}=await import('../src/components/RecoveryPanels.tsx');const html=render(RecoveryPanels,{privacyOpen:false,onUnlockPrivacy:noop,onRefresh:noop});
- assert.match(html,/回收站/);assert.match(html,/自动备份/);assert.doesNotMatch(html,/输入隐私密码|立即备份|恢复台账/);
-});
diff --git a/web/tests/selectors.test.mjs b/web/tests/selectors.test.mjs
index ca9de82..cbfbee3 100644
--- a/web/tests/selectors.test.mjs
+++ b/web/tests/selectors.test.mjs
@@ -1,7 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { latestVersion, latestRecordsByLocation, latestRecordsForAsset, latestBackupForAsset, filterRecords, toDatetimeLocal, toBackupTimestamp } from '../src/selectors.ts';
-import { createLatestImportReader, parseImportPreview } from '../src/importData.ts';
import { buildRegisteredTree } from '../src/pathTree.ts';
process.env.TZ = 'America/Los_Angeles';
@@ -74,12 +73,6 @@ test('editing a record without changing its minute retains original seconds', ()
assert.equal(toBackupTimestamp('2026-01-02T00:15', '2026-01-02T08:15:49.500Z'), '2026-01-02T08:15:49.500Z');
assert.equal(toBackupTimestamp('2026-01-02T00:16', '2026-01-02T08:15:49.500Z'), '2026-01-02T08:16:00.000Z');
});
-test('invalid import shape is rejected before confirmation without leaking a TypeError', () => {
- assert.throws(() => parseImportPreview('null'), /支持的备份台账格式/);
- assert.throws(() => parseImportPreview('{'), /JSON 内容无法解析/);
- assert.throws(() => parseImportPreview(JSON.stringify({ format: 'filebackup-ledger', schema_version: 1, ...state, records: null })), /支持的备份台账格式/);
- assert.equal(parseImportPreview(JSON.stringify({ format: 'filebackup-ledger', schema_version: 1, ...state })).records.length, 4);
-});
test('directory view retains every accepted asset including empty and slash-only source paths', () => {
const summaries = ['', ' ', '/', '\\\\', 'D:/Photos', 'D:/Photos/Me'].map((source_path, index) => ({
asset: { id: String(index), name: `资料${index}`, kind: 'folder', source_path, notes: '', created_at: '' }, locations: new Map(),
@@ -94,24 +87,6 @@ test('directory view retains every accepted asset including empty and slash-only
assert.equal(drive.children.get('photos').assets[0].asset.id, '4');
assert.equal(drive.children.get('photos').children.get('me').assets[0].asset.id, '5');
});
-test('a slow previous file selection cannot replace the latest import preview', async () => {
- const read = createLatestImportReader();
- let resolveOld;
- const old = read({ size: 10, text: () => new Promise(resolve => { resolveOld = resolve; }) });
- const latest = await read({ size: 10, text: async () => JSON.stringify({ format: 'filebackup-ledger', schema_version: 1, ...state, records: [] }) });
- resolveOld(JSON.stringify({ format: 'filebackup-ledger', schema_version: 1, ...state }));
- assert.equal(latest.records.length, 0);
- assert.equal(await old, undefined);
-});
-test('a stale parse error cannot replace a newer valid file selection', async () => {
- const read = createLatestImportReader();
- let resolveOld;
- const old = read({ size: 10, text: () => new Promise(resolve => { resolveOld = resolve; }) });
- await read({ size: 10, text: async () => JSON.stringify({ format: 'filebackup-ledger', schema_version: 1, ...state }) });
- resolveOld('null');
- assert.equal(await old, undefined);
-});
-
test('retired paths remain stored without participating in visible history searches', () => {
const legacy={...state,assets:[{...state.assets[0],source_path:String.raw`\\fixture\personal_folder`}],records:[{...state.records[0],stored_path:String.raw`D:\Photos`}]};
assert.equal(filterRecords(legacy,{keyword:'D:/Photos'}).length,0);