@huyooo/ui 2.1.4 → 2.1.6

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.
Files changed (38) hide show
  1. package/dist/{AuthkitAppSetting-BJWwY3T-.js → AuthkitAppSetting-CHVSyEY1.js} +1 -1
  2. package/dist/{FeedbackModal.vue_vue_type_script_setup_true_lang-BJj1bNKu.js → FeedbackModal.vue_vue_type_script_setup_true_lang-FIZdBxIZ.js} +1 -1
  3. package/dist/{LegalDocViewer-DCDSLVjc.js → LegalDocViewer-DiNoy_oj.js} +2 -2
  4. package/dist/PaySubscriptions-pEZtjp1g.js +1287 -0
  5. package/dist/{PricingPlans-CXk2DNb4.js → PricingPlans-DNPKQwFa.js} +2 -2
  6. package/dist/{ReferrerReferees-ZhroFXBA.js → ReferrerReferees-t5s4LzbY.js} +1 -1
  7. package/dist/UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-DbkGYZ2f.js +601 -0
  8. package/dist/{WidthContainer-CDf1GiFk.js → WidthContainer-FXZqDMid.js} +4 -4
  9. package/dist/authkit.js +3 -3
  10. package/dist/common.js +1 -1
  11. package/dist/components/Authkit/AuthkitAppSetting.vue.d.ts +2 -2
  12. package/dist/components/Feedback/FeedbackModal.vue.d.ts +2 -2
  13. package/dist/components/LandingPage/LandingPageSections.vue.d.ts +1 -1
  14. package/dist/components/Message/MessageTabs.vue.d.ts +2 -2
  15. package/dist/components/Pay/PaySubscriptions.vue.d.ts +2 -2
  16. package/dist/components/UserMenu/UserMenuModals.vue.d.ts +9 -9
  17. package/dist/composables/Billing/useBillingSubscriptionSummary.d.ts +77 -258
  18. package/dist/composables.js +3 -3
  19. package/dist/feedback.js +1 -1
  20. package/dist/main.js +103 -102
  21. package/dist/pay.d.ts +1 -1
  22. package/dist/pay.js +18 -17
  23. package/dist/referrer.js +1 -1
  24. package/dist/style.css +1 -1
  25. package/dist/types/api/billing.generated.d.ts +2 -2
  26. package/dist/types/subscription.d.ts +57 -0
  27. package/dist/types/user.d.ts +3 -0
  28. package/dist/useAuthkitUsersProfile-D4H_Gxgd.js +67 -0
  29. package/dist/useBillingSubscriptionSummary-BC3G0N4t.js +43 -0
  30. package/dist/{useRoutePermission-ZOeRg6Wq.js → useRoutePermission-CGq_LIZM.js} +1 -1
  31. package/dist/useSubscriptionCheckout-3BtQARep.js +388 -0
  32. package/dist/user.js +1 -1
  33. package/dist/utils/subscriptionDisplay.d.ts +6 -6
  34. package/package.json +1 -1
  35. package/dist/PaySubscriptions-CXLqpfgf.js +0 -1331
  36. package/dist/UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-COM36ViG.js +0 -598
  37. package/dist/useAuthkitUsersProfile-DX2PYmdU.js +0 -59
  38. package/dist/useSubscriptionCheckout-DAwwBVAk.js +0 -353
@@ -287,7 +287,7 @@ export type Api = {
287
287
  };
288
288
  };
289
289
  summary: {
290
- /** 获取当前用户订阅、配额、积分和待支付账单摘要 */
290
+ /** 获取当前用户订阅快照(产品、价格、权益、配额、积分) */
291
291
  post: {
292
292
  return: any;
293
293
  };
@@ -3581,7 +3581,7 @@ export interface ApiClient {
3581
3581
  }, config?: RequestConfig) => RequestBuilder<any>;
3582
3582
  };
3583
3583
  summary: {
3584
- /** 获取当前用户订阅、配额、积分和待支付账单摘要 */
3584
+ /** 获取当前用户订阅快照(产品、价格、权益、配额、积分) */
3585
3585
  post: (config?: RequestConfig) => RequestBuilder<any>;
3586
3586
  };
