@huyooo/ui 2.1.3 → 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 (62) hide show
  1. package/dist/{AuthkitAppSetting-1FsF45E3.js → AuthkitAppSetting-CHVSyEY1.js} +9 -9
  2. package/dist/{Contact-DBG20I8Y.js → Contact-BTQf8tEx.js} +3 -3
  3. package/dist/{CustomTable-HDwqEcmB.js → CustomTable-BY0oHLXc.js} +1 -1
  4. package/dist/{FeedbackModal.vue_vue_type_script_setup_true_lang-hveEkBb4.js → FeedbackModal.vue_vue_type_script_setup_true_lang-FIZdBxIZ.js} +5 -5
  5. package/dist/{LandingPageSectionTabs-BT08gT7_.js → LandingPageSectionTabs-Bl6X2W5W.js} +2 -2
  6. package/dist/{LegalDocViewer-DvsnAv6f.js → LegalDocViewer-DiNoy_oj.js} +10 -10
  7. package/dist/{MessageHandle-BUufez4S.js → MessageHandle-DDGFSJMg.js} +3 -3
  8. package/dist/{MessageList-rttvPmxV.js → MessageList-CE5E_5Uv.js} +1 -1
  9. package/dist/PaySubscriptions-pEZtjp1g.js +1287 -0
  10. package/dist/{PricingPlans-CQaXgOIR.js → PricingPlans-DNPKQwFa.js} +4 -4
  11. package/dist/{ReferrerReferees-CGrH-gYJ.js → ReferrerReferees-t5s4LzbY.js} +4 -4
  12. package/dist/{Upload.vue_vue_type_script_setup_true_lang-CgZQOZYt.js → Upload.vue_vue_type_script_setup_true_lang-DsrqOACa.js} +1 -1
  13. package/dist/UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-DbkGYZ2f.js +601 -0
  14. package/dist/{WidthContainer-BzU8aEwN.js → WidthContainer-FXZqDMid.js} +10 -10
  15. package/dist/apiClients-CWSwNzGk.js +272 -0
  16. package/dist/authkit.js +10 -10
  17. package/dist/common.js +2 -2
  18. package/dist/components/Authkit/AuthkitAppSetting.vue.d.ts +2 -2
  19. package/dist/components/Feedback/FeedbackModal.vue.d.ts +2 -2
  20. package/dist/components/LandingPage/LandingPageSections.vue.d.ts +1 -1
  21. package/dist/components/Message/MessageTabs.vue.d.ts +2 -2
  22. package/dist/components/Pay/PaySubscriptions.vue.d.ts +2 -2
  23. package/dist/components/UserMenu/UserMenuModals.vue.d.ts +9 -9
  24. package/dist/composables/Billing/useBillingSubscriptionSummary.d.ts +77 -258
  25. package/dist/composables.js +13 -13
  26. package/dist/feedback.js +2 -2
  27. package/dist/{fetchAuthPageAboutUs-DV7ArpNZ.js → fetchAuthPageAboutUs-CLQlGhQy.js} +2 -2
  28. package/dist/{index-Cn6LcfZO.js → index-BYH7DaQf.js} +1 -1
  29. package/dist/landingPage.js +1 -1
  30. package/dist/main.js +117 -116
  31. package/dist/message.js +5 -5
  32. package/dist/pay.d.ts +1 -1
  33. package/dist/pay.js +18 -17
  34. package/dist/privateCom.js +1 -1
  35. package/dist/referrer.js +1 -1
  36. package/dist/{runtime-Dp7MgwhI.js → runtime-DDJRAtkv.js} +1 -1
  37. package/dist/style.css +1 -1
  38. package/dist/types/api/billing.generated.d.ts +2 -2
  39. package/dist/types/subscription.d.ts +57 -0
  40. package/dist/types/user.d.ts +3 -0
  41. package/dist/upload.js +2 -2
  42. package/dist/{useAuthkitAppsAuthPageInfo-DZ1p-P3Q.js → useAuthkitAppsAuthPageInfo-2izIyMfu.js} +6 -2
  43. package/dist/{useAuthkitAuth-cHrJMM8E.js → useAuthkitAuth-CWHJs8zY.js} +2 -2
  44. package/dist/{useAuthkitCreateAndUpdate-Bbv7vZZn.js → useAuthkitCreateAndUpdate-COI5KVPJ.js} +1 -1
  45. package/dist/useAuthkitUsersProfile-D4H_Gxgd.js +67 -0
  46. package/dist/{useBillingStatusOptions-Br-iL77Z.js → useBillingStatusOptions-C6edto7H.js} +1 -1
  47. package/dist/useBillingSubscriptionSummary-BC3G0N4t.js +43 -0
  48. package/dist/{useEnsureAuthenticated-C8qS8DLL.js → useEnsureAuthenticated-RZ1DflLz.js} +2 -2
  49. package/dist/{useLegalDocs-C4qk5CTb.js → useLegalDocs-xXYvYpPC.js} +2 -2
  50. package/dist/{useMessageNotifications-D9uikt21.js → useMessageNotifications-pxa5LHjV.js} +1 -1
  51. package/dist/{usePageSEO-Dl6_kBWP.js → usePageSEO-B3stKP3n.js} +2 -2
  52. package/dist/{useRoutePermission-DYPZgvYv.js → useRoutePermission-CGq_LIZM.js} +3 -3
  53. package/dist/useSubscriptionCheckout-3BtQARep.js +388 -0
  54. package/dist/user.js +1 -1
  55. package/dist/utils/passkeySupport.d.ts +1 -1
  56. package/dist/utils/subscriptionDisplay.d.ts +6 -6
  57. package/package.json +1 -1
  58. package/dist/PaySubscriptions-Bv6LQ_Pf.js +0 -1331
  59. package/dist/UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-Di-VAlur.js +0 -598
  60. package/dist/apiClients-Ctcq8NZs.js +0 -245
  61. package/dist/useAuthkitUsersProfile-8FzLTfUJ.js +0 -55
  62. package/dist/useSubscriptionCheckout-CYU2Ke0y.js +0 -353
@@ -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-Di-VAlur.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,
@@ -2,7 +2,7 @@
2
2
  export declare function isPasskeyEnvironmentReady(): boolean;
3
3
  /** 返回无法使用 Passkey 的原因;为 null 表示环境检测通过 */
4
4
  export declare function getPasskeyEnvironmentIssue(): string | null;
5
- /** 将 WebAuthn 错误转为中文提示 */
5
+ /** 将 WebAuthn / 网络错误转为中文提示 */
6
6
  export declare function formatPasskeyError(error: unknown): string;
7
7
  /** 生成默认 Passkey 名称 */
8
8
  export declare function buildDefaultPasskeyName(): string;
@@ -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.3",
3
+ "version": "2.1.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [