@windrun-huaiin/third-ui 7.4.2 → 7.5.0
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.
|
@@ -22,20 +22,32 @@ function MoneyPriceInteractive({ data, config, upgradeApiEndpoint, signInPath })
|
|
|
22
22
|
const [tooltip, setTooltip] = React.useState({ show: false, content: '', x: 0, y: 0 });
|
|
23
23
|
// 确定用户状态
|
|
24
24
|
const getUserState = React.useCallback(() => {
|
|
25
|
-
var _a, _b;
|
|
26
25
|
if (!fingerprintContext)
|
|
27
26
|
return moneyPriceTypes.UserState.Anonymous;
|
|
28
27
|
const { xUser, xSubscription } = fingerprintContext;
|
|
29
28
|
if (!(xUser === null || xUser === void 0 ? void 0 : xUser.clerkUserId))
|
|
30
29
|
return moneyPriceTypes.UserState.Anonymous;
|
|
31
|
-
if (!(xSubscription === null || xSubscription === void 0 ? void 0 : xSubscription.status) || xSubscription.status
|
|
30
|
+
if (!(xSubscription === null || xSubscription === void 0 ? void 0 : xSubscription.status) || xSubscription.status !== 'active')
|
|
32
31
|
return moneyPriceTypes.UserState.FreeUser;
|
|
33
|
-
|
|
32
|
+
// 通过 priceId 精确匹配订阅计划
|
|
33
|
+
const userPriceId = xSubscription.priceId;
|
|
34
|
+
if (!userPriceId)
|
|
35
|
+
return moneyPriceTypes.UserState.FreeUser;
|
|
36
|
+
const providerConfig = moneyPriceConfigUtil.getActiveProviderConfig(config);
|
|
37
|
+
// 检查是否为 Pro 计划 (月付或年付)
|
|
38
|
+
const proMonthly = providerConfig.products.pro.plans.monthly.priceId;
|
|
39
|
+
const proYearly = providerConfig.products.pro.plans.yearly.priceId;
|
|
40
|
+
if (userPriceId === proMonthly || userPriceId === proYearly) {
|
|
34
41
|
return moneyPriceTypes.UserState.ProUser;
|
|
35
|
-
|
|
42
|
+
}
|
|
43
|
+
// 检查是否为 Ultra 计划 (月付或年付)
|
|
44
|
+
const ultraMonthly = providerConfig.products.ultra.plans.monthly.priceId;
|
|
45
|
+
const ultraYearly = providerConfig.products.ultra.plans.yearly.priceId;
|
|
46
|
+
if (userPriceId === ultraMonthly || userPriceId === ultraYearly) {
|
|
36
47
|
return moneyPriceTypes.UserState.UltraUser;
|
|
48
|
+
}
|
|
37
49
|
return moneyPriceTypes.UserState.FreeUser;
|
|
38
|
-
}, [fingerprintContext]);
|
|
50
|
+
}, [fingerprintContext, config]);
|
|
39
51
|
// 优化 userContext 使用 useMemo
|
|
40
52
|
const userContext = React.useMemo(() => {
|
|
41
53
|
var _a, _b, _c;
|
|
@@ -20,20 +20,32 @@ function MoneyPriceInteractive({ data, config, upgradeApiEndpoint, signInPath })
|
|
|
20
20
|
const [tooltip, setTooltip] = useState({ show: false, content: '', x: 0, y: 0 });
|
|
21
21
|
// 确定用户状态
|
|
22
22
|
const getUserState = useCallback(() => {
|
|
23
|
-
var _a, _b;
|
|
24
23
|
if (!fingerprintContext)
|
|
25
24
|
return UserState.Anonymous;
|
|
26
25
|
const { xUser, xSubscription } = fingerprintContext;
|
|
27
26
|
if (!(xUser === null || xUser === void 0 ? void 0 : xUser.clerkUserId))
|
|
28
27
|
return UserState.Anonymous;
|
|
29
|
-
if (!(xSubscription === null || xSubscription === void 0 ? void 0 : xSubscription.status) || xSubscription.status
|
|
28
|
+
if (!(xSubscription === null || xSubscription === void 0 ? void 0 : xSubscription.status) || xSubscription.status !== 'active')
|
|
30
29
|
return UserState.FreeUser;
|
|
31
|
-
|
|
30
|
+
// 通过 priceId 精确匹配订阅计划
|
|
31
|
+
const userPriceId = xSubscription.priceId;
|
|
32
|
+
if (!userPriceId)
|
|
33
|
+
return UserState.FreeUser;
|
|
34
|
+
const providerConfig = getActiveProviderConfig(config);
|
|
35
|
+
// 检查是否为 Pro 计划 (月付或年付)
|
|
36
|
+
const proMonthly = providerConfig.products.pro.plans.monthly.priceId;
|
|
37
|
+
const proYearly = providerConfig.products.pro.plans.yearly.priceId;
|
|
38
|
+
if (userPriceId === proMonthly || userPriceId === proYearly) {
|
|
32
39
|
return UserState.ProUser;
|
|
33
|
-
|
|
40
|
+
}
|
|
41
|
+
// 检查是否为 Ultra 计划 (月付或年付)
|
|
42
|
+
const ultraMonthly = providerConfig.products.ultra.plans.monthly.priceId;
|
|
43
|
+
const ultraYearly = providerConfig.products.ultra.plans.yearly.priceId;
|
|
44
|
+
if (userPriceId === ultraMonthly || userPriceId === ultraYearly) {
|
|
34
45
|
return UserState.UltraUser;
|
|
46
|
+
}
|
|
35
47
|
return UserState.FreeUser;
|
|
36
|
-
}, [fingerprintContext]);
|
|
48
|
+
}, [fingerprintContext, config]);
|
|
37
49
|
// 优化 userContext 使用 useMemo
|
|
38
50
|
const userContext = useMemo(() => {
|
|
39
51
|
var _a, _b, _c;
|
package/package.json
CHANGED
|
@@ -40,11 +40,30 @@ export function MoneyPriceInteractive({
|
|
|
40
40
|
const { xUser, xSubscription } = fingerprintContext;
|
|
41
41
|
|
|
42
42
|
if (!xUser?.clerkUserId) return UserState.Anonymous;
|
|
43
|
-
if (!xSubscription?.status || xSubscription.status
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (!xSubscription?.status || xSubscription.status !== 'active') return UserState.FreeUser;
|
|
44
|
+
|
|
45
|
+
// 通过 priceId 精确匹配订阅计划
|
|
46
|
+
const userPriceId = xSubscription.priceId;
|
|
47
|
+
if (!userPriceId) return UserState.FreeUser;
|
|
48
|
+
|
|
49
|
+
const providerConfig = getActiveProviderConfig(config);
|
|
50
|
+
|
|
51
|
+
// 检查是否为 Pro 计划 (月付或年付)
|
|
52
|
+
const proMonthly = providerConfig.products.pro.plans.monthly.priceId;
|
|
53
|
+
const proYearly = providerConfig.products.pro.plans.yearly.priceId;
|
|
54
|
+
if (userPriceId === proMonthly || userPriceId === proYearly) {
|
|
55
|
+
return UserState.ProUser;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 检查是否为 Ultra 计划 (月付或年付)
|
|
59
|
+
const ultraMonthly = providerConfig.products.ultra.plans.monthly.priceId;
|
|
60
|
+
const ultraYearly = providerConfig.products.ultra.plans.yearly.priceId;
|
|
61
|
+
if (userPriceId === ultraMonthly || userPriceId === ultraYearly) {
|
|
62
|
+
return UserState.UltraUser;
|
|
63
|
+
}
|
|
64
|
+
|
|
46
65
|
return UserState.FreeUser;
|
|
47
|
-
}, [fingerprintContext]);
|
|
66
|
+
}, [fingerprintContext, config]);
|
|
48
67
|
|
|
49
68
|
// 优化 userContext 使用 useMemo
|
|
50
69
|
const userContext = useMemo<UserContext>(() => {
|