@huyooo/ui 2.1.4 → 2.1.8

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 (39) 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-qRWHwi9x.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/useBillingPlans.d.ts +10 -2
  18. package/dist/composables/Billing/useBillingSubscriptionSummary.d.ts +77 -258
  19. package/dist/composables.js +3 -3
  20. package/dist/feedback.js +1 -1
  21. package/dist/main.js +103 -102
  22. package/dist/pay.d.ts +1 -1
  23. package/dist/pay.js +18 -17
  24. package/dist/referrer.js +1 -1
  25. package/dist/style.css +1 -1
  26. package/dist/types/api/billing.generated.d.ts +2 -2
  27. package/dist/types/subscription.d.ts +57 -0
  28. package/dist/types/user.d.ts +3 -0
  29. package/dist/useAuthkitUsersProfile-D4H_Gxgd.js +67 -0
  30. package/dist/useBillingSubscriptionSummary-BC3G0N4t.js +43 -0
  31. package/dist/{useRoutePermission-ZOeRg6Wq.js → useRoutePermission-CGq_LIZM.js} +1 -1
  32. package/dist/useSubscriptionCheckout-Dmg0kt4F.js +399 -0
  33. package/dist/user.js +1 -1
  34. package/dist/utils/subscriptionDisplay.d.ts +6 -6
  35. package/package.json +1 -1
  36. package/dist/PaySubscriptions-CXLqpfgf.js +0 -1331
  37. package/dist/UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-COM36ViG.js +0 -598
  38. package/dist/useAuthkitUsersProfile-DX2PYmdU.js +0 -59
  39. 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,399 @@