3587
3587
  userDetail: {
@@ -0,0 +1,57 @@
1
+ /** 与 billing / profile.subscription 对齐的用户订阅快照 */
2
+ export interface UserSubscriptionSnapshotFeature {
3
+ key: string;
4
+ name?: string;
5
+ description?: string;
6
+ type: string;
7
+ value?: boolean | number | string | null;
8
+ highlight?: boolean;
9
+ }
10
+ export interface UserSubscriptionSnapshotQuota {
11
+ id: string;
12
+ featureKey: string;
13
+ name: string;
14
+ description?: string;
15
+ limit: number;
16
+ used: number;
17
+ remaining: number;
18
+ unlimited: boolean;
19
+ period: string;
20
+ resetsAt: string | null;
21
+ percentage: number;
22
+ }
23
+ export interface UserSubscriptionSnapshotEntitlement {
24
+ kind: 'plan' | 'beta';
25
+ status: string;
26
+ startAt: string | null;
27
+ endAt: string | null;
28
+ acquiredBy: 'subscribe' | 'free' | 'grant';
29
+ grantType?: 'backfill' | 'beta' | null;
30
+ sourceId: string;
31
+ cancelAtPeriodEnd?: boolean;
32
+ pendingChange?: Record<string, unknown> | null;
33
+ }
34
+ export interface UserSubscriptionSnapshot {
35
+ syncedAt: string;
36
+ product: {
37
+ id: string;
38
+ name: string;
39
+ description?: string | null;
40
+ } | null;
41
+ price: {
42
+ id: string;
43
+ nickname?: string | null;
44
+ type: string;
45
+ interval?: string | null;
46
+ intervalCount?: number | null;
47
+ unitAmount?: number | null;
48
+ currency?: string | null;
49
+ } | null;
50
+ entitlement: UserSubscriptionSnapshotEntitlement | null;
51
+ features: UserSubscriptionSnapshotFeature[];
52
+ quotas: UserSubscriptionSnapshotQuota[];
53
+ pointsBalance: {
54
+ totalPoints: number;
55
+ updateAt: string | null;
56
+ } | null;
57
+ }
@@ -1,3 +1,4 @@
1
+ import { UserSubscriptionSnapshot } from './subscription';
1
2
  export type UserStatusType = 'inactive' | 'normal';
2
3
  export interface BaseEntity {
3
4
  id: string;
@@ -105,6 +106,8 @@ export interface UserProfileType extends AuditableEntity, UserBaseInfo {
105
106
  personalInviteCode: string;
106
107
  role: RoleInfo | null;
107
108
  permissions: PermissionInfo[];
109
+ /** 订阅快照(产品 / 价格 / 权益 / 配额) */
110
+ subscription?: UserSubscriptionSnapshot | null;
108
111
  creatorInfo?: OperatorInfo;
109
112
  updatorInfo?: OperatorInfo;
110
113
  }
@@ -0,0 +1,67 @@
1
+ import { ref as a, computed as i } from "vue";
2
+ import { g as p } from "./apiClients-CWSwNzGk.js";
3
+ import { u as l } from "./useAuthkitAuth-CWHJs8zY.js";
4
+ const e = a(null), n = a(!1), u = a(!1), s = a(!1);
5
+ function v() {
6
+ s.value = !0;
7
+ }
8
+ function d(t) {
9
+ return t === 401 || t === 40101;
10
+ }
11
+ const h = i(() => !!e.value), m = i(() => {
12
+ if (!s.value || !u.value)
13
+ return "pending";
14
+ if (e.value)
15
+ return "authenticated";
16
+ const {
17
+ getToken: t
18
+ } = l();
19
+ return t() ? "authenticated" : "unauthenticated";
20
+ });
21
+ async function g() {
22
+ const {
23
+ getToken: t,
24
+ clearAuth: f
25
+ } = l();
26
+ if (!t()) {
27
+ e.value = null, u.value = !0;
28
+ return;
29
+ }
30
+ n.value = !0, u.value = !1;
31
+ const {
32
+ data: r,
33
+ error: o
34
+ } = await p().auth.users.profile.post({
35
+ meta: {
36
+ silentError: !0
37
+ }
38
+ });
39
+ if (n.value = !1, r) {
40
+ if (e.value = r, r.subscription) {
41
+ const {
42
+ useBillingSubscriptionSummary: c
43
+ } = await import("./useBillingSubscriptionSummary-BC3G0N4t.js");
44
+ c().hydrateFromProfile(r.subscription);
45
+ }
46
+ } else d(o == null ? void 0 : o.code) && (e.value = null, console.warn("认证已过期,清除认证状态"), f());
47
+ u.value = !0;
48
+ }
49
+ function k() {
50
+ e.value = null, n.value = !1, u.value = !0;
51
+ }
52
+ function b() {
53
+ return {
54
+ userProfile: e,
55
+ loading: n,
56
+ usersProfileReady: u,
57
+ authSessionBootstrapped: s,
58
+ isLoggedIn: h,
59
+ authSessionState: m,
60
+ fetchUserProfile: g,
61
+ clearUserProfile: k,
62
+ markAuthSessionBootstrapped: v
63
+ };
64
+ }
65
+ export {
66
+ b as u
67
+ };
@@ -0,0 +1,43 @@
1
+ import { ref as u, computed as t } from "vue";
2
+ import { g as d } from "./apiClients-CWSwNzGk.js";
3
+ function r() {
4
+ return {
5
+ syncedAt: "",
6
+ product: null,
7
+ price: null,
8
+ entitlement: null,
9
+ features: [],
10
+ quotas: [],
11
+ pointsBalance: null
12
+ };
13
+ }
14
+ const e = u(r()), a = u(!1);
15
+ function B() {
16
+ const o = t(() => e.value.product), l = t(() => e.value.price), s = t(() => e.value.entitlement), i = t(() => e.value.features), c = t(() => e.value.quotas), f = t(() => e.value.pointsBalance);
17
+ async function m() {
18
+ a.value = !0;
19
+ const {
20
+ data: n,
21
+ error: v
22
+ } = await d().billing.subscriptions.summary.post();
23
+ a.value = !1, !v && (e.value = n || r());
24
+ }
25
+ function p(n) {
26
+ n && (e.value = n);
27
+ }
28
+ return {
29
+ summary: e,
30
+ product: o,
31
+ price: l,
32
+ entitlement: s,
33
+ features: i,
34
+ quotas: c,
35
+ pointsBalance: f,
36
+ loading: a,
37
+ refresh: m,
38
+ hydrateFromProfile: p
39
+ };
40
+ }
41
+ export {
42
+ B as useBillingSubscriptionSummary
43
+ };
@@ -1,7 +1,7 @@
1
1
  import { computed as g, ref as L, watch as S } from "vue";
2
2
  import { useRouter as w, useRoute as C } from "vue-router";
3
3
  import { u as k } from "./useAuthkitAppsAuthPageInfo-2izIyMfu.js";
4
- import { u as M } from "./useAuthkitUsersProfile-DX2PYmdU.js";
4
+ import { u as M } from "./useAuthkitUsersProfile-D4H_Gxgd.js";
5
5
  import { u as K } from "./useAuthkitAuth-CWHJs8zY.js";
6
6
  function O(e, s = "default") {
7
7
  const n = document;
@@ -0,0 +1,388 @@
1
+ import { ref as p, computed as q } from "vue";
2
+ import { d as _ } from "./useBillingStatusOptions-C6edto7H.js";
3
+ import { g as $ } from "./apiClients-CWSwNzGk.js";
4
+ /* empty css */
5
+ import { Message as h } from "@arco-design/web-vue";
6
+ import { u as z } from "./useEnsureAuthenticated-RZ1DflLz.js";
7
+ function D(e) {
8
+ var u;
9
+ const i = (u = e == null ? void 0 : e.metadata) == null ? void 0 : u.originalPrice;
10
+ return typeof i == "number" ? i : void 0;
11
+ }
12
+ function F(e) {
13
+ const i = D(e);
14
+ return !e || i === void 0 || i <= e.unitAmount ? 0 : i - e.unitAmount;
15
+ }
16
+ function H(e) {
17
+ const i = F(e);
18
+ return i > 0 ? `优惠 ¥${P(i)}` : "";
19
+ }
20
+ function P(e) {
21
+ return e === void 0 ? 0 : Math.floor(e / 100);
22
+ }
23
+ function J(e, i = 1) {
24
+ const u = i > 1 ? `每 ${i} ` : "按";
25
+ switch (e) {
26
+ case "month":
27
+ return `${u}月订阅`;
28
+ case "year":
29
+ return `${u}年订阅`;
30
+ case "day":
31
+ return `${u}天订阅`;
32
+ case "week":
33
+ return `${u}周订阅`;
34
+ default:
35
+ return "";
36
+ }
37
+ }
38
+ function W(e) {
39
+ const i = e != null && e.intervalCount && e.intervalCount > 1 ? `${e.intervalCount} ` : "";
40
+ switch (e == null ? void 0 : e.interval) {
41
+ case "month":
42
+ return `/ ${i}月`;
43
+ case "year":
44
+ return `/ ${i}年`;
45
+ case "day":
46
+ return `/ ${i}天`;
47
+ case "week":
48
+ return `/ ${i}周`;
49
+ default:
50
+ return "";
51
+ }
52
+ }
53
+ function X(e) {
54
+ const i = (e == null ? void 0 : e.intervalCount) ?? 1;
55
+ switch (e == null ? void 0 : e.interval) {
56
+ case "month":
57
+ return `${i} 个月`;
58
+ case "year":
59
+ return `${i} 年`;
60
+ case "day":
61
+ return `${i} 天`;
62
+ case "week":
63
+ return `${i} 周`;
64
+ default:
65
+ return "";
66
+ }
67
+ }
68
+ function A(e) {
69
+ switch (e) {
70
+ case "day":
71
+ return "每天";
72
+ case "week":
73
+ return "每周";
74
+ case "month":
75
+ return "每月";
76
+ case "year":
77
+ return "每年";
78
+ case "lifetime":
79
+ return "不重置";
80
+ default:
81
+ return "";
82
+ }
83
+ }
84
+ function S(e) {
85
+ if (e.type === "quota" && e.value !== void 0) {
86
+ const i = A(e.quotaPeriod), u = i ? ` / ${i}` : "";
87
+ return `${e.name}: ${e.value === -1 ? "无限" : e.value}${u}`;
88
+ }
89
+ if (e.type === "unlimited") {
90
+ const i = A(e.quotaPeriod);
91
+ return i ? `${e.name}: 不限 / ${i}` : `${e.name}不限`;
92
+ }
93
+ return e.type === "boolean" && e.value === !1 ? `${e.name}(不支持)` : e.name;
94
+ }
95
+ function I(e) {
96
+ return e.type !== "recurring" || !e.interval ? null : {
97
+ key: `${e.interval}:${e.intervalCount ?? 1}`,
98
+ interval: e.interval,
99
+ intervalCount: e.intervalCount ?? 1
100
+ };
101
+ }
102
+ function Y(e, i) {
103
+ const u = {
104
+ day: 1,
105
+ week: 2,
106
+ month: 3,
107
+ year: 4
108
+ };
109
+ return u[e.interval] - u[i.interval] || e.intervalCount - i.intervalCount;
110
+ }
111
+ function Z(e, i) {
112
+ let u = 0;
113
+ for (const l of e)
114
+ for (const f of l.prices) {
115
+ const s = I(f);
116
+ (s == null ? void 0 : s.key) === i && (u = Math.max(u, F(f)));
117
+ }
118
+ return u > 0 ? `最高优惠 ¥${P(u)}` : void 0;
119
+ }
120
+ function ee(e) {
121
+ return e.includes(":") ? e : `${e}:1`;
122
+ }
123
+ function B() {
124
+ return !!localStorage.getItem("jwtToken");
125
+ }
126
+ function ae(e = "month") {
127
+ const i = p([]), u = p(null), l = p(null), f = p(!1), s = p(!1), a = p(ee(e)), m = q(() => {
128
+ const n = /* @__PURE__ */ new Map();
129
+ for (const t of i.value)
130
+ for (const r of t.prices) {
131
+ const o = I(r);
132
+ o && n.set(o.key, o);
133
+ }
134
+ return [...n.values()].sort(Y).map((t) => ({
135
+ value: t.key,
136
+ label: J(t.interval, t.intervalCount),
137
+ badge: Z(i.value, t.key)
138
+ }));
139
+ }), g = q(() => {
140
+ const n = [];
141
+ for (const t of i.value) {
142
+ const r = t.prices.find((c) => {
143
+ const b = I(c);
144
+ return (b == null ? void 0 : b.key) === a.value;
145
+ }), o = t.prices.find((c) => c.type === "free"), d = r ?? (o && t.prices.every((c) => c.type === "free") ? o : void 0);
146
+ d && n.push({
147
+ ...t,
148
+ features: d.features ?? [],
149
+ selectedPrice: d
150
+ });
151
+ }
152
+ return n;
153
+ });
154
+ function x(n) {
155
+ a.value = n;
156
+ }
157
+ function y(n) {
158
+ const t = u.value, r = l.value;
159
+ return t != null && t.priceId && n.selectedPrice ? t.priceId === n.selectedPrice.id : t ? t.productId === n.id : r != null && r.priceId && n.selectedPrice ? r.priceId === n.selectedPrice.id : r ? r.productId === n.id : !1;
160
+ }
161
+ function C(n) {
162
+ var t;
163
+ return ((t = u.value) == null ? void 0 : t.productId) === n.id;
164
+ }
165
+ function v(n) {
166
+ var t;
167
+ return ((t = n.selectedPrice) == null ? void 0 : t.type) === "free";
168
+ }
169
+ function U() {
170
+ return !!u.value;
171
+ }
172
+ function E(n) {
173
+ return !!(!n.selectedPrice || y(n) || v(n) && U());
174
+ }
175
+ function w(n) {
176
+ var t;
177
+ return ((t = n.metadata) == null ? void 0 : t.recommended) === !0;
178
+ }
179
+ function M(n) {
180
+ var t;
181
+ return P((t = n.selectedPrice) == null ? void 0 : t.unitAmount);
182
+ }
183
+ function G(n) {
184
+ const t = D(n.selectedPrice);
185
+ return t === void 0 ? void 0 : P(t);
186
+ }
187
+ function O(n) {
188
+ return v(n) ? "" : W(n.selectedPrice);
189
+ }
190
+ function T(n) {
191
+ if (v(n)) {
192
+ const t = X(n.selectedPrice);
193
+ return t ? `${t}免费体验` : "免费体验";
194
+ }
195
+ return H(n.selectedPrice);
196
+ }
197
+ function j(n) {
198
+ const t = [];
199
+ return y(n) ? t.push({
200
+ label: "当前方案",
201
+ type: "current"
202
+ }) : v(n) ? t.push({
203
+ label: "免费体验",
204
+ type: "trial"
205
+ }) : w(n) && t.push({
206
+ label: "最受欢迎",
207
+ type: "recommended"
208
+ }), t;
209
+ }
210
+ function N(n) {
211
+ const t = u.value;
212
+ return y(n) ? "当前方案" : v(n) ? t ? "已订阅付费方案" : B() ? "免费开通" : "免费注册" : t ? C(n) ? "切换周期" : typeof t.unitAmount == "number" && n.selectedPrice.unitAmount > t.unitAmount ? "升级方案" : "切换方案" : "立即订阅";
213
+ }
214
+ function R(n, t) {
215
+ const r = n.features.find((o) => o.type === "quota" && o.value !== void 0);
216
+ if (r) {
217
+ const o = A(r.quotaPeriod), d = r.value === -1 ? "不限量" : r.value;
218
+ return `${r.name} ${o ? `${d} / ${o}` : d},覆盖核心使用场景。`;
219
+ }
220
+ return v(n) ? "注册后自动开通免费权益,适合先体验核心能力。" : t === 1 ? "为正式团队准备的高配能力组合。" : "包含入门所需的核心能力。";
221
+ }
222
+ function K(n) {
223
+ return n.filter((t) => t.highlight !== !1).map((t) => ({
224
+ title: S(t),
225
+ description: t.description || ""
226
+ }));
227
+ }
228
+ function Q(n) {
229
+ const t = n.filter((c) => c.highlight !== !1), r = t.filter((c) => c.type === "quota" || c.type === "unlimited").map((c) => ({
230
+ title: S(c),
231
+ description: c.description || ""
232
+ })), o = t.filter((c) => c.type === "boolean" && c.value !== !1).map((c) => ({
233
+ title: c.name,
234
+ description: c.description || ""
235
+ })), d = [];
236
+ return o.length && d.push({
237
+ title: "功能特性",
238
+ items: o
239
+ }), r.length && d.push({
240
+ title: "用量配额",
241
+ items: r
242
+ }), d;
243
+ }
244
+ async function k() {
245
+ f.value = !0;
246
+ const {
247
+ data: n,
248
+ error: t
249
+ } = await _.productOptions();
250
+ if (f.value = !1, t)
251
+ return;
252
+ i.value = Array.isArray(n) ? n : [], !m.value.some((o) => o.value === a.value) && m.value[0] && (a.value = m.value[0].value);
253
+ }
254
+ async function L() {
255
+ var o;
256
+ if (!B()) {
257
+ u.value = null, l.value = null;
258
+ return;
259
+ }
260
+ s.value = !0;
261
+ const {
262
+ data: n,
263
+ error: t
264
+ } = await $().billing.subscriptions.summary.post();
265
+ if (s.value = !1, t)
266
+ return;
267
+ const r = n;
268
+ if (!(r != null && r.entitlement) || !r.product) {
269
+ u.value = null, l.value = null;
270
+ return;
271
+ }
272
+ if (r.entitlement.acquiredBy === "subscribe" && r.price) {
273
+ u.value = {
274
+ id: r.entitlement.sourceId,
275
+ productId: r.product.id,
276
+ productName: r.product.name,
277
+ priceId: r.price.id,
278
+ interval: r.price.interval || void 0,
279
+ intervalCount: r.price.intervalCount || void 0,
280
+ unitAmount: r.price.unitAmount || void 0,
281
+ currency: r.price.currency || void 0,
282
+ status: r.entitlement.status,
283
+ currentPeriodStart: r.entitlement.startAt || void 0,
284
+ currentPeriodEnd: r.entitlement.endAt,
285
+ cancelAtPeriodEnd: !!r.entitlement.cancelAtPeriodEnd,
286
+ pendingChange: r.entitlement.pendingChange || null,
287
+ trialEnd: null
288
+ }, l.value = null;
289
+ return;
290
+ }
291
+ u.value = null, l.value = {
292
+ id: r.entitlement.sourceId,
293
+ productId: r.product.id,
294
+ productName: r.product.name,
295
+ priceId: (o = r.price) == null ? void 0 : o.id,
296
+ status: r.entitlement.status,
297
+ startAt: r.entitlement.startAt,
298
+ endAt: r.entitlement.endAt
299
+ };
300
+ }
301
+ async function V() {
302
+ await Promise.all([k(), L()]);
303
+ }
304
+ return {
305
+ products: i,
306
+ plans: g,
307
+ currentSubscription: u,
308
+ currentTrial: l,
309
+ listLoading: f,
310
+ currentLoading: s,
311
+ billingInterval: a,
312
+ billingIntervalTabs: m,
313
+ setBillingInterval: x,
314
+ isCurrentPlan: y,
315
+ isSameProduct: C,
316
+ isRecommendedPlan: w,
317
+ isFreePlan: v,
318
+ isPlanActionDisabled: E,
319
+ getDisplayPrice: M,
320
+ getDisplayOriginalPrice: G,
321
+ getDisplayCycle: O,
322
+ getPromotionLabel: T,
323
+ getBadgeLabels: j,
324
+ getButtonLabel: N,
325
+ getPlanSummary: R,
326
+ getFeatureItems: K,
327
+ getFeatureGroups: Q,
328
+ loadProducts: k,
329
+ loadCurrentSubscription: L,
330
+ refresh: V
331
+ };
332
+ }
333
+ function te(e) {
334
+ window.open(e, "_blank", "noopener,noreferrer");
335
+ }
336
+ function ne(e) {
337
+ return e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : "";
338
+ }
339
+ function re(e) {
340
+ return e && typeof e == "object" && "alipayUrl" in e && typeof e.alipayUrl == "string" ? e.alipayUrl : "";
341
+ }
342
+ function de(e) {
343
+ const i = p(null), {
344
+ ensureAuthenticated: u
345
+ } = z();
346
+ async function l(s) {
347
+ if (!s.selectedPrice) {
348
+ h.warning("当前方案暂无可购买价格");
349
+ return;
350
+ }
351
+ if (!u(() => l(s))) return;
352
+ const a = e.currentSubscription.value;
353
+ if ((a == null ? void 0 : a.priceId) === s.selectedPrice.id) {
354
+ h.info("当前已经是该方案");
355
+ return;
356
+ }
357
+ if (s.selectedPrice.type === "free")
358
+ return;
359
+ i.value = s.id;
360
+ const m = a ? await $().billing.subscriptions.change.post({
361
+ subscriptionId: a.id,
362
+ newPriceId: s.selectedPrice.id,
363
+ proration: !0
364
+ }) : await $().billing.subscriptions.create.post({
365
+ priceId: s.selectedPrice.id
366
+ });
367
+ if (i.value = null, m.error)
368
+ return;
369
+ const g = re(m.data);
370
+ if (g) {
371
+ te(g);
372
+ return;
373
+ }
374
+ h.success(ne(m.data) || "订阅已更新"), await e.refreshCurrentSubscription();
375
+ }
376
+ function f(s) {
377
+ return i.value === s.id;
378
+ }
379
+ return {
380
+ checkoutPlanId: i,
381
+ checkout: l,
382
+ isCheckingOut: f
383
+ };
384
+ }
385
+ export {
386
+ de as a,
387
+ ae as u
388
+ };
package/dist/user.js CHANGED
@@ -1,4 +1,4 @@
1
- import { U as a, a as n, b as r, c as t, d as U, _ as u, e as i, f as M, g as o, h as m, i as I, j as c, k as d, l as b, m as f } from "./UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-COM36ViG.js";
1
+ import { U as a, a as n, b as r, c as t, d as U, _ as u, e as i, f as M, g as o, h as m, i as I, j as c, k as d, l as b, m as f } from "./UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-DbkGYZ2f.js";
2
2
  export {
3
3
  a as UserAccountMenu,
4
4
  n as UserAvatar,
@@ -1,7 +1,7 @@
1
- import { BillingSubscriptionSummaryEntitlement } from '../composables/Billing/useBillingSubscriptionSummary';
1
+ import { UserSubscriptionSnapshotEntitlement } from '../types/subscription';
2
2
  /** 菜单/弹窗统一的订阅主操作文案 */
3
- export declare function getSubscriptionActionLabel(entitlement: BillingSubscriptionSummaryEntitlement | null | undefined, paidProductCount: number): "" | "升级" | "修改订阅" | "订阅" | "查看价格方案";
4
- export declare function shouldShowSubscriptionAction(entitlement: BillingSubscriptionSummaryEntitlement | null | undefined, paidProductCount: number, canUpgrade?: boolean): boolean;
5
- export declare function getEntitlementDisplayName(entitlement: BillingSubscriptionSummaryEntitlement | null | undefined): string;
6
- /** 权益/订阅到期时间标签(trial 统一为权益有效期,不再区分试用文案) */
7
- export declare function getEntitlementEndAtLabel(entitlement: Pick<BillingSubscriptionSummaryEntitlement, "type"> | null | undefined): "当前周期结束" | "权益有效期至";
3
+ export declare function getSubscriptionActionLabel(entitlement: UserSubscriptionSnapshotEntitlement | null | undefined, paidProductCount: number): "" | "订阅" | "查看价格方案" | "修改订阅" | "升级";
4
+ export declare function shouldShowSubscriptionAction(entitlement: UserSubscriptionSnapshotEntitlement | null | undefined, paidProductCount: number, canUpgrade?: boolean): boolean;
5
+ export declare function getEntitlementDisplayName(entitlement: UserSubscriptionSnapshotEntitlement | null | undefined, productName?: string | null): string;
6
+ /** 权益/订阅到期时间标签 */
7
+ export declare function getEntitlementEndAtLabel(entitlement: UserSubscriptionSnapshotEntitlement | null | undefined): "当前周期结束" | "权益有效期至";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huyooo/ui",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [