forked from bai/curriculum-project-hub
feat(filelib): 移除最近打开模块(ADR-0032,supersede ADR-0031 对应半部)
- FileLibRecentVisit 删表(手写迁移;表当日新建无生产数据) - recentService/recentRoutes/RecentView 删除;GridLibraryView 埋点与 navTarget 跳转一并移除;types 清 RecentEntry - 左栏保留 文件库/回收站(ADR-0031 回收站半部不受影响) - breadcrumb 的 role 字段保留(独立可用的增量字段)
This commit is contained in:
@@ -23,14 +23,6 @@
|
||||
import GrantsPanel from "./GrantsPanel.svelte";
|
||||
import OverviewPanel from "./OverviewPanel.svelte";
|
||||
|
||||
/** 最近打开上报的导航目标(ADR-0031):父组件传入后,本组件跳到对应节点并清除。 */
|
||||
export interface NavTarget {
|
||||
readonly nodeId: string;
|
||||
readonly filePath?: string | undefined;
|
||||
}
|
||||
|
||||
let { navTarget = null, onnavigated }: { navTarget?: NavTarget | null; onnavigated?: () => void } = $props();
|
||||
|
||||
const RANK: Record<Role, number> = { VIEW: 1, EDIT: 2, MANAGE: 3 };
|
||||
const atLeast = (role: Role, min: Role): boolean => RANK[role] >= RANK[min];
|
||||
|
||||
@@ -107,14 +99,6 @@
|
||||
|
||||
onMount(loadChildren);
|
||||
|
||||
/** 最近打开上报(ADR-0031):fire-and-forget,失败静默,不阻塞浏览。 */
|
||||
function record(nodeId: string, filePath?: string): void {
|
||||
void api("/database/api/recent", {
|
||||
method: "POST",
|
||||
body: { nodeId, ...(filePath !== undefined ? { filePath } : {}) },
|
||||
}).catch(() => undefined);
|
||||
}
|
||||
|
||||
function refresh(): void {
|
||||
selected = null;
|
||||
menu = null;
|
||||
@@ -126,7 +110,6 @@
|
||||
|
||||
function openNode(n: StackItem): void {
|
||||
selected = null;
|
||||
record(n.id);
|
||||
if (n.kind === "FOLDER") {
|
||||
stack = [...stack, n];
|
||||
void loadChildren();
|
||||
@@ -174,43 +157,6 @@
|
||||
void loadChildren();
|
||||
}
|
||||
|
||||
/** 跳到任意节点(最近打开入口):breadcrumb 建栈,FOLDER 进子层,PROJECT 进文件视图。 */
|
||||
async function navigateTo(target: NavTarget): Promise<void> {
|
||||
try {
|
||||
const r = await api<{ breadcrumb: Array<{ id: string | null; name: string | null; kind: "FOLDER" | "PROJECT"; role: Role | null }> }>(
|
||||
`/database/api/nodes/${target.nodeId}/breadcrumb`,
|
||||
);
|
||||
const visible = r.breadcrumb.filter(
|
||||
(e): e is { id: string; name: string; kind: "FOLDER" | "PROJECT"; role: Role | null } =>
|
||||
e.id !== null && e.name !== null,
|
||||
);
|
||||
if (visible.length === 0) return;
|
||||
const self = visible[visible.length - 1]!;
|
||||
selected = null;
|
||||
if (self.kind === "FOLDER") {
|
||||
view = "nodes";
|
||||
projectNode = null;
|
||||
clearSelectedFile();
|
||||
stack = visible.map((e) => ({ id: e.id, name: e.name, kind: e.kind, role: e.role ?? "VIEW" }));
|
||||
await loadChildren();
|
||||
} else {
|
||||
stack = visible.slice(0, -1).map((e) => ({ id: e.id, name: e.name, kind: e.kind, role: e.role ?? "VIEW" }));
|
||||
projectNode = await fetchDetail(self.id);
|
||||
view = "files";
|
||||
await loadFiles();
|
||||
if (target.filePath !== undefined) selectedFilePath.set(target.filePath);
|
||||
}
|
||||
} catch (e) {
|
||||
toastErr(errText(e));
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (navTarget === null) return;
|
||||
const t = navTarget;
|
||||
void navigateTo(t).finally(() => onnavigated?.());
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------ 节点操作 */
|
||||
|
||||
function openCreate(kind: "FOLDER" | "PROJECT", parentId: string | null): void {
|
||||
@@ -300,7 +246,6 @@
|
||||
/* ------------------------------------------------------------ 文件操作 */
|
||||
|
||||
function previewFile(f: FileEntry): void {
|
||||
if (projectNode !== null) record(projectNode.id, f.path);
|
||||
selectedFilePath.set(f.path);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user