1
+ import { ref as g, computed as S } from "vue";
2
+ import { d as V } 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 _ } from "./useEnsureAuthenticated-RZ1DflLz.js";
7
+ function D(e) {
8
+ var u;
9
+ const r = (u = e == null ? void 0 : e.metadata) == null ? void 0 : u.originalPrice;
10
+ return typeof r == "number" ? r : void 0;
11
+ }
12
+ function F(e) {
13
+ const r = D(e);
14
+ return !e || r === void 0 || r <= e.unitAmount ? 0 : r - e.unitAmount;
15
+ }
16
+ function H(e) {
17
+ var d;
18
+ const r = [], u = (d = e == null ? void 0 : e.metadata) == null ? void 0 : d.includedPointsLabel;
19
+ if (typeof u == "string" && u.trim())
20
+ r.push(u.trim());
21
+ else {
22
+ const s = typeof (e == null ? void 0 : e.bonusPoints) == "number" ? e.bonusPoints : 0;
23
+ s > 0 && r.push(`含 ${s.toLocaleString("zh-CN")} 积分`);
24
+ }
25
+ const l = F(e);
26
+ return l > 0 && r.push(`优惠 ¥${P(l)}`), r.join(" · ");
27
+ }
28
+ function P(e) {
29
+ return e === void 0 ? 0 : Math.floor(e / 100);
30
+ }
31
+ function J(e, r = 1) {
32
+ const u = r > 1 ? `每 ${r} ` : "按";
33
+ switch (e) {
34
+ case "month":
35
+ return `${u}月订阅`;
36
+ case "year":
37
+ return `${u}年订阅`;
38
+ case "day":
39
+ return `${u}天订阅`;
40
+ case "week":
41
+ return `${u}周订阅`;
42
+ default:
43
+ return "";
44
+ }
45
+ }
46
+ function W(e) {
47
+ const r = e != null && e.intervalCount && e.intervalCount > 1 ? `${e.intervalCount} ` : "";
48
+ switch (e == null ? void 0 : e.interval) {
49
+ case "month":
50
+ return `/ ${r}月`;
51
+ case "year":
52
+ return `/ ${r}年`;
53
+ case "day":
54
+ return `/ ${r}天`;
55
+ case "week":
56
+ return `/ ${r}周`;
57
+ default:
58
+ return "";
59
+ }
60
+ }
61
+ function X(e) {
62
+ const r = (e == null ? void 0 : e.intervalCount) ?? 1;
63
+ switch (e == null ? void 0 : e.interval) {
64
+ case "month":
65
+ return `${r} 个月`;
66
+ case "year":
67
+ return `${r} 年`;
68
+ case "day":
69
+ return `${r} 天`;
70
+ case "week":
71
+ return `${r} 周`;
72
+ default:
73
+ return "";
74
+ }
75
+ }
76
+ function A(e) {
77
+ switch (e) {
78
+ case "day":
79
+ return "每天";
80
+ case "week":
81
+ return "每周";
82
+ case "month":
83
+ return "每月";
84
+ case "year":
85
+ return "每年";
86
+ case "lifetime":
87
+ return "不重置";
88
+ default:
89
+ return "";
90
+ }
91
+ }
92
+ function q(e) {
93
+ if (e.type === "quota" && e.value !== void 0) {
94
+ const r = A(e.quotaPeriod), u = r ? ` / ${r}` : "";
95
+ return `${e.name}: ${e.value === -1 ? "无限" : e.value}${u}`;
96
+ }
97
+ if (e.type === "unlimited") {
98
+ const r = A(e.quotaPeriod);
99
+ return r ? `${e.name}: 不限 / ${r}` : `${e.name}不限`;
100
+ }
101
+ return e.type === "boolean" && e.value === !1 ? `${e.name}(不支持)` : e.name;
102
+ }
103
+ function I(e) {
104
+ return e.type !== "recurring" || !e.interval ? null : {
105
+ key: `${e.interval}:${e.intervalCount ?? 1}`,
106
+ interval: e.interval,
107
+ intervalCount: e.intervalCount ?? 1
108
+ };
109
+ }
110
+ function Y(e, r) {
111
+ const u = {
112
+ day: 1,
113
+ week: 2,
114
+ month: 3,
115
+ year: 4
116
+ };
117
+ return u[e.interval] - u[r.interval] || e.intervalCount - r.intervalCount;
118
+ }
119
+ function Z(e, r) {
120
+ let u = 0;
121
+ for (const l of e)
122
+ for (const d of l.prices) {
123
+ const s = I(d);
124
+ (s == null ? void 0 : s.key) === r && (u = Math.max(u, F(d)));
125
+ }
126
+ return u > 0 ? `最高优惠 ¥${P(u)}` : void 0;
127
+ }
128
+ function ee(e) {
129
+ return e.includes(":") ? e : `${e}:1`;
130
+ }
131
+ function B() {
132
+ return !!localStorage.getItem("jwtToken");
133
+ }
134
+ function ae(e = "month") {
135
+ const r = g([]), u = g(null), l = g(null), d = g(!1), s = g(!1), f = g(ee(e)), m = S(() => {
136
+ const n = /* @__PURE__ */ new Map();
137
+ for (const t of r.value)
138
+ for (const i of t.prices) {
139
+ const c = I(i);
140
+ c && n.set(c.key, c);
141
+ }
142
+ return [...n.values()].sort(Y).map((t) => ({
143
+ value: t.key,
144
+ label: J(t.interval, t.intervalCount),
145
+ badge: Z(r.value, t.key)
146
+ }));
147
+ }), p = S(() => {
148
+ const n = [];
149
+ for (const t of r.value) {
150
+ const i = t.prices.find((o) => {
151
+ const b = I(o);
152
+ return (b == null ? void 0 : b.key) === f.value;
153
+ }), c = t.prices.find((o) => o.type === "free"), a = i ?? (c && t.prices.every((o) => o.type === "free") ? c : void 0);
154
+ a && n.push({
155
+ ...t,
156
+ features: a.features ?? [],
157
+ selectedPrice: a
158
+ });
159
+ }
160
+ return n;
161
+ });
162
+ function x(n) {
163
+ f.value = n;
164
+ }
165
+ function y(n) {
166
+ const t = u.value, i = l.value;
167
+ return t != null && t.priceId && n.selectedPrice ? t.priceId === n.selectedPrice.id : t ? t.productId === n.id : i != null && i.priceId && n.selectedPrice ? i.priceId === n.selectedPrice.id : i ? i.productId === n.id : !1;
168
+ }
169
+ function C(n) {
170
+ var t;
171
+ return ((t = u.value) == null ? void 0 : t.productId) === n.id;
172
+ }
173
+ function v(n) {
174
+ var t;
175
+ return ((t = n.selectedPrice) == null ? void 0 : t.type) === "free";
176
+ }
177
+ function U() {
178
+ return !!u.value;
179
+ }
180
+ function E(n) {
181
+ return !!(!n.selectedPrice || y(n) || v(n) && U());
182
+ }
183
+ function w(n) {
184
+ var t;
185
+ return ((t = n.metadata) == null ? void 0 : t.recommended) === !0;
186
+ }
187
+ function M(n) {
188
+ var t;
189
+ return P((t = n.selectedPrice) == null ? void 0 : t.unitAmount);
190
+ }
191
+ function j(n) {
192
+ const t = D(n.selectedPrice);
193
+ return t === void 0 ? void 0 : P(t);
194
+ }
195
+ function G(n) {
196
+ return v(n) ? "" : W(n.selectedPrice);
197
+ }
198
+ function O(n) {
199
+ if (v(n)) {
200
+ const t = X(n.selectedPrice);
201
+ return t ? `${t}免费体验` : "免费体验";
202
+ }
203
+ return H(n.selectedPrice);
204
+ }
205
+ function T(n) {
206
+ const t = [];
207
+ return y(n) ? t.push({
208
+ label: "当前方案",
209
+ type: "current"
210
+ }) : v(n) ? t.push({
211
+ label: "免费体验",
212
+ type: "trial"
213
+ }) : w(n) && t.push({
214
+ label: "最受欢迎",
215
+ type: "recommended"
216
+ }), t;
217
+ }
218
+ function N(n) {
219
+ const t = u.value;
220
+ return y(n) ? "当前方案" : v(n) ? t ? "已订阅付费方案" : B() ? "免费开通" : "免费注册" : t ? C(n) ? "切换周期" : typeof t.unitAmount == "number" && n.selectedPrice.unitAmount > t.unitAmount ? "升级方案" : "切换方案" : "立即订阅";
221
+ }
222
+ function R(n, t) {
223
+ const i = typeof n.description == "string" ? n.description.trim() : "";
224
+ if (i)
225
+ return i;
226
+ const c = n.features.find((a) => a.type === "quota" && a.value !== void 0);
227
+ if (c) {
228
+ const a = A(c.quotaPeriod), o = c.value === -1 ? "不限量" : c.value;
229
+ return `${c.name} ${a ? `${o} / ${a}` : o},覆盖核心使用场景。`;
230
+ }
231
+ return v(n) ? "注册后自动开通免费权益,适合先体验核心能力。" : t === 1 ? "为正式团队准备的高配能力组合。" : "包含入门所需的核心能力。";
232
+ }
233
+ function z(n) {
234
+ return n.filter((t) => t.highlight !== !1).map((t) => ({
235
+ title: q(t),
236
+ description: t.description || ""
237
+ }));
238
+ }
239
+ function K(n) {
240
+ const t = n.filter((o) => o.highlight !== !1), i = t.filter((o) => o.type === "quota" || o.type === "unlimited").map((o) => ({
241
+ title: q(o),
242
+ description: o.description || ""
243
+ })), c = t.filter((o) => o.type === "boolean" && o.value !== !1).map((o) => ({
244
+ title: o.name,
245
+ description: o.description || ""
246
+ })), a = [];
247
+ return c.length && a.push({
248
+ title: "功能特性",
249
+ items: c
250
+ }), i.length && a.push({
251
+ title: "用量配额",
252
+ items: i
253
+ }), a;
254
+ }
255
+ async function k() {
256
+ d.value = !0;
257
+ const {
258
+ data: n,
259
+ error: t
260
+ } = await V.productOptions();
261
+ if (d.value = !1, t)
262
+ return;
263
+ r.value = Array.isArray(n) ? n : [], !m.value.some((c) => c.value === f.value) && m.value[0] && (f.value = m.value[0].value);
264
+ }
265
+ async function L() {
266
+ var c;
267
+ if (!B()) {
268
+ u.value = null, l.value = null;
269
+ return;
270
+ }
271
+ s.value = !0;
272
+ const {
273
+ data: n,
274
+ error: t
275
+ } = await $().billing.subscriptions.summary.post();
276
+ if (s.value = !1, t)
277
+ return;
278
+ const i = n;
279
+ if (!(i != null && i.entitlement) || !i.product) {
280
+ u.value = null, l.value = null;
281
+ return;
282
+ }
283
+ if (i.entitlement.acquiredBy === "subscribe" && i.price) {
284
+ u.value = {
285
+ id: i.entitlement.sourceId,
286
+ productId: i.product.id,
287
+ productName: i.product.name,
288
+ priceId: i.price.id,
289
+ interval: i.price.interval || void 0,
290
+ intervalCount: i.price.intervalCount || void 0,
291
+ unitAmount: i.price.unitAmount || void 0,
292
+ currency: i.price.currency || void 0,
293
+ status: i.entitlement.status,
294
+ currentPeriodStart: i.entitlement.startAt || void 0,
295
+ currentPeriodEnd: i.entitlement.endAt,
296
+ cancelAtPeriodEnd: !!i.entitlement.cancelAtPeriodEnd,
297
+ pendingChange: i.entitlement.pendingChange || null,
298
+ trialEnd: null
299
+ }, l.value = null;
300
+ return;
301
+ }
302
+ u.value = null, l.value = {
303
+ id: i.entitlement.sourceId,
304
+ productId: i.product.id,
305
+ productName: i.product.name,
306
+ priceId: (c = i.price) == null ? void 0 : c.id,
307
+ status: i.entitlement.status,
308
+ startAt: i.entitlement.startAt,
309
+ endAt: i.entitlement.endAt
310
+ };
311
+ }
312
+ async function Q() {
313
+ await Promise.all([k(), L()]);
314
+ }
315
+ return {
316
+ products: r,
317
+ plans: p,
318
+ currentSubscription: u,
319
+ currentTrial: l,
320
+ listLoading: d,
321
+ currentLoading: s,
322
+ billingInterval: f,
323
+ billingIntervalTabs: m,
324
+ setBillingInterval: x,
325
+ isCurrentPlan: y,
326
+ isSameProduct: C,
327
+ isRecommendedPlan: w,
328
+ isFreePlan: v,
329
+ isPlanActionDisabled: E,
330
+ getDisplayPrice: M,
331
+ getDisplayOriginalPrice: j,
332
+ getDisplayCycle: G,
333
+ getPromotionLabel: O,
334
+ getBadgeLabels: T,
335
+ getButtonLabel: N,
336
+ getPlanSummary: R,
337
+ getFeatureItems: z,
338
+ getFeatureGroups: K,
339
+ loadProducts: k,
340
+ loadCurrentSubscription: L,
341
+ refresh: Q
342
+ };
343
+ }
344
+ function te(e) {
345
+ window.open(e, "_blank", "noopener,noreferrer");
346
+ }
347
+ function ne(e) {
348
+ return e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : "";
349
+ }
350
+ function re(e) {
351
+ return e && typeof e == "object" && "alipayUrl" in e && typeof e.alipayUrl == "string" ? e.alipayUrl : "";
352
+ }
353
+ function de(e) {
354
+ const r = g(null), {
355
+ ensureAuthenticated: u
356
+ } = _();
357
+ async function l(s) {
358
+ if (!s.selectedPrice) {
359
+ h.warning("当前方案暂无可购买价格");
360
+ return;
361
+ }
362
+ if (!u(() => l(s))) return;
363
+ const f = e.currentSubscription.value;
364
+ if ((f == null ? void 0 : f.priceId) === s.selectedPrice.id) {
365
+ h.info("当前已经是该方案");
366
+ return;
367
+ }
368
+ if (s.selectedPrice.type === "free")
369
+ return;
370
+ r.value = s.id;
371
+ const m = f ? await $().billing.subscriptions.change.post({
372
+ subscriptionId: f.id,
373
+ newPriceId: s.selectedPrice.id,
374
+ proration: !0
375
+ }) : await $().billing.subscriptions.create.post({
376
+ priceId: s.selectedPrice.id
377
+ });
378
+ if (r.value = null, m.error)
379
+ return;
380
+ const p = re(m.data);
381
+ if (p) {
382
+ te(p);
383
+ return;
384
+ }
385
+ h.success(ne(m.data) || "订阅已更新"), await e.refreshCurrentSubscription();
386
+ }
387
+ function d(s) {
388
+ return r.value === s.id;
389
+ }
390
+ return {
391
+ checkoutPlanId: r,
392
+ checkout: l,
393
+ isCheckingOut: d
394
+ };
395
+ }
396
+ export {
397
+ de as a,
398
+ ae as u
399
+ };
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.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [