@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.
- package/dist/{AuthkitAppSetting-1FsF45E3.js → AuthkitAppSetting-CHVSyEY1.js} +9 -9
- package/dist/{Contact-DBG20I8Y.js → Contact-BTQf8tEx.js} +3 -3
- package/dist/{CustomTable-HDwqEcmB.js → CustomTable-BY0oHLXc.js} +1 -1
- package/dist/{FeedbackModal.vue_vue_type_script_setup_true_lang-hveEkBb4.js → FeedbackModal.vue_vue_type_script_setup_true_lang-FIZdBxIZ.js} +5 -5
- package/dist/{LandingPageSectionTabs-BT08gT7_.js → LandingPageSectionTabs-Bl6X2W5W.js} +2 -2
- package/dist/{LegalDocViewer-DvsnAv6f.js → LegalDocViewer-DiNoy_oj.js} +10 -10
- package/dist/{MessageHandle-BUufez4S.js → MessageHandle-DDGFSJMg.js} +3 -3
- package/dist/{MessageList-rttvPmxV.js → MessageList-CE5E_5Uv.js} +1 -1
- package/dist/PaySubscriptions-pEZtjp1g.js +1287 -0
- package/dist/{PricingPlans-CQaXgOIR.js → PricingPlans-DNPKQwFa.js} +4 -4
- package/dist/{ReferrerReferees-CGrH-gYJ.js → ReferrerReferees-t5s4LzbY.js} +4 -4
- package/dist/{Upload.vue_vue_type_script_setup_true_lang-CgZQOZYt.js → Upload.vue_vue_type_script_setup_true_lang-DsrqOACa.js} +1 -1
- package/dist/UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-DbkGYZ2f.js +601 -0
- package/dist/{WidthContainer-BzU8aEwN.js → WidthContainer-FXZqDMid.js} +10 -10
- package/dist/apiClients-CWSwNzGk.js +272 -0
- package/dist/authkit.js +10 -10
- package/dist/common.js +2 -2
- package/dist/components/Authkit/AuthkitAppSetting.vue.d.ts +2 -2
- package/dist/components/Feedback/FeedbackModal.vue.d.ts +2 -2
- package/dist/components/LandingPage/LandingPageSections.vue.d.ts +1 -1
- package/dist/components/Message/MessageTabs.vue.d.ts +2 -2
- package/dist/components/Pay/PaySubscriptions.vue.d.ts +2 -2
- package/dist/components/UserMenu/UserMenuModals.vue.d.ts +9 -9
- package/dist/composables/Billing/useBillingSubscriptionSummary.d.ts +77 -258
- package/dist/composables.js +13 -13
- package/dist/feedback.js +2 -2
- package/dist/{fetchAuthPageAboutUs-DV7ArpNZ.js → fetchAuthPageAboutUs-CLQlGhQy.js} +2 -2
- package/dist/{index-Cn6LcfZO.js → index-BYH7DaQf.js} +1 -1
- package/dist/landingPage.js +1 -1
- package/dist/main.js +117 -116
- package/dist/message.js +5 -5
- package/dist/pay.d.ts +1 -1
- package/dist/pay.js +18 -17
- package/dist/privateCom.js +1 -1
- package/dist/referrer.js +1 -1
- package/dist/{runtime-Dp7MgwhI.js → runtime-DDJRAtkv.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/types/api/billing.generated.d.ts +2 -2
- package/dist/types/subscription.d.ts +57 -0
- package/dist/types/user.d.ts +3 -0
- package/dist/upload.js +2 -2
- package/dist/{useAuthkitAppsAuthPageInfo-DZ1p-P3Q.js → useAuthkitAppsAuthPageInfo-2izIyMfu.js} +6 -2
- package/dist/{useAuthkitAuth-cHrJMM8E.js → useAuthkitAuth-CWHJs8zY.js} +2 -2
- package/dist/{useAuthkitCreateAndUpdate-Bbv7vZZn.js → useAuthkitCreateAndUpdate-COI5KVPJ.js} +1 -1
- package/dist/useAuthkitUsersProfile-D4H_Gxgd.js +67 -0
- package/dist/{useBillingStatusOptions-Br-iL77Z.js → useBillingStatusOptions-C6edto7H.js} +1 -1
- package/dist/useBillingSubscriptionSummary-BC3G0N4t.js +43 -0
- package/dist/{useEnsureAuthenticated-C8qS8DLL.js → useEnsureAuthenticated-RZ1DflLz.js} +2 -2
- package/dist/{useLegalDocs-C4qk5CTb.js → useLegalDocs-xXYvYpPC.js} +2 -2
- package/dist/{useMessageNotifications-D9uikt21.js → useMessageNotifications-pxa5LHjV.js} +1 -1
- package/dist/{usePageSEO-Dl6_kBWP.js → usePageSEO-B3stKP3n.js} +2 -2
- package/dist/{useRoutePermission-DYPZgvYv.js → useRoutePermission-CGq_LIZM.js} +3 -3
- package/dist/useSubscriptionCheckout-3BtQARep.js +388 -0
- package/dist/user.js +1 -1
- package/dist/utils/passkeySupport.d.ts +1 -1
- package/dist/utils/subscriptionDisplay.d.ts +6 -6
- package/package.json +1 -1
- package/dist/PaySubscriptions-Bv6LQ_Pf.js +0 -1331
- package/dist/UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-Di-VAlur.js +0 -598
- package/dist/apiClients-Ctcq8NZs.js +0 -245
- package/dist/useAuthkitUsersProfile-8FzLTfUJ.js +0 -55
- package/dist/useSubscriptionCheckout-CYU2Ke0y.js +0 -353
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { eden as f, defineMiddleware as p, createClient as U } from "@vafast/api-client";
|
|
2
|
-
/* empty css */
|
|
3
|
-
import { Message as b } from "@arco-design/web-vue";
|
|
4
|
-
import { ref as v, computed as A } from "vue";
|
|
5
|
-
function g(e, r = 3) {
|
|
6
|
-
const o = e.indexOf("@");
|
|
7
|
-
if (o > 1) {
|
|
8
|
-
const n = e.slice(0, r), u = e.slice(o);
|
|
9
|
-
return n + "***" + u;
|
|
10
|
-
}
|
|
11
|
-
return e;
|
|
12
|
-
}
|
|
13
|
-
function E(e) {
|
|
14
|
-
const r = e.trim();
|
|
15
|
-
return r.length < 7 ? r : `${r.slice(0, 3)}****${r.slice(-4)}`;
|
|
16
|
-
}
|
|
17
|
-
const j = {
|
|
18
|
-
normal: "正常",
|
|
19
|
-
pending: "待完善",
|
|
20
|
-
forbidden: "已禁用",
|
|
21
|
-
deleted: "已注销"
|
|
22
|
-
};
|
|
23
|
-
function ee(e) {
|
|
24
|
-
return e ? j[e] ?? e : "-";
|
|
25
|
-
}
|
|
26
|
-
function re(e) {
|
|
27
|
-
var o, n, u, h, w, m, a, i, t;
|
|
28
|
-
const r = [];
|
|
29
|
-
if ((o = e.email) != null && o.trim() && r.push(g(e.email.trim())), (n = e.phone) != null && n.trim() && r.push(E(e.phone.trim())), e.wechat) {
|
|
30
|
-
const s = (u = e.wechat.nickname) == null ? void 0 : u.trim();
|
|
31
|
-
r.push(s ? `微信(${s})` : "微信");
|
|
32
|
-
}
|
|
33
|
-
return (w = (h = e.github) == null ? void 0 : h.login) != null && w.trim() && r.push(`GitHub(${e.github.login.trim()})`), (a = (m = e.google) == null ? void 0 : m.email) != null && a.trim() && r.push(g(e.google.email.trim())), (t = (i = e.microsoft) == null ? void 0 : i.email) != null && t.trim() && r.push(g(e.microsoft.email.trim())), r.length > 0 ? r.join(" / ") : "-";
|
|
34
|
-
}
|
|
35
|
-
const k = /* @__PURE__ */ new Set();
|
|
36
|
-
function te(e) {
|
|
37
|
-
return k.add(e), () => {
|
|
38
|
-
k.delete(e);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function $() {
|
|
42
|
-
try {
|
|
43
|
-
localStorage.removeItem("jwtToken"), localStorage.removeItem("refreshToken");
|
|
44
|
-
} catch (e) {
|
|
45
|
-
console.warn("Failed to clear localStorage:", e);
|
|
46
|
-
}
|
|
47
|
-
k.forEach((e) => e());
|
|
48
|
-
}
|
|
49
|
-
function ne(e) {
|
|
50
|
-
try {
|
|
51
|
-
localStorage.setItem("jwtToken", e.jwtToken), localStorage.setItem("refreshToken", e.refreshToken);
|
|
52
|
-
} catch (r) {
|
|
53
|
-
console.warn("Failed to set localStorage:", r);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function x() {
|
|
57
|
-
try {
|
|
58
|
-
return localStorage.getItem("refreshToken");
|
|
59
|
-
} catch (e) {
|
|
60
|
-
return console.warn("Failed to get refreshToken from localStorage:", e), null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function O(e) {
|
|
64
|
-
try {
|
|
65
|
-
localStorage.setItem("jwtToken", e);
|
|
66
|
-
} catch (r) {
|
|
67
|
-
console.warn("Failed to update jwtToken in localStorage:", r);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function z(e) {
|
|
71
|
-
return f(e);
|
|
72
|
-
}
|
|
73
|
-
function H(e) {
|
|
74
|
-
return f(e);
|
|
75
|
-
}
|
|
76
|
-
function L(e) {
|
|
77
|
-
return f(e);
|
|
78
|
-
}
|
|
79
|
-
function D(e) {
|
|
80
|
-
return f(e);
|
|
81
|
-
}
|
|
82
|
-
function F(e) {
|
|
83
|
-
return f(e);
|
|
84
|
-
}
|
|
85
|
-
function N(e) {
|
|
86
|
-
return f(e);
|
|
87
|
-
}
|
|
88
|
-
const S = v(!1), y = v("signIn");
|
|
89
|
-
function _(e) {
|
|
90
|
-
e != null && e.view && (y.value = e.view), S.value = !0;
|
|
91
|
-
}
|
|
92
|
-
function B() {
|
|
93
|
-
S.value = !1, y.value = "signIn";
|
|
94
|
-
}
|
|
95
|
-
function q() {
|
|
96
|
-
return {
|
|
97
|
-
open: _,
|
|
98
|
-
close: B,
|
|
99
|
-
isOpen: A(() => S.value),
|
|
100
|
-
view: A(() => y.value)
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
const T = 40101, I = 401;
|
|
104
|
-
function J(e) {
|
|
105
|
-
var r;
|
|
106
|
-
return e.status === I || ((r = e.error) == null ? void 0 : r.code) === I;
|
|
107
|
-
}
|
|
108
|
-
function G(e) {
|
|
109
|
-
var r;
|
|
110
|
-
return J(e) && ((r = e.error) == null ? void 0 : r.code) !== T;
|
|
111
|
-
}
|
|
112
|
-
function K() {
|
|
113
|
-
const {
|
|
114
|
-
open: e
|
|
115
|
-
} = q();
|
|
116
|
-
e();
|
|
117
|
-
}
|
|
118
|
-
function M() {
|
|
119
|
-
$(), K();
|
|
120
|
-
}
|
|
121
|
-
async function V(e) {
|
|
122
|
-
const r = x();
|
|
123
|
-
if (!r)
|
|
124
|
-
throw new Error("No refresh token available");
|
|
125
|
-
try {
|
|
126
|
-
const n = await (await fetch(`${e.authPrefixUrl}/auth/refresh`, {
|
|
127
|
-
method: "POST",
|
|
128
|
-
headers: {
|
|
129
|
-
"Content-Type": "application/json",
|
|
130
|
-
"app-id": e.appId
|
|
131
|
-
},
|
|
132
|
-
body: JSON.stringify({
|
|
133
|
-
refreshToken: r
|
|
134
|
-
})
|
|
135
|
-
})).json();
|
|
136
|
-
if (n.jwtToken)
|
|
137
|
-
return O(n.jwtToken), n.refreshToken && localStorage.setItem("refreshToken", n.refreshToken), n.jwtToken;
|
|
138
|
-
throw new Error(n.message || "Token refresh failed");
|
|
139
|
-
} catch (o) {
|
|
140
|
-
throw console.error("Token refresh failed:", o), o;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function C(e) {
|
|
144
|
-
let r = !1, o = [];
|
|
145
|
-
function n(a, i = null) {
|
|
146
|
-
o.forEach(({
|
|
147
|
-
resolve: t,
|
|
148
|
-
reject: s
|
|
149
|
-
}) => {
|
|
150
|
-
a ? s(a) : i && t(i);
|
|
151
|
-
}), o = [];
|
|
152
|
-
}
|
|
153
|
-
const u = p(async (a, i) => (a.headers.set("app-id", e.appId), i()), {
|
|
154
|
-
name: "app-id"
|
|
155
|
-
}), h = p(async (a, i) => {
|
|
156
|
-
const t = e.getAccessToken();
|
|
157
|
-
return t && a.headers.set("authorization", `Bearer ${t}`), i();
|
|
158
|
-
}, {
|
|
159
|
-
name: "token"
|
|
160
|
-
}), w = p(async (a, i) => {
|
|
161
|
-
var s;
|
|
162
|
-
const t = await i();
|
|
163
|
-
if (((s = t.error) == null ? void 0 : s.code) !== T)
|
|
164
|
-
return t;
|
|
165
|
-
if (r)
|
|
166
|
-
return new Promise((c, P) => {
|
|
167
|
-
o.push({
|
|
168
|
-
resolve: async (R) => {
|
|
169
|
-
a.headers.set("authorization", `Bearer ${R}`), c(await i());
|
|
170
|
-
},
|
|
171
|
-
reject: () => P(t)
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
r = !0;
|
|
175
|
-
try {
|
|
176
|
-
const c = await V(e);
|
|
177
|
-
return n(null, c), a.headers.set("authorization", `Bearer ${c}`), await i();
|
|
178
|
-
} catch (c) {
|
|
179
|
-
return n(c, null), M(), t;
|
|
180
|
-
} finally {
|
|
181
|
-
r = !1;
|
|
182
|
-
}
|
|
183
|
-
}, {
|
|
184
|
-
name: "token-refresh"
|
|
185
|
-
}), m = p(async (a, i) => {
|
|
186
|
-
const t = await i();
|
|
187
|
-
return G(t) ? (M(), t) : (t.error && t.error.code !== T && b.error(t.error.message || "请求失败"), t);
|
|
188
|
-
}, {
|
|
189
|
-
name: "error-message"
|
|
190
|
-
});
|
|
191
|
-
return {
|
|
192
|
-
appIdMiddleware: u,
|
|
193
|
-
tokenMiddleware: h,
|
|
194
|
-
tokenRefreshMiddleware: w,
|
|
195
|
-
errorMessageMiddleware: m
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function oe(e, r) {
|
|
199
|
-
const {
|
|
200
|
-
tokenRefreshMiddleware: o,
|
|
201
|
-
errorMessageMiddleware: n
|
|
202
|
-
} = C(r);
|
|
203
|
-
return e.use(o).use(n);
|
|
204
|
-
}
|
|
205
|
-
function l(e, r) {
|
|
206
|
-
return U({
|
|
207
|
-
baseURL: e,
|
|
208
|
-
timeout: 3e4
|
|
209
|
-
}).use(r.appIdMiddleware).use(r.tokenMiddleware).use(r.tokenRefreshMiddleware).use(r.errorMessageMiddleware);
|
|
210
|
-
}
|
|
211
|
-
function W(e) {
|
|
212
|
-
const r = C(e);
|
|
213
|
-
return {
|
|
214
|
-
auth: H(l(e.authPrefixUrl, r)),
|
|
215
|
-
billing: L(l(e.billingPrefixUrl, r)),
|
|
216
|
-
ones: F(l(e.onesPrefixUrl, r)),
|
|
217
|
-
log: D(l(e.logPrefixUrl, r)),
|
|
218
|
-
ai: z(l(e.aiPrefixUrl, r)),
|
|
219
|
-
webhook: N(l(e.webhookPrefixUrl, r))
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
let d = null;
|
|
223
|
-
function ie(e) {
|
|
224
|
-
if (d)
|
|
225
|
-
throw new Error("Huyooo UI Runtime 已初始化,不能重复创建");
|
|
226
|
-
return d = W(e), d;
|
|
227
|
-
}
|
|
228
|
-
function ae() {
|
|
229
|
-
if (!d)
|
|
230
|
-
throw new Error("请先在应用入口调用 app.use(createHuyoooUI(config))");
|
|
231
|
-
return d;
|
|
232
|
-
}
|
|
233
|
-
export {
|
|
234
|
-
re as b,
|
|
235
|
-
C as c,
|
|
236
|
-
ee as f,
|
|
237
|
-
ae as g,
|
|
238
|
-
g as h,
|
|
239
|
-
ie as i,
|
|
240
|
-
te as o,
|
|
241
|
-
$ as r,
|
|
242
|
-
ne as s,
|
|
243
|
-
q as u,
|
|
244
|
-
oe as w
|
|
245
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ref as a, computed as l } from "vue";
|
|
2
|
-
import { g as c } from "./apiClients-Ctcq8NZs.js";
|
|
3
|
-
import { u as i } from "./useAuthkitAuth-cHrJMM8E.js";
|
|
4
|
-
const e = a(null), n = a(!1), u = a(!1), o = a(!1);
|
|
5
|
-
function v() {
|
|
6
|
-
o.value = !0;
|
|
7
|
-
}
|
|
8
|
-
function p(t) {
|
|
9
|
-
return t === 401 || t === 40101;
|
|
10
|
-
}
|
|
11
|
-
const d = l(() => !!e.value), h = l(() => {
|
|
12
|
-
if (!o.value || !u.value)
|
|
13
|
-
return "pending";
|
|
14
|
-
if (e.value)
|
|
15
|
-
return "authenticated";
|
|
16
|
-
const {
|
|
17
|
-
getToken: t
|
|
18
|
-
} = i();
|
|
19
|
-
return t() ? "authenticated" : "unauthenticated";
|
|
20
|
-
});
|
|
21
|
-
async function g() {
|
|
22
|
-
const {
|
|
23
|
-
getToken: t,
|
|
24
|
-
clearAuth: f
|
|
25
|
-
} = i();
|
|
26
|
-
if (!t()) {
|
|
27
|
-
e.value = null, u.value = !0;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
n.value = !0, u.value = !1;
|
|
31
|
-
const {
|
|
32
|
-
data: s,
|
|
33
|
-
error: r
|
|
34
|
-
} = await c().auth.users.profile.post({});
|
|
35
|
-
n.value = !1, s ? e.value = s : p(r == null ? void 0 : r.code) && (e.value = null, console.warn("认证已过期,清除认证状态"), f()), u.value = !0;
|
|
36
|
-
}
|
|
37
|
-
function m() {
|
|
38
|
-
e.value = null, n.value = !1, u.value = !0;
|
|
39
|
-
}
|
|
40
|
-
function U() {
|
|
41
|
-
return {
|
|
42
|
-
userProfile: e,
|
|
43
|
-
loading: n,
|
|
44
|
-
usersProfileReady: u,
|
|
45
|
-
authSessionBootstrapped: o,
|
|
46
|
-
isLoggedIn: d,
|
|
47
|
-
authSessionState: h,
|
|
48
|
-
fetchUserProfile: g,
|
|
49
|
-
clearUserProfile: m,
|
|
50
|
-
markAuthSessionBootstrapped: v
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
U as u
|
|
55
|
-
};
|
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
import { ref as g, computed as q } from "vue";
|
|
2
|
-
import { d as z } from "./useBillingStatusOptions-Br-iL77Z.js";
|
|
3
|
-
import { g as $ } from "./apiClients-Ctcq8NZs.js";
|
|
4
|
-
/* empty css */
|
|
5
|
-
import { Message as h } from "@arco-design/web-vue";
|
|
6
|
-
import { u as H } from "./useEnsureAuthenticated-C8qS8DLL.js";
|
|
7
|
-
function D(e) {
|
|
8
|
-
var i;
|
|
9
|
-
const r = (i = e == null ? void 0 : e.metadata) == null ? void 0 : i.originalPrice;
|
|
10
|
-
return typeof r == "number" ? r : void 0;
|
|
11
|
-
}
|
|
12
|
-
function F(e) {
|
|
13
|
-
const r = D(e);
|
|
14
|
-
return !e || r === void 0 || r <= e.unitAmount ? 0 : r - e.unitAmount;
|
|
15
|
-
}
|
|
16
|
-
function J(e) {
|
|
17
|
-
const r = F(e);
|
|
18
|
-
return r > 0 ? `优惠 ¥${p(r)}` : "";
|
|
19
|
-
}
|
|
20
|
-
function p(e) {
|
|
21
|
-
return e === void 0 ? 0 : Math.floor(e / 100);
|
|
22
|
-
}
|
|
23
|
-
function N(e, r = 1) {
|
|
24
|
-
const i = r > 1 ? `每 ${r} ` : "按";
|
|
25
|
-
switch (e) {
|
|
26
|
-
case "month":
|
|
27
|
-
return `${i}月订阅`;
|
|
28
|
-
case "year":
|
|
29
|
-
return `${i}年订阅`;
|
|
30
|
-
case "day":
|
|
31
|
-
return `${i}天订阅`;
|
|
32
|
-
case "week":
|
|
33
|
-
return `${i}周订阅`;
|
|
34
|
-
default:
|
|
35
|
-
return "";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function W(e) {
|
|
39
|
-
const r = e != null && e.intervalCount && e.intervalCount > 1 ? `${e.intervalCount} ` : "";
|
|
40
|
-
switch (e == null ? void 0 : e.interval) {
|
|
41
|
-
case "month":
|
|
42
|
-
return `/ ${r}月`;
|
|
43
|
-
case "year":
|
|
44
|
-
return `/ ${r}年`;
|
|
45
|
-
case "day":
|
|
46
|
-
return `/ ${r}天`;
|
|
47
|
-
case "week":
|
|
48
|
-
return `/ ${r}周`;
|
|
49
|
-
default:
|
|
50
|
-
return "";
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function X(e) {
|
|
54
|
-
const r = (e == null ? void 0 : e.intervalCount) ?? 1;
|
|
55
|
-
switch (e == null ? void 0 : e.interval) {
|
|
56
|
-
case "month":
|
|
57
|
-
return `${r} 个月`;
|
|
58
|
-
case "year":
|
|
59
|
-
return `${r} 年`;
|
|
60
|
-
case "day":
|
|
61
|
-
return `${r} 天`;
|
|
62
|
-
case "week":
|
|
63
|
-
return `${r} 周`;
|
|
64
|
-
default:
|
|
65
|
-
return "";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function I(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 r = I(e.quotaPeriod), i = r ? ` / ${r}` : "";
|
|
87
|
-
return `${e.name}: ${e.value === -1 ? "无限" : e.value}${i}`;
|
|
88
|
-
}
|
|
89
|
-
if (e.type === "unlimited") {
|
|
90
|
-
const r = I(e.quotaPeriod);
|
|
91
|
-
return r ? `${e.name}: 不限 / ${r}` : `${e.name}不限`;
|
|
92
|
-
}
|
|
93
|
-
return e.type === "boolean" && e.value === !1 ? `${e.name}(不支持)` : e.name;
|
|
94
|
-
}
|
|
95
|
-
function w(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, r) {
|
|
103
|
-
const i = {
|
|
104
|
-
day: 1,
|
|
105
|
-
week: 2,
|
|
106
|
-
month: 3,
|
|
107
|
-
year: 4
|
|
108
|
-
};
|
|
109
|
-
return i[e.interval] - i[r.interval] || e.intervalCount - r.intervalCount;
|
|
110
|
-
}
|
|
111
|
-
function Z(e, r) {
|
|
112
|
-
let i = 0;
|
|
113
|
-
for (const f of e)
|
|
114
|
-
for (const d of f.prices) {
|
|
115
|
-
const s = w(d);
|
|
116
|
-
(s == null ? void 0 : s.key) === r && (i = Math.max(i, F(d)));
|
|
117
|
-
}
|
|
118
|
-
return i > 0 ? `最高优惠 ¥${p(i)}` : 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 r = g([]), i = g(null), f = g(null), d = g(!1), s = g(!1), l = g(ee(e)), m = q(() => {
|
|
128
|
-
const t = /* @__PURE__ */ new Map();
|
|
129
|
-
for (const n of r.value)
|
|
130
|
-
for (const u of n.prices) {
|
|
131
|
-
const c = w(u);
|
|
132
|
-
c && t.set(c.key, c);
|
|
133
|
-
}
|
|
134
|
-
return [...t.values()].sort(Y).map((n) => ({
|
|
135
|
-
value: n.key,
|
|
136
|
-
label: N(n.interval, n.intervalCount),
|
|
137
|
-
badge: Z(r.value, n.key)
|
|
138
|
-
}));
|
|
139
|
-
}), y = q(() => {
|
|
140
|
-
const t = [];
|
|
141
|
-
for (const n of r.value) {
|
|
142
|
-
const u = n.prices.find((o) => {
|
|
143
|
-
const b = w(o);
|
|
144
|
-
return (b == null ? void 0 : b.key) === l.value;
|
|
145
|
-
}), c = n.prices.find((o) => o.type === "free"), a = u ?? (c && n.prices.every((o) => o.type === "free") ? c : void 0);
|
|
146
|
-
a && t.push({
|
|
147
|
-
...n,
|
|
148
|
-
features: a.features ?? [],
|
|
149
|
-
selectedPrice: a
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
return t;
|
|
153
|
-
});
|
|
154
|
-
function x(t) {
|
|
155
|
-
l.value = t;
|
|
156
|
-
}
|
|
157
|
-
function P(t) {
|
|
158
|
-
const n = i.value, u = f.value;
|
|
159
|
-
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;
|
|
160
|
-
}
|
|
161
|
-
function A(t) {
|
|
162
|
-
var n;
|
|
163
|
-
return ((n = i.value) == null ? void 0 : n.productId) === t.id;
|
|
164
|
-
}
|
|
165
|
-
function v(t) {
|
|
166
|
-
var n;
|
|
167
|
-
return ((n = t.selectedPrice) == null ? void 0 : n.type) === "free";
|
|
168
|
-
}
|
|
169
|
-
function U() {
|
|
170
|
-
return !!i.value;
|
|
171
|
-
}
|
|
172
|
-
function M(t) {
|
|
173
|
-
return !!(!t.selectedPrice || P(t) || v(t) && U());
|
|
174
|
-
}
|
|
175
|
-
function C(t) {
|
|
176
|
-
var n;
|
|
177
|
-
return ((n = t.metadata) == null ? void 0 : n.recommended) === !0;
|
|
178
|
-
}
|
|
179
|
-
function G(t) {
|
|
180
|
-
var n;
|
|
181
|
-
return p((n = t.selectedPrice) == null ? void 0 : n.unitAmount);
|
|
182
|
-
}
|
|
183
|
-
function O(t) {
|
|
184
|
-
const n = D(t.selectedPrice);
|
|
185
|
-
return n === void 0 ? void 0 : p(n);
|
|
186
|
-
}
|
|
187
|
-
function T(t) {
|
|
188
|
-
return v(t) ? "" : W(t.selectedPrice);
|
|
189
|
-
}
|
|
190
|
-
function j(t) {
|
|
191
|
-
if (v(t)) {
|
|
192
|
-
const n = X(t.selectedPrice);
|
|
193
|
-
return n ? `${n}免费体验` : "免费体验";
|
|
194
|
-
}
|
|
195
|
-
return J(t.selectedPrice);
|
|
196
|
-
}
|
|
197
|
-
function R(t) {
|
|
198
|
-
const n = [];
|
|
199
|
-
return P(t) ? n.push({
|
|
200
|
-
label: "当前方案",
|
|
201
|
-
type: "current"
|
|
202
|
-
}) : v(t) ? n.push({
|
|
203
|
-
label: "免费体验",
|
|
204
|
-
type: "trial"
|
|
205
|
-
}) : C(t) && n.push({
|
|
206
|
-
label: "最受欢迎",
|
|
207
|
-
type: "recommended"
|
|
208
|
-
}), n;
|
|
209
|
-
}
|
|
210
|
-
function E(t) {
|
|
211
|
-
const n = i.value;
|
|
212
|
-
return P(t) ? "当前方案" : v(t) ? n ? "已订阅付费方案" : B() ? "免费开通" : "免费注册" : n ? A(t) ? "切换周期" : typeof n.unitAmount == "number" && t.selectedPrice.unitAmount > n.unitAmount ? "升级方案" : "切换方案" : "立即订阅";
|
|
213
|
-
}
|
|
214
|
-
function K(t, n) {
|
|
215
|
-
const u = t.features.find((c) => c.type === "quota" && c.value !== void 0);
|
|
216
|
-
if (u) {
|
|
217
|
-
const c = I(u.quotaPeriod), a = u.value === -1 ? "不限量" : u.value;
|
|
218
|
-
return `${u.name} ${c ? `${a} / ${c}` : a},覆盖核心使用场景。`;
|
|
219
|
-
}
|
|
220
|
-
return v(t) ? "注册后自动开通免费权益,适合先体验核心能力。" : n === 1 ? "为正式团队准备的高配能力组合。" : "包含入门所需的核心能力。";
|
|
221
|
-
}
|
|
222
|
-
function Q(t) {
|
|
223
|
-
return t.filter((n) => n.highlight !== !1).map((n) => ({
|
|
224
|
-
title: S(n),
|
|
225
|
-
description: n.description || ""
|
|
226
|
-
}));
|
|
227
|
-
}
|
|
228
|
-
function V(t) {
|
|
229
|
-
const n = t.filter((o) => o.highlight !== !1), u = n.filter((o) => o.type === "quota" || o.type === "unlimited").map((o) => ({
|
|
230
|
-
title: S(o),
|
|
231
|
-
description: o.description || ""
|
|
232
|
-
})), c = n.filter((o) => o.type === "boolean" && o.value !== !1).map((o) => ({
|
|
233
|
-
title: o.name,
|
|
234
|
-
description: o.description || ""
|
|
235
|
-
})), a = [];
|
|
236
|
-
return c.length && a.push({
|
|
237
|
-
title: "功能特性",
|
|
238
|
-
items: c
|
|
239
|
-
}), u.length && a.push({
|
|
240
|
-
title: "用量配额",
|
|
241
|
-
items: u
|
|
242
|
-
}), a;
|
|
243
|
-
}
|
|
244
|
-
async function k() {
|
|
245
|
-
d.value = !0;
|
|
246
|
-
const {
|
|
247
|
-
data: t,
|
|
248
|
-
error: n
|
|
249
|
-
} = await z.productOptions();
|
|
250
|
-
if (d.value = !1, n)
|
|
251
|
-
return;
|
|
252
|
-
r.value = Array.isArray(t) ? t : [], !m.value.some((c) => c.value === l.value) && m.value[0] && (l.value = m.value[0].value);
|
|
253
|
-
}
|
|
254
|
-
async function L() {
|
|
255
|
-
if (!B()) {
|
|
256
|
-
i.value = null, f.value = null;
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
s.value = !0;
|
|
260
|
-
const {
|
|
261
|
-
data: t,
|
|
262
|
-
error: n
|
|
263
|
-
} = await $().billing.subscriptions.summary.post();
|
|
264
|
-
s.value = !1, !n && (i.value = (t == null ? void 0 : t.current) ?? null, f.value = (t == null ? void 0 : t.trial) ?? null);
|
|
265
|
-
}
|
|
266
|
-
async function _() {
|
|
267
|
-
await Promise.all([k(), L()]);
|
|
268
|
-
}
|
|
269
|
-
return {
|
|
270
|
-
products: r,
|
|
271
|
-
plans: y,
|
|
272
|
-
currentSubscription: i,
|
|
273
|
-
currentTrial: f,
|
|
274
|
-
listLoading: d,
|
|
275
|
-
currentLoading: s,
|
|
276
|
-
billingInterval: l,
|
|
277
|
-
billingIntervalTabs: m,
|
|
278
|
-
setBillingInterval: x,
|
|
279
|
-
isCurrentPlan: P,
|
|
280
|
-
isSameProduct: A,
|
|
281
|
-
isRecommendedPlan: C,
|
|
282
|
-
isFreePlan: v,
|
|
283
|
-
isPlanActionDisabled: M,
|
|
284
|
-
getDisplayPrice: G,
|
|
285
|
-
getDisplayOriginalPrice: O,
|
|
286
|
-
getDisplayCycle: T,
|
|
287
|
-
getPromotionLabel: j,
|
|
288
|
-
getBadgeLabels: R,
|
|
289
|
-
getButtonLabel: E,
|
|
290
|
-
getPlanSummary: K,
|
|
291
|
-
getFeatureItems: Q,
|
|
292
|
-
getFeatureGroups: V,
|
|
293
|
-
loadProducts: k,
|
|
294
|
-
loadCurrentSubscription: L,
|
|
295
|
-
refresh: _
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
function te(e) {
|
|
299
|
-
window.open(e, "_blank", "noopener,noreferrer");
|
|
300
|
-
}
|
|
301
|
-
function ne(e) {
|
|
302
|
-
return e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : "";
|
|
303
|
-
}
|
|
304
|
-
function re(e) {
|
|
305
|
-
return e && typeof e == "object" && "alipayUrl" in e && typeof e.alipayUrl == "string" ? e.alipayUrl : "";
|
|
306
|
-
}
|
|
307
|
-
function fe(e) {
|
|
308
|
-
const r = g(null), {
|
|
309
|
-
ensureAuthenticated: i
|
|
310
|
-
} = H();
|
|
311
|
-
async function f(s) {
|
|
312
|
-
if (!s.selectedPrice) {
|
|
313
|
-
h.warning("当前方案暂无可购买价格");
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
if (!i(() => f(s))) return;
|
|
317
|
-
const l = e.currentSubscription.value;
|
|
318
|
-
if ((l == null ? void 0 : l.priceId) === s.selectedPrice.id) {
|
|
319
|
-
h.info("当前已经是该方案");
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
if (s.selectedPrice.type === "free")
|
|
323
|
-
return;
|
|
324
|
-
r.value = s.id;
|
|
325
|
-
const m = l ? await $().billing.subscriptions.change.post({
|
|
326
|
-
subscriptionId: l.id,
|
|
327
|
-
newPriceId: s.selectedPrice.id,
|
|
328
|
-
proration: !0
|
|
329
|
-
}) : await $().billing.subscriptions.create.post({
|
|
330
|
-
priceId: s.selectedPrice.id
|
|
331
|
-
});
|
|
332
|
-
if (r.value = null, m.error)
|
|
333
|
-
return;
|
|
334
|
-
const y = re(m.data);
|
|
335
|
-
if (y) {
|
|
336
|
-
te(y);
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
h.success(ne(m.data) || "订阅已更新"), await e.refreshCurrentSubscription();
|
|
340
|
-
}
|
|
341
|
-
function d(s) {
|
|
342
|
-
return r.value === s.id;
|
|
343
|
-
}
|
|
344
|
-
return {
|
|
345
|
-
checkoutPlanId: r,
|
|
346
|
-
checkout: f,
|
|
347
|
-
isCheckingOut: d
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
export {
|
|
351
|
-
fe as a,
|
|
352
|
-
ae as u
|
|
353
|
-
};
|