@huyooo/ui 0.5.54 → 0.5.58

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,118 +0,0 @@
1
- import { defineComponent as g, ref as S, createElementBlock as t, createCommentVNode as f, openBlock as o, normalizeClass as K, createBlock as u, createElementVNode as l, unref as M, toDisplayString as C, Fragment as _, renderList as v, normalizeStyle as A } from "vue";
2
- import { Icon as q } from "@iconify/vue";
3
- import { _ as B } from "./_plugin-vue_export-helper-CHgC5LLL.js";
4
- const I = /* @__PURE__ */ g({
5
- __name: "MenuItem",
6
- props: {
7
- hidden: {
8
- type: Boolean,
9
- required: !0,
10
- default: () => !1
11
- },
12
- path: {
13
- type: String,
14
- required: !0,
15
- default: () => ""
16
- },
17
- icon: {
18
- type: String,
19
- required: !0,
20
- default: () => ""
21
- },
22
- name: {
23
- type: String,
24
- required: !0,
25
- default: () => ""
26
- },
27
- active: {
28
- type: Boolean,
29
- required: !0,
30
- default: () => !1
31
- }
32
- },
33
- setup(d) {
34
- const a = d, c = S(!1);
35
- function i() {
36
- c.value = !0;
37
- }
38
- function r() {
39
- c.value = !1;
40
- }
41
- return (s, p) => a.hidden ? f("", !0) : (o(), t("div", {
42
- key: 0,
43
- class: K(["List", {
44
- Active: a.active,
45
- Hover: c.value && !a.active
46
- }]),
47
- onMouseover: i,
48
- onMouseout: r
49
- }, [a.icon ? (o(), u(M(q), {
50
- key: 0,
51
- class: "icon",
52
- icon: a.icon
53
- }, null, 8, ["icon"])) : f("", !0), l("span", null, C(a.name), 1)], 34));
54
- }
55
- }), k = /* @__PURE__ */ B(I, [["__scopeId", "data-v-6276a4d5"]]), T = {
56
- class: "Menu"
57
- }, $ = {
58
- class: "Title"
59
- }, m = {
60
- class: "MenuItem2"
61
- }, x = /* @__PURE__ */ g({
62
- __name: "Menu",
63
- props: {
64
- menus: {
65
- type: Array,
66
- required: !0,
67
- default: () => []
68
- },
69
- selectedKeys: {
70
- type: Array,
71
- required: !0,
72
- default: () => []
73
- }
74
- },
75
- emits: ["update:selectedKeys", "change"],
76
- setup(d, {
77
- emit: a
78
- }) {
79
- const c = d, i = a;
80
- function r(s, p) {
81
- console.log(s, "itemitemitemitem"), i("change", s, p);
82
- }
83
- return (s, p) => (o(), t("div", T, [(o(!0), t(_, null, v(c.menus, (e, h) => (o(), t("div", {
84
- key: h
85
- }, [e.children && e.children.length !== 0 ? (o(), t(_, {
86
- key: 0
87
- }, [l("span", {
88
- class: "TitleContent",
89
- style: A({
90
- marginTop: h !== 0 ? "20px" : "0"
91
- })
92
- }, [e != null && e.icon ? (o(), u(M(q), {
93
- key: 0,
94
- class: "icon",
95
- icon: e.icon
96
- }, null, 8, ["icon"])) : f("", !0), l("span", $, C(e.name), 1)], 4), l("span", m, [(o(!0), t(_, null, v(e.children, (n, y) => (o(), u(k, {
97
- key: y,
98
- hidden: n == null ? void 0 : n.hidden,
99
- path: n.path,
100
- icon: n == null ? void 0 : n.icon,
101
- name: n.name,
102
- active: c.selectedKeys.includes(n.path),
103
- onClick: (z) => r(n, y)
104
- }, null, 8, ["hidden", "path", "icon", "name", "active", "onClick"]))), 128))])], 64)) : (o(), u(k, {
105
- key: 1,
106
- hidden: e == null ? void 0 : e.hidden,
107
- path: e.path,
108
- icon: e == null ? void 0 : e.icon,
109
- name: e.name,
110
- active: c.selectedKeys.includes(e.path),
111
- onClick: (n) => r(e, h)
112
- }, null, 8, ["hidden", "path", "icon", "name", "active", "onClick"]))]))), 128))]));
113
- }
114
- }), N = /* @__PURE__ */ B(x, [["__scopeId", "data-v-df591619"]]);
115
- export {
116
- N as M,
117
- k as a
118
- };
@@ -1,197 +0,0 @@
1
- import { ref as l, readonly as b, computed as T } from "vue";
2
- import { d as y, e as A, f as x, g as i, c as d } from "./auth-CDARHcht.js";
3
- const u = l("signIn"), v = [], w = [], m = [], t = l(null);
4
- function C() {
5
- try {
6
- const e = localStorage.getItem("jwtToken");
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 j() {
15
- if (t.value)
16
- return t.value;
17
- try {
18
- const e = localStorage.getItem("jwtToken");
19
- return e && (t.value = e), e;
20
- } catch (e) {
21
- return console.warn("Failed to access localStorage:", e), null;
22
- }
23
- }
24
- function p(e) {
25
- t.value = e;
26
- try {
27
- localStorage.setItem("jwtToken", e);
28
- } catch (o) {
29
- console.warn("Failed to save token to localStorage:", o);
30
- }
31
- }
32
- function E() {
33
- t.value = null;
34
- try {
35
- localStorage.removeItem("jwtToken");
36
- } catch (e) {
37
- console.warn("Failed to clear localStorage:", e);
38
- }
39
- }
40
- function V(e) {
41
- v.push(e);
42
- }
43
- function $(e) {
44
- w.push(e);
45
- }
46
- function F(e) {
47
- m.push(e);
48
- }
49
- function L() {
50
- const e = l(!1), o = l(!1), c = l(!1);
51
- function h(a) {
52
- e.value = !0, x({
53
- email: a.email,
54
- password: a.password
55
- }).then(({
56
- data: n
57
- }) => {
58
- e.value = !1, p(n.jwtToken), v.forEach((S) => S(n));
59
- }).catch((n) => {
60
- e.value = !1, console.error("登录失败:", n);
61
- });
62
- }
63
- function r(a) {
64
- o.value = !0, A({
65
- email: a.email,
66
- userToken: a.userToken,
67
- emailVerifyId: a.emailVerifyId,
68
- password: a.password,
69
- referrerId: a.referrerId
70
- }).then(() => {
71
- o.value = !1, u.value = "signIn", w.forEach((n) => n());
72
- }).catch((n) => {
73
- o.value = !1, console.error("注册失败:", n);
74
- });
75
- }
76
- function k(a) {
77
- c.value = !0, y({
78
- email: a.email,
79
- userToken: a.userToken,
80
- emailVerifyId: a.emailVerifyId,
81
- password: a.password
82
- }).then(() => {
83
- c.value = !1, u.value = "signIn", m.forEach((n) => n());
84
- }).catch((n) => {
85
- c.value = !1, console.error("重置密码失败:", n);
86
- });
87
- }
88
- function I() {
89
- u.value = "signUp";
90
- }
91
- function P() {
92
- u.value = "resetPassword";
93
- }
94
- function U() {
95
- u.value = "signIn";
96
- }
97
- return {
98
- signInSubmit: h,
99
- signUpSubmit: r,
100
- resetPasswordSubmit: k,
101
- currentView: u,
102
- authSignInLoading: e,
103
- authSignUpLoading: o,
104
- resetPasswordLoading: c,
105
- switchSignUp: I,
106
- switchResetPassword: P,
107
- switchSignIn: U,
108
- addSignInCallback: V,
109
- addSignUpCallback: $,
110
- addResetPasswordCallback: F,
111
- // 简化的token管理
112
- jwtToken: b(t),
113
- getToken: j,
114
- setToken: p,
115
- initializeAuth: C,
116
- clearAuth: E
117
- };
118
- }
119
- function R(e) {
120
- return console.log(i.authPrefixUrl, "globalConfig.authPrefixUrl"), d({
121
- url: `${i.authPrefixUrl}/restfulApi/users/profile`,
122
- method: "post",
123
- data: e
124
- });
125
- }
126
- function G(e) {
127
- return d({
128
- url: `${i.authPrefixUrl}/restfulApi/users/update/baseInfo`,
129
- method: "post",
130
- data: e
131
- });
132
- }
133
- function H(e) {
134
- return d({
135
- url: `${i.authPrefixUrl}/restfulApi/users/update/email`,
136
- method: "post",
137
- data: e
138
- });
139
- }
140
- function J(e) {
141
- return d({
142
- url: `${i.authPrefixUrl}/restfulApi/users/update/password`,
143
- method: "post",
144
- data: e
145
- });
146
- }
147
- function K() {
148
- return d({
149
- url: `${i.authPrefixUrl}/restfulApi/users//unbind/email`,
150
- method: "post"
151
- });
152
- }
153
- const s = l(null), g = l(!1), f = l(!1), z = T(() => !!s.value);
154
- async function B() {
155
- var h;
156
- const {
157
- getToken: e,
158
- clearAuth: o
159
- } = L();
160
- if (!e()) {
161
- console.warn("No authentication token found"), s.value = null;
162
- return;
163
- }
164
- g.value = !0, f.value = !1;
165
- try {
166
- const {
167
- data: r
168
- } = await R();
169
- g.value = !1, r ? (s.value = r, f.value = !0) : (console.warn("获取用户资料返回空数据"), s.value = null, f.value = !1);
170
- } catch (r) {
171
- g.value = !1, f.value = !1, console.error("获取用户资料失败:", r), ((h = r == null ? void 0 : r.response) == null ? void 0 : h.status) === 401 && (console.warn("认证已过期,清除认证状态"), o()), s.value = null;
172
- }
173
- }
174
- function N() {
175
- s.value = null;
176
- }
177
- function M() {
178
- return {
179
- userProfile: s,
180
- loading: g,
181
- usersProfileSuccess: f,
182
- isLoggedIn: z,
183
- // 新增:基于userProfile的登录状态
184
- fetchUserProfile: B,
185
- clearUserProfile: N
186
- // 新增:清除用户信息的方法
187
- };
188
- }
189
- export {
190
- M as a,
191
- R as b,
192
- G as c,
193
- J as d,
194
- H as e,
195
- K as f,
196
- L as u
197
- };