mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-26 15:24:48 +08:00
feat: enhance replay and fast-forward replay
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
// 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);
|
||||
export function extractReplayIdFromSearchParams(params: string) {
|
||||
const urlParams = new URLSearchParams(params);
|
||||
if (urlParams.has("replay")) {
|
||||
return urlParams.get("replay");
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { extractReplayIdFromURL } from "./get-replay-id";
|
||||
import { extractReplayIdFromSearchParams } from "./get-replay-id";
|
||||
|
||||
export function useReplay() {
|
||||
const replayId = useMemo(() => {
|
||||
return extractReplayIdFromURL();
|
||||
}, []);
|
||||
const searchParams = useSearchParams();
|
||||
const replayId = useMemo(
|
||||
() => extractReplayIdFromSearchParams(searchParams.toString()),
|
||||
[searchParams],
|
||||
);
|
||||
return { isReplay: replayId != null, replayId };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user