0.1.11 ai修复与全屏

This commit is contained in:
liaibo
2026-01-10 10:35:21 +08:00
parent e74219c802
commit 0bcdc3e730
55 changed files with 6597 additions and 174 deletions
+44
View File
@@ -7,14 +7,25 @@ import { buildDocumentTree } from "@/lib/documents";
type TypedClient = SupabaseClient<Database>;
export type SidebarTableRow = {
id: string;
workspace_id: string | null;
document_id: string;
title: string | null;
created_at: string | null;
updated_at: string | null;
};
export interface SidebarDataset {
documents: DocumentRecord[];
trashedDocuments: TrashRecord[];
trashedMediaAssets: MediaAsset[];
/**
* 仅依据远端 mindmap_data 判定的页面 id 列表;本地文件检测由服务器侧辅助完成
*/
mindmapDocs: string[];
mediaAssets?: MediaAsset[];
tables?: SidebarTableRow[];
}
export async function fetchSidebarDataset(
@@ -76,6 +87,7 @@ export async function fetchSidebarDataset(
.from("media_assets")
.select("*")
.eq("workspace_id", workspaceId)
.is("deleted_at", null)
.order("created_at", { ascending: false });
if (assetError) {
@@ -84,11 +96,43 @@ export async function fetchSidebarDataset(
const mediaAssets: MediaAsset[] = (assetRows ?? []) as MediaAsset[];
const { data: trashedAssetRows, error: trashedAssetError } = await client
.from("media_assets")
.select("*")
.eq("workspace_id", workspaceId)
.not("deleted_at", "is", null)
.is("purged_at", null)
.order("deleted_at", { ascending: false })
.limit(200);
if (trashedAssetError) {
throw new Error(`获取附件垃圾桶失败:${trashedAssetError.message}`);
}
const trashedMediaAssets: MediaAsset[] = (trashedAssetRows ?? []) as MediaAsset[];
// 说明:当前 supabase types 可能未包含 document_tables;这里用 any 兜底,
// 避免类型缺失阻塞侧边栏功能。
const { data: tableRows, error: tableError } = await (client as any)
.from("document_tables")
.select("id,workspace_id,document_id,title,created_at,updated_at,is_archived")
.eq("workspace_id", workspaceId)
.eq("is_archived", false)
.order("created_at", { ascending: true });
if (tableError) {
throw new Error(`获取在线表格列表失败:${tableError.message}`);
}
const tables: SidebarTableRow[] = (tableRows ?? []) as unknown as SidebarTableRow[];
return {
documents,
trashedDocuments,
trashedMediaAssets,
mindmapDocs,
mediaAssets,
tables,
};
}