's'
This commit is contained in:
@@ -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<string | null>(
|
||||
() => readVipBootstrapState().paidType
|
||||
@@ -178,7 +180,6 @@ export default function HomeClient() {
|
||||
() => readVipBootstrapState().userEmail
|
||||
);
|
||||
const [payPendingOrderId, setPayPendingOrderId] = useState<string | null>(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 (
|
||||
<>
|
||||
<VipLayout isLoggedIn={isLoggedIn} userName={userName} userEmail={userEmail} onLogout={handleLogout}>
|
||||
{isLoggedIn ? (
|
||||
<DashboardPage userName={userName} userEmail={userEmail} />
|
||||
) : showGuestLanding ? (
|
||||
<>
|
||||
<LandingPage
|
||||
onJoin={handlePay}
|
||||
onVerify={checkPaymentFromPB}
|
||||
onVerifyByEmail={checkVerifyByEmail}
|
||||
onVerifySuccess={handleVerifySuccess}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<HomePageSkeleton variant="main" />
|
||||
<LandingPage
|
||||
onJoin={handlePay}
|
||||
onVerify={checkPaymentFromPB}
|
||||
onVerifyByEmail={checkVerifyByEmail}
|
||||
onVerifySuccess={handleVerifySuccess}
|
||||
/>
|
||||
)}
|
||||
</VipLayout>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user