@huyooo/ui 0.15.1 → 0.15.2

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.
@@ -366,7 +366,6 @@ export type Api = {
366
366
  body: {
367
367
  priceId: string;
368
368
  featureKey: string;
369
- name: string;
370
369
  description?: string;
371
370
  limit: number;
372
371
  period: "day" | "week" | "month" | "year" | "lifetime";
@@ -389,7 +388,6 @@ export type Api = {
389
388
  post: {
390
389
  body: {
391
390
  id: string;
392
- name?: string;
393
391
  description?: string;
394
392
  limit?: number;
395
393
  period?: "day" | "week" | "month" | "year" | "lifetime";
@@ -3375,7 +3373,6 @@ export interface ApiClient {
3375
3373
  post: (body: {
3376
3374
  priceId: string;
3377
3375
  featureKey: string;
3378
- name: string;
3379
3376
  description?: string;
3380
3377
  limit: number;
3381
3378
  period: "day" | "week" | "month" | "year" | "lifetime";
@@ -3392,7 +3389,6 @@ export interface ApiClient {
3392
3389
  /** 更新配额定义 */
3393
3390
  post: (body: {
3394
3391
  id: string;
3395
- name?: string;
3396
3392
  description?: string;
3397
3393
  limit?: number;
3398
3394
  period?: "day" | "week" | "month" | "year" | "lifetime";
@@ -1,19 +1,19 @@
1
- import { ref as y, computed as q } from "vue";
2
- import { d as J } from "./useBillingStatusOptions-CAsu1hrf.js";
3
- import { h as I } from "./apiClients-DT7o0IpO.js";
1
+ import { ref as y, computed as L } from "vue";
2
+ import { d as H } from "./useBillingStatusOptions-CAsu1hrf.js";
3
+ import { h as $ } from "./apiClients-DT7o0IpO.js";
4
4
  /* empty css */
5
5
  import { Message as g } from "@arco-design/web-vue";
6
- import { u as N } from "./useEnsureAuthenticated-BEKhtQAl.js";
7
- function x(e) {
6
+ import { u as J } from "./useEnsureAuthenticated-BEKhtQAl.js";
7
+ function M(e) {
8
8
  var i;
9
9
  const r = (i = e == null ? void 0 : e.metadata) == null ? void 0 : i.originalPrice;
10
10
  return typeof r == "number" ? r : void 0;
11
11
  }
12
- function W(e) {
13
- const r = x(e);
12
+ function N(e) {
13
+ const r = M(e);
14
14
  return !e || r === void 0 || r <= e.unitAmount ? 0 : Math.round((1 - e.unitAmount / r) * 100);
15
15
  }
16
- function X(e) {
16
+ function W(e) {
17
17
  var l, f;
18
18
  const r = (l = e == null ? void 0 : e.metadata) == null ? void 0 : l.discountLabel;
19
19
  if (typeof r == "string" && r.trim())
@@ -21,10 +21,10 @@ function X(e) {
21
21
  const i = (f = e == null ? void 0 : e.metadata) == null ? void 0 : f.savingMonths;
22
22
  return typeof i == "number" && i > 0 ? `买 ${12 - i} 个月送 ${i} 个月` : "";
23
23
  }
24
- function S(e) {
24
+ function q(e) {
25
25
  return e === void 0 ? 0 : Math.floor(e / 100);
26
26
  }
27
- function Y(e, r = 1) {
27
+ function X(e, r = 1) {
28
28
  const i = r > 1 ? `每 ${r} ` : "按";
29
29
  switch (e) {
30
30
  case "month":
@@ -39,7 +39,7 @@ function Y(e, r = 1) {
39
39
  return "";
40
40
  }
41
41
  }
42
- function Z(e) {
42
+ function Y(e) {
43
43
  const r = e != null && e.intervalCount && e.intervalCount > 1 ? `${e.intervalCount} ` : "";
44
44
  switch (e == null ? void 0 : e.interval) {
45
45
  case "month":
@@ -54,7 +54,7 @@ function Z(e) {
54
54
  return "";
55
55
  }
56
56
  }
57
- function w(e) {
57
+ function I(e) {
58
58
  switch (e) {
59
59
  case "day":
60
60
  return "每天";
@@ -70,25 +70,25 @@ function w(e) {
70
70
  return "";
71
71
  }
72
72
  }
73
- function B(e) {
73
+ function S(e) {
74
74
  if (e.type === "quota" && e.value !== void 0) {
75
- const r = w(e.quotaPeriod), i = r ? ` / ${r}` : "";
75
+ const r = I(e.quotaPeriod), i = r ? ` / ${r}` : "";
76
76
  return `${e.name}: ${e.value === -1 ? "无限" : e.value}${i}`;
77
77
  }
78
78
  if (e.type === "unlimited") {
79
- const r = w(e.quotaPeriod);
79
+ const r = I(e.quotaPeriod);
80
80
  return r ? `${e.name}: 不限 / ${r}` : `${e.name}不限`;
81
81
  }
82
82
  return e.type === "boolean" && e.value === !1 ? `${e.name}(不支持)` : e.name;
83
83
  }
84
- function C(e) {
84
+ function w(e) {
85
85
  return e.type !== "recurring" || !e.interval ? null : {
86
86
  key: `${e.interval}:${e.intervalCount ?? 1}`,
87
87
  interval: e.interval,
88
88
  intervalCount: e.intervalCount ?? 1
89
89
  };
90
90
  }
91
- function ee(e, r) {
91
+ function Z(e, r) {
92
92
  const i = {
93
93
  day: 1,
94
94
  week: 2,
@@ -97,58 +97,57 @@ function ee(e, r) {
97
97
  };
98
98
  return i[e.interval] - i[r.interval] || e.intervalCount - r.intervalCount;
99
99
  }
100
- function te(e, r) {
100
+ function ee(e, r) {
101
101
  let i = 0;
102
102
  for (const l of e)
103
103
  for (const f of l.prices) {
104
- const s = C(f);
105
- (s == null ? void 0 : s.key) === r && (i = Math.max(i, W(f)));
104
+ const s = w(f);
105
+ (s == null ? void 0 : s.key) === r && (i = Math.max(i, N(f)));
106
106
  }
107
107
  return i > 0 ? `省 ${i}%` : void 0;
108
108
  }
109
- function ne(e) {
109
+ function te(e) {
110
110
  return e.includes(":") ? e : `${e}:1`;
111
111
  }
112
- function D() {
112
+ function B() {
113
113
  return !!localStorage.getItem("jwtToken");
114
114
  }
115
- function de(e = "month") {
116
- const r = y([]), i = y(null), l = y(null), f = y(!1), s = y(!1), d = y(ne(e)), a = q(() => {
115
+ function fe(e = "month") {
116
+ const r = y([]), i = y(null), l = y(null), f = y(!1), s = y(!1), d = y(te(e)), a = L(() => {
117
117
  const t = /* @__PURE__ */ new Map();
118
118
  for (const n of r.value)
119
119
  for (const u of n.prices) {
120
- const c = C(u);
120
+ const c = w(u);
121
121
  c && t.set(c.key, c);
122
122
  }
123
- return [...t.values()].sort(ee).map((n) => ({
123
+ return [...t.values()].sort(Z).map((n) => ({
124
124
  value: n.key,
125
- label: Y(n.interval, n.intervalCount),
126
- badge: te(r.value, n.key)
125
+ label: X(n.interval, n.intervalCount),
126
+ badge: ee(r.value, n.key)
127
127
  }));
128
- }), b = q(() => {
129
- var n;
128
+ }), p = L(() => {
130
129
  const t = [];
131
- for (const u of r.value) {
132
- const c = u.prices.find((p) => {
133
- const $ = C(p);
134
- return ($ == null ? void 0 : $.key) === d.value;
135
- }), m = u.prices.find((p) => p.type === "free"), o = c ?? (m && u.prices.every((p) => p.type === "free") ? m : void 0);
136
- o && t.push({
137
- ...u,
138
- features: (n = o.features) != null && n.length ? o.features : u.features,
139
- selectedPrice: o
130
+ for (const n of r.value) {
131
+ const u = n.prices.find((o) => {
132
+ const h = w(o);
133
+ return (h == null ? void 0 : h.key) === d.value;
134
+ }), c = n.prices.find((o) => o.type === "free"), m = u ?? (c && n.prices.every((o) => o.type === "free") ? c : void 0);
135
+ m && t.push({
136
+ ...n,
137
+ features: m.features ?? [],
138
+ selectedPrice: m
140
139
  });
141
140
  }
142
141
  return t;
143
142
  });
144
- function F(t) {
143
+ function x(t) {
145
144
  d.value = t;
146
145
  }
147
146
  function P(t) {
148
147
  const n = i.value, u = l.value;
149
148
  return n != null && n.priceId && t.selectedPrice ? n.priceId === t.selectedPrice.id : n ? n.productId === t.id : u != null && u.priceId && t.selectedPrice ? u.priceId === t.selectedPrice.id : u ? u.productId === t.id : !1;
150
149
  }
151
- function k(t) {
150
+ function C(t) {
152
151
  var n;
153
152
  return ((n = i.value) == null ? void 0 : n.productId) === t.id;
154
153
  }
@@ -156,39 +155,39 @@ function de(e = "month") {
156
155
  var n;
157
156
  return ((n = t.selectedPrice) == null ? void 0 : n.type) === "free";
158
157
  }
159
- function U() {
158
+ function F() {
160
159
  return !!i.value;
161
160
  }
162
- function T(t) {
163
- return !!(!t.selectedPrice || P(t) || v(t) && U());
161
+ function U(t) {
162
+ return !!(!t.selectedPrice || P(t) || v(t) && F());
164
163
  }
165
- function h(t) {
164
+ function b(t) {
166
165
  var n;
167
166
  return ((n = t.metadata) == null ? void 0 : n.recommended) === !0;
168
167
  }
169
- function j(t) {
168
+ function T(t) {
170
169
  var n;
171
- return S((n = t.selectedPrice) == null ? void 0 : n.unitAmount);
170
+ return q((n = t.selectedPrice) == null ? void 0 : n.unitAmount);
171
+ }
172
+ function j(t) {
173
+ const n = M(t.selectedPrice);
174
+ return n === void 0 ? void 0 : q(n);
172
175
  }
173
176
  function G(t) {
174
- const n = x(t.selectedPrice);
175
- return n === void 0 ? void 0 : S(n);
177
+ return v(t) ? "" : Y(t.selectedPrice);
176
178
  }
177
179
  function O(t) {
178
- return v(t) ? "" : Z(t.selectedPrice);
179
- }
180
- function R(t) {
181
180
  var n;
182
181
  if (v(t)) {
183
182
  const u = (n = t.selectedPrice) == null ? void 0 : n.trialPeriodDays;
184
183
  return u ? `${u} 天免费体验` : "免费体验";
185
184
  }
186
- return X(t.selectedPrice);
185
+ return W(t.selectedPrice);
187
186
  }
188
- function E(t) {
189
- return P(t) ? "当前方案" : h(t) ? "最受欢迎" : "";
187
+ function R(t) {
188
+ return P(t) ? "当前方案" : b(t) ? "最受欢迎" : "";
190
189
  }
191
- function K(t) {
190
+ function E(t) {
192
191
  const n = [];
193
192
  return P(t) ? n.push({
194
193
  label: "当前方案",
@@ -196,32 +195,32 @@ function de(e = "month") {
196
195
  }) : v(t) ? n.push({
197
196
  label: "免费体验",
198
197
  type: "trial"
199
- }) : h(t) && n.push({
198
+ }) : b(t) && n.push({
200
199
  label: "最受欢迎",
201
200
  type: "recommended"
202
201
  }), n;
203
202
  }
204
- function Q(t) {
203
+ function K(t) {
205
204
  const n = i.value;
206
- return P(t) ? "当前方案" : v(t) ? n ? "已订阅付费方案" : D() ? "免费开通" : "免费注册" : n ? k(t) ? "切换周期" : typeof n.unitAmount == "number" && t.selectedPrice.unitAmount > n.unitAmount ? "升级方案" : "切换方案" : "立即订阅";
205
+ return P(t) ? "当前方案" : v(t) ? n ? "已订阅付费方案" : B() ? "免费开通" : "免费注册" : n ? C(t) ? "切换周期" : typeof n.unitAmount == "number" && t.selectedPrice.unitAmount > n.unitAmount ? "升级方案" : "切换方案" : "立即订阅";
207
206
  }
208
- function V(t, n) {
207
+ function Q(t, n) {
209
208
  const u = t.features.find((c) => c.type === "quota" && c.value !== void 0);
210
209
  if (u) {
211
- const c = w(u.quotaPeriod), m = u.value === -1 ? "不限量" : u.value;
210
+ const c = I(u.quotaPeriod), m = u.value === -1 ? "不限量" : u.value;
212
211
  return `${u.name} ${c ? `${m} / ${c}` : m},覆盖核心使用场景。`;
213
212
  }
214
213
  return v(t) ? "注册后自动开通免费权益,适合先体验核心能力。" : n === 1 ? "为正式团队准备的高配能力组合。" : "包含入门所需的核心能力。";
215
214
  }
216
- function _(t) {
215
+ function V(t) {
217
216
  return t.filter((n) => n.highlight !== !1).map((n) => ({
218
- title: B(n),
217
+ title: S(n),
219
218
  description: n.description || ""
220
219
  }));
221
220
  }
222
- function z(t) {
221
+ function _(t) {
223
222
  const n = t.filter((o) => o.highlight !== !1), u = n.filter((o) => o.type === "quota" || o.type === "unlimited").map((o) => ({
224
- title: B(o),
223
+ title: S(o),
225
224
  description: o.description || ""
226
225
  })), c = n.filter((o) => o.type === "boolean" && o.value !== !1).map((o) => ({
227
226
  title: o.name,
@@ -235,17 +234,17 @@ function de(e = "month") {
235
234
  items: u
236
235
  }), m;
237
236
  }
238
- async function A() {
237
+ async function k() {
239
238
  f.value = !0;
240
239
  try {
241
- const t = await J.productOptions();
240
+ const t = await H.productOptions();
242
241
  r.value = Array.isArray(t) ? t : [], !a.value.some((u) => u.value === d.value) && a.value[0] && (d.value = a.value[0].value);
243
242
  } finally {
244
243
  f.value = !1;
245
244
  }
246
245
  }
247
- async function L() {
248
- if (!D()) {
246
+ async function A() {
247
+ if (!B()) {
249
248
  i.value = null, l.value = null;
250
249
  return;
251
250
  }
@@ -254,7 +253,7 @@ function de(e = "month") {
254
253
  const {
255
254
  data: t,
256
255
  error: n
257
- } = await I.subscriptions.summary.post();
256
+ } = await $.subscriptions.summary.post();
258
257
  if (n) {
259
258
  console.error("加载当前订阅失败", n);
260
259
  return;
@@ -264,55 +263,55 @@ function de(e = "month") {
264
263
  s.value = !1;
265
264
  }
266
265
  }
267
- async function H() {
268
- await Promise.all([A(), L()]);
266
+ async function z() {
267
+ await Promise.all([k(), A()]);
269
268
  }
270
269
  return {
271
270
  products: r,
272
- plans: b,
271
+ plans: p,
273
272
  currentSubscription: i,
274
273
  currentTrial: l,
275
274
  listLoading: f,
276
275
  currentLoading: s,
277
276
  billingInterval: d,
278
277
  billingIntervalTabs: a,
279
- setBillingInterval: F,
278
+ setBillingInterval: x,
280
279
  isCurrentPlan: P,
281
- isSameProduct: k,
282
- isRecommendedPlan: h,
280
+ isSameProduct: C,
281
+ isRecommendedPlan: b,
283
282
  isFreePlan: v,
284
- isPlanActionDisabled: T,
285
- getDisplayPrice: j,
286
- getDisplayOriginalPrice: G,
287
- getDisplayCycle: O,
288
- getPromotionLabel: R,
289
- getBadgeLabel: E,
290
- getBadgeLabels: K,
291
- getButtonLabel: Q,
292
- getPlanSummary: V,
293
- getFeatureItems: _,
294
- getFeatureGroups: z,
295
- loadProducts: A,
296
- loadCurrentSubscription: L,
297
- refresh: H
283
+ isPlanActionDisabled: U,
284
+ getDisplayPrice: T,
285
+ getDisplayOriginalPrice: j,
286
+ getDisplayCycle: G,
287
+ getPromotionLabel: O,
288
+ getBadgeLabel: R,
289
+ getBadgeLabels: E,
290
+ getButtonLabel: K,
291
+ getPlanSummary: Q,
292
+ getFeatureItems: V,
293
+ getFeatureGroups: _,
294
+ loadProducts: k,
295
+ loadCurrentSubscription: A,
296
+ refresh: z
298
297
  };
299
298
  }
300
- function re(e) {
299
+ function ne(e) {
301
300
  window.open(e, "_blank", "noopener,noreferrer");
302
301
  }
303
- function M(e) {
302
+ function D(e) {
304
303
  return e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : "";
305
304
  }
306
- function ie(e) {
305
+ function re(e) {
307
306
  return e && typeof e == "object" && "alipayUrl" in e && typeof e.alipayUrl == "string" ? e.alipayUrl : "";
308
307
  }
309
- function ue(e) {
308
+ function ie(e) {
310
309
  return e && typeof e == "object" && "status" in e && e.status === "trialing";
311
310
  }
312
- function me(e) {
311
+ function de(e) {
313
312
  const r = y(null), {
314
313
  ensureAuthenticated: i
315
- } = N();
314
+ } = J();
316
315
  async function l(s) {
317
316
  if (!s.selectedPrice) {
318
317
  g.warning("当前方案暂无可购买价格");
@@ -328,23 +327,23 @@ function me(e) {
328
327
  try {
329
328
  if (s.selectedPrice.type === "free")
330
329
  return;
331
- const a = d ? await I.subscriptions.change.post({
330
+ const a = d ? await $.subscriptions.change.post({
332
331
  subscriptionId: d.id,
333
332
  newPriceId: s.selectedPrice.id,
334
333
  proration: !0
335
- }) : await I.subscriptions.create.post({
334
+ }) : await $.subscriptions.create.post({
336
335
  priceId: s.selectedPrice.id
337
336
  });
338
337
  if (a.error) {
339
338
  g.error(a.error.message || "订阅操作失败");
340
339
  return;
341
340
  }
342
- const b = ie(a.data);
343
- if (b) {
344
- re(b);
341
+ const p = re(a.data);
342
+ if (p) {
343
+ ne(p);
345
344
  return;
346
345
  }
347
- ue(a.data) ? g.success(M(a.data) || "试用已开始") : g.success(M(a.data) || "订阅已更新"), await e.refreshCurrentSubscription();
346
+ ie(a.data) ? g.success(D(a.data) || "试用已开始") : g.success(D(a.data) || "订阅已更新"), await e.refreshCurrentSubscription();
348
347
  } catch (a) {
349
348
  console.error("订阅操作失败", a), g.error("订阅操作失败,请稍后重试");
350
349
  } finally {
@@ -361,6 +360,6 @@ function me(e) {
361
360
  };
362
361
  }
363
362
  export {
364
- me as a,
365
- de as u
363
+ de as a,
364
+ fe as u
366
365
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huyooo/ui",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [