@huyooo/ui 2.1.12 → 2.1.14

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