@huyooo/ui 0.4.13 → 0.4.16

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,326 +0,0 @@
1
- import { ref as u, computed as b } from "vue";
2
- import { api as s } from "@huyooo/api";
3
- function O(e, t) {
4
- return s({
5
- url: `${e}/restfulApi/apps/findOne`,
6
- method: "post",
7
- data: t
8
- });
9
- }
10
- function V() {
11
- return s({
12
- url: "/restfulApi/apps/authPageInfo",
13
- method: "post"
14
- });
15
- }
16
- const i = u({
17
- id: "",
18
- appKey: "",
19
- name: "",
20
- description: "",
21
- homePageUrl: "",
22
- applicationLogo: "",
23
- applicationLogoUrl: "",
24
- oauth: {
25
- google: {
26
- // redirectURI: '',
27
- // clientID: '',
28
- // clientSecret: '',
29
- enabled: !1
30
- },
31
- microsoft: {
32
- // redirectURI: '',
33
- // clientID: '',
34
- // clientSecret: '',
35
- enabled: !1
36
- },
37
- github: {
38
- // redirectURI: '',
39
- // clientID: '',
40
- // clientSecret: '',
41
- enabled: !1
42
- },
43
- wechat: {
44
- // redirectURI: '',
45
- // clientID: '',
46
- // clientSecret: '',
47
- enabled: !1
48
- }
49
- },
50
- authorizationCallback: "",
51
- aboutUs: {
52
- // 个人信息收集清单
53
- personalInformationCollectionList: {
54
- type: "doc",
55
- content: []
56
- },
57
- // 第三方信息共享清单
58
- thirdPartyInformationSharingList: {
59
- type: "doc",
60
- content: []
61
- },
62
- // 用户服务协议
63
- userServiceAgreement: {
64
- type: "doc",
65
- content: []
66
- },
67
- // 隐私协议
68
- privacyPolicy: {
69
- type: "doc",
70
- content: []
71
- },
72
- // 证照信息
73
- licenseInformation: {
74
- type: "doc",
75
- content: []
76
- }
77
- },
78
- brand: {
79
- theme: "dark",
80
- logo: "",
81
- favicon: "",
82
- backgroundType: "image",
83
- backgroundColor: "",
84
- backgroundImageUrl: "",
85
- backgroundImage: "/66a0d5b35203890887f0e1a4/6714e2458fe86895bf3da8ae/1ef8ed72-1731-6e00-93d1-fa24165f1a3e.webp"
86
- }
87
- });
88
- function Z() {
89
- function e(t) {
90
- V().then(({
91
- data: a
92
- }) => {
93
- i.value.id = a.id, i.value.appKey = a.appKey, i.value.name = a.name, i.value.description = a.description, i.value.homePageUrl = a.homePageUrl, i.value.applicationLogo = a.applicationLogo, i.value.applicationLogoUrl = a.applicationLogoUrl, i.value.oauth = a.oauth, i.value.authorizationCallback = a.authorizationCallback, i.value.aboutUs = a.aboutUs, i.value.brand = a.brand, t && t();
94
- }).catch((a) => {
95
- console.error("获取应用认证页面信息失败:", a);
96
- });
97
- }
98
- return {
99
- appsData: i,
100
- appsAuthPageInfoApi: e
101
- };
102
- }
103
- function z(e) {
104
- return s({
105
- url: "/restfulApi/auth/signIn",
106
- method: "post",
107
- data: e
108
- });
109
- }
110
- function E(e) {
111
- return s({
112
- url: "/restfulApi/auth/resetPassword",
113
- method: "post",
114
- data: e
115
- });
116
- }
117
- function T(e) {
118
- return s({
119
- url: "/restfulApi/auth/signUp",
120
- method: "post",
121
- data: e
122
- });
123
- }
124
- function B(e) {
125
- return s({
126
- url: "/restfulApi/oauth2/authorize",
127
- method: "post",
128
- data: e
129
- });
130
- }
131
- const p = u("signIn"), I = [], A = [], U = [];
132
- function x(e) {
133
- I.push(e);
134
- }
135
- function C(e) {
136
- A.push(e);
137
- }
138
- function R(e) {
139
- U.push(e);
140
- }
141
- function D() {
142
- const e = u(!1), t = u(!1), a = u(!1);
143
- function v(n) {
144
- e.value = !0, z({
145
- email: n.email,
146
- password: n.password
147
- }).then(({
148
- data: r
149
- }) => {
150
- e.value = !1, localStorage.setItem("jwtToken", r.jwtToken), I.forEach((L) => L(r));
151
- }).catch((r) => {
152
- e.value = !1, console.error("登录失败:", r);
153
- });
154
- }
155
- function o(n) {
156
- t.value = !0, T({
157
- email: n.email,
158
- userToken: n.userToken,
159
- emailVerifyId: n.emailVerifyId,
160
- password: n.password,
161
- source: "searchEngine",
162
- isRecommend: !1
163
- }).then(() => {
164
- t.value = !1, p.value = "signIn", A.forEach((r) => r());
165
- }).catch((r) => {
166
- t.value = !1, console.error("注册失败:", r);
167
- });
168
- }
169
- function P(n) {
170
- a.value = !0, E({
171
- email: n.email,
172
- userToken: n.userToken,
173
- emailVerifyId: n.emailVerifyId,
174
- password: n.password
175
- }).then(() => {
176
- a.value = !1, p.value = "signIn", U.forEach((r) => r());
177
- }).catch((r) => {
178
- a.value = !1, console.error("重置密码失败:", r);
179
- });
180
- }
181
- function w() {
182
- p.value = "signUp";
183
- }
184
- function y() {
185
- p.value = "resetPassword";
186
- }
187
- function S() {
188
- p.value = "signIn";
189
- }
190
- return {
191
- signInSubmit: v,
192
- signUpSubmit: o,
193
- resetPasswordSubmit: P,
194
- currentView: p,
195
- authSignInLoading: e,
196
- authSignUpLoading: t,
197
- resetPasswordLoading: a,
198
- switchSignUp: w,
199
- switchResetPassword: y,
200
- switchSignIn: S,
201
- addSignInCallback: x,
202
- addSignUpCallback: C,
203
- addResetPasswordCallback: R
204
- };
205
- }
206
- const j = u(!1);
207
- function M() {
208
- return {
209
- show: j
210
- };
211
- }
212
- function q(e) {
213
- return s({
214
- url: "/restfulApi/users/profile",
215
- method: "post",
216
- data: e
217
- });
218
- }
219
- function G(e) {
220
- return s({
221
- url: "/restfulApi/users/update/baseInfo",
222
- method: "post",
223
- data: e
224
- });
225
- }
226
- function H(e) {
227
- return s({
228
- url: "/restfulApi/users/update/email",
229
- method: "post",
230
- data: e
231
- });
232
- }
233
- function J(e) {
234
- return s({
235
- url: "/restfulApi/users/update/password",
236
- method: "post",
237
- data: e
238
- });
239
- }
240
- function N() {
241
- return s({
242
- url: "/restfulApi/users//unbind/email",
243
- method: "post"
244
- });
245
- }
246
- const g = u(null), m = u(!1);
247
- async function $() {
248
- m.value = !0;
249
- try {
250
- const {
251
- data: e
252
- } = await q();
253
- e ? g.value = e : console.warn("获取用户资料返回空数据");
254
- } catch (e) {
255
- console.error("获取用户资料失败:", e), g.value = null;
256
- } finally {
257
- m.value = !1;
258
- }
259
- }
260
- function Q() {
261
- return {
262
- userProfile: g,
263
- loading: m,
264
- fetchUserProfile: $
265
- };
266
- }
267
- const l = u(""), d = u("/api"), f = u(""), c = u(""), h = u("ap-beijing");
268
- function k() {
269
- const e = [], t = [];
270
- return l.value || (e.push("appId"), t.push("appId is required for Authkit")), c.value || (e.push("bucketId"), t.push("bucketId is required for Authkit")), f.value || (e.push("bucket"), t.push("bucket is required for Authkit")), l.value && !/^[a-zA-Z0-9]{24}$/.test(l.value) && t.push("appId format is invalid (should be 24 character alphanumeric)"), c.value && !/^[a-zA-Z0-9]{24}$/.test(c.value) && t.push("bucketId format is invalid (should be 24 character alphanumeric)"), {
271
- isValid: e.length === 0 && t.length === 0,
272
- missingFields: e,
273
- errors: t
274
- };
275
- }
276
- function W() {
277
- const e = b(() => k()), t = b(() => ({
278
- appId: l.value,
279
- prefixUrl: d.value,
280
- bucket: f.value,
281
- bucketId: c.value,
282
- region: h.value
283
- }));
284
- function a(o) {
285
- o.appId !== void 0 && (l.value = o.appId), o.prefixUrl !== void 0 && (d.value = o.prefixUrl), o.bucket !== void 0 && (f.value = o.bucket), o.bucketId !== void 0 && (c.value = o.bucketId), o.region !== void 0 && (h.value = o.region);
286
- }
287
- function v() {
288
- const o = k();
289
- if (!o.isValid)
290
- throw new Error(`Authkit configuration incomplete: ${o.errors.join(", ")}`);
291
- return {
292
- appId: l.value,
293
- prefixUrl: d.value,
294
- bucket: f.value,
295
- bucketId: c.value,
296
- region: h.value
297
- };
298
- }
299
- return {
300
- // 原有的 ref 访问方式(向后兼容)
301
- appId: l,
302
- prefixUrl: d,
303
- bucket: f,
304
- bucketId: c,
305
- region: h,
306
- // 新增的类型安全功能
307
- config: t,
308
- validation: e,
309
- setConfig: a,
310
- getRequiredConfig: v
311
- };
312
- }
313
- export {
314
- Z as U,
315
- Q as a,
316
- M as b,
317
- W as c,
318
- O as d,
319
- q as e,
320
- G as f,
321
- J as g,
322
- H as h,
323
- N as i,
324
- B as o,
325
- D as u
326
- };