@huyooo/ui 0.11.6 → 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/{AuthkitAppSetting-CjQiWZab.js → AuthkitAppSetting-DrX6fwKt.js} +7 -6
- package/dist/{useEnsureAuthenticated-C_Ss0e9n.js → AuthkitGithubBinding-r2oVuCSV.js} +631 -680
- package/dist/PricingPlans-DWqkkLzP.js +276 -0
- package/dist/{ReferrerReferees-CHSoGrE1.js → ReferrerReferees-B-ISyXHw.js} +1 -1
- package/dist/{UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-B4tD8pIE.js → UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-Czix4_tj.js} +3 -3
- package/dist/{WidthContainer-BzS-A143.js → WidthContainer-CYYbzXj0.js} +16 -15
- package/dist/authkit.js +30 -28
- package/dist/common.js +1 -1
- package/dist/components/Pay/PricingPlans.vue.d.ts +2 -0
- package/dist/composables/Billing/useBillingPlans.d.ts +29 -1
- package/dist/composables.js +41 -40
- package/dist/main.js +228 -226
- package/dist/pay.js +2 -2
- package/dist/referrer.js +1 -1
- package/dist/style.css +1 -1
- package/dist/useAuthkitAuth-Doj5VYjK.js +170 -0
- package/dist/useAuthkitUsersProfile-FJnHJad-.js +36 -0
- package/dist/useEnsureAuthenticated-D78tsddF.js +56 -0
- package/dist/{useSEO--jTDDkXk.js → useSEO-BZhVKEZr.js} +1 -1
- package/dist/useSubscriptionCheckout-DmxORGSV.js +372 -0
- package/dist/user.js +1 -1
- package/package.json +1 -1
- package/dist/PricingPlans-BfVy4xU0.js +0 -210
- package/dist/useAuthkitUsersProfile-D4h6OOdR.js +0 -201
- package/dist/useSubscriptionCheckout-CQ6wHuLI.js +0 -345
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { ref as s, readonly as P } from "vue";
|
|
2
|
+
import { e as c } from "./apiClients-KFp-rs-C.js";
|
|
3
|
+
const a = s("signIn"), m = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), t = s(null), p = "jwtToken";
|
|
4
|
+
function k() {
|
|
5
|
+
try {
|
|
6
|
+
const e = localStorage.getItem(p);
|
|
7
|
+
if (e)
|
|
8
|
+
return t.value = e, !0;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.warn("Failed to access localStorage:", e);
|
|
11
|
+
}
|
|
12
|
+
return !1;
|
|
13
|
+
}
|
|
14
|
+
function U() {
|
|
15
|
+
try {
|
|
16
|
+
const e = new URL(window.location.href), r = e.searchParams.get("token");
|
|
17
|
+
if (!r) return !1;
|
|
18
|
+
const i = e.searchParams.get("userId"), d = e.searchParams.get("appId"), f = e.searchParams.get("needBindIdentity") === "true";
|
|
19
|
+
u(r), ["token", "userId", "appId", "needBindIdentity"].forEach((w) => e.searchParams.delete(w));
|
|
20
|
+
const h = `${e.pathname}${e.search}${e.hash}`;
|
|
21
|
+
return window.history.replaceState({}, "", h), g({
|
|
22
|
+
jwtToken: r,
|
|
23
|
+
userId: i,
|
|
24
|
+
appId: d,
|
|
25
|
+
needBindIdentity: f
|
|
26
|
+
}), !0;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return console.warn("Failed to handle OAuth callback:", e), !1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function L() {
|
|
32
|
+
return U() ? !0 : k();
|
|
33
|
+
}
|
|
34
|
+
function E() {
|
|
35
|
+
return t.value || k() ? t.value : null;
|
|
36
|
+
}
|
|
37
|
+
function u(e) {
|
|
38
|
+
t.value = e;
|
|
39
|
+
try {
|
|
40
|
+
localStorage.setItem(p, e);
|
|
41
|
+
} catch (r) {
|
|
42
|
+
console.warn("Failed to save token to localStorage:", r);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function O(e) {
|
|
46
|
+
u(e.jwtToken), g(e);
|
|
47
|
+
}
|
|
48
|
+
function V() {
|
|
49
|
+
t.value = null;
|
|
50
|
+
try {
|
|
51
|
+
localStorage.removeItem(p);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.warn("Failed to clear localStorage:", e);
|
|
54
|
+
}
|
|
55
|
+
b();
|
|
56
|
+
}
|
|
57
|
+
function l(e, r) {
|
|
58
|
+
return e.add(r), () => {
|
|
59
|
+
e.delete(r);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function g(e) {
|
|
63
|
+
m.forEach((r) => {
|
|
64
|
+
r(e);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function j() {
|
|
68
|
+
I.forEach((e) => void e());
|
|
69
|
+
}
|
|
70
|
+
function A() {
|
|
71
|
+
S.forEach((e) => void e());
|
|
72
|
+
}
|
|
73
|
+
function b() {
|
|
74
|
+
v.forEach((e) => void e());
|
|
75
|
+
}
|
|
76
|
+
function F(e) {
|
|
77
|
+
return l(m, e);
|
|
78
|
+
}
|
|
79
|
+
function R(e) {
|
|
80
|
+
return l(I, e);
|
|
81
|
+
}
|
|
82
|
+
function B(e) {
|
|
83
|
+
return l(S, e);
|
|
84
|
+
}
|
|
85
|
+
function $(e) {
|
|
86
|
+
return l(v, e);
|
|
87
|
+
}
|
|
88
|
+
function x() {
|
|
89
|
+
const e = s(!1), r = s(!1), i = s(!1);
|
|
90
|
+
async function d(n) {
|
|
91
|
+
e.value = !0;
|
|
92
|
+
const {
|
|
93
|
+
data: o
|
|
94
|
+
} = await c.auth.signIn.unified.post({
|
|
95
|
+
identifier: n.identifier || n.email || "",
|
|
96
|
+
password: n.password,
|
|
97
|
+
code: n.code,
|
|
98
|
+
emailVerifyId: n.emailVerifyId,
|
|
99
|
+
method: n.method || "password"
|
|
100
|
+
});
|
|
101
|
+
e.value = !1, o && (u(o.jwtToken), g(o));
|
|
102
|
+
}
|
|
103
|
+
async function f(n) {
|
|
104
|
+
r.value = !0;
|
|
105
|
+
const {
|
|
106
|
+
error: o
|
|
107
|
+
} = n.type === "phone" ? await c.auth.signUp.phone.post({
|
|
108
|
+
phone: n.phone || "",
|
|
109
|
+
code: n.code || "",
|
|
110
|
+
password: n.password,
|
|
111
|
+
referrerId: n.referrerId
|
|
112
|
+
}) : await c.auth.signUp.post({
|
|
113
|
+
email: n.email || "",
|
|
114
|
+
userToken: n.userToken || "",
|
|
115
|
+
emailVerifyId: n.emailVerifyId || "",
|
|
116
|
+
password: n.password || "",
|
|
117
|
+
referrerId: n.referrerId
|
|
118
|
+
});
|
|
119
|
+
r.value = !1, o || (a.value = "signIn", j());
|
|
120
|
+
}
|
|
121
|
+
async function h(n) {
|
|
122
|
+
i.value = !0;
|
|
123
|
+
const {
|
|
124
|
+
error: o
|
|
125
|
+
} = await c.auth.resetPassword.post({
|
|
126
|
+
method: n.method || "email",
|
|
127
|
+
email: n.email,
|
|
128
|
+
phone: n.phone,
|
|
129
|
+
userToken: n.userToken,
|
|
130
|
+
code: n.code,
|
|
131
|
+
emailVerifyId: n.emailVerifyId,
|
|
132
|
+
password: n.password
|
|
133
|
+
});
|
|
134
|
+
i.value = !1, o || (a.value = "signIn", A());
|
|
135
|
+
}
|
|
136
|
+
function w() {
|
|
137
|
+
a.value = "signUp";
|
|
138
|
+
}
|
|
139
|
+
function y() {
|
|
140
|
+
a.value = "resetPassword";
|
|
141
|
+
}
|
|
142
|
+
function T() {
|
|
143
|
+
a.value = "signIn";
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
signInSubmit: d,
|
|
147
|
+
signUpSubmit: f,
|
|
148
|
+
resetPasswordSubmit: h,
|
|
149
|
+
currentView: a,
|
|
150
|
+
authSignInLoading: e,
|
|
151
|
+
authSignUpLoading: r,
|
|
152
|
+
resetPasswordLoading: i,
|
|
153
|
+
switchSignUp: w,
|
|
154
|
+
switchResetPassword: y,
|
|
155
|
+
switchSignIn: T,
|
|
156
|
+
onSignIn: F,
|
|
157
|
+
onSignUp: R,
|
|
158
|
+
onResetPassword: B,
|
|
159
|
+
onSignOut: $,
|
|
160
|
+
jwtToken: P(t),
|
|
161
|
+
getToken: E,
|
|
162
|
+
setToken: u,
|
|
163
|
+
completeSignIn: O,
|
|
164
|
+
restoreSession: L,
|
|
165
|
+
clearAuth: V
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
x as u
|
|
170
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ref as l, computed as f } from "vue";
|
|
2
|
+
import { e as c } from "./apiClients-KFp-rs-C.js";
|
|
3
|
+
import { u as i } from "./useAuthkitAuth-Doj5VYjK.js";
|
|
4
|
+
const o = l(null), u = l(!1), t = l(!1), r = f(() => !!o.value);
|
|
5
|
+
async function v() {
|
|
6
|
+
const {
|
|
7
|
+
getToken: n,
|
|
8
|
+
clearAuth: a
|
|
9
|
+
} = i();
|
|
10
|
+
if (!n()) {
|
|
11
|
+
console.warn("No authentication token found"), o.value = null;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
u.value = !0, t.value = !1;
|
|
15
|
+
const {
|
|
16
|
+
data: s,
|
|
17
|
+
error: e
|
|
18
|
+
} = await c.users.profile.post({});
|
|
19
|
+
u.value = !1, s ? (o.value = s, t.value = !0) : (o.value = null, t.value = !1, ((e == null ? void 0 : e.code) === 401 || (e == null ? void 0 : e.code) === 40101) && (console.warn("认证已过期,清除认证状态"), a()));
|
|
20
|
+
}
|
|
21
|
+
function d() {
|
|
22
|
+
o.value = null;
|
|
23
|
+
}
|
|
24
|
+
function P() {
|
|
25
|
+
return {
|
|
26
|
+
userProfile: o,
|
|
27
|
+
loading: u,
|
|
28
|
+
usersProfileSuccess: t,
|
|
29
|
+
isLoggedIn: r,
|
|
30
|
+
fetchUserProfile: v,
|
|
31
|
+
clearUserProfile: d
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
P as u
|
|
36
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { computed as f } from "vue";
|
|
2
|
+
import { u as r } from "./useAuthkitAuth-Doj5VYjK.js";
|
|
3
|
+
import { u as d } from "./apiClients-KFp-rs-C.js";
|
|
4
|
+
const A = "jwtToken";
|
|
5
|
+
let e = null, i = !1;
|
|
6
|
+
async function h(n) {
|
|
7
|
+
n.intent && await n.intent();
|
|
8
|
+
}
|
|
9
|
+
function g() {
|
|
10
|
+
if (i) return;
|
|
11
|
+
i = !0;
|
|
12
|
+
const {
|
|
13
|
+
onSignIn: n
|
|
14
|
+
} = r();
|
|
15
|
+
n(() => {
|
|
16
|
+
const t = e;
|
|
17
|
+
e = null, t && h(t);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function o() {
|
|
21
|
+
try {
|
|
22
|
+
return localStorage.getItem(A);
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function k() {
|
|
28
|
+
g();
|
|
29
|
+
const {
|
|
30
|
+
jwtToken: n
|
|
31
|
+
} = r(), {
|
|
32
|
+
open: t
|
|
33
|
+
} = d(), c = f(() => !!(n.value || o()));
|
|
34
|
+
function u() {
|
|
35
|
+
return !!(n.value || o());
|
|
36
|
+
}
|
|
37
|
+
function l(a) {
|
|
38
|
+
return u() ? !0 : (e = {
|
|
39
|
+
intent: a ?? null
|
|
40
|
+
}, t({
|
|
41
|
+
view: "signIn"
|
|
42
|
+
}), !1);
|
|
43
|
+
}
|
|
44
|
+
function s() {
|
|
45
|
+
e = null;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
isAuthenticatedRef: c,
|
|
49
|
+
isAuthenticated: u,
|
|
50
|
+
ensureAuthenticated: l,
|
|
51
|
+
clearPendingIntent: s
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
k as u
|
|
56
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref as I, computed as d, watch as _, isRef as G, toValue as B, hasInjectionContext as F, inject as J, watchEffect as Q, getCurrentInstance as Z, onBeforeUnmount as X, onDeactivated as Y, onActivated as ee } from "vue";
|
|
2
2
|
import { useRouter as V, useRoute as K } from "vue-router";
|
|
3
3
|
import { u as R } from "./useAuthkitAppsAuthPageInfo-B9_VzVkQ.js";
|
|
4
|
-
import {
|
|
4
|
+
import { u as U } from "./useAuthkitUsersProfile-FJnHJad-.js";
|
|
5
5
|
const v = I({
|
|
6
6
|
key: "",
|
|
7
7
|
name: ""
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { ref as y, computed as q } from "vue";
|
|
2
|
+
import { f as h } from "./apiClients-KFp-rs-C.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { Message as g } from "@arco-design/web-vue";
|
|
5
|
+
import { u as J } from "./useEnsureAuthenticated-D78tsddF.js";
|
|
6
|
+
function x(e) {
|
|
7
|
+
var i;
|
|
8
|
+
const n = (i = e == null ? void 0 : e.metadata) == null ? void 0 : i.originalPrice;
|
|
9
|
+
return typeof n == "number" ? n : void 0;
|
|
10
|
+
}
|
|
11
|
+
function N(e) {
|
|
12
|
+
const n = x(e);
|
|
13
|
+
return !e || n === void 0 || n <= e.unitAmount ? 0 : Math.round((1 - e.unitAmount / n) * 100);
|
|
14
|
+
}
|
|
15
|
+
function W(e) {
|
|
16
|
+
var l, f;
|
|
17
|
+
const n = (l = e == null ? void 0 : e.metadata) == null ? void 0 : l.discountLabel;
|
|
18
|
+
if (typeof n == "string" && n.trim())
|
|
19
|
+
return n;
|
|
20
|
+
const i = (f = e == null ? void 0 : e.metadata) == null ? void 0 : f.savingMonths;
|
|
21
|
+
return typeof i == "number" && i > 0 ? `买 ${12 - i} 个月送 ${i} 个月` : "";
|
|
22
|
+
}
|
|
23
|
+
function B(e) {
|
|
24
|
+
return e === void 0 ? 0 : Math.floor(e / 100);
|
|
25
|
+
}
|
|
26
|
+
function X(e, n = 1) {
|
|
27
|
+
const i = n > 1 ? `每 ${n} ` : "按";
|
|
28
|
+
switch (e) {
|
|
29
|
+
case "month":
|
|
30
|
+
return `${i}月订阅`;
|
|
31
|
+
case "year":
|
|
32
|
+
return `${i}年订阅`;
|
|
33
|
+
case "day":
|
|
34
|
+
return `${i}天订阅`;
|
|
35
|
+
case "week":
|
|
36
|
+
return `${i}周订阅`;
|
|
37
|
+
default:
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function Y(e) {
|
|
42
|
+
const n = e != null && e.intervalCount && e.intervalCount > 1 ? `${e.intervalCount} ` : "";
|
|
43
|
+
switch (e == null ? void 0 : e.interval) {
|
|
44
|
+
case "month":
|
|
45
|
+
return `/ ${n}月`;
|
|
46
|
+
case "year":
|
|
47
|
+
return `/ ${n}年`;
|
|
48
|
+
case "day":
|
|
49
|
+
return `/ ${n}天`;
|
|
50
|
+
case "week":
|
|
51
|
+
return `/ ${n}周`;
|
|
52
|
+
default:
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function w(e) {
|
|
57
|
+
switch (e) {
|
|
58
|
+
case "day":
|
|
59
|
+
return "每天";
|
|
60
|
+
case "week":
|
|
61
|
+
return "每周";
|
|
62
|
+
case "month":
|
|
63
|
+
return "每月";
|
|
64
|
+
case "year":
|
|
65
|
+
return "每年";
|
|
66
|
+
case "lifetime":
|
|
67
|
+
return "不重置";
|
|
68
|
+
default:
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function D(e) {
|
|
73
|
+
if (e.type === "quota" && e.value !== void 0) {
|
|
74
|
+
const n = w(e.quotaPeriod), i = n ? ` / ${n}` : "";
|
|
75
|
+
return `${e.name}: ${e.value === -1 ? "无限" : e.value}${i}`;
|
|
76
|
+
}
|
|
77
|
+
if (e.type === "unlimited") {
|
|
78
|
+
const n = w(e.quotaPeriod);
|
|
79
|
+
return n ? `${e.name}: 不限 / ${n}` : `${e.name}不限`;
|
|
80
|
+
}
|
|
81
|
+
return e.type === "boolean" && e.value === !1 ? `${e.name}(不支持)` : e.name;
|
|
82
|
+
}
|
|
83
|
+
function C(e) {
|
|
84
|
+
return e.type !== "recurring" || !e.interval ? null : {
|
|
85
|
+
key: `${e.interval}:${e.intervalCount ?? 1}`,
|
|
86
|
+
interval: e.interval,
|
|
87
|
+
intervalCount: e.intervalCount ?? 1
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function Z(e, n) {
|
|
91
|
+
const i = {
|
|
92
|
+
day: 1,
|
|
93
|
+
week: 2,
|
|
94
|
+
month: 3,
|
|
95
|
+
year: 4
|
|
96
|
+
};
|
|
97
|
+
return i[e.interval] - i[n.interval] || e.intervalCount - n.intervalCount;
|
|
98
|
+
}
|
|
99
|
+
function ee(e, n) {
|
|
100
|
+
let i = 0;
|
|
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
|
+
}
|
|
106
|
+
return i > 0 ? `省 ${i}%` : void 0;
|
|
107
|
+
}
|
|
108
|
+
function te(e) {
|
|
109
|
+
return e.includes(":") ? e : `${e}:1`;
|
|
110
|
+
}
|
|
111
|
+
function M() {
|
|
112
|
+
return !!localStorage.getItem("jwtToken");
|
|
113
|
+
}
|
|
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
|
+
const t = /* @__PURE__ */ new Map();
|
|
117
|
+
for (const r of n.value)
|
|
118
|
+
for (const u of r.prices) {
|
|
119
|
+
const c = C(u);
|
|
120
|
+
c && t.set(c.key, c);
|
|
121
|
+
}
|
|
122
|
+
return [...t.values()].sort(Z).map((r) => ({
|
|
123
|
+
value: r.key,
|
|
124
|
+
label: X(r.interval, r.intervalCount),
|
|
125
|
+
badge: ee(n.value, r.key)
|
|
126
|
+
}));
|
|
127
|
+
}), b = q(() => {
|
|
128
|
+
var r;
|
|
129
|
+
const t = [];
|
|
130
|
+
for (const u of n.value) {
|
|
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
|
+
...u,
|
|
137
|
+
features: (r = o.features) != null && r.length ? o.features : u.features,
|
|
138
|
+
selectedPrice: o
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return t;
|
|
142
|
+
});
|
|
143
|
+
function F(t) {
|
|
144
|
+
d.value = t;
|
|
145
|
+
}
|
|
146
|
+
function P(t) {
|
|
147
|
+
const r = i.value, u = l.value;
|
|
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
|
+
}
|
|
150
|
+
function k(t) {
|
|
151
|
+
var r;
|
|
152
|
+
return ((r = i.value) == null ? void 0 : r.productId) === t.id;
|
|
153
|
+
}
|
|
154
|
+
function v(t) {
|
|
155
|
+
var r;
|
|
156
|
+
return ((r = t.selectedPrice) == null ? void 0 : r.type) === "free";
|
|
157
|
+
}
|
|
158
|
+
function U() {
|
|
159
|
+
return !!i.value;
|
|
160
|
+
}
|
|
161
|
+
function T(t) {
|
|
162
|
+
return !!(!t.selectedPrice || P(t) || v(t) && U());
|
|
163
|
+
}
|
|
164
|
+
function $(t) {
|
|
165
|
+
var r;
|
|
166
|
+
return ((r = t.metadata) == null ? void 0 : r.recommended) === !0;
|
|
167
|
+
}
|
|
168
|
+
function j(t) {
|
|
169
|
+
var r;
|
|
170
|
+
return B((r = t.selectedPrice) == null ? void 0 : r.unitAmount);
|
|
171
|
+
}
|
|
172
|
+
function G(t) {
|
|
173
|
+
const r = x(t.selectedPrice);
|
|
174
|
+
return r === void 0 ? void 0 : B(r);
|
|
175
|
+
}
|
|
176
|
+
function O(t) {
|
|
177
|
+
return v(t) ? "" : Y(t.selectedPrice);
|
|
178
|
+
}
|
|
179
|
+
function R(t) {
|
|
180
|
+
var r;
|
|
181
|
+
if (v(t)) {
|
|
182
|
+
const u = (r = t.selectedPrice) == null ? void 0 : r.trialPeriodDays;
|
|
183
|
+
return u ? `${u} 天免费体验` : "免费体验";
|
|
184
|
+
}
|
|
185
|
+
return W(t.selectedPrice);
|
|
186
|
+
}
|
|
187
|
+
function E(t) {
|
|
188
|
+
return P(t) ? "当前方案" : $(t) ? "最受欢迎" : "";
|
|
189
|
+
}
|
|
190
|
+
function K(t) {
|
|
191
|
+
const r = [];
|
|
192
|
+
return P(t) ? r.push({
|
|
193
|
+
label: "当前方案",
|
|
194
|
+
type: "current"
|
|
195
|
+
}) : v(t) ? r.push({
|
|
196
|
+
label: "免费体验",
|
|
197
|
+
type: "trial"
|
|
198
|
+
}) : $(t) && r.push({
|
|
199
|
+
label: "最受欢迎",
|
|
200
|
+
type: "recommended"
|
|
201
|
+
}), r;
|
|
202
|
+
}
|
|
203
|
+
function Q(t) {
|
|
204
|
+
const r = i.value;
|
|
205
|
+
return P(t) ? "当前方案" : v(t) ? r ? "已订阅付费方案" : M() ? "免费开通" : "免费注册" : r ? k(t) ? "切换周期" : typeof r.unitAmount == "number" && t.selectedPrice.unitAmount > r.unitAmount ? "升级方案" : "切换方案" : "立即订阅";
|
|
206
|
+
}
|
|
207
|
+
function V(t, r) {
|
|
208
|
+
const u = t.features.find((c) => c.type === "quota" && c.value !== void 0);
|
|
209
|
+
if (u) {
|
|
210
|
+
const c = w(u.quotaPeriod), m = u.value === -1 ? "不限量" : u.value;
|
|
211
|
+
return `${u.name} ${c ? `${m} / ${c}` : m},覆盖核心使用场景。`;
|
|
212
|
+
}
|
|
213
|
+
return v(t) ? "注册后自动开通免费权益,适合先体验核心能力。" : r === 1 ? "为正式团队准备的高配能力组合。" : "包含入门所需的核心能力。";
|
|
214
|
+
}
|
|
215
|
+
function _(t) {
|
|
216
|
+
return t.filter((r) => r.highlight !== !1).map((r) => ({
|
|
217
|
+
title: D(r),
|
|
218
|
+
description: r.description || ""
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
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
|
+
})), m = [];
|
|
229
|
+
return c.length && m.push({
|
|
230
|
+
title: "功能特性",
|
|
231
|
+
items: c
|
|
232
|
+
}), u.length && m.push({
|
|
233
|
+
title: "用量配额",
|
|
234
|
+
items: u
|
|
235
|
+
}), m;
|
|
236
|
+
}
|
|
237
|
+
async function A() {
|
|
238
|
+
f.value = !0;
|
|
239
|
+
try {
|
|
240
|
+
const {
|
|
241
|
+
data: t,
|
|
242
|
+
error: r
|
|
243
|
+
} = await h.products.listActive.post();
|
|
244
|
+
if (r) {
|
|
245
|
+
console.error("加载产品列表失败", r);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
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
|
+
} finally {
|
|
250
|
+
f.value = !1;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async function L() {
|
|
254
|
+
if (!M()) {
|
|
255
|
+
i.value = null;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
s.value = !0;
|
|
259
|
+
try {
|
|
260
|
+
const {
|
|
261
|
+
data: t,
|
|
262
|
+
error: r
|
|
263
|
+
} = await h.subscriptions.summary.post();
|
|
264
|
+
if (r) {
|
|
265
|
+
console.error("加载当前订阅失败", r);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
i.value = (t == null ? void 0 : t.current) ?? null, l.value = (t == null ? void 0 : t.trial) ?? null;
|
|
269
|
+
} finally {
|
|
270
|
+
s.value = !1;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async function H() {
|
|
274
|
+
await Promise.all([A(), L()]);
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
products: n,
|
|
278
|
+
plans: b,
|
|
279
|
+
currentSubscription: i,
|
|
280
|
+
currentTrial: l,
|
|
281
|
+
listLoading: f,
|
|
282
|
+
currentLoading: s,
|
|
283
|
+
billingInterval: d,
|
|
284
|
+
billingIntervalTabs: a,
|
|
285
|
+
setBillingInterval: F,
|
|
286
|
+
isCurrentPlan: P,
|
|
287
|
+
isSameProduct: k,
|
|
288
|
+
isRecommendedPlan: $,
|
|
289
|
+
isFreePlan: v,
|
|
290
|
+
isPlanActionDisabled: T,
|
|
291
|
+
getDisplayPrice: j,
|
|
292
|
+
getDisplayOriginalPrice: G,
|
|
293
|
+
getDisplayCycle: O,
|
|
294
|
+
getPromotionLabel: R,
|
|
295
|
+
getBadgeLabel: E,
|
|
296
|
+
getBadgeLabels: K,
|
|
297
|
+
getButtonLabel: Q,
|
|
298
|
+
getPlanSummary: V,
|
|
299
|
+
getFeatureItems: _,
|
|
300
|
+
getFeatureGroups: z,
|
|
301
|
+
loadProducts: A,
|
|
302
|
+
loadCurrentSubscription: L,
|
|
303
|
+
refresh: H
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function re(e) {
|
|
307
|
+
window.open(e, "_blank", "noopener,noreferrer");
|
|
308
|
+
}
|
|
309
|
+
function S(e) {
|
|
310
|
+
return e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : "";
|
|
311
|
+
}
|
|
312
|
+
function ne(e) {
|
|
313
|
+
return e && typeof e == "object" && "alipayUrl" in e && typeof e.alipayUrl == "string" ? e.alipayUrl : "";
|
|
314
|
+
}
|
|
315
|
+
function ie(e) {
|
|
316
|
+
return e && typeof e == "object" && "status" in e && e.status === "trialing";
|
|
317
|
+
}
|
|
318
|
+
function fe(e) {
|
|
319
|
+
const n = y(null), {
|
|
320
|
+
ensureAuthenticated: i
|
|
321
|
+
} = J();
|
|
322
|
+
async function l(s) {
|
|
323
|
+
if (!s.selectedPrice) {
|
|
324
|
+
g.warning("当前方案暂无可购买价格");
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
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("当前已经是该方案");
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
n.value = s.id;
|
|
334
|
+
try {
|
|
335
|
+
if (s.selectedPrice.type === "free")
|
|
336
|
+
return;
|
|
337
|
+
const a = d ? await h.subscriptions.change.post({
|
|
338
|
+
subscriptionId: d.id,
|
|
339
|
+
newPriceId: s.selectedPrice.id,
|
|
340
|
+
proration: !0
|
|
341
|
+
}) : await h.subscriptions.create.post({
|
|
342
|
+
priceId: s.selectedPrice.id
|
|
343
|
+
});
|
|
344
|
+
if (a.error) {
|
|
345
|
+
g.error(a.error.message || "订阅操作失败");
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const b = ne(a.data);
|
|
349
|
+
if (b) {
|
|
350
|
+
re(b);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
ie(a.data) ? g.success(S(a.data) || "试用已开始") : g.success(S(a.data) || "订阅已更新"), await e.refreshCurrentSubscription();
|
|
354
|
+
} catch (a) {
|
|
355
|
+
console.error("订阅操作失败", a), g.error("订阅操作失败,请稍后重试");
|
|
356
|
+
} finally {
|
|
357
|
+
n.value = null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function f(s) {
|
|
361
|
+
return n.value === s.id;
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
checkoutPlanId: n,
|
|
365
|
+
checkout: l,
|
|
366
|
+
isCheckingOut: f
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
export {
|
|
370
|
+
fe as a,
|
|
371
|
+
le as u
|
|
372
|
+
};
|
package/dist/user.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as a, a as n, b as r, c as t, d as U, _ as u, e as i, f as M, g as o, h as m, i as I, j as c, k as d, l as b, m as f } from "./UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { U as a, a as n, b as r, c as t, d as U, _ as u, e as i, f as M, g as o, h as m, i as I, j as c, k as d, l as b, m as f } from "./UserMenuInvitationsItem.vue_vue_type_script_setup_true_lang-Czix4_tj.js";
|
|
2
2
|
export {
|
|
3
3
|
a as UserAccountMenu,
|
|
4
4
|
n as UserAvatar,
|