diff --git a/src/game_pages/detail/index.tsx b/src/game_pages/detail/index.tsx index 695a61f..45d1409 100644 --- a/src/game_pages/detail/index.tsx +++ b/src/game_pages/detail/index.tsx @@ -54,13 +54,25 @@ dayjs.locale("zh-cn"); const useSceneRedirect = (defaultPage: string) => { useLoad((options) => { if (options.scene) { - const decoded = decodeURIComponent(options.scene); - const params = Object.fromEntries(new URLSearchParams(decoded)); - const query = Object.entries(params) - .map(([k, v]) => `${k}=${encodeURIComponent(v)}`) - .join("&"); + try { + const decoded = decodeURIComponent(options.scene || ""); + const params: Record = {}; + decoded.split("&").forEach((pair) => { + const [key, value] = pair.split("="); + if (key) params[key] = value ? decodeURIComponent(value) : ""; + }); - Taro.redirectTo({ url: `/${defaultPage}?${query}` }); + // 拼接成 URL query + const query = Object.entries(params) + .map(([k, v]) => `${k}=${encodeURIComponent(v)}`) + .join("&"); + + Taro.redirectTo({ + url: query ? `/${defaultPage}?${query}` : `/${defaultPage}`, + }); + } catch (err) { + console.error("scene 解析失败:", err); + } } }); }; @@ -324,8 +336,10 @@ const SharePopup = forwardRef(({ id, from, detail, userInfo }, ref) => { // const posterRef = useRef(); useEffect(() => { - changeMessageType(); - }, []); + if (id) { + changeMessageType(); + } + }, [id]); async function changeMessageType() { try { @@ -1394,7 +1408,9 @@ function Index() { useDidShow(async () => { // await updateLocation(); // await fetchUserInfo(); - await fetchDetail(); + if (id) { + await fetchDetail(); + } }); const updateLocation = async () => { diff --git a/src/other_pages/ntrp-evaluate/index.tsx b/src/other_pages/ntrp-evaluate/index.tsx index 623c08d..aac57e7 100644 --- a/src/other_pages/ntrp-evaluate/index.tsx +++ b/src/other_pages/ntrp-evaluate/index.tsx @@ -192,7 +192,7 @@ function Intro() { @@ -236,7 +236,7 @@ function Intro() { @@ -244,7 +244,7 @@ function Intro() {