diff --git a/app/HomeClient.tsx b/app/HomeClient.tsx index b5658a3..ea56ffc 100644 --- a/app/HomeClient.tsx +++ b/app/HomeClient.tsx @@ -1,7 +1,6 @@ "use client"; import { useCallback, useEffect, useState } from "react"; -import { HomePageSkeleton } from "@/app/components/HomePageSkeleton"; import { triggerPay } from "@/app/lib/triggerPay"; import { getPayEnv, getDeviceFromEnv } from "@/app/lib/payEnv"; import { usePayStatusPoll } from "@/app/lib/usePayStatusPoll"; @@ -166,7 +165,10 @@ function readVipBootstrapState(): { return { paidType: null, userName: null, userEmail: null }; } -/** 首页:init 完成前若尚未从本地恢复 VIP,不渲染落地页(避免 H5 reload 后先闪未解锁) */ +/** + * 首页:首帧以 localStorage 为准展示 VIP 控制台或访客落地页;init 仅后台同步/校验, + * 仅在服务端明确「非 VIP」等异常时更新状态(见 verifyInBackground / probe)。 + */ export default function HomeClient() { const [paidType, setPaidType] = useState( () => readVipBootstrapState().paidType @@ -178,7 +180,6 @@ export default function HomeClient() { () => readVipBootstrapState().userEmail ); const [payPendingOrderId, setPayPendingOrderId] = useState(null); - const [initDone, setInitDone] = useState(false); const savePaidType = useCallback((type: string | null) => { if (type) setStorage("paidType", type); @@ -526,7 +527,6 @@ export default function HomeClient() { const urlParams = new URLSearchParams(window.location.search); if (urlParams.get("type")?.trim() === "clean") { clearAllStorage(); - setInitDone(true); return; } /* paid=1 来自 URL 时不再无条件设置,需通过 confirm 或 PB 校验 */ @@ -661,13 +661,7 @@ export default function HomeClient() { } }; - void (async () => { - try { - await init(); - } finally { - setInitDone(true); - } - })(); + void init(); }, [ clearAllStorage, getOrCreateUserId, @@ -737,24 +731,19 @@ export default function HomeClient() { }, [clearAllStorage]); const isLoggedIn = paidType === "vip"; - const showGuestLanding = initDone && !isLoggedIn; return ( <> {isLoggedIn ? ( - ) : showGuestLanding ? ( - <> - - ) : ( - + )} diff --git a/app/HomeClientLoader.tsx b/app/HomeClientLoader.tsx index 3d7f80d..bf5ee9d 100644 --- a/app/HomeClientLoader.tsx +++ b/app/HomeClientLoader.tsx @@ -1,11 +1,13 @@ "use client"; import dynamic from "next/dynamic"; -import { HomePageSkeleton } from "./components/HomePageSkeleton"; const HomeClient = dynamic(() => import("./HomeClient"), { ssr: false, - loading: () => , + /** 仅纯色底,避免分包加载前白屏;真正 VIP/非 VIP 界面由 HomeClient 首帧同步读 localStorage 渲染 */ + loading: () => ( +
+ ), }); export function HomeClientLoader() { diff --git a/app/components/HomePageSkeleton.tsx b/app/components/HomePageSkeleton.tsx deleted file mode 100644 index f6c17b8..0000000 --- a/app/components/HomePageSkeleton.tsx +++ /dev/null @@ -1,63 +0,0 @@ -function SkeletonBlocks() { - return ( -
-
-
-
-
-
-
-
-
-
-
-
-
- ); -} - -type HomePageSkeletonProps = { - className?: string; - /** full:整页含顶栏;main:仅主内容区(已包在 VipLayout 内时用) */ - variant?: "full" | "main"; -}; - -/** - * 首页骨架(Server/Client 均可引用),保证首屏 HTML 即有可见结构,避免白屏。 - */ -export function HomePageSkeleton({ - className = "", - variant = "full", -}: HomePageSkeletonProps) { - const main = ( -
- -
- ); - - if (variant === "main") { - return ( -
- {main} -
- ); - } - - return ( -
-
-
-
-
- {main} -
- ); -} diff --git a/app/page.tsx b/app/page.tsx index 7801860..b3757e3 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,16 +1,9 @@ -import { HomePageSkeleton } from "./components/HomePageSkeleton"; import { HomeClientLoader } from "./HomeClientLoader"; export default function Page() { return ( -
- {/* SSR 即输出骨架,JS 未执行前也不白屏 */} -
- -
-
- -
+
+
); }