@huyooo/ui 0.12.1 → 0.13.1

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,531 +0,0 @@
1
- /* empty css */
2
- /* empty css */
3
- /* empty css */
4
- import { U as gt } from "./index-D3Kp6R4z.js";
5
- /* empty css */
6
- /* empty css */
7
- /* empty css */
8
- /* empty css */
9
- import { ref as v, computed as f, defineComponent as yt, openBlock as s, createBlock as I, unref as n, isRef as bt, withCtx as o, createElementVNode as i, createElementBlock as r, toDisplayString as c, createTextVNode as p, createVNode as d, createCommentVNode as g, Fragment as _t, renderList as kt } from "vue";
10
- import { Modal as ht, Button as w, Popconfirm as St, Tabs as wt, TabPane as D, Tag as O, Spin as Pt, Empty as Ct, Progress as xt } from "@arco-design/web-vue";
11
- import { f as P, g as F } from "./apiClients-B8bOvWw_.js";
12
- import { u as It } from "./useAuthkitCreateAndUpdate-CUf8HARI.js";
13
- import { C as H } from "./CustomTable-BUkwlbzN.js";
14
- import { _ as zt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
15
- function j() {
16
- return {
17
- current: null,
18
- trial: null,
19
- entitlement: null,
20
- features: [],
21
- quotas: [],
22
- pointsBalance: null,
23
- pendingInvoice: null
24
- };
25
- }
26
- function At() {
27
- const l = v(j()), C = v(!1), E = f(() => l.value.current), z = f(() => l.value.trial), L = f(() => l.value.entitlement), y = f(() => l.value.features), k = f(() => l.value.quotas), u = f(() => l.value.pointsBalance), U = f(() => l.value.pendingInvoice);
28
- async function A() {
29
- C.value = !0;
30
- try {
31
- const {
32
- data: W,
33
- error: N
34
- } = await P.subscriptions.summary.post();
35
- if (N)
36
- throw new Error(N.message || "获取订阅摘要失败");
37
- l.value = W || j();
38
- } finally {
39
- C.value = !1;
40
- }
41
- }
42
- return {
43
- summary: l,
44
- current: E,
45
- trial: z,
46
- entitlement: L,
47
- features: y,
48
- quotas: k,
49
- pointsBalance: u,
50
- pendingInvoice: U,
51
- loading: C,
52
- refresh: A
53
- };
54
- }
55
- function Wt(l) {
56
- return /^https?:\/\//i.test(l) || l.startsWith("//");
57
- }
58
- function Nt() {
59
- if (F.openPricing) {
60
- F.openPricing();
61
- return;
62
- }
63
- const l = F.pricingUrl || "/Pricing";
64
- if (Wt(l)) {
65
- window.open(l, "_blank", "noopener,noreferrer");
66
- return;
67
- }
68
- window.location.assign(l);
69
- }
70
- const Et = {
71
- class: "content"
72
- }, Lt = {
73
- key: 0,
74
- class: "current-subscription-card"
75
- }, Ut = {
76
- class: "subscription-header"
77
- }, Tt = {
78
- class: "subscription-info"
79
- }, $t = {
80
- class: "subscription-actions"
81
- }, Bt = {
82
- class: "subscription-details"
83
- }, qt = {
84
- key: 0,
85
- class: "detail-item"
86
- }, Dt = {
87
- key: 1,
88
- class: "detail-item"
89
- }, Ft = {
90
- key: 2,
91
- class: "detail-item"
92
- }, Vt = {
93
- class: "label"
94
- }, Mt = {
95
- key: 3,
96
- class: "detail-item warning"
97
- }, Rt = {
98
- key: 4,
99
- class: "detail-item"
100
- }, Kt = {
101
- key: 0,
102
- class: "pending-invoice-alert"
103
- }, Ot = {
104
- key: 1,
105
- class: "no-subscription-row"
106
- }, Ht = {
107
- key: 1
108
- }, jt = {
109
- key: 0,
110
- class: "quotas-loading"
111
- }, Gt = {
112
- key: 1,
113
- class: "no-quotas"
114
- }, Jt = {
115
- key: 2,
116
- class: "quotas-grid"
117
- }, Qt = {
118
- class: "quota-header"
119
- }, Xt = {
120
- class: "quota-name"
121
- }, Yt = {
122
- class: "quota-period"
123
- }, Zt = {
124
- class: "quota-progress"
125
- }, te = {
126
- class: "quota-detail"
127
- }, ee = {
128
- key: 0
129
- }, ne = {
130
- key: 1
131
- }, ae = {
132
- key: 2,
133
- class: "reset-time"
134
- }, ie = /* @__PURE__ */ yt({
135
- __name: "PaySubscriptions",
136
- emits: ["confirm", "cancel"],
137
- setup(l, {
138
- expose: C,
139
- emit: E
140
- }) {
141
- const z = E, {
142
- changeType: L,
143
- show: y
144
- } = It(z), k = v("subscriptions"), {
145
- current: u,
146
- entitlement: U,
147
- quotas: A,
148
- pointsBalance: W,
149
- pendingInvoice: N,
150
- loading: G,
151
- refresh: T
152
- } = At(), h = f(() => U.value), V = v([]), $ = v(!1), b = v({
153
- current: 1,
154
- pageSize: 10,
155
- total: 0
156
- }), M = v([]), B = v(!1), _ = v({
157
- current: 1,
158
- pageSize: 10,
159
- total: 0
160
- }), J = f(() => G.value), Q = [{
161
- dataIndex: "productName",
162
- title: "产品",
163
- minWidth: 120
164
- }, {
165
- dataIndex: "interval",
166
- slotName: "interval",
167
- title: "周期",
168
- minWidth: 80
169
- }, {
170
- dataIndex: "unitAmount",
171
- slotName: "unitAmount",
172
- title: "价格",
173
- minWidth: 100
174
- }, {
175
- dataIndex: "status",
176
- slotName: "status",
177
- title: "状态",
178
- minWidth: 100
179
- }, {
180
- dataIndex: "currentPeriodStart",
181
- title: "开始时间",
182
- minWidth: 160
183
- }, {
184
- dataIndex: "currentPeriodEnd",
185
- title: "结束时间",
186
- minWidth: 160
187
- }, {
188
- dataIndex: "createAt",
189
- title: "创建时间",
190
- minWidth: 160
191
- }], X = [{
192
- dataIndex: "productName",
193
- title: "产品",
194
- minWidth: 120
195
- }, {
196
- dataIndex: "total",
197
- slotName: "total",
198
- title: "金额",
199
- minWidth: 100
200
- }, {
201
- dataIndex: "status",
202
- slotName: "status",
203
- title: "状态",
204
- minWidth: 100
205
- }, {
206
- dataIndex: "tradeNo",
207
- title: "交易号",
208
- minWidth: 200
209
- }, {
210
- dataIndex: "paidAt",
211
- title: "支付时间",
212
- minWidth: 160
213
- }, {
214
- dataIndex: "createAt",
215
- title: "创建时间",
216
- minWidth: 160
217
- }, {
218
- dataIndex: "actions",
219
- slotName: "actions",
220
- title: "操作",
221
- minWidth: 100,
222
- fixed: "right"
223
- }];
224
- function Y(t) {
225
- return {
226
- trialing: "blue",
227
- active: "green",
228
- past_due: "orange",
229
- canceled: "gray",
230
- expired: "gray",
231
- incomplete: "red"
232
- }[t] || "gray";
233
- }
234
- function Z(t) {
235
- return {
236
- trialing: "试用中",
237
- active: "已激活",
238
- past_due: "逾期",
239
- canceled: "已取消",
240
- expired: "已过期",
241
- incomplete: "未完成",
242
- paused: "已暂停"
243
- }[t] || t;
244
- }
245
- function tt(t) {
246
- return {
247
- draft: "gray",
248
- open: "orange",
249
- paid: "green",
250
- void: "red",
251
- uncollectible: "red"
252
- }[t] || "gray";
253
- }
254
- function et(t) {
255
- return {
256
- draft: "草稿",
257
- open: "待支付",
258
- paid: "已支付",
259
- void: "已作废",
260
- uncollectible: "无法收款"
261
- }[t] || t;
262
- }
263
- function nt(t) {
264
- return {
265
- day: "每天",
266
- week: "每周",
267
- month: "每月",
268
- year: "每年",
269
- lifetime: "不重置"
270
- }[t] || t;
271
- }
272
- function R(t, e = 1) {
273
- const m = e > 1 ? `每 ${e} ` : "按", S = {
274
- day: `${m}天`,
275
- week: `${m}周`,
276
- month: `${m}月`,
277
- year: `${m}年`
278
- };
279
- return t ? S[t] || t : "-";
280
- }
281
- function at(t, e, m = 1) {
282
- if (typeof t != "number") return "-";
283
- const S = R(e, m).replace("按", "").replace("每 ", "");
284
- return `¥${(t / 100).toFixed(2)} / ${S}`;
285
- }
286
- function it() {
287
- y.value = !1, z("cancel");
288
- }
289
- function K() {
290
- Nt();
291
- }
292
- function st(t) {
293
- window.open(t, "_blank", "noopener,noreferrer");
294
- }
295
- async function ot() {
296
- await T();
297
- }
298
- async function x() {
299
- $.value = !0;
300
- const {
301
- data: t
302
- } = await P.subscriptions.my.post({
303
- current: b.value.current,
304
- pageSize: b.value.pageSize
305
- });
306
- $.value = !1, t && (V.value = t.items, b.value.total = t.count);
307
- }
308
- async function q() {
309
- B.value = !0;
310
- const {
311
- data: t
312
- } = await P.invoices.my.post({
313
- current: _.value.current,
314
- pageSize: _.value.pageSize
315
- });
316
- B.value = !1, t && (M.value = t.items, _.value.total = t.count);
317
- }
318
- async function lt(t) {
319
- const {
320
- data: e
321
- } = await P.invoices.pay.post({
322
- id: t.id
323
- });
324
- e != null && e.alipayUrl && st(e.alipayUrl);
325
- }
326
- async function rt() {
327
- if (!u.value) return;
328
- const {
329
- error: t
330
- } = await P.subscriptions.cancel.post({
331
- subscriptionId: u.value.id,
332
- cancelAtPeriodEnd: !0
333
- });
334
- t || (await T(), await x());
335
- }
336
- async function ut() {
337
- if (!u.value) return;
338
- const {
339
- error: t
340
- } = await P.subscriptions.resume.post({
341
- subscriptionId: u.value.id
342
- });
343
- t || (await T(), await x());
344
- }
345
- function ct(t) {
346
- b.value.current = t, x();
347
- }
348
- function dt(t) {
349
- b.value.pageSize = t, b.value.current = 1, x();
350
- }
351
- function pt(t) {
352
- _.value.current = t, q();
353
- }
354
- function mt(t) {
355
- _.value.pageSize = t, _.value.current = 1, q();
356
- }
357
- function vt(t) {
358
- return (t == null ? void 0 : t.target) === "invoices" ? "invoices" : (t == null ? void 0 : t.target) === "quotas" ? "quotas" : "subscriptions";
359
- }
360
- function ft(t, e) {
361
- y.value = e, L.value = "编辑", k.value = vt(t), e && (ot(), x(), q());
362
- }
363
- return C({
364
- setData: ft
365
- }), (t, e) => (s(), I(n(ht), {
366
- visible: n(y),
367
- "onUpdate:visible": e[2] || (e[2] = (m) => bt(y) ? y.value = m : null),
368
- loading: !1,
369
- "body-class": "SubscriptionsbodyClass",
370
- "mask-closable": !1,
371
- footer: !1,
372
- width: n(gt),
373
- onCancel: it
374
- }, {
375
- title: o(() => [...e[3] || (e[3] = [p(" 订阅管理 ", -1)])]),
376
- default: o(() => {
377
- var m, S;
378
- return [i("div", Et, [h.value ? (s(), r("div", Lt, [i("div", Ut, [i("div", Tt, [i("h3", null, c(h.value.productName), 1)]), i("div", $t, [h.value.type === "trial" ? (s(), I(n(w), {
379
- key: 0,
380
- type: "primary",
381
- size: "small",
382
- onClick: K
383
- }, {
384
- default: o(() => [...e[4] || (e[4] = [p(" 立即订阅 ", -1)])]),
385
- _: 1
386
- })) : (m = n(u)) != null && m.cancelAtPeriodEnd ? (s(), I(n(w), {
387
- key: 1,
388
- type: "primary",
389
- size: "small",
390
- onClick: ut
391
- }, {
392
- default: o(() => [...e[5] || (e[5] = [p(" 恢复订阅 ", -1)])]),
393
- _: 1
394
- })) : n(u) ? (s(), I(n(St), {
395
- key: 2,
396
- content: "取消后订阅将在当前周期结束时失效,确定取消吗?",
397
- onOk: rt
398
- }, {
399
- default: o(() => [d(n(w), {
400
- type: "outline",
401
- size: "small",
402
- status: "warning"
403
- }, {
404
- default: o(() => [...e[6] || (e[6] = [p(" 取消订阅 ", -1)])]),
405
- _: 1
406
- })]),
407
- _: 1
408
- })) : g("", !0)])]), i("div", Bt, [n(u) ? (s(), r("div", qt, [e[7] || (e[7] = i("span", {
409
- class: "label"
410
- }, "计费周期:", -1)), i("span", null, c(R(n(u).interval, n(u).intervalCount)), 1)])) : g("", !0), n(u) ? (s(), r("div", Dt, [e[8] || (e[8] = i("span", {
411
- class: "label"
412
- }, "价格:", -1)), i("span", null, c(at(n(u).unitAmount, n(u).interval, n(u).intervalCount)), 1)])) : g("", !0), h.value.endAt ? (s(), r("div", Ft, [i("span", Vt, c(h.value.type === "trial" ? "试用有效期至:" : "当前周期结束:"), 1), i("span", null, c(h.value.endAt), 1)])) : g("", !0), (S = n(u)) != null && S.cancelAtPeriodEnd ? (s(), r("div", Mt, [...e[9] || (e[9] = [i("span", {
413
- class: "label"
414
- }, "订阅将于周期结束后停止", -1)])])) : g("", !0), n(W) ? (s(), r("div", Rt, [e[10] || (e[10] = i("span", {
415
- class: "label"
416
- }, "积分余额:", -1)), i("span", null, c(n(W).totalPoints), 1)])) : g("", !0)]), n(N) ? (s(), r("div", Kt, [e[12] || (e[12] = i("div", null, [i("strong", null, "存在待支付账单"), i("span", null, "请前往账单记录选择具体账单完成支付。")], -1)), d(n(w), {
417
- type: "primary",
418
- status: "warning",
419
- size: "small",
420
- onClick: e[0] || (e[0] = (a) => k.value = "invoices")
421
- }, {
422
- default: o(() => [...e[11] || (e[11] = [p(" 去处理 ", -1)])]),
423
- _: 1
424
- })])) : g("", !0)])) : (s(), r("div", Ot, [e[14] || (e[14] = i("span", {
425
- class: "no-subscription-text"
426
- }, "暂无方案", -1)), d(n(w), {
427
- type: "primary",
428
- size: "small",
429
- onClick: K
430
- }, {
431
- default: o(() => [...e[13] || (e[13] = [p("查看价格方案", -1)])]),
432
- _: 1
433
- })])), d(n(wt), {
434
- "active-key": k.value,
435
- "onUpdate:activeKey": e[1] || (e[1] = (a) => k.value = a),
436
- class: "subscription-tabs"
437
- }, {
438
- default: o(() => [d(n(D), {
439
- key: "subscriptions",
440
- title: "订阅历史"
441
- }, {
442
- default: o(() => [d(H, {
443
- columns: Q,
444
- data: V.value,
445
- loading: $.value,
446
- pagination: b.value,
447
- onPageChange: ct,
448
- onPageSizeChange: dt
449
- }, {
450
- status: o(({
451
- record: a
452
- }) => [d(n(O), {
453
- color: Y(a.status)
454
- }, {
455
- default: o(() => [p(c(Z(a.status)), 1)]),
456
- _: 2
457
- }, 1032, ["color"])]),
458
- interval: o(({
459
- record: a
460
- }) => [p(c(a.interval === "month" ? "按月" : a.interval === "year" ? "按年" : a.interval || "-"), 1)]),
461
- unitAmount: o(({
462
- record: a
463
- }) => [p(c(a.unitAmount ? `¥${(a.unitAmount / 100).toFixed(2)}` : "-"), 1)]),
464
- _: 1
465
- }, 8, ["data", "loading", "pagination"])]),
466
- _: 1
467
- }), d(n(D), {
468
- key: "invoices",
469
- title: "账单记录"
470
- }, {
471
- default: o(() => [d(H, {
472
- columns: X,
473
- data: M.value,
474
- loading: B.value,
475
- pagination: _.value,
476
- onPageChange: pt,
477
- onPageSizeChange: mt
478
- }, {
479
- status: o(({
480
- record: a
481
- }) => [d(n(O), {
482
- color: tt(a.status)
483
- }, {
484
- default: o(() => [p(c(et(a.status)), 1)]),
485
- _: 2
486
- }, 1032, ["color"])]),
487
- total: o(({
488
- record: a
489
- }) => [p(" ¥" + c((a.total / 100).toFixed(2)), 1)]),
490
- actions: o(({
491
- record: a
492
- }) => [a.status === "open" ? (s(), I(n(w), {
493
- key: 0,
494
- type: "primary",
495
- status: "warning",
496
- size: "mini",
497
- onClick: (se) => lt(a)
498
- }, {
499
- default: o(() => [...e[15] || (e[15] = [p(" 去支付 ", -1)])]),
500
- _: 1
501
- }, 8, ["onClick"])) : (s(), r("span", Ht, "-"))]),
502
- _: 1
503
- }, 8, ["data", "loading", "pagination"])]),
504
- _: 1
505
- }), d(n(D), {
506
- key: "quotas",
507
- title: "配额使用"
508
- }, {
509
- default: o(() => [J.value ? (s(), r("div", jt, [d(n(Pt))])) : n(A).length === 0 ? (s(), r("div", Gt, [d(n(Ct), {
510
- description: "暂无配额限制"
511
- })])) : (s(), r("div", Jt, [(s(!0), r(_t, null, kt(n(A), (a) => (s(), r("div", {
512
- key: a.featureKey,
513
- class: "quota-card"
514
- }, [i("div", Qt, [i("span", Xt, c(a.name), 1), i("span", Yt, c(nt(a.period)), 1)]), i("div", Zt, [d(n(xt), {
515
- percent: a.percentage,
516
- status: a.percentage >= 90 ? "danger" : a.percentage >= 70 ? "warning" : "normal"
517
- }, null, 8, ["percent", "status"])]), i("div", te, [a.unlimited ? (s(), r("span", ee, "无限制")) : (s(), r("span", ne, "已使用 " + c(a.used) + " / " + c(a.limit), 1)), a.resetsAt ? (s(), r("span", ae, c(a.resetsAt) + " 重置", 1)) : g("", !0)])]))), 128))]))]),
518
- _: 1
519
- })]),
520
- _: 1
521
- }, 8, ["active-key"])])];
522
- }),
523
- _: 1
524
- }, 8, ["visible", "width"]));
525
- }
526
- }), ke = /* @__PURE__ */ zt(ie, [["__scopeId", "data-v-a5f046fb"]]);
527
- export {
528
- ke as P,
529
- Nt as o,
530
- At as u
531
- };