mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-23 16:35:59 +00:00
fix(frontend): address static demo PR review comments
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import { isStaticWebsiteOnly } from "@/core/static-mode";
|
||||
import { DEMO_THREAD_IDS } from "@/core/threads/static-demo";
|
||||
|
||||
import { ChatProviders } from "./providers";
|
||||
|
||||
export function generateStaticParams() {
|
||||
if (!isStaticWebsiteOnly()) {
|
||||
return [];
|
||||
}
|
||||
return DEMO_THREAD_IDS.map((thread_id) => ({ thread_id }));
|
||||
}
|
||||
|
||||
|
||||
@@ -325,11 +325,7 @@ export function ArtifactFilePreview({
|
||||
<iframe
|
||||
className="size-full"
|
||||
title="Artifact preview"
|
||||
sandbox={
|
||||
isWriteFile
|
||||
? "allow-scripts allow-forms"
|
||||
: "allow-scripts allow-forms allow-same-origin"
|
||||
}
|
||||
sandbox="allow-scripts allow-forms"
|
||||
src={isWriteFile ? undefined : htmlPreviewUrl}
|
||||
srcDoc={isWriteFile ? content : undefined}
|
||||
/>
|
||||
|
||||
@@ -13,7 +13,10 @@ export function urlOfArtifact({
|
||||
download?: boolean;
|
||||
isMock?: boolean;
|
||||
}) {
|
||||
if (isMock || isStaticWebsiteOnly()) {
|
||||
if (isStaticWebsiteOnly()) {
|
||||
return staticDemoArtifactURL({ filepath, threadId, download });
|
||||
}
|
||||
if (isMock) {
|
||||
return `${getBackendBaseURL()}/mock/api/threads/${threadId}/artifacts${filepath}${download ? "?download=true" : ""}`;
|
||||
}
|
||||
return `${getBackendBaseURL()}/api/threads/${threadId}/artifacts${filepath}${download ? "?download=true" : ""}`;
|
||||
@@ -25,7 +28,20 @@ export function extractArtifactsFromThread(thread: AgentThread) {
|
||||
|
||||
export function resolveArtifactURL(absolutePath: string, threadId: string) {
|
||||
if (isStaticWebsiteOnly()) {
|
||||
return `${getBackendBaseURL()}/mock/api/threads/${threadId}/artifacts${absolutePath}`;
|
||||
return staticDemoArtifactURL({ filepath: absolutePath, threadId });
|
||||
}
|
||||
return `${getBackendBaseURL()}/api/threads/${threadId}/artifacts${absolutePath}`;
|
||||
}
|
||||
|
||||
function staticDemoArtifactURL({
|
||||
filepath,
|
||||
threadId,
|
||||
download = false,
|
||||
}: {
|
||||
filepath: string;
|
||||
threadId: string;
|
||||
download?: boolean;
|
||||
}) {
|
||||
const demoPath = filepath.replace(/^\/mnt\//, "/");
|
||||
return `${getBackendBaseURL()}/demo/threads/${threadId}${demoPath}${download ? "?download=true" : ""}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user