@jnrs/vue-core 1.1.1 → 1.1.2
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/index-Bh-gM-SZ.js +171 -0
- package/dist/index-DEkMXVh9.js +109 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/piniaStore/base/menu.d.ts +9 -9
- package/dist/piniaStore/index.js +4 -162
- package/dist/types/base.d.ts +0 -1
- package/dist/vueRouter/index.js +8 -103
- package/dist/vueRouter/types.d.ts +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import "pinia-plugin-persistedstate";
|
|
2
|
+
import { ref as r } from "vue";
|
|
3
|
+
import { defineStore as i } from "pinia";
|
|
4
|
+
import { a as y } from "./index-DEkMXVh9.js";
|
|
5
|
+
class p {
|
|
6
|
+
// 默认全屏元素,可配置
|
|
7
|
+
defaultElement;
|
|
8
|
+
constructor(e) {
|
|
9
|
+
this.defaultElement = e || document.documentElement;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 进入全屏
|
|
13
|
+
* @param element 可选,指定要全屏的元素
|
|
14
|
+
*/
|
|
15
|
+
async request(e) {
|
|
16
|
+
const o = e || this.defaultElement;
|
|
17
|
+
try {
|
|
18
|
+
await o.requestFullscreen({
|
|
19
|
+
navigationUI: "hide"
|
|
20
|
+
});
|
|
21
|
+
} catch (n) {
|
|
22
|
+
console.error("进入全屏失败:", n);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 退出全屏
|
|
27
|
+
*/
|
|
28
|
+
async exit() {
|
|
29
|
+
if (document.fullscreenElement)
|
|
30
|
+
try {
|
|
31
|
+
await document.exitFullscreen();
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.error("退出全屏失败:", e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 切换全屏状态
|
|
38
|
+
* @param element 可选,指定要切换全屏的元素
|
|
39
|
+
*/
|
|
40
|
+
async toggle(e) {
|
|
41
|
+
document.fullscreenElement ? await this.exit() : await this.request(e);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 判断当前是否处于全屏状态
|
|
45
|
+
* @returns boolean
|
|
46
|
+
*/
|
|
47
|
+
isFullscreen() {
|
|
48
|
+
return !!document.fullscreenElement;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 设置默认全屏元素
|
|
52
|
+
* @param element 新的默认元素
|
|
53
|
+
*/
|
|
54
|
+
setDefaultElement(e) {
|
|
55
|
+
this.defaultElement = e;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 获取当前全屏的元素(如果存在)
|
|
59
|
+
* @returns HTMLElement | null
|
|
60
|
+
*/
|
|
61
|
+
getFullscreenElement() {
|
|
62
|
+
return document.fullscreenElement;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const l = new p(), h = i(
|
|
66
|
+
"@jnrs/vue-core/pinia:system",
|
|
67
|
+
() => {
|
|
68
|
+
const t = r("zh-CN"), e = r("light"), o = r(!1), n = r(l.isFullscreen());
|
|
69
|
+
return { i18n: t, theme: e, menuCollapse: o, documentFullscreen: n, toggleCollapse: () => {
|
|
70
|
+
o.value = !o.value;
|
|
71
|
+
}, toggleFullScreen: async () => {
|
|
72
|
+
await l.toggle(), n.value = l.isFullscreen();
|
|
73
|
+
} };
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
persist: {
|
|
77
|
+
pick: ["i18n", "theme", "menuCollapse"]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
), g = i(
|
|
81
|
+
"@jnrs/vue-core/pinia:auth",
|
|
82
|
+
() => {
|
|
83
|
+
const t = r(!1), e = r(), o = r(), n = r();
|
|
84
|
+
return {
|
|
85
|
+
hasAuthenticated: t,
|
|
86
|
+
token: e,
|
|
87
|
+
userInfo: o,
|
|
88
|
+
dict: n,
|
|
89
|
+
asyncSetAuth: async (s) => {
|
|
90
|
+
t.value = !0, s.token && (e.value = s.token), s.userInfo && (o.value = s.userInfo), s.dict && (n.value = s.dict);
|
|
91
|
+
},
|
|
92
|
+
asyncClearAuth: async () => {
|
|
93
|
+
t.value = !1, e.value = void 0, o.value = void 0, n.value = void 0;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
persist: {
|
|
99
|
+
pick: ["hasAuthenticated", "token", "userInfo", "dict"]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
), u = [];
|
|
103
|
+
for (let t = 0; t < 256; ++t)
|
|
104
|
+
u.push((t + 256).toString(16).slice(1));
|
|
105
|
+
function v(t, e = 0) {
|
|
106
|
+
return (u[t[e + 0]] + u[t[e + 1]] + u[t[e + 2]] + u[t[e + 3]] + "-" + u[t[e + 4]] + u[t[e + 5]] + "-" + u[t[e + 6]] + u[t[e + 7]] + "-" + u[t[e + 8]] + u[t[e + 9]] + "-" + u[t[e + 10]] + u[t[e + 11]] + u[t[e + 12]] + u[t[e + 13]] + u[t[e + 14]] + u[t[e + 15]]).toLowerCase();
|
|
107
|
+
}
|
|
108
|
+
let a;
|
|
109
|
+
const f = new Uint8Array(16);
|
|
110
|
+
function b() {
|
|
111
|
+
if (!a) {
|
|
112
|
+
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
113
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
114
|
+
a = crypto.getRandomValues.bind(crypto);
|
|
115
|
+
}
|
|
116
|
+
return a(f);
|
|
117
|
+
}
|
|
118
|
+
const w = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), m = { randomUUID: w };
|
|
119
|
+
function S(t, e, o) {
|
|
120
|
+
t = t || {};
|
|
121
|
+
const n = t.random ?? t.rng?.() ?? b();
|
|
122
|
+
if (n.length < 16)
|
|
123
|
+
throw new Error("Random bytes length must be >= 16");
|
|
124
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, v(n);
|
|
125
|
+
}
|
|
126
|
+
function x(t, e, o) {
|
|
127
|
+
return m.randomUUID && !t ? m.randomUUID() : S(t);
|
|
128
|
+
}
|
|
129
|
+
const E = i(
|
|
130
|
+
"@jnrs/vue-core/pinia:menu",
|
|
131
|
+
() => {
|
|
132
|
+
const t = r(!1), e = r([]), o = async (c) => {
|
|
133
|
+
if (t.value)
|
|
134
|
+
return e.value;
|
|
135
|
+
n(c), e.value = c, t.value = !0;
|
|
136
|
+
try {
|
|
137
|
+
await y(e.value);
|
|
138
|
+
} catch (s) {
|
|
139
|
+
throw s;
|
|
140
|
+
}
|
|
141
|
+
return e.value;
|
|
142
|
+
}, n = (c) => {
|
|
143
|
+
for (const s of c)
|
|
144
|
+
s.meta.uuid = x(), s.children && n(s.children);
|
|
145
|
+
};
|
|
146
|
+
return { hasFetchedAsyncMenus: t, menus: e, asyncSetMenus: o, asyncClearMenu: () => {
|
|
147
|
+
t.value = !1, e.value = [];
|
|
148
|
+
} };
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
persist: {
|
|
152
|
+
pick: ["menus"]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
console.log(
|
|
157
|
+
"%c✨ 欢迎使用 @jnrs/vue-core/pinia",
|
|
158
|
+
'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
|
|
159
|
+
);
|
|
160
|
+
const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
161
|
+
__proto__: null,
|
|
162
|
+
useAuthStore: g,
|
|
163
|
+
useMenuStore: E,
|
|
164
|
+
useSystemStore: h
|
|
165
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
166
|
+
export {
|
|
167
|
+
g as a,
|
|
168
|
+
E as b,
|
|
169
|
+
A as i,
|
|
170
|
+
h as u
|
|
171
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { createWebHistory as p, createRouter as d } from "vue-router";
|
|
2
|
+
const h = {
|
|
3
|
+
history: p(),
|
|
4
|
+
routes: []
|
|
5
|
+
};
|
|
6
|
+
let n, s, i, m;
|
|
7
|
+
const f = ({
|
|
8
|
+
options: o,
|
|
9
|
+
fileModules: t,
|
|
10
|
+
layoutName: e,
|
|
11
|
+
globalComponent: a,
|
|
12
|
+
handleBeforeEach: r
|
|
13
|
+
}) => (s = t, e && (i = e), a && (m = a), n = d({ ...h, ...o }), n.beforeEach(
|
|
14
|
+
async (c, u) => r?.(c, u)
|
|
15
|
+
), n), g = async (o, t = "push") => {
|
|
16
|
+
try {
|
|
17
|
+
return await n[t](o);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.warn(`router.${t} 失败`, {
|
|
20
|
+
code: "ROUTER_NOT_MATCH",
|
|
21
|
+
message: "未匹配到有效路由",
|
|
22
|
+
error: o || e,
|
|
23
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
24
|
+
}), n[t]({ name: "404" });
|
|
25
|
+
}
|
|
26
|
+
}, _ = (o) => s[`/src/views${o}.vue`], l = async (o, t) => {
|
|
27
|
+
for (const e of o) {
|
|
28
|
+
if (e.meta.fullPathTitle = t ? t.meta.fullPathTitle + "," + e.meta.title : e.meta.title, !e.component) {
|
|
29
|
+
e.children && e.children.length > 0 && l(e.children, e);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const a = e.component.replace(/[^a-zA-Z0-9/._-]/g, "");
|
|
33
|
+
if (!a.startsWith("/") || a.includes("..")) {
|
|
34
|
+
console.warn("[Router] 组件加载失败", {
|
|
35
|
+
code: "INVALID_COMPONENT_PATH",
|
|
36
|
+
message: "组件路径拼写不符合规则,应以 '/' 开头且不能包含 '..',请检查 component 字段是否配置正确",
|
|
37
|
+
menu: {
|
|
38
|
+
path: e.path,
|
|
39
|
+
name: e.name,
|
|
40
|
+
component: e.component
|
|
41
|
+
},
|
|
42
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
43
|
+
});
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const r = _(a);
|
|
47
|
+
if (!r) {
|
|
48
|
+
console.warn("[Router] 组件加载失败", {
|
|
49
|
+
code: "COMPONENT_NOT_FOUND",
|
|
50
|
+
message: "组件加载器无效,请检查 component 字段是否配置正确",
|
|
51
|
+
menu: {
|
|
52
|
+
path: e.path,
|
|
53
|
+
name: e.name,
|
|
54
|
+
component: e.component
|
|
55
|
+
},
|
|
56
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
57
|
+
});
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
let c = {
|
|
61
|
+
name: e.name,
|
|
62
|
+
path: e.path,
|
|
63
|
+
meta: e.meta,
|
|
64
|
+
redirect: e.redirect,
|
|
65
|
+
component: () => r()
|
|
66
|
+
};
|
|
67
|
+
e.meta?.global ? (m !== void 0 && (c = {
|
|
68
|
+
name: "_globalComponent_" + e.name,
|
|
69
|
+
path: e.path,
|
|
70
|
+
meta: e.meta,
|
|
71
|
+
redirect: e.redirect,
|
|
72
|
+
component: () => m,
|
|
73
|
+
children: [
|
|
74
|
+
{
|
|
75
|
+
path: "",
|
|
76
|
+
name: e.name,
|
|
77
|
+
meta: e.meta,
|
|
78
|
+
component: () => r()
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}), n.addRoute(c)) : n.addRoute(i, c);
|
|
82
|
+
}
|
|
83
|
+
}, O = () => {
|
|
84
|
+
const o = [];
|
|
85
|
+
for (const t of n.getRoutes())
|
|
86
|
+
o.push({
|
|
87
|
+
name: t.name,
|
|
88
|
+
path: t.path,
|
|
89
|
+
meta: t.meta
|
|
90
|
+
});
|
|
91
|
+
return o;
|
|
92
|
+
}, T = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
93
|
+
__proto__: null,
|
|
94
|
+
asyncGenerateRoute: l,
|
|
95
|
+
createVueRouter: f,
|
|
96
|
+
getRoutes: O,
|
|
97
|
+
handleRouter: g
|
|
98
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
99
|
+
console.log(
|
|
100
|
+
"%c✨ 欢迎使用 @jnrs/vue-core/router",
|
|
101
|
+
'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
|
|
102
|
+
);
|
|
103
|
+
export {
|
|
104
|
+
l as a,
|
|
105
|
+
f as b,
|
|
106
|
+
T as c,
|
|
107
|
+
O as g,
|
|
108
|
+
g as h
|
|
109
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { c as r } from "./index-DEkMXVh9.js";
|
|
2
|
+
import { i } from "./index-Bh-gM-SZ.js";
|
|
1
3
|
console.log(
|
|
2
4
|
"%c✨ 欢迎使用 @jnrs/vue-core",
|
|
3
5
|
'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
|
|
4
6
|
);
|
|
7
|
+
export {
|
|
8
|
+
i as piniaStore,
|
|
9
|
+
r as vueRouter
|
|
10
|
+
};
|
|
@@ -19,10 +19,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
19
19
|
noAuth?: boolean | undefined;
|
|
20
20
|
global?: boolean | undefined;
|
|
21
21
|
fullPathTitle?: string | undefined;
|
|
22
|
+
todoCount?: number | undefined;
|
|
22
23
|
};
|
|
23
24
|
path: string;
|
|
24
25
|
name?: string | undefined;
|
|
25
|
-
todoCount?: number | undefined;
|
|
26
26
|
component?: string | undefined;
|
|
27
27
|
redirect?: string | undefined;
|
|
28
28
|
children?: /*elided*/ any[] | undefined;
|
|
@@ -37,10 +37,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
37
37
|
noAuth?: boolean | undefined;
|
|
38
38
|
global?: boolean | undefined;
|
|
39
39
|
fullPathTitle?: string | undefined;
|
|
40
|
+
todoCount?: number | undefined;
|
|
40
41
|
};
|
|
41
42
|
path: string;
|
|
42
43
|
name?: string | undefined;
|
|
43
|
-
todoCount?: number | undefined;
|
|
44
44
|
component?: string | undefined;
|
|
45
45
|
redirect?: string | undefined;
|
|
46
46
|
children?: /*elided*/ any[] | undefined;
|
|
@@ -56,10 +56,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
56
56
|
noAuth?: boolean | undefined;
|
|
57
57
|
global?: boolean | undefined;
|
|
58
58
|
fullPathTitle?: string | undefined;
|
|
59
|
+
todoCount?: number | undefined;
|
|
59
60
|
};
|
|
60
61
|
path: string;
|
|
61
62
|
name?: string | undefined;
|
|
62
|
-
todoCount?: number | undefined;
|
|
63
63
|
component?: string | undefined;
|
|
64
64
|
redirect?: string | undefined;
|
|
65
65
|
children?: /*elided*/ any[] | undefined;
|
|
@@ -78,10 +78,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
78
78
|
noAuth?: boolean | undefined;
|
|
79
79
|
global?: boolean | undefined;
|
|
80
80
|
fullPathTitle?: string | undefined;
|
|
81
|
+
todoCount?: number | undefined;
|
|
81
82
|
};
|
|
82
83
|
path: string;
|
|
83
84
|
name?: string | undefined;
|
|
84
|
-
todoCount?: number | undefined;
|
|
85
85
|
component?: string | undefined;
|
|
86
86
|
redirect?: string | undefined;
|
|
87
87
|
children?: /*elided*/ any[] | undefined;
|
|
@@ -96,10 +96,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
96
96
|
noAuth?: boolean | undefined;
|
|
97
97
|
global?: boolean | undefined;
|
|
98
98
|
fullPathTitle?: string | undefined;
|
|
99
|
+
todoCount?: number | undefined;
|
|
99
100
|
};
|
|
100
101
|
path: string;
|
|
101
102
|
name?: string | undefined;
|
|
102
|
-
todoCount?: number | undefined;
|
|
103
103
|
component?: string | undefined;
|
|
104
104
|
redirect?: string | undefined;
|
|
105
105
|
children?: /*elided*/ any[] | undefined;
|
|
@@ -115,10 +115,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
115
115
|
noAuth?: boolean | undefined;
|
|
116
116
|
global?: boolean | undefined;
|
|
117
117
|
fullPathTitle?: string | undefined;
|
|
118
|
+
todoCount?: number | undefined;
|
|
118
119
|
};
|
|
119
120
|
path: string;
|
|
120
121
|
name?: string | undefined;
|
|
121
|
-
todoCount?: number | undefined;
|
|
122
122
|
component?: string | undefined;
|
|
123
123
|
redirect?: string | undefined;
|
|
124
124
|
children?: /*elided*/ any[] | undefined;
|
|
@@ -137,10 +137,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
137
137
|
noAuth?: boolean | undefined;
|
|
138
138
|
global?: boolean | undefined;
|
|
139
139
|
fullPathTitle?: string | undefined;
|
|
140
|
+
todoCount?: number | undefined;
|
|
140
141
|
};
|
|
141
142
|
path: string;
|
|
142
143
|
name?: string | undefined;
|
|
143
|
-
todoCount?: number | undefined;
|
|
144
144
|
component?: string | undefined;
|
|
145
145
|
redirect?: string | undefined;
|
|
146
146
|
children?: /*elided*/ any[] | undefined;
|
|
@@ -155,10 +155,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
155
155
|
noAuth?: boolean | undefined;
|
|
156
156
|
global?: boolean | undefined;
|
|
157
157
|
fullPathTitle?: string | undefined;
|
|
158
|
+
todoCount?: number | undefined;
|
|
158
159
|
};
|
|
159
160
|
path: string;
|
|
160
161
|
name?: string | undefined;
|
|
161
|
-
todoCount?: number | undefined;
|
|
162
162
|
component?: string | undefined;
|
|
163
163
|
redirect?: string | undefined;
|
|
164
164
|
children?: /*elided*/ any[] | undefined;
|
|
@@ -174,10 +174,10 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
|
|
|
174
174
|
noAuth?: boolean | undefined;
|
|
175
175
|
global?: boolean | undefined;
|
|
176
176
|
fullPathTitle?: string | undefined;
|
|
177
|
+
todoCount?: number | undefined;
|
|
177
178
|
};
|
|
178
179
|
path: string;
|
|
179
180
|
name?: string | undefined;
|
|
180
|
-
todoCount?: number | undefined;
|
|
181
181
|
component?: string | undefined;
|
|
182
182
|
redirect?: string | undefined;
|
|
183
183
|
children?: /*elided*/ any[] | undefined;
|
package/dist/piniaStore/index.js
CHANGED
|
@@ -1,165 +1,7 @@
|
|
|
1
1
|
import "pinia-plugin-persistedstate";
|
|
2
|
-
import {
|
|
3
|
-
import { defineStore as a } from "pinia";
|
|
4
|
-
import { asyncGenerateRoute as p } from "../vueRouter/index.js";
|
|
5
|
-
class h {
|
|
6
|
-
// 默认全屏元素,可配置
|
|
7
|
-
defaultElement;
|
|
8
|
-
constructor(e) {
|
|
9
|
-
this.defaultElement = e || document.documentElement;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 进入全屏
|
|
13
|
-
* @param element 可选,指定要全屏的元素
|
|
14
|
-
*/
|
|
15
|
-
async request(e) {
|
|
16
|
-
const u = e || this.defaultElement;
|
|
17
|
-
try {
|
|
18
|
-
await u.requestFullscreen({
|
|
19
|
-
navigationUI: "hide"
|
|
20
|
-
});
|
|
21
|
-
} catch (t) {
|
|
22
|
-
console.error("进入全屏失败:", t);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 退出全屏
|
|
27
|
-
*/
|
|
28
|
-
async exit() {
|
|
29
|
-
if (document.fullscreenElement)
|
|
30
|
-
try {
|
|
31
|
-
await document.exitFullscreen();
|
|
32
|
-
} catch (e) {
|
|
33
|
-
console.error("退出全屏失败:", e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 切换全屏状态
|
|
38
|
-
* @param element 可选,指定要切换全屏的元素
|
|
39
|
-
*/
|
|
40
|
-
async toggle(e) {
|
|
41
|
-
document.fullscreenElement ? await this.exit() : await this.request(e);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 判断当前是否处于全屏状态
|
|
45
|
-
* @returns boolean
|
|
46
|
-
*/
|
|
47
|
-
isFullscreen() {
|
|
48
|
-
return !!document.fullscreenElement;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* 设置默认全屏元素
|
|
52
|
-
* @param element 新的默认元素
|
|
53
|
-
*/
|
|
54
|
-
setDefaultElement(e) {
|
|
55
|
-
this.defaultElement = e;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 获取当前全屏的元素(如果存在)
|
|
59
|
-
* @returns HTMLElement | null
|
|
60
|
-
*/
|
|
61
|
-
getFullscreenElement() {
|
|
62
|
-
return document.fullscreenElement;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
console.log("%c✨ 欢迎使用 @jnrs/shared", 'background: #8061BF; color: #f2f2f2; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;');
|
|
66
|
-
const l = new h(), F = a(
|
|
67
|
-
"@jnrs/vue-core/pinia:system",
|
|
68
|
-
() => {
|
|
69
|
-
const n = r("zh-CN"), e = r("light"), u = r(!1), t = r(l.isFullscreen());
|
|
70
|
-
return { i18n: n, theme: e, menuCollapse: u, documentFullscreen: t, toggleCollapse: () => {
|
|
71
|
-
u.value = !u.value;
|
|
72
|
-
}, toggleFullScreen: async () => {
|
|
73
|
-
await l.toggle(), t.value = l.isFullscreen();
|
|
74
|
-
} };
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
persist: {
|
|
78
|
-
pick: ["i18n", "theme", "menuCollapse"]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
), C = a(
|
|
82
|
-
"@jnrs/vue-core/pinia:auth",
|
|
83
|
-
() => {
|
|
84
|
-
const n = r(!1), e = r(), u = r(), t = r();
|
|
85
|
-
return {
|
|
86
|
-
hasAuthenticated: n,
|
|
87
|
-
token: e,
|
|
88
|
-
userInfo: u,
|
|
89
|
-
dict: t,
|
|
90
|
-
asyncSetAuth: async (s) => {
|
|
91
|
-
n.value = !0, s.token && (e.value = s.token), s.userInfo && (u.value = s.userInfo), s.dict && (t.value = s.dict);
|
|
92
|
-
},
|
|
93
|
-
asyncClearAuth: async () => {
|
|
94
|
-
n.value = !1, e.value = void 0, u.value = void 0, t.value = void 0;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
persist: {
|
|
100
|
-
pick: ["hasAuthenticated", "token", "userInfo", "dict"]
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
), o = [];
|
|
104
|
-
for (let n = 0; n < 256; ++n)
|
|
105
|
-
o.push((n + 256).toString(16).slice(1));
|
|
106
|
-
function y(n, e = 0) {
|
|
107
|
-
return (o[n[e + 0]] + o[n[e + 1]] + o[n[e + 2]] + o[n[e + 3]] + "-" + o[n[e + 4]] + o[n[e + 5]] + "-" + o[n[e + 6]] + o[n[e + 7]] + "-" + o[n[e + 8]] + o[n[e + 9]] + "-" + o[n[e + 10]] + o[n[e + 11]] + o[n[e + 12]] + o[n[e + 13]] + o[n[e + 14]] + o[n[e + 15]]).toLowerCase();
|
|
108
|
-
}
|
|
109
|
-
let i;
|
|
110
|
-
const f = new Uint8Array(16);
|
|
111
|
-
function g() {
|
|
112
|
-
if (!i) {
|
|
113
|
-
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
114
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
115
|
-
i = crypto.getRandomValues.bind(crypto);
|
|
116
|
-
}
|
|
117
|
-
return i(f);
|
|
118
|
-
}
|
|
119
|
-
const v = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), m = { randomUUID: v };
|
|
120
|
-
function w(n, e, u) {
|
|
121
|
-
n = n || {};
|
|
122
|
-
const t = n.random ?? n.rng?.() ?? g();
|
|
123
|
-
if (t.length < 16)
|
|
124
|
-
throw new Error("Random bytes length must be >= 16");
|
|
125
|
-
return t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128, y(t);
|
|
126
|
-
}
|
|
127
|
-
function x(n, e, u) {
|
|
128
|
-
return m.randomUUID && !n ? m.randomUUID() : w(n);
|
|
129
|
-
}
|
|
130
|
-
const I = a(
|
|
131
|
-
"@jnrs/vue-core/pinia:menu",
|
|
132
|
-
() => {
|
|
133
|
-
const n = r(!1), e = r([]), u = async (c) => {
|
|
134
|
-
if (n.value)
|
|
135
|
-
return e.value;
|
|
136
|
-
t(c), e.value = c, n.value = !0;
|
|
137
|
-
try {
|
|
138
|
-
await p(e.value);
|
|
139
|
-
} catch (s) {
|
|
140
|
-
throw s;
|
|
141
|
-
}
|
|
142
|
-
return e.value;
|
|
143
|
-
}, t = (c) => {
|
|
144
|
-
for (const s of c)
|
|
145
|
-
s.meta.uuid = x(), s.children && t(s.children);
|
|
146
|
-
};
|
|
147
|
-
return { hasFetchedAsyncMenus: n, menus: e, asyncSetMenus: u, asyncClearMenu: () => {
|
|
148
|
-
n.value = !1, e.value = [];
|
|
149
|
-
} };
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
persist: {
|
|
153
|
-
pick: ["menus"]
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
console.log(
|
|
158
|
-
"%c✨ 欢迎使用 @jnrs/vue-core/pinia",
|
|
159
|
-
'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
|
|
160
|
-
);
|
|
2
|
+
import { a as o, b as r, u } from "../index-Bh-gM-SZ.js";
|
|
161
3
|
export {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
4
|
+
o as useAuthStore,
|
|
5
|
+
r as useMenuStore,
|
|
6
|
+
u as useSystemStore
|
|
165
7
|
};
|
package/dist/types/base.d.ts
CHANGED
package/dist/vueRouter/index.js
CHANGED
|
@@ -1,105 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
const d = {
|
|
4
|
-
history: l(),
|
|
5
|
-
routes: []
|
|
6
|
-
};
|
|
7
|
-
let n, s, i, m;
|
|
8
|
-
const R = ({
|
|
9
|
-
options: o,
|
|
10
|
-
fileModules: t,
|
|
11
|
-
layoutName: e,
|
|
12
|
-
globalComponent: a,
|
|
13
|
-
handleBeforeEach: r
|
|
14
|
-
}) => (s = t, e && (i = e), a && (m = a), n = p({ ...d, ...o }), n.beforeEach(
|
|
15
|
-
async (c, u) => r?.(c, u)
|
|
16
|
-
), n), O = async (o, t = "push") => {
|
|
17
|
-
try {
|
|
18
|
-
return await n[t](o);
|
|
19
|
-
} catch (e) {
|
|
20
|
-
console.warn(`router.${t} 失败`, {
|
|
21
|
-
code: "ROUTER_NOT_MATCH",
|
|
22
|
-
message: "未匹配到有效路由",
|
|
23
|
-
error: o || e,
|
|
24
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
25
|
-
}), n[t]({ name: "404" });
|
|
26
|
-
}
|
|
27
|
-
}, h = (o) => s[`/src/views${o}.vue`], f = async (o, t) => {
|
|
28
|
-
for (const e of o) {
|
|
29
|
-
if (e.meta.fullPathTitle = t ? t.meta.fullPathTitle + "," + e.meta.title : e.meta.title, !e.component) {
|
|
30
|
-
e.children && e.children.length > 0 && f(e.children, e);
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
const a = e.component.replace(/[^a-zA-Z0-9/._-]/g, "");
|
|
34
|
-
if (!a.startsWith("/") || a.includes("..")) {
|
|
35
|
-
console.warn("[Router] 组件加载失败", {
|
|
36
|
-
code: "INVALID_COMPONENT_PATH",
|
|
37
|
-
message: "组件路径拼写不符合规则,应以 '/' 开头且不能包含 '..',请检查 component 字段是否配置正确",
|
|
38
|
-
menu: {
|
|
39
|
-
path: e.path,
|
|
40
|
-
name: e.name,
|
|
41
|
-
component: e.component
|
|
42
|
-
},
|
|
43
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
44
|
-
});
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
const r = h(a);
|
|
48
|
-
if (!r) {
|
|
49
|
-
console.warn("[Router] 组件加载失败", {
|
|
50
|
-
code: "COMPONENT_NOT_FOUND",
|
|
51
|
-
message: "组件加载器无效,请检查 component 字段是否配置正确",
|
|
52
|
-
menu: {
|
|
53
|
-
path: e.path,
|
|
54
|
-
name: e.name,
|
|
55
|
-
component: e.component
|
|
56
|
-
},
|
|
57
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
58
|
-
});
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
let c = {
|
|
62
|
-
name: e.name,
|
|
63
|
-
path: e.path,
|
|
64
|
-
meta: e.meta,
|
|
65
|
-
redirect: e.redirect,
|
|
66
|
-
component: () => r()
|
|
67
|
-
};
|
|
68
|
-
e.meta?.global ? (m !== void 0 && (c = {
|
|
69
|
-
name: "_globalComponent_" + e.name,
|
|
70
|
-
path: e.path,
|
|
71
|
-
meta: e.meta,
|
|
72
|
-
redirect: e.redirect,
|
|
73
|
-
component: () => m,
|
|
74
|
-
children: [
|
|
75
|
-
{
|
|
76
|
-
path: "",
|
|
77
|
-
name: e.name,
|
|
78
|
-
meta: e.meta,
|
|
79
|
-
component: () => r()
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
}), n.addRoute(c)) : n.addRoute(i, c);
|
|
83
|
-
}
|
|
84
|
-
}, _ = () => {
|
|
85
|
-
const o = [];
|
|
86
|
-
for (const t of n.getRoutes())
|
|
87
|
-
o.push({
|
|
88
|
-
name: t.name,
|
|
89
|
-
path: t.path,
|
|
90
|
-
meta: t.meta
|
|
91
|
-
});
|
|
92
|
-
return o;
|
|
93
|
-
};
|
|
94
|
-
console.log(
|
|
95
|
-
"%c✨ 欢迎使用 @jnrs/vue-core/router",
|
|
96
|
-
'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
|
|
97
|
-
);
|
|
1
|
+
import { useRoute as o, useRouter as a } from "vue-router";
|
|
2
|
+
import { a as u, b as s, g as R, h as n } from "../index-DEkMXVh9.js";
|
|
98
3
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
4
|
+
u as asyncGenerateRoute,
|
|
5
|
+
s as createVueRouter,
|
|
6
|
+
R as getRoutes,
|
|
7
|
+
n as handleRouter,
|
|
8
|
+
o as useRoute,
|
|
9
|
+
a as useRouter
|
|
105
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jnrs/vue-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "巨能前端工程化开发,Vue 专用核心功能包",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jnrs",
|
|
@@ -37,12 +37,13 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
+
"@vueuse/core": "^14.1.0",
|
|
40
41
|
"pinia": "^3.0.3",
|
|
41
42
|
"pinia-plugin-persistedstate": "^4.7.1",
|
|
42
43
|
"vue": "^3.5.22",
|
|
43
44
|
"vue-router": "^4.5.1",
|
|
44
|
-
"@jnrs/
|
|
45
|
-
"@jnrs/
|
|
45
|
+
"@jnrs/core": "1.1.2",
|
|
46
|
+
"@jnrs/shared": "1.1.2"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@vitejs/plugin-vue": "^6.0.1",
|