@jnrs/vue-core 1.1.2 → 1.1.4

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/README.md CHANGED
@@ -1,7 +1,13 @@
1
1
  # @jnrs/vue-core
2
2
 
3
3
  ## ✨ 介绍
4
- 巨能前端工程化开发,Vue 专用核心功能包
4
+ 巨能前端工程化开发,Vue 专用核心功能包。
5
+ - Pinia store
6
+ - Vue composables
7
+ - Vue Router
8
+ - 全局指令
9
+ - 插件
10
+ - 公共 Vue 组件
5
11
 
6
12
  ## 💻 技术栈
7
13
  TypeScript、Vue3 生态
@@ -31,12 +37,12 @@ import { useAuthStore } from '@jnrs/vue-core/pinia'
31
37
  ``` typescript
32
38
  /**
33
39
  * useSystemStore 系统仓库
34
- * @returns i18n 国际化
35
- * @returns theme 主题
40
+ * @returns theme 主题(国际化、主题、自定义强调色)
36
41
  * @returns menuCollapse 菜单是否折叠
37
42
  * @returns documentFullscreen 文档是否全屏
38
43
  * @methods toggleCollapse 折叠菜单切换
39
44
  * @methods toggleFullScreen 全屏切换
45
+ * @methods setTheme 设置主题
40
46
  */
41
47
  ```
42
48
  ``` typescript
@@ -75,3 +81,10 @@ import { useAuthStore } from '@jnrs/vue-core/pinia'
75
81
  - createVueRouter 创建 vue-router 实例
76
82
  - asyncGenerateRoute 设置动态路由,生成路由记录
77
83
 
84
+ #### @jnrs/vue-core/components 模块
85
+ Vue 组件
86
+ - GlobalSetting 全局偏好设置
87
+
88
+ #### @jnrs/vue-core/composables 模块
89
+ Vue 组合式 API
90
+ - GlobalSetting 全局偏好设置
@@ -0,0 +1,4 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {
2
+ handleShow: () => void;
3
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
4
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { default as GlobalSetting } from './GlobalSetting.vue';
2
+ export { GlobalSetting };
@@ -0,0 +1,93 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".globalSetting_item[data-v-b18e046e]{margin-bottom:20px}.globalSetting_header{margin-bottom:0;padding-bottom:20px}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { defineComponent as c, ref as h, createBlock as r, openBlock as a, unref as l, withCtx as n, createElementVNode as u, createVNode as _, createElementBlock as g, Fragment as f, renderList as C, createTextVNode as V, toDisplayString as S } from "vue";
3
+ import { ElDrawer as k, ElRadioGroup as p, ElRadio as b } from "element-plus";
4
+ import { u as E, L as x, M as y, C as L } from "../system-C18uA6p7.js";
5
+ const N = { class: "globalSetting_item" }, w = { class: "globalSetting_item" }, I = { class: "globalSetting_item" }, T = /* @__PURE__ */ c({
6
+ __name: "GlobalSetting",
7
+ setup(d, { expose: s }) {
8
+ const { theme: o, setLocale: m, setMode: i, setCustomColor: O } = E(), v = h(!1);
9
+ return s({ handleShow: () => {
10
+ v.value = !0;
11
+ } }), (D, t) => (a(), r(l(k), {
12
+ "header-class": "globalSetting_header",
13
+ modelValue: v.value,
14
+ "onUpdate:modelValue": t[3] || (t[3] = (e) => v.value = e),
15
+ title: "全局偏好设置"
16
+ }, {
17
+ default: n(() => [
18
+ u("div", N, [
19
+ t[4] || (t[4] = u("h4", null, "语言", -1)),
20
+ _(l(p), {
21
+ modelValue: l(o).locale,
22
+ "onUpdate:modelValue": t[0] || (t[0] = (e) => l(o).locale = e),
23
+ onChange: l(m)
24
+ }, {
25
+ default: n(() => [
26
+ (a(!0), g(f, null, C(l(x), (e) => (a(), r(l(b), {
27
+ key: e.value,
28
+ value: e.value
29
+ }, {
30
+ default: n(() => [
31
+ V(S(e.label), 1)
32
+ ]),
33
+ _: 2
34
+ }, 1032, ["value"]))), 128))
35
+ ]),
36
+ _: 1
37
+ }, 8, ["modelValue", "onChange"])
38
+ ]),
39
+ u("div", w, [
40
+ t[5] || (t[5] = u("h4", null, "主题", -1)),
41
+ _(l(p), {
42
+ modelValue: l(o).mode,
43
+ "onUpdate:modelValue": t[1] || (t[1] = (e) => l(o).mode = e),
44
+ onChange: l(i)
45
+ }, {
46
+ default: n(() => [
47
+ (a(!0), g(f, null, C(l(y), (e) => (a(), r(l(b), {
48
+ key: e.value,
49
+ value: e.value
50
+ }, {
51
+ default: n(() => [
52
+ V(S(e.label), 1)
53
+ ]),
54
+ _: 2
55
+ }, 1032, ["value"]))), 128))
56
+ ]),
57
+ _: 1
58
+ }, 8, ["modelValue", "onChange"])
59
+ ]),
60
+ u("div", I, [
61
+ t[6] || (t[6] = u("h4", null, "强调色", -1)),
62
+ _(l(p), {
63
+ modelValue: l(o).customColor,
64
+ "onUpdate:modelValue": t[2] || (t[2] = (e) => l(o).customColor = e),
65
+ onChange: l(O)
66
+ }, {
67
+ default: n(() => [
68
+ (a(!0), g(f, null, C(l(L), (e) => (a(), r(l(b), {
69
+ key: e.value,
70
+ value: e.value
71
+ }, {
72
+ default: n(() => [
73
+ V(S(e.label), 1)
74
+ ]),
75
+ _: 2
76
+ }, 1032, ["value"]))), 128))
77
+ ]),
78
+ _: 1
79
+ }, 8, ["modelValue", "onChange"])
80
+ ])
81
+ ]),
82
+ _: 1
83
+ }, 8, ["modelValue"]));
84
+ }
85
+ }), U = (d, s) => {
86
+ const o = d.__vccOpts || d;
87
+ for (const [m, i] of s)
88
+ o[m] = i;
89
+ return o;
90
+ }, R = /* @__PURE__ */ U(T, [["__scopeId", "data-v-b18e046e"]]);
91
+ export {
92
+ R as GlobalSetting
93
+ };
@@ -0,0 +1 @@
1
+ export { useAsyncTableHeight } from './useAsyncTableHeight';
@@ -0,0 +1,124 @@
1
+ import { ref as M, onMounted as N, onUnmounted as P } from "vue";
2
+ var R = typeof global == "object" && global && global.Object === Object && global, B = typeof self == "object" && self && self.Object === Object && self, k = R || B || Function("return this")(), T = k.Symbol, L = Object.prototype, F = L.hasOwnProperty, U = L.toString, m = T ? T.toStringTag : void 0;
3
+ function z(e) {
4
+ var n = F.call(e, m), i = e[m];
5
+ try {
6
+ e[m] = void 0;
7
+ var o = !0;
8
+ } catch {
9
+ }
10
+ var a = U.call(e);
11
+ return o && (n ? e[m] = i : delete e[m]), a;
12
+ }
13
+ var G = Object.prototype, _ = G.toString;
14
+ function q(e) {
15
+ return _.call(e);
16
+ }
17
+ var D = "[object Null]", X = "[object Undefined]", E = T ? T.toStringTag : void 0;
18
+ function J(e) {
19
+ return e == null ? e === void 0 ? X : D : E && E in Object(e) ? z(e) : q(e);
20
+ }
21
+ function K(e) {
22
+ return e != null && typeof e == "object";
23
+ }
24
+ var Q = "[object Symbol]";
25
+ function V(e) {
26
+ return typeof e == "symbol" || K(e) && J(e) == Q;
27
+ }
28
+ var Y = /\s/;
29
+ function Z(e) {
30
+ for (var n = e.length; n-- && Y.test(e.charAt(n)); )
31
+ ;
32
+ return n;
33
+ }
34
+ var ee = /^\s+/;
35
+ function ne(e) {
36
+ return e && e.slice(0, Z(e) + 1).replace(ee, "");
37
+ }
38
+ function v(e) {
39
+ var n = typeof e;
40
+ return e != null && (n == "object" || n == "function");
41
+ }
42
+ var w = NaN, te = /^[-+]0x[0-9a-f]+$/i, re = /^0b[01]+$/i, ie = /^0o[0-7]+$/i, oe = parseInt;
43
+ function $(e) {
44
+ if (typeof e == "number")
45
+ return e;
46
+ if (V(e))
47
+ return w;
48
+ if (v(e)) {
49
+ var n = typeof e.valueOf == "function" ? e.valueOf() : e;
50
+ e = v(n) ? n + "" : n;
51
+ }
52
+ if (typeof e != "string")
53
+ return e === 0 ? e : +e;
54
+ e = ne(e);
55
+ var i = re.test(e);
56
+ return i || ie.test(e) ? oe(e.slice(2), i ? 2 : 8) : te.test(e) ? w : +e;
57
+ }
58
+ var j = function() {
59
+ return k.Date.now();
60
+ }, ae = "Expected a function", ce = Math.max, fe = Math.min;
61
+ function ue(e, n, i) {
62
+ var o, a, f, u, r, c, s = 0, S = !1, l = !1, y = !0;
63
+ if (typeof e != "function")
64
+ throw new TypeError(ae);
65
+ n = $(n) || 0, v(i) && (S = !!i.leading, l = "maxWait" in i, f = l ? ce($(i.maxWait) || 0, n) : f, y = "trailing" in i ? !!i.trailing : y);
66
+ function p(t) {
67
+ var d = o, g = a;
68
+ return o = a = void 0, s = t, u = e.apply(g, d), u;
69
+ }
70
+ function H(t) {
71
+ return s = t, r = setTimeout(b, n), S ? p(t) : u;
72
+ }
73
+ function W(t) {
74
+ var d = t - c, g = t - s, I = n - d;
75
+ return l ? fe(I, f - g) : I;
76
+ }
77
+ function O(t) {
78
+ var d = t - c, g = t - s;
79
+ return c === void 0 || d >= n || d < 0 || l && g >= f;
80
+ }
81
+ function b() {
82
+ var t = j();
83
+ if (O(t))
84
+ return x(t);
85
+ r = setTimeout(b, W(t));
86
+ }
87
+ function x(t) {
88
+ return r = void 0, y && o ? p(t) : (o = a = void 0, u);
89
+ }
90
+ function A() {
91
+ r !== void 0 && clearTimeout(r), s = 0, o = c = a = r = void 0;
92
+ }
93
+ function C() {
94
+ return r === void 0 ? u : x(j());
95
+ }
96
+ function h() {
97
+ var t = j(), d = O(t);
98
+ if (o = arguments, a = this, c = t, d) {
99
+ if (r === void 0)
100
+ return H(c);
101
+ if (l)
102
+ return clearTimeout(r), r = setTimeout(b, n), p(c);
103
+ }
104
+ return r === void 0 && (r = setTimeout(b, n)), u;
105
+ }
106
+ return h.cancel = A, h.flush = C, h;
107
+ }
108
+ const de = (e = "el-table", n = 36, i = 40) => {
109
+ const o = M(500), a = ue(() => {
110
+ const f = document.querySelector(`.${e}`);
111
+ if (f) {
112
+ const u = f.getBoundingClientRect(), r = window.innerHeight, c = u.top + n + i, s = r - c;
113
+ o.value = s > 100 ? s : 100;
114
+ }
115
+ }, 300);
116
+ return N(() => {
117
+ a(), window.addEventListener("resize", a);
118
+ }), P(() => {
119
+ window.removeEventListener("resize", a);
120
+ }), { maxHeight: o };
121
+ };
122
+ export {
123
+ de as useAsyncTableHeight
124
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : useAsyncTableHeight.ts
5
+ * @Date : 2025/12/09
6
+ * @Desc. : 根据视口动态计算表格高度
7
+ */
8
+ /**
9
+ * @param {*} className 表格类名,默认值 el-table,如果页面存在多个表格,则必须分别传入自定义类名
10
+ * @param {*} FOOT_HEIGHT 总底部高度
11
+ * @param {*} PADDING_HEIGHT 总边距
12
+ */
13
+ export declare const useAsyncTableHeight: (className?: string, FOOT_HEIGHT?: number, PADDING_HEIGHT?: number) => {
14
+ maxHeight: import('vue').Ref<number, number>;
15
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * 语言选项
3
+ */
4
+ export declare const LOCALE_OPTIONS: readonly [{
5
+ readonly value: "zhCn";
6
+ readonly label: "中文";
7
+ }, {
8
+ readonly value: "en";
9
+ readonly label: "English";
10
+ }];
11
+ /**
12
+ * 主题模式选项
13
+ */
14
+ export declare const MODE_OPTIONS: readonly [{
15
+ readonly value: "auto";
16
+ readonly label: "跟随系统";
17
+ }, {
18
+ readonly value: "light";
19
+ readonly label: "浅色";
20
+ }, {
21
+ readonly value: "dark";
22
+ readonly label: "深色";
23
+ }];
24
+ /**
25
+ * 强调色选项
26
+ */
27
+ export declare const COLOR_OPTIONS: readonly [{
28
+ readonly value: "oklch(0.6 0.19 41)";
29
+ readonly label: "JNRS";
30
+ }, {
31
+ readonly value: "oklch(0.51 0.21 264)";
32
+ readonly label: "蔚蓝";
33
+ }, {
34
+ readonly value: "oklch(0.90 0.16 98)";
35
+ readonly label: "月黄";
36
+ }, {
37
+ readonly value: "oklch(0.63 0.25 27)";
38
+ readonly label: "京东红";
39
+ }, {
40
+ readonly value: "oklch(0.65 0.24 33)";
41
+ readonly label: "淘宝红";
42
+ }, {
43
+ readonly value: "oklch(0.61 0.20 261)";
44
+ readonly label: "钉钉蓝";
45
+ }, {
46
+ readonly value: "oklch(0.70 0.12 152)";
47
+ readonly label: "微信绿";
48
+ }];
@@ -0,0 +1,100 @@
1
+ import "pinia-plugin-persistedstate";
2
+ import { u as m } from "./system-C18uA6p7.js";
3
+ import { ref as s } from "vue";
4
+ import { defineStore as d } from "pinia";
5
+ import { a as p } from "./index-DEkMXVh9.js";
6
+ const y = d(
7
+ "@jnrs/vue-core/pinia:auth",
8
+ () => {
9
+ const e = s(!1), n = s(null), u = s(null), o = s(null);
10
+ return {
11
+ hasAuthenticated: e,
12
+ token: n,
13
+ userInfo: u,
14
+ dict: o,
15
+ setUserInfo: (a) => {
16
+ u.value = a;
17
+ },
18
+ setToken: (a) => {
19
+ n.value = a, e.value = !0;
20
+ },
21
+ setDict: (a) => {
22
+ o.value = a;
23
+ },
24
+ asyncClearAuth: async () => {
25
+ n.value = null, u.value = null, o.value = null, e.value = !1;
26
+ }
27
+ };
28
+ },
29
+ {
30
+ persist: {
31
+ pick: ["hasAuthenticated", "token", "userInfo", "dict"]
32
+ }
33
+ }
34
+ ), t = [];
35
+ for (let e = 0; e < 256; ++e)
36
+ t.push((e + 256).toString(16).slice(1));
37
+ function v(e, n = 0) {
38
+ return (t[e[n + 0]] + t[e[n + 1]] + t[e[n + 2]] + t[e[n + 3]] + "-" + t[e[n + 4]] + t[e[n + 5]] + "-" + t[e[n + 6]] + t[e[n + 7]] + "-" + t[e[n + 8]] + t[e[n + 9]] + "-" + t[e[n + 10]] + t[e[n + 11]] + t[e[n + 12]] + t[e[n + 13]] + t[e[n + 14]] + t[e[n + 15]]).toLowerCase();
39
+ }
40
+ let i;
41
+ const h = new Uint8Array(16);
42
+ function g() {
43
+ if (!i) {
44
+ if (typeof crypto > "u" || !crypto.getRandomValues)
45
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
46
+ i = crypto.getRandomValues.bind(crypto);
47
+ }
48
+ return i(h);
49
+ }
50
+ const f = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), l = { randomUUID: f };
51
+ function b(e, n, u) {
52
+ e = e || {};
53
+ const o = e.random ?? e.rng?.() ?? g();
54
+ if (o.length < 16)
55
+ throw new Error("Random bytes length must be >= 16");
56
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, v(o);
57
+ }
58
+ function U(e, n, u) {
59
+ return l.randomUUID && !e ? l.randomUUID() : b(e);
60
+ }
61
+ const x = d(
62
+ "@jnrs/vue-core/pinia:menu",
63
+ () => {
64
+ const e = s(!1), n = s([]), u = async (c) => {
65
+ if (e.value)
66
+ return n.value;
67
+ o(c), n.value = c, e.value = !0;
68
+ try {
69
+ await p(n.value);
70
+ } catch (r) {
71
+ throw r;
72
+ }
73
+ return n.value;
74
+ }, o = (c) => {
75
+ for (const r of c)
76
+ r.meta.uuid = U(), r.children && o(r.children);
77
+ };
78
+ return { hasFetchedAsyncMenus: e, menus: n, asyncSetMenus: u };
79
+ }
80
+ // {
81
+ // persist: {
82
+ // pick: ['menus']
83
+ // }
84
+ // }
85
+ );
86
+ console.log(
87
+ "%c✨ 欢迎使用 @jnrs/vue-core/pinia",
88
+ 'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
89
+ );
90
+ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
91
+ __proto__: null,
92
+ useAuthStore: y,
93
+ useMenuStore: x,
94
+ useSystemStore: m
95
+ }, Symbol.toStringTag, { value: "Module" }));
96
+ export {
97
+ x as a,
98
+ R as i,
99
+ y as u
100
+ };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { c as r } from "./index-DEkMXVh9.js";
2
- import { i } from "./index-Bh-gM-SZ.js";
2
+ import { i } from "./index-BEHnZZvl.js";
3
3
  console.log(
4
4
  "%c✨ 欢迎使用 @jnrs/vue-core",
5
5
  'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
@@ -0,0 +1,4 @@
1
+ import { Locale, ThemeMode } from '@jnrs/shared';
2
+ export declare function isLocale(value: unknown): value is Locale;
3
+ export declare function isThemeMode(value: unknown): value is ThemeMode;
4
+ export declare function isValidColor(value: unknown): value is string;
@@ -1,13 +1,8 @@
1
- import { Dict, User } from '../../types/base';
2
- interface Auth {
3
- token: string;
4
- userInfo: User;
5
- dict: Dict;
6
- }
1
+ import { Dict, User } from '@jnrs/shared';
7
2
  /**
8
3
  * useAuthStore 权限仓库
9
- * @returns hasAuthenticated 是否已登录
10
- * @returns token 登录凭证
4
+ * @returns hasAuthenticated 是否已身份验证
5
+ * @returns token 身份验证凭证
11
6
  * @returns userInfo 用户信息
12
7
  * @returns dict 字典
13
8
  * @methods asyncSetAuth 设置权限信息
@@ -15,24 +10,89 @@ interface Auth {
15
10
  */
16
11
  export declare const useAuthStore: import('pinia').StoreDefinition<"@jnrs/vue-core/pinia:auth", Pick<{
17
12
  hasAuthenticated: import('vue').Ref<boolean, boolean>;
18
- token: import('vue').Ref<string | undefined, string | undefined>;
19
- userInfo: import('vue').Ref<any, any>;
20
- dict: import('vue').Ref<Dict | undefined, Dict | undefined>;
21
- asyncSetAuth: (data: Auth) => Promise<void>;
13
+ token: import('vue').Ref<string | null, string | null>;
14
+ userInfo: import('vue').Ref<{
15
+ [x: string]: unknown;
16
+ id: number;
17
+ name: string;
18
+ role: number;
19
+ permissions?: string[] | undefined;
20
+ jobTitle?: number | undefined;
21
+ workNo?: string | undefined;
22
+ workgroup?: string | undefined;
23
+ avatarFileName?: string | undefined;
24
+ } | null, User | {
25
+ [x: string]: unknown;
26
+ id: number;
27
+ name: string;
28
+ role: number;
29
+ permissions?: string[] | undefined;
30
+ jobTitle?: number | undefined;
31
+ workNo?: string | undefined;
32
+ workgroup?: string | undefined;
33
+ avatarFileName?: string | undefined;
34
+ } | null>;
35
+ dict: import('vue').Ref<Dict | null, Dict | null>;
36
+ setUserInfo: (d: User) => void;
37
+ setToken: (d: string) => void;
38
+ setDict: (d: Dict) => void;
22
39
  asyncClearAuth: () => Promise<void>;
23
40
  }, "hasAuthenticated" | "token" | "userInfo" | "dict">, Pick<{
24
41
  hasAuthenticated: import('vue').Ref<boolean, boolean>;
25
- token: import('vue').Ref<string | undefined, string | undefined>;
26
- userInfo: import('vue').Ref<any, any>;
27
- dict: import('vue').Ref<Dict | undefined, Dict | undefined>;
28
- asyncSetAuth: (data: Auth) => Promise<void>;
42
+ token: import('vue').Ref<string | null, string | null>;
43
+ userInfo: import('vue').Ref<{
44
+ [x: string]: unknown;
45
+ id: number;
46
+ name: string;
47
+ role: number;
48
+ permissions?: string[] | undefined;
49
+ jobTitle?: number | undefined;
50
+ workNo?: string | undefined;
51
+ workgroup?: string | undefined;
52
+ avatarFileName?: string | undefined;
53
+ } | null, User | {
54
+ [x: string]: unknown;
55
+ id: number;
56
+ name: string;
57
+ role: number;
58
+ permissions?: string[] | undefined;
59
+ jobTitle?: number | undefined;
60
+ workNo?: string | undefined;
61
+ workgroup?: string | undefined;
62
+ avatarFileName?: string | undefined;
63
+ } | null>;
64
+ dict: import('vue').Ref<Dict | null, Dict | null>;
65
+ setUserInfo: (d: User) => void;
66
+ setToken: (d: string) => void;
67
+ setDict: (d: Dict) => void;
29
68
  asyncClearAuth: () => Promise<void>;
30
69
  }, never>, Pick<{
31
70
  hasAuthenticated: import('vue').Ref<boolean, boolean>;
32
- token: import('vue').Ref<string | undefined, string | undefined>;
33
- userInfo: import('vue').Ref<any, any>;
34
- dict: import('vue').Ref<Dict | undefined, Dict | undefined>;
35
- asyncSetAuth: (data: Auth) => Promise<void>;
71
+ token: import('vue').Ref<string | null, string | null>;
72
+ userInfo: import('vue').Ref<{
73
+ [x: string]: unknown;
74
+ id: number;
75
+ name: string;
76
+ role: number;
77
+ permissions?: string[] | undefined;
78
+ jobTitle?: number | undefined;
79
+ workNo?: string | undefined;
80
+ workgroup?: string | undefined;
81
+ avatarFileName?: string | undefined;
82
+ } | null, User | {
83
+ [x: string]: unknown;
84
+ id: number;
85
+ name: string;
86
+ role: number;
87
+ permissions?: string[] | undefined;
88
+ jobTitle?: number | undefined;
89
+ workNo?: string | undefined;
90
+ workgroup?: string | undefined;
91
+ avatarFileName?: string | undefined;
92
+ } | null>;
93
+ dict: import('vue').Ref<Dict | null, Dict | null>;
94
+ setUserInfo: (d: User) => void;
95
+ setToken: (d: string) => void;
96
+ setDict: (d: Dict) => void;
36
97
  asyncClearAuth: () => Promise<void>;
37
- }, "asyncSetAuth" | "asyncClearAuth">>;
38
- export {};
98
+ }, "setUserInfo" | "setToken" | "setDict" | "asyncClearAuth">>;
@@ -20,6 +20,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
20
20
  global?: boolean | undefined;
21
21
  fullPathTitle?: string | undefined;
22
22
  todoCount?: number | undefined;
23
+ permissions?: [] | undefined;
23
24
  };
24
25
  path: string;
25
26
  name?: string | undefined;
@@ -38,6 +39,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
38
39
  global?: boolean | undefined;
39
40
  fullPathTitle?: string | undefined;
40
41
  todoCount?: number | undefined;
42
+ permissions?: [] | undefined;
41
43
  };
42
44
  path: string;
43
45
  name?: string | undefined;
@@ -57,6 +59,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
57
59
  global?: boolean | undefined;
58
60
  fullPathTitle?: string | undefined;
59
61
  todoCount?: number | undefined;
62
+ permissions?: [] | undefined;
60
63
  };
61
64
  path: string;
62
65
  name?: string | undefined;
@@ -64,8 +67,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
64
67
  redirect?: string | undefined;
65
68
  children?: /*elided*/ any[] | undefined;
66
69
  }[]>;
67
- asyncClearMenu: () => void;
68
- }, "menus" | "hasFetchedAsyncMenus">, Pick<{
70
+ }, "hasFetchedAsyncMenus" | "menus">, Pick<{
69
71
  hasFetchedAsyncMenus: import('vue').Ref<boolean, boolean>;
70
72
  menus: import('vue').Ref<{
71
73
  meta: {
@@ -79,6 +81,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
79
81
  global?: boolean | undefined;
80
82
  fullPathTitle?: string | undefined;
81
83
  todoCount?: number | undefined;
84
+ permissions?: [] | undefined;
82
85
  };
83
86
  path: string;
84
87
  name?: string | undefined;
@@ -97,6 +100,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
97
100
  global?: boolean | undefined;
98
101
  fullPathTitle?: string | undefined;
99
102
  todoCount?: number | undefined;
103
+ permissions?: [] | undefined;
100
104
  };
101
105
  path: string;
102
106
  name?: string | undefined;
@@ -116,6 +120,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
116
120
  global?: boolean | undefined;
117
121
  fullPathTitle?: string | undefined;
118
122
  todoCount?: number | undefined;
123
+ permissions?: [] | undefined;
119
124
  };
120
125
  path: string;
121
126
  name?: string | undefined;
@@ -123,7 +128,6 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
123
128
  redirect?: string | undefined;
124
129
  children?: /*elided*/ any[] | undefined;
125
130
  }[]>;
126
- asyncClearMenu: () => void;
127
131
  }, never>, Pick<{
128
132
  hasFetchedAsyncMenus: import('vue').Ref<boolean, boolean>;
129
133
  menus: import('vue').Ref<{
@@ -138,6 +142,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
138
142
  global?: boolean | undefined;
139
143
  fullPathTitle?: string | undefined;
140
144
  todoCount?: number | undefined;
145
+ permissions?: [] | undefined;
141
146
  };
142
147
  path: string;
143
148
  name?: string | undefined;
@@ -156,6 +161,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
156
161
  global?: boolean | undefined;
157
162
  fullPathTitle?: string | undefined;
158
163
  todoCount?: number | undefined;
164
+ permissions?: [] | undefined;
159
165
  };
160
166
  path: string;
161
167
  name?: string | undefined;
@@ -175,6 +181,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
175
181
  global?: boolean | undefined;
176
182
  fullPathTitle?: string | undefined;
177
183
  todoCount?: number | undefined;
184
+ permissions?: [] | undefined;
178
185
  };
179
186
  path: string;
180
187
  name?: string | undefined;
@@ -182,5 +189,4 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
182
189
  redirect?: string | undefined;
183
190
  children?: /*elided*/ any[] | undefined;
184
191
  }[]>;
185
- asyncClearMenu: () => void;
186
- }, "asyncSetMenus" | "asyncClearMenu">>;
192
+ }, "asyncSetMenus">>;
@@ -1,31 +1,71 @@
1
+ import { Locale, ThemeMode } from '@jnrs/shared';
2
+ type Theme = {
3
+ locale: Locale;
4
+ mode: ThemeMode;
5
+ customColor: string;
6
+ };
1
7
  /**
2
8
  * useSystemStore 系统仓库
3
- * @returns i18n 国际化
4
- * @returns theme 主题
9
+ * @returns theme 主题(国际化、主题、自定义强调色)
5
10
  * @returns menuCollapse 菜单是否折叠
6
11
  * @returns documentFullscreen 文档是否全屏
7
12
  * @methods toggleCollapse 折叠菜单切换
8
13
  * @methods toggleFullScreen 全屏切换
14
+ * @methods setTheme 设置主题
9
15
  */
10
16
  export declare const useSystemStore: import('pinia').StoreDefinition<"@jnrs/vue-core/pinia:system", Pick<{
11
- i18n: import('vue').Ref<string, string>;
12
- theme: import('vue').Ref<"light" | "dark", "light" | "dark">;
17
+ theme: import('vue').Ref<{
18
+ locale: Locale;
19
+ mode: ThemeMode;
20
+ customColor: string;
21
+ }, Theme | {
22
+ locale: Locale;
23
+ mode: ThemeMode;
24
+ customColor: string;
25
+ }>;
26
+ computedThemeMode: import('vue').ComputedRef<"light" | "dark">;
13
27
  menuCollapse: import('vue').Ref<boolean, boolean>;
14
28
  documentFullscreen: import('vue').Ref<boolean, boolean>;
15
- toggleCollapse: () => void;
29
+ toggleCollapse: () => boolean;
16
30
  toggleFullScreen: () => Promise<void>;
17
- }, "i18n" | "theme" | "menuCollapse" | "documentFullscreen">, Pick<{
18
- i18n: import('vue').Ref<string, string>;
19
- theme: import('vue').Ref<"light" | "dark", "light" | "dark">;
31
+ setLocale: (value: unknown) => void;
32
+ setMode: (value: unknown) => void;
33
+ setCustomColor: (value: unknown) => void;
34
+ }, "theme" | "menuCollapse" | "documentFullscreen">, Pick<{
35
+ theme: import('vue').Ref<{
36
+ locale: Locale;
37
+ mode: ThemeMode;
38
+ customColor: string;
39
+ }, Theme | {
40
+ locale: Locale;
41
+ mode: ThemeMode;
42
+ customColor: string;
43
+ }>;
44
+ computedThemeMode: import('vue').ComputedRef<"light" | "dark">;
20
45
  menuCollapse: import('vue').Ref<boolean, boolean>;
21
46
  documentFullscreen: import('vue').Ref<boolean, boolean>;
22
- toggleCollapse: () => void;
47
+ toggleCollapse: () => boolean;
23
48
  toggleFullScreen: () => Promise<void>;
24
- }, never>, Pick<{
25
- i18n: import('vue').Ref<string, string>;
26
- theme: import('vue').Ref<"light" | "dark", "light" | "dark">;
49
+ setLocale: (value: unknown) => void;
50
+ setMode: (value: unknown) => void;
51
+ setCustomColor: (value: unknown) => void;
52
+ }, "computedThemeMode">, Pick<{
53
+ theme: import('vue').Ref<{
54
+ locale: Locale;
55
+ mode: ThemeMode;
56
+ customColor: string;
57
+ }, Theme | {
58
+ locale: Locale;
59
+ mode: ThemeMode;
60
+ customColor: string;
61
+ }>;
62
+ computedThemeMode: import('vue').ComputedRef<"light" | "dark">;
27
63
  menuCollapse: import('vue').Ref<boolean, boolean>;
28
64
  documentFullscreen: import('vue').Ref<boolean, boolean>;
29
- toggleCollapse: () => void;
65
+ toggleCollapse: () => boolean;
30
66
  toggleFullScreen: () => Promise<void>;
31
- }, "toggleCollapse" | "toggleFullScreen">>;
67
+ setLocale: (value: unknown) => void;
68
+ setMode: (value: unknown) => void;
69
+ setCustomColor: (value: unknown) => void;
70
+ }, "toggleCollapse" | "toggleFullScreen" | "setLocale" | "setMode" | "setCustomColor">>;
71
+ export {};
@@ -1,7 +1,8 @@
1
1
  import "pinia-plugin-persistedstate";
2
- import { a as o, b as r, u } from "../index-Bh-gM-SZ.js";
2
+ import { u as t } from "../system-C18uA6p7.js";
3
+ import { u, a } from "../index-BEHnZZvl.js";
3
4
  export {
4
- o as useAuthStore,
5
- r as useMenuStore,
6
- u as useSystemStore
5
+ u as useAuthStore,
6
+ a as useMenuStore,
7
+ t as useSystemStore
7
8
  };
@@ -0,0 +1,76 @@
1
+ import { ref as a, computed as v, watch as h } from "vue";
2
+ import { defineStore as f } from "pinia";
3
+ import { Fullscreen as p } from "@jnrs/shared";
4
+ import { usePreferredDark as k } from "@vueuse/core";
5
+ const C = [
6
+ { value: "zhCn", label: "中文" },
7
+ { value: "en", label: "English" }
8
+ ], g = [
9
+ { value: "auto", label: "跟随系统" },
10
+ { value: "light", label: "浅色" },
11
+ { value: "dark", label: "深色" }
12
+ ], b = [
13
+ { value: "oklch(0.6 0.19 41)", label: "JNRS" },
14
+ { value: "oklch(0.51 0.21 264)", label: "蔚蓝" },
15
+ { value: "oklch(0.90 0.16 98)", label: "月黄" },
16
+ { value: "oklch(0.63 0.25 27)", label: "京东红" },
17
+ { value: "oklch(0.65 0.24 33)", label: "淘宝红" },
18
+ { value: "oklch(0.61 0.20 261)", label: "钉钉蓝" },
19
+ { value: "oklch(0.70 0.12 152)", label: "微信绿" }
20
+ ];
21
+ function y(e) {
22
+ return e === "zhCn" || e === "en";
23
+ }
24
+ function L(e) {
25
+ return e === "light" || e === "dark" || e === "auto";
26
+ }
27
+ function O(e) {
28
+ return typeof e == "string" && e.trim() !== "";
29
+ }
30
+ const j = f(
31
+ "@jnrs/vue-core/pinia:system",
32
+ () => {
33
+ const e = a(!1), n = () => e.value = !e.value, s = new p(), r = a(!1), i = async () => {
34
+ await s.toggle(), r.value = s.isFullscreen();
35
+ }, o = a({
36
+ locale: C[0].value,
37
+ mode: g[0].value,
38
+ customColor: b[0].value
39
+ }), m = v(() => o.value.mode === "auto" ? u.value ? "dark" : "light" : o.value.mode), u = k();
40
+ return h(
41
+ [() => o.value.mode, u, () => o.value.customColor],
42
+ ([l, d, c]) => {
43
+ const t = document.documentElement;
44
+ t.classList.remove("light", "dark"), l === "auto" ? t.classList.add(d ? "dark" : "light") : t.classList.add(l), c ? t.style.setProperty("--jnrs-color-primary", c) : t.style.removeProperty("--jnrs-color-primary");
45
+ },
46
+ { immediate: !0 }
47
+ ), {
48
+ theme: o,
49
+ computedThemeMode: m,
50
+ menuCollapse: e,
51
+ documentFullscreen: r,
52
+ toggleCollapse: n,
53
+ toggleFullScreen: i,
54
+ setLocale: (l) => {
55
+ y(l) && (o.value.locale = l);
56
+ },
57
+ setMode: (l) => {
58
+ L(l) && (o.value.mode = l);
59
+ },
60
+ setCustomColor: (l) => {
61
+ O(l) && (o.value.customColor = l);
62
+ }
63
+ };
64
+ },
65
+ {
66
+ persist: {
67
+ pick: ["theme", "menuCollapse"]
68
+ }
69
+ }
70
+ );
71
+ export {
72
+ b as C,
73
+ C as L,
74
+ g as M,
75
+ j as u
76
+ };
@@ -1,35 +1,4 @@
1
1
  import { RouteMeta } from 'vue-router';
2
- /**
3
- * 用户信息
4
- */
5
- export interface User {
6
- id: number;
7
- name: string;
8
- account?: string;
9
- role?: number;
10
- jobTitle?: number;
11
- workNo?: string;
12
- workgroup?: null | string;
13
- avatarFileName?: string;
14
- loginDateTime?: string;
15
- [key: string]: unknown;
16
- }
17
- /**
18
- * 字典
19
- */
20
- export interface DictItem {
21
- label: string;
22
- value: string | number;
23
- displayColor?: string;
24
- sequence?: number;
25
- [key: string]: unknown;
26
- }
27
- /**
28
- * 字典键值对
29
- */
30
- export interface Dict {
31
- [key: string]: DictItem[];
32
- }
33
2
  /**
34
3
  * 定义菜单项接口
35
4
  */
@@ -8,6 +8,7 @@ declare module 'vue-router' {
8
8
  global?: boolean;
9
9
  fullPathTitle?: string;
10
10
  todoCount?: number;
11
+ permissions?: [];
11
12
  }
12
13
  }
13
14
  export interface RouteModule {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jnrs/vue-core",
3
- "version": "1.1.2",
4
- "description": "巨能前端工程化开发,Vue 专用核心功能包",
3
+ "version": "1.1.4",
4
+ "description": "巨能前端工程化开发,Vue 专用核心功能包。",
5
5
  "keywords": [
6
6
  "jnrs",
7
7
  "vue-core"
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "type": "module",
19
19
  "types": "dist/index.d.ts",
20
+ "sideEffects": true,
20
21
  "files": [
21
22
  "dist",
22
23
  "README.md",
@@ -34,22 +35,32 @@
34
35
  "./pinia": {
35
36
  "import": "./dist/piniaStore/index.js",
36
37
  "types": "./dist/piniaStore/index.d.ts"
38
+ },
39
+ "./components": {
40
+ "import": "./dist/components/index.js",
41
+ "types": "./dist/components/index.d.ts"
42
+ },
43
+ "./composables": {
44
+ "import": "./dist/composables/index.js",
45
+ "types": "./dist/composables/index.d.ts"
37
46
  }
38
47
  },
39
48
  "peerDependencies": {
40
49
  "@vueuse/core": "^14.1.0",
50
+ "element-plus": "^2.11.9",
41
51
  "pinia": "^3.0.3",
42
52
  "pinia-plugin-persistedstate": "^4.7.1",
43
53
  "vue": "^3.5.22",
44
54
  "vue-router": "^4.5.1",
45
- "@jnrs/core": "1.1.2",
46
- "@jnrs/shared": "1.1.2"
55
+ "@jnrs/shared": "1.1.4",
56
+ "@jnrs/core": "1.1.3"
47
57
  },
48
58
  "devDependencies": {
49
59
  "@vitejs/plugin-vue": "^6.0.1",
50
60
  "rimraf": "^6.0.1",
51
61
  "typescript": "^5.9.3",
52
62
  "vite": "^7.1.7",
63
+ "vite-plugin-css-injected-by-js": "^3.5.2",
53
64
  "vite-plugin-dts": "^4.5.4",
54
65
  "vue-tsc": "^3.1.0"
55
66
  },
@@ -1,171 +0,0 @@
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
- };