feat: add Replay Mode

This commit is contained in:
Li Xin
2025-04-24 21:51:08 +08:00
parent 3735706065
commit cb4b7b7495
10 changed files with 1035 additions and 40 deletions

View 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;
}

View 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 };
}

View File

@@ -0,0 +1,4 @@
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT
export * from "./hooks";