@huyooo/ui 0.11.7 → 0.11.9
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.
- package/dist/PricingPlans-DWqkkLzP.js +276 -0
- package/dist/components/Pay/PricingPlans.vue.d.ts +2 -0
- package/dist/composables.js +1 -1
- package/dist/main.js +2 -2
- package/dist/pay.js +2 -2
- package/dist/style.css +1 -1
- package/dist/{useSubscriptionCheckout-BubIsxjO.js → useSubscriptionCheckout-DmxORGSV.js} +120 -134
- package/package.json +1 -1
- package/dist/PricingPlans-Cf20-GqK.js +0 -251
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as y, computed as q } from "vue";
|
|
2
2
|
import { f as h } from "./apiClients-KFp-rs-C.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import { Message as
|
|
5
|
-
import { u as
|
|
6
|
-
function
|
|
4
|
+
import { Message as g } from "@arco-design/web-vue";
|
|
5
|
+
import { u as J } from "./useEnsureAuthenticated-D78tsddF.js";
|
|
6
|
+
function x(e) {
|
|
7
7
|
var i;
|
|
8
8
|
const n = (i = e == null ? void 0 : e.metadata) == null ? void 0 : i.originalPrice;
|
|
9
9
|
return typeof n == "number" ? n : void 0;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const n =
|
|
11
|
+
function N(e) {
|
|
12
|
+
const n = x(e);
|
|
13
13
|
return !e || n === void 0 || n <= e.unitAmount ? 0 : Math.round((1 - e.unitAmount / n) * 100);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
var
|
|
17
|
-
const n = (
|
|
15
|
+
function W(e) {
|
|
16
|
+
var l, f;
|
|
17
|
+
const n = (l = e == null ? void 0 : e.metadata) == null ? void 0 : l.discountLabel;
|
|
18
18
|
if (typeof n == "string" && n.trim())
|
|
19
19
|
return n;
|
|
20
|
-
const i = (
|
|
20
|
+
const i = (f = e == null ? void 0 : e.metadata) == null ? void 0 : f.savingMonths;
|
|
21
21
|
return typeof i == "number" && i > 0 ? `买 ${12 - i} 个月送 ${i} 个月` : "";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function B(e) {
|
|
24
24
|
return e === void 0 ? 0 : Math.floor(e / 100);
|
|
25
25
|
}
|
|
26
26
|
function X(e, n = 1) {
|
|
@@ -53,7 +53,7 @@ function Y(e) {
|
|
|
53
53
|
return "";
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function w(e) {
|
|
57
57
|
switch (e) {
|
|
58
58
|
case "day":
|
|
59
59
|
return "每天";
|
|
@@ -69,18 +69,18 @@ function k(e) {
|
|
|
69
69
|
return "";
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function D(e) {
|
|
73
73
|
if (e.type === "quota" && e.value !== void 0) {
|
|
74
|
-
const n =
|
|
74
|
+
const n = w(e.quotaPeriod), i = n ? ` / ${n}` : "";
|
|
75
75
|
return `${e.name}: ${e.value === -1 ? "无限" : e.value}${i}`;
|
|
76
76
|
}
|
|
77
77
|
if (e.type === "unlimited") {
|
|
78
|
-
const n =
|
|
78
|
+
const n = w(e.quotaPeriod);
|
|
79
79
|
return n ? `${e.name}: 不限 / ${n}` : `${e.name}不限`;
|
|
80
80
|
}
|
|
81
81
|
return e.type === "boolean" && e.value === !1 ? `${e.name}(不支持)` : e.name;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function C(e) {
|
|
84
84
|
return e.type !== "recurring" || !e.interval ? null : {
|
|
85
85
|
key: `${e.interval}:${e.intervalCount ?? 1}`,
|
|
86
86
|
interval: e.interval,
|
|
@@ -98,25 +98,25 @@ function Z(e, n) {
|
|
|
98
98
|
}
|
|
99
99
|
function ee(e, n) {
|
|
100
100
|
let i = 0;
|
|
101
|
-
for (const
|
|
102
|
-
for (const
|
|
103
|
-
const
|
|
104
|
-
(
|
|
101
|
+
for (const l of e)
|
|
102
|
+
for (const f of l.prices) {
|
|
103
|
+
const s = C(f);
|
|
104
|
+
(s == null ? void 0 : s.key) === n && (i = Math.max(i, N(f)));
|
|
105
105
|
}
|
|
106
106
|
return i > 0 ? `省 ${i}%` : void 0;
|
|
107
107
|
}
|
|
108
108
|
function te(e) {
|
|
109
109
|
return e.includes(":") ? e : `${e}:1`;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function M() {
|
|
112
112
|
return !!localStorage.getItem("jwtToken");
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
const n =
|
|
114
|
+
function le(e = "month") {
|
|
115
|
+
const n = y([]), i = y(null), l = y(null), f = y(!1), s = y(!1), d = y(te(e)), a = q(() => {
|
|
116
116
|
const t = /* @__PURE__ */ new Map();
|
|
117
117
|
for (const r of n.value)
|
|
118
118
|
for (const u of r.prices) {
|
|
119
|
-
const c =
|
|
119
|
+
const c = C(u);
|
|
120
120
|
c && t.set(c.key, c);
|
|
121
121
|
}
|
|
122
122
|
return [...t.values()].sort(Z).map((r) => ({
|
|
@@ -124,107 +124,107 @@ function fe(e = "month") {
|
|
|
124
124
|
label: X(r.interval, r.intervalCount),
|
|
125
125
|
badge: ee(n.value, r.key)
|
|
126
126
|
}));
|
|
127
|
-
}),
|
|
127
|
+
}), b = q(() => {
|
|
128
128
|
var r;
|
|
129
129
|
const t = [];
|
|
130
130
|
for (const u of n.value) {
|
|
131
|
-
const c = u.prices.find((
|
|
132
|
-
const
|
|
133
|
-
return (
|
|
134
|
-
}), m = u.prices.find((
|
|
135
|
-
|
|
131
|
+
const c = u.prices.find((p) => {
|
|
132
|
+
const I = C(p);
|
|
133
|
+
return (I == null ? void 0 : I.key) === d.value;
|
|
134
|
+
}), m = u.prices.find((p) => p.type === "free"), o = c ?? (m && u.prices.every((p) => p.type === "free") ? m : void 0);
|
|
135
|
+
o && t.push({
|
|
136
136
|
...u,
|
|
137
|
-
features: (r =
|
|
138
|
-
selectedPrice:
|
|
137
|
+
features: (r = o.features) != null && r.length ? o.features : u.features,
|
|
138
|
+
selectedPrice: o
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
return t;
|
|
142
142
|
});
|
|
143
|
-
function
|
|
144
|
-
|
|
143
|
+
function F(t) {
|
|
144
|
+
d.value = t;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
const r = i.value, u =
|
|
146
|
+
function P(t) {
|
|
147
|
+
const r = i.value, u = l.value;
|
|
148
148
|
return r != null && r.priceId && t.selectedPrice ? r.priceId === t.selectedPrice.id : r ? r.productId === t.id : u != null && u.priceId && t.selectedPrice ? u.priceId === t.selectedPrice.id : u ? u.productId === t.id : !1;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function k(t) {
|
|
151
151
|
var r;
|
|
152
152
|
return ((r = i.value) == null ? void 0 : r.productId) === t.id;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function v(t) {
|
|
155
155
|
var r;
|
|
156
156
|
return ((r = t.selectedPrice) == null ? void 0 : r.type) === "free";
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function U() {
|
|
159
159
|
return !!i.value;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
return !!(!t.selectedPrice ||
|
|
161
|
+
function T(t) {
|
|
162
|
+
return !!(!t.selectedPrice || P(t) || v(t) && U());
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function $(t) {
|
|
165
165
|
var r;
|
|
166
166
|
return ((r = t.metadata) == null ? void 0 : r.recommended) === !0;
|
|
167
167
|
}
|
|
168
168
|
function j(t) {
|
|
169
169
|
var r;
|
|
170
|
-
return
|
|
170
|
+
return B((r = t.selectedPrice) == null ? void 0 : r.unitAmount);
|
|
171
171
|
}
|
|
172
172
|
function G(t) {
|
|
173
|
-
const r =
|
|
174
|
-
return r === void 0 ? void 0 :
|
|
173
|
+
const r = x(t.selectedPrice);
|
|
174
|
+
return r === void 0 ? void 0 : B(r);
|
|
175
175
|
}
|
|
176
176
|
function O(t) {
|
|
177
|
-
return
|
|
177
|
+
return v(t) ? "" : Y(t.selectedPrice);
|
|
178
178
|
}
|
|
179
179
|
function R(t) {
|
|
180
180
|
var r;
|
|
181
|
-
if (
|
|
181
|
+
if (v(t)) {
|
|
182
182
|
const u = (r = t.selectedPrice) == null ? void 0 : r.trialPeriodDays;
|
|
183
183
|
return u ? `${u} 天免费体验` : "免费体验";
|
|
184
184
|
}
|
|
185
|
-
return
|
|
185
|
+
return W(t.selectedPrice);
|
|
186
186
|
}
|
|
187
187
|
function E(t) {
|
|
188
|
-
return
|
|
188
|
+
return P(t) ? "当前方案" : $(t) ? "最受欢迎" : "";
|
|
189
189
|
}
|
|
190
190
|
function K(t) {
|
|
191
191
|
const r = [];
|
|
192
|
-
return
|
|
192
|
+
return P(t) ? r.push({
|
|
193
193
|
label: "当前方案",
|
|
194
194
|
type: "current"
|
|
195
|
-
}) :
|
|
195
|
+
}) : v(t) ? r.push({
|
|
196
196
|
label: "免费体验",
|
|
197
197
|
type: "trial"
|
|
198
|
-
}) :
|
|
198
|
+
}) : $(t) && r.push({
|
|
199
199
|
label: "最受欢迎",
|
|
200
200
|
type: "recommended"
|
|
201
201
|
}), r;
|
|
202
202
|
}
|
|
203
203
|
function Q(t) {
|
|
204
204
|
const r = i.value;
|
|
205
|
-
return
|
|
205
|
+
return P(t) ? "当前方案" : v(t) ? r ? "已订阅付费方案" : M() ? "免费开通" : "免费注册" : r ? k(t) ? "切换周期" : typeof r.unitAmount == "number" && t.selectedPrice.unitAmount > r.unitAmount ? "升级方案" : "切换方案" : "立即订阅";
|
|
206
206
|
}
|
|
207
207
|
function V(t, r) {
|
|
208
208
|
const u = t.features.find((c) => c.type === "quota" && c.value !== void 0);
|
|
209
209
|
if (u) {
|
|
210
|
-
const c =
|
|
210
|
+
const c = w(u.quotaPeriod), m = u.value === -1 ? "不限量" : u.value;
|
|
211
211
|
return `${u.name} ${c ? `${m} / ${c}` : m},覆盖核心使用场景。`;
|
|
212
212
|
}
|
|
213
|
-
return
|
|
213
|
+
return v(t) ? "注册后自动开通免费权益,适合先体验核心能力。" : r === 1 ? "为正式团队准备的高配能力组合。" : "包含入门所需的核心能力。";
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function _(t) {
|
|
216
216
|
return t.filter((r) => r.highlight !== !1).map((r) => ({
|
|
217
|
-
title:
|
|
217
|
+
title: D(r),
|
|
218
218
|
description: r.description || ""
|
|
219
219
|
}));
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
const r = t.filter((
|
|
223
|
-
title:
|
|
224
|
-
description:
|
|
225
|
-
})), c = r.filter((
|
|
226
|
-
title:
|
|
227
|
-
description:
|
|
221
|
+
function z(t) {
|
|
222
|
+
const r = t.filter((o) => o.highlight !== !1), u = r.filter((o) => o.type === "quota" || o.type === "unlimited").map((o) => ({
|
|
223
|
+
title: D(o),
|
|
224
|
+
description: o.description || ""
|
|
225
|
+
})), c = r.filter((o) => o.type === "boolean" && o.value !== !1).map((o) => ({
|
|
226
|
+
title: o.name,
|
|
227
|
+
description: o.description || ""
|
|
228
228
|
})), m = [];
|
|
229
229
|
return c.length && m.push({
|
|
230
230
|
title: "功能特性",
|
|
@@ -234,8 +234,8 @@ function fe(e = "month") {
|
|
|
234
234
|
items: u
|
|
235
235
|
}), m;
|
|
236
236
|
}
|
|
237
|
-
async function
|
|
238
|
-
|
|
237
|
+
async function A() {
|
|
238
|
+
f.value = !0;
|
|
239
239
|
try {
|
|
240
240
|
const {
|
|
241
241
|
data: t,
|
|
@@ -245,17 +245,17 @@ function fe(e = "month") {
|
|
|
245
245
|
console.error("加载产品列表失败", r);
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
-
n.value = Array.isArray(t) ? t : [], !a.value.some((c) => c.value ===
|
|
248
|
+
n.value = Array.isArray(t) ? t : [], !a.value.some((c) => c.value === d.value) && a.value[0] && (d.value = a.value[0].value);
|
|
249
249
|
} finally {
|
|
250
|
-
|
|
250
|
+
f.value = !1;
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
async function
|
|
254
|
-
if (!
|
|
253
|
+
async function L() {
|
|
254
|
+
if (!M()) {
|
|
255
255
|
i.value = null;
|
|
256
256
|
return;
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
s.value = !0;
|
|
259
259
|
try {
|
|
260
260
|
const {
|
|
261
261
|
data: t,
|
|
@@ -265,29 +265,29 @@ function fe(e = "month") {
|
|
|
265
265
|
console.error("加载当前订阅失败", r);
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
|
-
i.value = (t == null ? void 0 : t.current) ?? null,
|
|
268
|
+
i.value = (t == null ? void 0 : t.current) ?? null, l.value = (t == null ? void 0 : t.trial) ?? null;
|
|
269
269
|
} finally {
|
|
270
|
-
|
|
270
|
+
s.value = !1;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
async function
|
|
274
|
-
await Promise.all([
|
|
273
|
+
async function H() {
|
|
274
|
+
await Promise.all([A(), L()]);
|
|
275
275
|
}
|
|
276
276
|
return {
|
|
277
277
|
products: n,
|
|
278
|
-
plans:
|
|
278
|
+
plans: b,
|
|
279
279
|
currentSubscription: i,
|
|
280
|
-
currentTrial:
|
|
281
|
-
listLoading:
|
|
282
|
-
currentLoading:
|
|
283
|
-
billingInterval:
|
|
280
|
+
currentTrial: l,
|
|
281
|
+
listLoading: f,
|
|
282
|
+
currentLoading: s,
|
|
283
|
+
billingInterval: d,
|
|
284
284
|
billingIntervalTabs: a,
|
|
285
|
-
setBillingInterval:
|
|
286
|
-
isCurrentPlan:
|
|
287
|
-
isSameProduct:
|
|
288
|
-
isRecommendedPlan:
|
|
289
|
-
isFreePlan:
|
|
290
|
-
isPlanActionDisabled:
|
|
285
|
+
setBillingInterval: F,
|
|
286
|
+
isCurrentPlan: P,
|
|
287
|
+
isSameProduct: k,
|
|
288
|
+
isRecommendedPlan: $,
|
|
289
|
+
isFreePlan: v,
|
|
290
|
+
isPlanActionDisabled: T,
|
|
291
291
|
getDisplayPrice: j,
|
|
292
292
|
getDisplayOriginalPrice: G,
|
|
293
293
|
getDisplayCycle: O,
|
|
@@ -296,17 +296,17 @@ function fe(e = "month") {
|
|
|
296
296
|
getBadgeLabels: K,
|
|
297
297
|
getButtonLabel: Q,
|
|
298
298
|
getPlanSummary: V,
|
|
299
|
-
getFeatureItems:
|
|
300
|
-
getFeatureGroups:
|
|
301
|
-
loadProducts:
|
|
302
|
-
loadCurrentSubscription:
|
|
303
|
-
refresh:
|
|
299
|
+
getFeatureItems: _,
|
|
300
|
+
getFeatureGroups: z,
|
|
301
|
+
loadProducts: A,
|
|
302
|
+
loadCurrentSubscription: L,
|
|
303
|
+
refresh: H
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
306
|
function re(e) {
|
|
307
307
|
window.open(e, "_blank", "noopener,noreferrer");
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function S(e) {
|
|
310
310
|
return e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : "";
|
|
311
311
|
}
|
|
312
312
|
function ne(e) {
|
|
@@ -315,72 +315,58 @@ function ne(e) {
|
|
|
315
315
|
function ie(e) {
|
|
316
316
|
return e && typeof e == "object" && "status" in e && e.status === "trialing";
|
|
317
317
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const n = g(null), {
|
|
318
|
+
function fe(e) {
|
|
319
|
+
const n = y(null), {
|
|
321
320
|
ensureAuthenticated: i
|
|
322
|
-
} =
|
|
323
|
-
async function
|
|
324
|
-
if (!
|
|
325
|
-
|
|
321
|
+
} = J();
|
|
322
|
+
async function l(s) {
|
|
323
|
+
if (!s.selectedPrice) {
|
|
324
|
+
g.warning("当前方案暂无可购买价格");
|
|
326
325
|
return;
|
|
327
326
|
}
|
|
328
|
-
if (!i(() =>
|
|
329
|
-
const
|
|
330
|
-
if ((
|
|
331
|
-
|
|
327
|
+
if (!i(() => l(s))) return;
|
|
328
|
+
const d = e.currentSubscription.value;
|
|
329
|
+
if ((d == null ? void 0 : d.priceId) === s.selectedPrice.id) {
|
|
330
|
+
g.info("当前已经是该方案");
|
|
332
331
|
return;
|
|
333
332
|
}
|
|
334
|
-
n.value =
|
|
333
|
+
n.value = s.id;
|
|
335
334
|
try {
|
|
336
|
-
if (
|
|
337
|
-
if (l) {
|
|
338
|
-
v.info("当前已有付费订阅,无需重复开通免费体验");
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
const P = await ue.trials.start.post({
|
|
342
|
-
priceId: o.selectedPrice.id
|
|
343
|
-
});
|
|
344
|
-
if (P.error) {
|
|
345
|
-
v.error(P.error.message || "免费体验开通失败");
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
v.success(C(P.data) || "免费体验已开通"), await e.refreshCurrentSubscription();
|
|
335
|
+
if (s.selectedPrice.type === "free")
|
|
349
336
|
return;
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
newPriceId: o.selectedPrice.id,
|
|
337
|
+
const a = d ? await h.subscriptions.change.post({
|
|
338
|
+
subscriptionId: d.id,
|
|
339
|
+
newPriceId: s.selectedPrice.id,
|
|
354
340
|
proration: !0
|
|
355
341
|
}) : await h.subscriptions.create.post({
|
|
356
|
-
priceId:
|
|
342
|
+
priceId: s.selectedPrice.id
|
|
357
343
|
});
|
|
358
344
|
if (a.error) {
|
|
359
|
-
|
|
345
|
+
g.error(a.error.message || "订阅操作失败");
|
|
360
346
|
return;
|
|
361
347
|
}
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
re(
|
|
348
|
+
const b = ne(a.data);
|
|
349
|
+
if (b) {
|
|
350
|
+
re(b);
|
|
365
351
|
return;
|
|
366
352
|
}
|
|
367
|
-
ie(a.data) ?
|
|
353
|
+
ie(a.data) ? g.success(S(a.data) || "试用已开始") : g.success(S(a.data) || "订阅已更新"), await e.refreshCurrentSubscription();
|
|
368
354
|
} catch (a) {
|
|
369
|
-
console.error("订阅操作失败", a),
|
|
355
|
+
console.error("订阅操作失败", a), g.error("订阅操作失败,请稍后重试");
|
|
370
356
|
} finally {
|
|
371
357
|
n.value = null;
|
|
372
358
|
}
|
|
373
359
|
}
|
|
374
|
-
function
|
|
375
|
-
return n.value ===
|
|
360
|
+
function f(s) {
|
|
361
|
+
return n.value === s.id;
|
|
376
362
|
}
|
|
377
363
|
return {
|
|
378
364
|
checkoutPlanId: n,
|
|
379
|
-
checkout:
|
|
380
|
-
isCheckingOut:
|
|
365
|
+
checkout: l,
|
|
366
|
+
isCheckingOut: f
|
|
381
367
|
};
|
|
382
368
|
}
|
|
383
369
|
export {
|
|
384
|
-
|
|
385
|
-
|
|
370
|
+
fe as a,
|
|
371
|
+
le as u
|
|
386
372
|
};
|