mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-26 07:14:47 +08:00
feat: add Replay Mode
This commit is contained in:
13
web/src/core/replay/get-replay-id.ts
Normal file
13
web/src/core/replay/get-replay-id.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export function extractReplayIdFromURL() {
|
||||
if (typeof window === "undefined") {
|
||||
return null;
|
||||
}
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams.has("replay")) {
|
||||
return urlParams.get("replay");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
13
web/src/core/replay/hooks.ts
Normal file
13
web/src/core/replay/hooks.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { extractReplayIdFromURL } from "./get-replay-id";
|
||||
|
||||
export function useReplay() {
|
||||
const replayId = useMemo(() => {
|
||||
return extractReplayIdFromURL();
|
||||
}, []);
|
||||
return { isReplay: replayId != null, replayId };
|
||||
}
|
||||
4
web/src/core/replay/index.ts
Normal file
4
web/src/core/replay/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export * from "./hooks";
|
||||
Reference in New Issue
Block a user