From e49fc1fc89d513841e306f79158733d29451bf2b Mon Sep 17 00:00:00 2001 From: chiyi Date: Mon, 12 Oct 2026 14:45:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(canvas):=20=E8=8A=82=E7=82=B9=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=9D=A1=E7=B2=BE=E7=AE=80=E4=B8=BA+=E5=8F=82?= =?UTF-8?q?=E8=80=83=E5=9B=BE/=E5=88=A0=E9=99=A4,=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E4=B8=8E=E5=9B=BE=E5=BA=93=E6=94=B9blob=E5=8A=A0=E8=BD=BD,?= =?UTF-8?q?=E5=8F=82=E8=80=83=E5=9B=BE=E8=87=AA=E5=8A=A8=E8=BF=9E=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api.js | 27 +++++-- .../src/components/canvas/CanvasNodeView.vue | 4 +- frontend/src/views/CanvasView.vue | 73 +++++++++++++++++-- 3 files changed, 88 insertions(+), 16 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index b7d43ea..5449dea 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -60,10 +60,9 @@ export function generatedUrl(name) { return `${BASE}/images/${s.replace(/^\/?images\//, '')}` } -/** Load a private image (thumbnail, falling back to the original) using the - * same Bearer token the SPA already has. Returns a browser blob: URL so the - * component can revoke it later. Throws on real failure. */ -export async function loadImageBlob(name, signal) { +/** Fetch a private image (thumbnail first, original as fallback) with the + * SPA's Bearer token. Returns { blob, status } — throws on real failure. */ +async function fetchImageBlob(name, signal) { const headers = auth.token ? { Authorization: `Bearer ${auth.token}` } : {} let u = thumbUrl(name) let r = await fetch(u, { headers, credentials: 'include', signal }) @@ -72,8 +71,24 @@ export async function loadImageBlob(name, signal) { r = await fetch(u, { headers, credentials: 'include', signal }) } if (!r.ok) throw new Error(`图片加载失败 (${r.status})`) - const blob = await r.blob() - return { url: URL.createObjectURL(blob), status: r.status } + return { blob: await r.blob(), status: r.status } +} + +/** Same as fetchImageBlob but returns a revocable blob: URL for /