chore: import existing Endoleap Pages Router project

This commit is contained in:
2026-11-05 23:18:09 +08:00
commit 982fa188e2
84 changed files with 8374 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import type { Profile } from "./api";
export type Workspace = { id: string; name: string };
type Request = <T>(path: string, options?: RequestInit) => Promise<T>;
export async function loadWorkspaceHome(
request: Request,
signal?: AbortSignal,
) {
const [profile, result] = await Promise.all([
request<Profile>("profile", { signal }),
request<Workspace[] | { items: Workspace[] }>("workspaces", { signal }),
]);
return {
profile,
workspaces: Array.isArray(result) ? result : result.items || [],
};
}
export async function createBoard(
request: Request,
title: string,
workspaceId: string,
onWorkspaceCreated: (workspace: Workspace) => void,
) {
let id = workspaceId;
if (!id) {
const workspace = await request<Workspace>("workspaces", {
method: "POST",
body: JSON.stringify({ name: "个人空间" }),
});
id = workspace.id;
onWorkspaceCreated(workspace);
}
return request<{ id: string }>("workspaces/" + id + "/materials", {
method: "POST",
body: JSON.stringify({
kind: "board",
title: title.trim(),
content: { schema_version: 1 },
}),
});
}