From 04b807da8e2e7fbaff49f78dad25ba8065c2a68b Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Mon, 16 Mar 2026 11:32:11 +0800 Subject: [PATCH] v0.1.4-p2 --- backend/main.py | 22 +++++++++++++++++++ .../modules/dashboard/BotDashboardModule.tsx | 15 +++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/backend/main.py b/backend/main.py index f1a388e..12556d2 100644 --- a/backend/main.py +++ b/backend/main.py @@ -3096,6 +3096,28 @@ def public_download_workspace_file( return _serve_workspace_file(bot_id=bot_id, path=path, download=download, request=request, session=session) +@app.get("/api/bots/{bot_id}/workspace/raw/{path:path}") +def raw_workspace_file( + bot_id: str, + path: str, + download: bool = False, + request: Request = None, + session: Session = Depends(get_session), +): + return _serve_workspace_file(bot_id=bot_id, path=path, download=download, request=request, session=session) + + +@app.get("/public/bots/{bot_id}/workspace/raw/{path:path}") +def public_raw_workspace_file( + bot_id: str, + path: str, + download: bool = False, + request: Request = None, + session: Session = Depends(get_session), +): + return _serve_workspace_file(bot_id=bot_id, path=path, download=download, request=request, session=session) + + @app.post("/api/bots/{bot_id}/workspace/upload") async def upload_workspace_files( bot_id: str, diff --git a/frontend/src/modules/dashboard/BotDashboardModule.tsx b/frontend/src/modules/dashboard/BotDashboardModule.tsx index 390d2c3..604b7e5 100644 --- a/frontend/src/modules/dashboard/BotDashboardModule.tsx +++ b/frontend/src/modules/dashboard/BotDashboardModule.tsx @@ -1123,6 +1123,17 @@ export function BotDashboardModule({ if (forceDownload) query.push('download=1'); return `/public/bots/${encodeURIComponent(selectedBotId)}/workspace/download?${query.join('&')}`; }; + const buildWorkspaceRawHref = (filePath: string, forceDownload: boolean = false) => { + const normalized = String(filePath || '') + .trim() + .split('/') + .filter(Boolean) + .map((part) => encodeURIComponent(part)) + .join('/'); + if (!normalized) return ''; + const base = `/public/bots/${encodeURIComponent(selectedBotId)}/workspace/raw/${normalized}`; + return forceDownload ? `${base}?download=1` : base; + }; const closeWorkspacePreview = () => { setWorkspacePreview(null); setWorkspacePreviewFullscreen(false); @@ -1143,7 +1154,7 @@ export function BotDashboardModule({ const copyWorkspacePreviewUrl = async (filePath: string) => { const normalized = String(filePath || '').trim(); if (!selectedBotId || !normalized) return; - const hrefRaw = buildWorkspaceDownloadHref(normalized, false); + const hrefRaw = buildWorkspaceRawHref(normalized, false); const href = (() => { try { return new URL(hrefRaw, window.location.origin).href; @@ -6982,7 +6993,7 @@ export function BotDashboardModule({ ) : workspacePreview.isHtml ? (