's'
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
const WECHAT_STORAGE_KEY = "salon_join_wechat";
|
||||
|
||||
@@ -76,6 +77,8 @@ export default function MyRegistrationStatus() {
|
||||
}
|
||||
};
|
||||
|
||||
const pathname = usePathname();
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
let cancelled = false;
|
||||
@@ -90,16 +93,23 @@ export default function MyRegistrationStatus() {
|
||||
if (e.persisted && !cancelled) fetchStatus();
|
||||
};
|
||||
window.addEventListener("vip:updated", onUpdate);
|
||||
window.addEventListener("registration:refresh", onUpdate);
|
||||
document.addEventListener("visibilitychange", onVisibilityChange);
|
||||
window.addEventListener("pageshow", onPageShow);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
window.removeEventListener("vip:updated", onUpdate);
|
||||
window.removeEventListener("registration:refresh", onUpdate);
|
||||
document.removeEventListener("visibilitychange", onVisibilityChange);
|
||||
window.removeEventListener("pageshow", onPageShow);
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 每次进入首页时强制重新拉取,避免预取/缓存导致显示旧状态
|
||||
useEffect(() => {
|
||||
if (pathname === "/") fetchStatus();
|
||||
}, [pathname]);
|
||||
|
||||
if (loading || !data?.hasRecord || !data.record) return null;
|
||||
|
||||
const rec = data.record;
|
||||
|
||||
Reference in New Issue
Block a user