mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-10 17:35:57 +00:00
feat(frontend): support static website demo mode (#3170)
* feat(frontend): support static website demo mode * fix(frontend): render html artifact previews from blob content * chore(frontend): apply pre-commit formatting * fix(frontend): address static demo PR review comments * Update the release information of DeerFlow --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { getBackendBaseURL } from "../config";
|
||||
import { isStaticWebsiteOnly } from "../static-mode";
|
||||
import type { AgentThread } from "../threads";
|
||||
|
||||
export function urlOfArtifact({
|
||||
@@ -12,6 +13,9 @@ export function urlOfArtifact({
|
||||
download?: boolean;
|
||||
isMock?: boolean;
|
||||
}) {
|
||||
if (isStaticWebsiteOnly()) {
|
||||
return staticDemoArtifactURL({ filepath, threadId, download });
|
||||
}
|
||||
if (isMock) {
|
||||
return `${getBackendBaseURL()}/mock/api/threads/${threadId}/artifacts${filepath}${download ? "?download=true" : ""}`;
|
||||
}
|
||||
@@ -23,5 +27,21 @@ export function extractArtifactsFromThread(thread: AgentThread) {
|
||||
}
|
||||
|
||||
export function resolveArtifactURL(absolutePath: string, threadId: string) {
|
||||
if (isStaticWebsiteOnly()) {
|
||||
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