import { NextResponse } from "next/server"; import { isConvexEnabled } from "@/lib/convex/enabled"; import { getAuthedConvexClient } from "@/lib/convex/route"; import { api } from "@/lib/convex/api"; export const dynamic = "force-dynamic"; interface EmptyTrashPayload { workspaceId?: string; } export async function POST(request: Request) { if (isConvexEnabled()) { const { client } = await getAuthedConvexClient(); const { workspaceId }: EmptyTrashPayload = await request.json().catch(() => ({})); if (!workspaceId) { return NextResponse.json({ error: "缺少 workspaceId" }, { status: 400 }); } try { const result = await client.mutation(api.mindmaps.emptyTrashByWorkspace, { workspaceId }); return NextResponse.json({ ok: true, removed: result?.deletedCount ?? 0 }); } catch (error) { return NextResponse.json({ error: (error as Error).message }, { status: 400 }); } } return NextResponse.json({ error: "当前仅支持 Convex 模式" }, { status: 501 }); }