From dfce4fc88fe67a69f3114834948d55d9a070acb7 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 23 Feb 2026 17:51:03 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20v3.0=20bug=E4=BF=AE=E5=A4=8D=E2=80=94?= =?UTF-8?q?=E2=80=94=E5=88=86=E4=BA=AB=E6=9D=83=E9=99=90=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E3=80=81session=5Fnot=5Ffound=E5=8F=8B=E5=A5=BD=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E3=80=81=E5=9B=BE=E7=89=87=E8=AF=86=E5=88=AB=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/report-preview/page.jsx | 127 ++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 5 deletions(-) diff --git a/app/report-preview/page.jsx b/app/report-preview/page.jsx index fb771fa..95b6692 100644 --- a/app/report-preview/page.jsx +++ b/app/report-preview/page.jsx @@ -1,6 +1,7 @@ 'use client'; import { useEffect, useMemo, useRef, useState } from 'react'; +import { useRouter } from 'next/navigation'; import Starfield from '../../components/Starfield'; const ZODIAC_SYMBOL = { @@ -81,6 +82,11 @@ export default function ReportPreviewPage() { const [error, setError] = useState(''); const headerRef = useRef(null); const [headerVisible, setHeaderVisible] = useState(false); + const [showShare, setShowShare] = useState(false); + const [copied, setCopied] = useState(false); + const [showRestart, setShowRestart] = useState(false); + const [isOwner, setIsOwner] = useState(false); + const router = useRouter(); useEffect(() => { if (typeof window === 'undefined') return; @@ -112,7 +118,12 @@ export default function ReportPreviewPage() { setData(d.report); return; } - if (d?.status === 'error') throw new Error(d?.error || '生成失败'); + if (d?.status === 'error') { + if (d?.error === 'session_not_found') { + throw new Error('SESSION_NOT_FOUND'); + } + throw new Error(d?.error || '生成失败'); + } // generating 或 not_started → 等2秒再试 if (attempt < 29) { await new Promise(resolve => setTimeout(resolve, 2000)); @@ -123,7 +134,13 @@ export default function ReportPreviewPage() { finally { setLoading(false); } }; - useEffect(() => { load(); }, [sid]); + useEffect(() => { + if (sid) { + const localSid = localStorage.getItem('lingjing_sid') || ''; + setIsOwner(localSid === sid); + load(); + } + }, [sid]); return (
@@ -133,7 +150,7 @@ export default function ReportPreviewPage() {

LINGJING REPORT

-

你的灵镜报告

+

{isOwner ? '你的灵镜报告' : 'ta的灵镜报告'}

{loading ? ( @@ -145,8 +162,18 @@ export default function ReportPreviewPage() { ) : null} {error ? (
-

{error}

- + {error === 'SESSION_NOT_FOUND' ? ( + <> +

找不到你的报告记录

+

可能是之前的对话已过期

+ + + ) : ( + <> +

{error}

+ + + )}
) : null} @@ -311,7 +338,97 @@ export default function ReportPreviewPage() { ) : null} + + {/* 底部操作区(仅本人可见) */} + {!loading && !error && data && isOwner ? ( +
+ + +
+ ) : null} + + + {/* 分享弹窗 */} + {showShare ? ( +
setShowShare(false)}> +
e.stopPropagation()}> +

分享给朋友

+

朋友可以直接看到你的完整报告

+
+

+ {typeof window !== 'undefined' ? window.location.href : ''} +

+ +
+

朋友看完可以在页面底部做自己的报告

+ +
+
+ ) : null} + + {/* 重做确认弹窗 */} + {showRestart ? ( +
setShowRestart(false)}> +
e.stopPropagation()}> +

重新开始?

+

重新开始会生成全新报告,当前报告不会保留,确定吗?

+
+ + +
+
+
+ ) : null} + + {/* 分享页底部引导(仅非本人查看时显示) */} + {!isOwner ? ( +
+

看完 ta 的报告?来做你自己的

+ +
+ ) : null} +
); }