0.3.2.1 UI修复3

This commit is contained in:
liaibo
2026-01-20 07:24:12 +08:00
parent fa7235b1a7
commit f13de35321
16 changed files with 741 additions and 108 deletions
@@ -542,7 +542,7 @@ function SidebarContent({ initialData, sidebarQuery }: SidebarContentProps) {
setOpen(false);
return;
}
const officeFileType = officeFileTypeFromAsset(asset.file_name ?? null, asset.mime_type ?? null);
if (officeFileType) {
const officeBase = getMnoteRuntimeConfig().onlyofficeBaseUrl;
@@ -571,15 +571,34 @@ function SidebarContent({ initialData, sidebarQuery }: SidebarContentProps) {
})();
return;
}
const url = asset.signed_url ?? asset.file_url;
if (!url) {
window.alert("暂无可用的文件链接");
return;
}
if (typeof window !== "undefined") {
window.open(url, "_blank", "noopener,noreferrer");
}
void (async () => {
try {
const res = await fetch(`/api/media/sign?assetId=${encodeURIComponent(asset.id)}`);
if (!res.ok) {
const payload = await res.json().catch(() => null);
throw new Error(payload?.error ?? "生成签名链接失败");
}
const { signedUrl } = (await res.json()) as { signedUrl: string };
if (!signedUrl) {
throw new Error("暂无可用的文件链接");
}
if (typeof window !== "undefined") {
window.open(signedUrl, "_blank", "noopener,noreferrer");
}
setOpen(false);
} catch {
const fallback = asset.signed_url ?? asset.file_url;
if (!fallback) {
window.alert("暂无可用的文件链接");
return;
}
if (typeof window !== "undefined") {
window.open(fallback, "_blank", "noopener,noreferrer");
}
setOpen(false);
}
})();
}, [activeId, editorBridge, router, setOpen]);
const handleFileTreeBlankMouseDown = useCallback(() => {
@@ -846,13 +865,28 @@ function SidebarContent({ initialData, sidebarQuery }: SidebarContentProps) {
window.alert("在线表格暂不支持下载(后续可做导出 JSON/Excel");
return;
}
const url = asset.signed_url ?? asset.file_url;
if (!url) {
window.alert("暂无可用的下载链接");
return;
}
if (typeof window !== "undefined") {
window.open(url, "_blank", "noopener,noreferrer");
try {
const res = await fetch(`/api/media/sign?assetId=${encodeURIComponent(asset.id)}`);
if (!res.ok) {
const payload = await res.json().catch(() => null);
throw new Error(payload?.error ?? "生成签名链接失败");
}
const { signedUrl } = (await res.json()) as { signedUrl: string };
if (!signedUrl) {
throw new Error("暂无可用的下载链接");
}
if (typeof window !== "undefined") {
window.open(signedUrl, "_blank", "noopener,noreferrer");
}
} catch {
const fallback = asset.signed_url ?? asset.file_url;
if (!fallback) {
window.alert("暂无可用的下载链接");
return;
}
if (typeof window !== "undefined") {
window.open(fallback, "_blank", "noopener,noreferrer");
}
}
}, []);