@jnrs/vue-core 1.1.2 → 1.1.3

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,6 @@ 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 全局偏好设置
@@ -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,122 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".globalSetting_item[data-v-122c674a]{margin-bottom:20px}.globalSetting_header{margin-bottom:0;padding-bottom:20px;border-bottom:1px solid #e4e4e7}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { defineComponent as g, ref as y, createBlock as d, openBlock as n, unref as t, withCtx as s, createElementBlock as i, Fragment as h, renderList as m, createElementVNode as k, createVNode as S, toDisplayString as b, createTextVNode as C } from "vue";
3
+ import { ElDrawer as x, ElRadioGroup as E, ElRadio as V } from "element-plus";
4
+ import { u as w } from "../system-DSegwP0Z.js";
5
+ const N = /* @__PURE__ */ g({
6
+ __name: "GlobalSetting",
7
+ setup(u, { expose: r }) {
8
+ const { theme: a, setTheme: c } = w(), l = y(!1), _ = [
9
+ {
10
+ title: "语言",
11
+ key: "locale",
12
+ select: [
13
+ {
14
+ value: "zhCn",
15
+ label: "中文"
16
+ },
17
+ {
18
+ value: "en",
19
+ label: "English"
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ title: "主题",
25
+ key: "mode",
26
+ select: [
27
+ {
28
+ value: "light",
29
+ label: "浅色"
30
+ },
31
+ {
32
+ value: "dark",
33
+ label: "深色"
34
+ },
35
+ {
36
+ value: "auto",
37
+ label: "跟随系统"
38
+ }
39
+ ]
40
+ },
41
+ {
42
+ title: "强调色",
43
+ key: "customColor",
44
+ select: [
45
+ {
46
+ value: "oklch(0.6 0.19 41)",
47
+ label: "JNRS"
48
+ },
49
+ {
50
+ value: "oklch(0.51 0.21 264)",
51
+ label: "蔚蓝"
52
+ },
53
+ {
54
+ value: "oklch(0.90 0.16 98)",
55
+ label: "月黄"
56
+ },
57
+ {
58
+ value: "oklch(0.63 0.25 27)",
59
+ label: "京东红"
60
+ },
61
+ {
62
+ value: "oklch(0.65 0.24 33)",
63
+ label: "淘宝红"
64
+ },
65
+ {
66
+ value: "oklch(0.61 0.20 261)",
67
+ label: "钉钉蓝"
68
+ },
69
+ {
70
+ value: "oklch(0.70 0.12 152)",
71
+ label: "微信绿"
72
+ }
73
+ ]
74
+ }
75
+ ];
76
+ return r({
77
+ handleShow: () => {
78
+ l.value = !0;
79
+ }
80
+ }), (R, v) => (n(), d(t(x), {
81
+ "header-class": "globalSetting_header",
82
+ modelValue: l.value,
83
+ "onUpdate:modelValue": v[0] || (v[0] = (e) => l.value = e),
84
+ title: "全局偏好设置"
85
+ }, {
86
+ default: s(() => [
87
+ (n(), i(h, null, m(_, (e, p) => k("div", {
88
+ class: "globalSetting_item",
89
+ key: p
90
+ }, [
91
+ k("h4", null, b(e.title), 1),
92
+ S(t(E), {
93
+ "model-value": t(a)[e.key],
94
+ onChange: (o) => t(c)(e.key, o)
95
+ }, {
96
+ default: s(() => [
97
+ (n(!0), i(h, null, m(e.select, (o, f) => (n(), d(t(V), {
98
+ value: o.value,
99
+ key: f
100
+ }, {
101
+ default: s(() => [
102
+ C(b(o.label), 1)
103
+ ]),
104
+ _: 2
105
+ }, 1032, ["value"]))), 128))
106
+ ]),
107
+ _: 2
108
+ }, 1032, ["model-value", "onChange"])
109
+ ])), 64))
110
+ ]),
111
+ _: 1
112
+ }, 8, ["modelValue"]));
113
+ }
114
+ }), B = (u, r) => {
115
+ const a = u.__vccOpts || u;
116
+ for (const [c, l] of r)
117
+ a[c] = l;
118
+ return a;
119
+ }, F = /* @__PURE__ */ B(N, [["__scopeId", "data-v-122c674a"]]);
120
+ export {
121
+ F as GlobalSetting
122
+ };
@@ -0,0 +1,94 @@
1
+ import "pinia-plugin-persistedstate";
2
+ import { u as m } from "./system-DSegwP0Z.js";
3
+ import { ref as i } from "vue";
4
+ import { defineStore as l } from "pinia";
5
+ import { a as p } from "./index-DEkMXVh9.js";
6
+ const y = l(
7
+ "@jnrs/vue-core/pinia:auth",
8
+ () => {
9
+ const e = i(!1), n = i(), u = i(), o = i();
10
+ return {
11
+ hasAuthenticated: e,
12
+ token: n,
13
+ userInfo: u,
14
+ dict: o,
15
+ asyncSetAuth: async (c) => {
16
+ e.value = !0, c.token && (n.value = c.token), c.userInfo && (u.value = c.userInfo), c.dict && (o.value = c.dict);
17
+ },
18
+ asyncClearAuth: async () => {
19
+ e.value = !1, n.value = void 0, u.value = void 0, o.value = void 0;
20
+ }
21
+ };
22
+ },
23
+ {
24
+ persist: {
25
+ pick: ["hasAuthenticated", "token", "userInfo", "dict"]
26
+ }
27
+ }
28
+ ), t = [];
29
+ for (let e = 0; e < 256; ++e)
30
+ t.push((e + 256).toString(16).slice(1));
31
+ function v(e, n = 0) {
32
+ 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();
33
+ }
34
+ let a;
35
+ const h = new Uint8Array(16);
36
+ function f() {
37
+ if (!a) {
38
+ if (typeof crypto > "u" || !crypto.getRandomValues)
39
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
40
+ a = crypto.getRandomValues.bind(crypto);
41
+ }
42
+ return a(h);
43
+ }
44
+ const g = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), d = { randomUUID: g };
45
+ function b(e, n, u) {
46
+ e = e || {};
47
+ const o = e.random ?? e.rng?.() ?? f();
48
+ if (o.length < 16)
49
+ throw new Error("Random bytes length must be >= 16");
50
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, v(o);
51
+ }
52
+ function S(e, n, u) {
53
+ return d.randomUUID && !e ? d.randomUUID() : b(e);
54
+ }
55
+ const U = l(
56
+ "@jnrs/vue-core/pinia:menu",
57
+ () => {
58
+ const e = i(!1), n = i([]), u = async (s) => {
59
+ if (e.value)
60
+ return n.value;
61
+ o(s), n.value = s, e.value = !0;
62
+ try {
63
+ await p(n.value);
64
+ } catch (r) {
65
+ throw r;
66
+ }
67
+ return n.value;
68
+ }, o = (s) => {
69
+ for (const r of s)
70
+ r.meta.uuid = S(), r.children && o(r.children);
71
+ };
72
+ return { hasFetchedAsyncMenus: e, menus: n, asyncSetMenus: u };
73
+ }
74
+ // {
75
+ // persist: {
76
+ // pick: ['menus']
77
+ // }
78
+ // }
79
+ );
80
+ console.log(
81
+ "%c✨ 欢迎使用 @jnrs/vue-core/pinia",
82
+ 'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
83
+ );
84
+ const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
85
+ __proto__: null,
86
+ useAuthStore: y,
87
+ useMenuStore: U,
88
+ useSystemStore: m
89
+ }, Symbol.toStringTag, { value: "Module" }));
90
+ export {
91
+ U as a,
92
+ k as i,
93
+ y as u
94
+ };
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-pLO4r50y.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;'
@@ -1,4 +1,4 @@
1
- import { Dict, User } from '../../types/base';
1
+ import { Dict, User } from '@jnrs/shared';
2
2
  interface Auth {
3
3
  token: string;
4
4
  userInfo: User;
@@ -64,8 +64,7 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
64
64
  redirect?: string | undefined;
65
65
  children?: /*elided*/ any[] | undefined;
66
66
  }[]>;
