0.5 缩减重构

This commit is contained in:
lix-2026
2026-04-13 19:21:42 +08:00
parent af92c4b149
commit 71fb1aee7e
2023 changed files with 21113 additions and 394493 deletions
+28 -28
View File
@@ -50,17 +50,17 @@ export const createDefaultTableSnapshot = (schema: TableSchema): DocumentTableSn
* @param documentId 当前文档的 ID
* @param title 表格的初始标题
* @returns 新创建的 DocumentTable
*/
export async function createOnlineTable(
documentId: string,
title: string = "未命名表格"
): Promise<DocumentTable> {
// 假设 Next.js API 路由 /api/tables/create 负责与 Supabase 交互
const response = await fetch("/api/tables/create", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
*/
export async function createOnlineTable(
documentId: string,
title: string = "未命名表格"
): Promise<DocumentTable> {
// 假设 Next.js API 路由 /api/tables/create 负责与 Supabase 交互
const response = await fetch("/api/tables/create", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
documentId,
title,
@@ -68,28 +68,28 @@ export async function createOnlineTable(
snapshot: createDefaultTableSnapshot(DEFAULT_TABLE_SCHEMA),
}),
});
if (!response.ok) {
throw new Error("Failed to create online table.");
}
const newTable: DocumentTable = await response.json();
return newTable;
}
/**
* 获取表格元数据 (用于紧凑模式渲染)
* 实际实现中,这可能需要一个更复杂的获取逻辑,例如同时获取前 N 行数据
*/
if (!response.ok) {
throw new Error("Failed to create online table.");
}
const newTable: DocumentTable = await response.json();
return newTable;
}
/**
* 获取表格元数据 (用于紧凑模式渲染)
* 实际实现中,这可能需要一个更复杂的获取逻辑,例如同时获取前 N 行数据
*/
export async function getDocumentTable(tableId: string): Promise<DocumentTable> {
const response = await fetch(`/api/tables/${tableId}`, {
method: "GET",
headers: { "Content-Type": "application/json" },
});
if (!response.ok) {
throw new Error("Failed to fetch document table.");
}
if (!response.ok) {
throw new Error("Failed to fetch document table.");
}
return response.json() as Promise<DocumentTable>;
}