From 099a7a77b817837c58a9eb301b86fdaa2c6ca574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9D=B0?= Date: Mon, 13 Oct 2025 14:34:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=AB=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E8=BF=9B=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game_pages/detail/index.tsx | 34 ++++++++++++++++++------- src/other_pages/ntrp-evaluate/index.tsx | 6 ++--- 2 files changed, 28 insertions(+), 12 deletions(-) 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() {