feat: 收口 mindmap Phase 6 Leptos UI shell
This commit is contained in:
@@ -25,6 +25,14 @@ export async function GET(
|
||||
{ params }: { params: Promise<{ docId: string; mindmapId: string }> },
|
||||
) {
|
||||
const { docId, mindmapId } = await params;
|
||||
const url = new URL(request.url);
|
||||
const view = url.searchParams.get("view");
|
||||
const queryName =
|
||||
view === "simple_mind_map_scene" || url.searchParams.get("queryName") === "mindmap.simple_mind_map_scene.get"
|
||||
? "mindmap.simple_mind_map_scene.get"
|
||||
: view === "editor_scene"
|
||||
? "mindmap.editor_scene.get"
|
||||
: "mindmaps.get";
|
||||
|
||||
if (isConvexEnabled()) {
|
||||
const { auth, client } = await getAuthedConvexClient();
|
||||
@@ -43,11 +51,12 @@ export async function GET(
|
||||
},
|
||||
});
|
||||
const envelope = buildDocumentQueryEnvelope({
|
||||
name: "mindmaps.get",
|
||||
name: queryName,
|
||||
payload: {
|
||||
documentId: docId,
|
||||
mindmapId,
|
||||
workspaceId: null,
|
||||
rootNodeId: url.searchParams.get("rootNodeId"),
|
||||
},
|
||||
});
|
||||
const plan = await resolveRustBridgeQueryPlan({ context, envelope });
|
||||
@@ -65,6 +74,9 @@ export async function GET(
|
||||
client,
|
||||
plan,
|
||||
});
|
||||
if (queryName === "mindmap.simple_mind_map_scene.get" || queryName === "mindmap.editor_scene.get") {
|
||||
return NextResponse.json(res);
|
||||
}
|
||||
return NextResponse.json({
|
||||
data: res?.data ?? defaultMindmapData,
|
||||
source: "convex",
|
||||
@@ -97,9 +109,12 @@ export async function POST(
|
||||
|
||||
if (isConvexEnabled()) {
|
||||
const { auth, client } = await getAuthedConvexClient();
|
||||
const { data, createOnly } = (await request.json().catch(() => ({ data: null }))) as {
|
||||
const { data, createOnly, commandName, commands, projectionRevision } = (await request.json().catch(() => ({ data: null }))) as {
|
||||
data?: unknown;
|
||||
createOnly?: boolean;
|
||||
commandName?: string;
|
||||
commands?: unknown[];
|
||||
projectionRevision?: number | null;
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -116,22 +131,31 @@ export async function POST(
|
||||
client: "wolai-frontend",
|
||||
},
|
||||
});
|
||||
const isCommandApply = commandName === "mindmap.command.apply";
|
||||
const envelope = buildDocumentCommandEnvelope({
|
||||
name: "mindmaps.put",
|
||||
payload: {
|
||||
documentId: docId,
|
||||
mindmapId,
|
||||
data: data ?? defaultMindmapData,
|
||||
createOnly: typeof createOnly === "boolean" ? createOnly : false,
|
||||
},
|
||||
name: isCommandApply ? "mindmap.command.apply" : "mindmaps.put",
|
||||
payload: isCommandApply
|
||||
? {
|
||||
documentId: docId,
|
||||
mindmapId,
|
||||
workspaceId: null,
|
||||
commands: Array.isArray(commands) ? commands : [],
|
||||
projectionRevision: typeof projectionRevision === "number" ? projectionRevision : null,
|
||||
}
|
||||
: {
|
||||
documentId: docId,
|
||||
mindmapId,
|
||||
data: data ?? defaultMindmapData,
|
||||
createOnly: typeof createOnly === "boolean" ? createOnly : false,
|
||||
},
|
||||
context,
|
||||
target: {
|
||||
workspaceId: null,
|
||||
pageId: docId,
|
||||
blockId: mindmapId,
|
||||
},
|
||||
reason: "mindmap-route:put",
|
||||
refs: ["task-032", "mindmap-route"],
|
||||
reason: isCommandApply ? "mindmap-route:command-apply" : "mindmap-route:put",
|
||||
refs: isCommandApply ? ["task-166", "mindmap-command-bridge"] : ["task-032", "mindmap-route"],
|
||||
});
|
||||
const plan = await resolveRustBridgeCommandPlan({ context, envelope });
|
||||
const result = await executeRustBridgeMutationTransport<{
|
||||
|
||||
Reference in New Issue
Block a user