67
- asyncClearMenu: () => void;
68
- }, "menus" | "hasFetchedAsyncMenus">, Pick<{
67
+ }, "hasFetchedAsyncMenus" | "menus">, Pick<{
69
68
  hasFetchedAsyncMenus: import('vue').Ref<boolean, boolean>;
70
69
  menus: import('vue').Ref<{
71
70
  meta: {
@@ -123,7 +122,6 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
123
122
  redirect?: string | undefined;
124
123
  children?: /*elided*/ any[] | undefined;
125
124
  }[]>;
126
- asyncClearMenu: () => void;
127
125
  }, never>, Pick<{
128
126
  hasFetchedAsyncMenus: import('vue').Ref<boolean, boolean>;
129
127
  menus: import('vue').Ref<{
@@ -182,5 +180,4 @@ export declare const useMenuStore: import('pinia').StoreDefinition<"@jnrs/vue-co
182
180
  redirect?: string | undefined;
183
181
  children?: /*elided*/ any[] | undefined;
184
182
  }[]>;
185
- asyncClearMenu: () => void;
186
- }, "asyncSetMenus" | "asyncClearMenu">>;
183
+ }, "asyncSetMenus">>;
@@ -1,31 +1,63 @@
1
+ type LocaleType = 'zhCn' | 'en';
2
+ type ThemeMode = 'light' | 'dark' | 'auto';
3
+ type Theme = {
4
+ locale: LocaleType;
5
+ mode: ThemeMode;
6
+ customColor?: string;
7
+ };
1
8
  /**
2
9
  * useSystemStore 系统仓库
3
- * @returns i18n 国际化
4
- * @returns theme 主题
10
+ * @returns theme 主题(国际化、主题、自定义强调色)
5
11
  * @returns menuCollapse 菜单是否折叠
6
12
  * @returns documentFullscreen 文档是否全屏
7
13
  * @methods toggleCollapse 折叠菜单切换
8
14
  * @methods toggleFullScreen 全屏切换
15
+ * @methods setTheme 设置主题
9
16
  */
