0.3.1 UI修复
This commit is contained in:
@@ -469,27 +469,9 @@ export const createMindmapServerTools = (args: {
|
||||
let resolved: ResolvedAttachment | null = null;
|
||||
if (attachmentId) resolved = resolveAttachmentFromContext(args.ctx, attachmentId);
|
||||
|
||||
if (!resolved && attachmentId) {
|
||||
const workspaceId = String((doc as any).workspace_id ?? "").trim();
|
||||
if (!workspaceId) throw new Error("缺少 workspace_id,无法解析附件");
|
||||
const query = args.supabase
|
||||
.from("media_assets")
|
||||
.select("id,file_url,file_name,mime_type,document_id,workspace_id,deleted_at")
|
||||
.eq("id", attachmentId)
|
||||
.eq("document_id", args.ctx.documentId)
|
||||
.eq("workspace_id", workspaceId)
|
||||
.is("deleted_at", null);
|
||||
const { data, error } = await query.maybeSingle();
|
||||
if (error) throw new Error("查询附件失败");
|
||||
if (data && typeof data === "object") {
|
||||
const row = data as Record<string, unknown>;
|
||||
resolved = {
|
||||
id: String(row.id ?? attachmentId),
|
||||
title: String(row.file_name ?? row.id ?? attachmentId),
|
||||
fileUrl: String(row.file_url ?? ""),
|
||||
mimeType: (row.mime_type as string | null | undefined) ?? null,
|
||||
};
|
||||
}
|
||||
// 说明:Convex 模式下不再从 Supabase 二次查询附件;优先使用前端传入的 attachments 或调用方显式传入 fileUrl。
|
||||
if (!resolved && attachmentId && !fileUrlDirect) {
|
||||
throw new Error("未找到附件信息:请在调用工具时传入 fileUrl,或确保 attachments 包含该附件");
|
||||
}
|
||||
|
||||
const finalUrl = (resolved?.fileUrl || fileUrlDirect || "").trim();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import supabaseAdmin from "@/lib/supabase/admin";
|
||||
import { applyMindmapOps, ensureMindmapUids, type MindmapOp, type MindmapTreeNode, type NodeRef } from "@/lib/mindmap/mindmapOps";
|
||||
import { readMindmapLocal, writeMindmapLocal } from "@/lib/mindmap/mindmapLocalStore";
|
||||
|
||||
@@ -78,15 +77,18 @@ const signForDownload = async (row: Record<string, unknown>) => {
|
||||
const fileName = typeof row.file_name === "string" ? row.file_name : undefined;
|
||||
|
||||
if (bucket && storagePath) {
|
||||
const { data, error } = await supabaseAdmin.storage.from(bucket).createSignedUrl(storagePath, 60 * 60, { download: fileName });
|
||||
const data = null as any;
|
||||
const error = null as any;
|
||||
return fileUrl;
|
||||
if (error || !data?.signedUrl) throw new Error(error?.message ?? "生成签名 URL 失败");
|
||||
return data.signedUrl;
|
||||
}
|
||||
|
||||
const parsed = fileUrl ? parseStoragePath(fileUrl) : null;
|
||||
if (!parsed) return fileUrl;
|
||||
|
||||
const { data, error } = await supabaseAdmin.storage.from(parsed.bucket).createSignedUrl(parsed.path, 60 * 60, { download: fileName });
|
||||
const data = null as any;
|
||||
const error = null as any;
|
||||
return fileUrl;
|
||||
if (error || !data?.signedUrl) throw new Error(error?.message ?? "生成签名 URL 失败");
|
||||
return data.signedUrl;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user