pref:点击手机登陆后日志优化

This commit is contained in:
zdl
2025-11-26 11:43:16 +08:00
parent 7a2c73f3ca
commit 7b4c4be7bf
5 changed files with 8 additions and 34 deletions

View File

@@ -69,18 +69,20 @@ export const useSubscription = () => {
const error = useSelector(selectSubscriptionError);
const isSubscriptionModalOpen = useSelector(selectSubscriptionModalOpen);
// 自动加载订阅信息
// 自动加载订阅信息(带防重复逻辑)
useEffect(() => {
if (isAuthenticated && user) {
// 用户已登录,加载订阅信息
dispatch(fetchSubscriptionInfo());
logger.debug('useSubscription', '加载订阅信息', { userId: user.id });
// 只在没有数据且未在加载时才请求,避免多个组件重复调用
if (!subscriptionInfo.type && !loading) {
dispatch(fetchSubscriptionInfo());
logger.debug('useSubscription', '加载订阅信息', { userId: user.id });
}
} else {
// 用户未登录,重置为免费版
dispatch(resetToFree());
logger.debug('useSubscription', '用户未登录,重置为免费版');
}
}, [isAuthenticated, user, dispatch]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAuthenticated, user?.id, dispatch]);
// 获取订阅级别数值
const getSubscriptionLevel = (type = null) => {