v0.1.4-p2

main
mula.liu 2026-03-16 11:32:11 +08:00
parent c5b88d50df
commit 04b807da8e
2 changed files with 35 additions and 2 deletions

View File

@ -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,

View File

@ -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 ? (
<iframe
className="workspace-preview-embed"
src={buildWorkspaceDownloadHref(workspacePreview.path, false)}
src={buildWorkspaceRawHref(workspacePreview.path, false)}
title={workspacePreview.path}
/>
) : workspacePreview.isMarkdown ? (