@windrun-huaiin/third-ui 7.5.2 → 7.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -24,17 +24,30 @@ export function MoneyPriceInteractive({
|
|
|
24
24
|
const { redirectToSignIn, user } = useClerk();
|
|
25
25
|
const router = useRouter();
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
//
|
|
27
|
+
const [billingType, setBillingType] = useState<'monthly' | 'yearly'>(() => {
|
|
28
|
+
// 懒初始化:只在组件首次渲染时计算一次
|
|
29
|
+
// 如果用户有活跃订阅,通过 priceId 精确匹配计费周期
|
|
30
30
|
if (fingerprintContext?.xSubscription?.status === 'active' && fingerprintContext.xSubscription.priceId) {
|
|
31
|
-
|
|
31
|
+
const userPriceId = fingerprintContext.xSubscription.priceId;
|
|
32
|
+
const providerConfig = getActiveProviderConfig(config);
|
|
33
|
+
|
|
34
|
+
// 检查所有年付计划的 priceId
|
|
35
|
+
const yearlyPriceIds = [
|
|
36
|
+
providerConfig.products.free.plans.yearly.priceId,
|
|
37
|
+
providerConfig.products.pro.plans.yearly.priceId,
|
|
38
|
+
providerConfig.products.ultra.plans.yearly.priceId
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
// 如果匹配到年付计划,返回 yearly,否则返回 monthly
|
|
42
|
+
if (yearlyPriceIds.includes(userPriceId)) {
|
|
43
|
+
return 'yearly';
|
|
44
|
+
} else {
|
|
45
|
+
return 'monthly';
|
|
46
|
+
}
|
|
32
47
|
}
|
|
33
48
|
// 否则使用默认值
|
|
34
49
|
return data.billingSwitch.defaultKey as 'monthly' | 'yearly';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const [billingType, setBillingType] = useState<'monthly' | 'yearly'>(getInitialBillingType());
|
|
50
|
+
});
|
|
38
51
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
39
52
|
const [tooltip, setTooltip] = useState<{
|
|
40
53
|
show: boolean;
|