10
17
  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">;
18
+ theme: import('vue').Ref<{
19
+ locale: LocaleType;
20
+ mode: ThemeMode;
21
+ customColor?: string | undefined;
22
+ }, Theme | {
23
+ locale: LocaleType;
24
+ mode: ThemeMode;
25
+ customColor?: string | undefined;
26
+ }>;
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
+ setTheme: <K extends keyof Theme>(key: K, value: Theme[K]) => void;
32
+ }, "theme" | "menuCollapse" | "documentFullscreen">, Pick<{
33
+ theme: import('vue').Ref<{
34
+ locale: LocaleType;
35
+ mode: ThemeMode;
36
+ customColor?: string | undefined;
37
+ }, Theme | {
38
+ locale: LocaleType;
39
+ mode: ThemeMode;
40
+ customColor?: string | undefined;
41
+ }>;
20
42
  menuCollapse: import('vue').Ref<boolean, boolean>;
21
43
  documentFullscreen: import('vue').Ref<boolean, boolean>;
22
- toggleCollapse: () => void;
44
+ toggleCollapse: () => boolean;
23
45
  toggleFullScreen: () => Promise<void>;
46
+ setTheme: <K extends keyof Theme>(key: K, value: Theme[K]) => void;
24
47
  }, never>, Pick<{
25
- i18n: import('vue').Ref<string, string>;
26
- theme: import('vue').Ref<"light" | "dark", "light" | "dark">;
48
+ theme: import('vue').Ref<{
49
+ locale: LocaleType;
50
+ mode: ThemeMode;
51
+ customColor?: string | undefined;
52
+ }, Theme | {
53
+ locale: LocaleType;
54
+ mode: ThemeMode;
55
+ customColor?: string | undefined;
56
+ }>;
27
57
  menuCollapse: import('vue').Ref<boolean, boolean>;
28
58
  documentFullscreen: import('vue').Ref<boolean, boolean>;
29
- toggleCollapse: () => void;
59
+ toggleCollapse: () => boolean;
30
60
  toggleFullScreen: () => Promise<void>;
31
- }, "toggleCollapse" | "toggleFullScreen">>;
61
+ setTheme: <K extends keyof Theme>(key: K, value: Theme[K]) => void;
62
+ }, "toggleCollapse" | "toggleFullScreen" | "setTheme">>;
63
+ 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-DSegwP0Z.js";
3
+ import { u, a } from "../index-pLO4r50y.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
  };