@jnrs/vue-core 1.1.6 → 1.2.1

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
@@ -87,7 +87,14 @@ import { useAuthStore } from '@jnrs/vue-core/pinia'
87
87
 
88
88
  #### @jnrs/vue-core/components 模块
89
89
  Vue 组件
90
- - GlobalSetting 全局偏好设置
90
+ - GlobalSetting 全局偏好设置组件
91
+ - JnImageView 图片预览组件
92
+ ```ts
93
+ type PreviewSrcList = {
94
+ src: string
95
+ fileName: string
96
+ }
97
+ ```
91
98
 
92
99
  #### @jnrs/vue-core/composables 模块
93
100
  Vue 组合式 API
@@ -0,0 +1,21 @@
1
+ import { FileItem } from '@jnrs/shared';
2
+ interface JnImageViewProps {
3
+ /**
4
+ * 图片源地址,同原生属性一致
5
+ */
6
+ src?: string;
7
+ /**
8
+ * 开启图片预览功能
9
+ */
10
+ previewSrcList?: FileItem[];
11
+ /**
12
+ * 是否开启预览功能
13
+ */
14
+ preview?: boolean;
15
+ /**
16
+ * 图片最大高度
17
+ */
18
+ maxHeight?: string;
19
+ }
20
+ declare const _default: import('vue').DefineComponent<JnImageViewProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<JnImageViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
21
+ export default _default;
@@ -0,0 +1,25 @@
1
+ import { FileItem } from '@jnrs/shared';
2
+ interface JnPdfViewProps {
3
+ /**
4
+ * 文件列表
5
+ */
6
+ fileList?: FileItem[];
7
+ /**
8
+ * 是否显示文件名
9
+ */
10
+ showFileName?: boolean;
11
+ /**
12
+ * 是否是 pdf 文件(pdf 文件直接预览,其他文件下载)
13
+ */
14
+ isPdf?: boolean;
15
+ /**
16
+ * 预览窗口宽度
17
+ */
18
+ windowWidth?: number;
19
+ /**
20
+ * 预览窗口高度
21
+ */
22
+ windowHeight?: number;
23
+ }
24
+ declare const _default: import('vue').DefineComponent<JnPdfViewProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<JnPdfViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
25
+ export default _default;
@@ -1,2 +1,4 @@
1
1
  import { default as GlobalSetting } from './GlobalSetting.vue';
2
- export { GlobalSetting };
2
+ import { default as JnImageView } from './JnImageView.vue';
3
+ import { default as JnPdfView } from './JnPdfView.vue';
4
+ export { GlobalSetting, JnImageView, JnPdfView };
@@ -1,34 +1,45 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".globalSetting_item[data-v-b0382b1b]{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 O, ref as y, createBlock as d, openBlock as n, unref as l, withCtx as r, createElementVNode as u, createVNode as _, toDisplayString as s, createElementBlock as c, Fragment as S, renderList as b, createTextVNode as f } from "vue";
3
- import { ElDrawer as k, ElRadioGroup as C, ElRadio as V } from "element-plus";
4
- import { u as E, L as G, M as $, C as L } from "../system-KZETuQYC.js";
5
- const N = { class: "globalSetting_item" }, j = { class: "globalSetting_item" }, w = { class: "globalSetting_item" }, I = /* @__PURE__ */ O({
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".globalSetting_item[data-v-85ebefe8]{margin-bottom:20px}.globalSetting_header{margin-bottom:0;padding-bottom:20px}.jnImageView[data-v-f05df144]{display:block;width:100%;height:100%}.jnImageView .jnImageView_error[data-v-f05df144]{display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:.8em;line-height:1.1em;text-align:center;filter:opacity(.7)}.jn_image_view_icon[data-v-f05df144]:hover{color:var(--jnrs-color-primary);transform:scale(1.2);transition:all .3s ease}.jnFileView[data-v-d17155ca]{display:block;width:100%;height:100%;line-height:1em;cursor:pointer}.jnFileView:hover .jnFileView_btn[data-v-d17155ca]{color:var(--jnrs-color-primary)}.jnFileView .jnFileView_fileName[data-v-d17155ca]{font-size:.8em;color:var(--jnrs-font-primary-06);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.jnFileView .jnFileView_btn[data-v-d17155ca]{height:auto;padding:0;text-decoration:underline;font-size:.9em;transition:all .3s ease}")),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
2
+ import { defineComponent as y, ref as I, createBlock as k, openBlock as r, unref as e, withCtx as n, createElementVNode as v, createVNode as t, toDisplayString as m, isRef as L, createElementBlock as g, Fragment as C, renderList as p, createTextVNode as S, computed as O, normalizeStyle as P, createCommentVNode as E } from "vue";
3
+ import { storeToRefs as R } from "pinia";
4
+ import { ElDrawer as B, ElSwitch as D, ElRadioGroup as V, ElRadio as $, ElImage as F, ElIcon as f, ElButton as G } from "element-plus";
5
+ import { u as J, b as T, L as H, M, C as U } from "../index-KdP2kDTZ.js";
6
+ import { Back as z, Right as W, DArrowRight as A, ZoomOut as Z, ZoomIn as x, Switch as q, RefreshLeft as K, Refresh as Q, Download as X } from "@element-plus/icons-vue";
7
+ import { downloadByUrl as N } from "@jnrs/shared";
8
+ const Y = { class: "globalSetting_item" }, ee = { class: "globalSetting_item" }, le = { class: "globalSetting_item" }, te = { class: "globalSetting_item" }, oe = /* @__PURE__ */ y({
6
9
  __name: "GlobalSetting",
7
- setup(m, { expose: i }) {
8
- const { theme: o, setLocale: v, setMode: g, setPrimaryColor: h } = E(), p = y(!1);
9
- return i({ handleShow: () => {
10
- p.value = !0;
11
- } }), (a, t) => (n(), d(l(k), {
10
+ setup(o, { expose: w }) {
11
+ const { isMock: i } = R(J()), { theme: a, setLocale: c, setMode: s, setPrimaryColor: _ } = T(), h = I(!1);
12
+ return w({ handleShow: () => {
13
+ h.value = !0;
14
+ } }), (u, d) => (r(), k(e(B), {
12
15
  "header-class": "globalSetting_header",
13
- modelValue: p.value,
14
- "onUpdate:modelValue": t[3] || (t[3] = (e) => p.value = e),
15
- title: a.$t("@jnrs/vue-core.components.GlobalSetting.title")
16
+ modelValue: h.value,
17
+ "onUpdate:modelValue": d[4] || (d[4] = (l) => h.value = l),
18
+ title: u.$t("@jnrs/vue-core.components.GlobalSetting.title")
16
19
  }, {
17
- default: r(() => [
18
- u("div", N, [
19
- u("h4", null, s(a.$t("@jnrs/vue-core.components.GlobalSetting.language")), 1),
20
- _(l(C), {
21
- modelValue: l(o).locale,
22
- "onUpdate:modelValue": t[0] || (t[0] = (e) => l(o).locale = e),
23
- onChange: l(v)
20
+ default: n(() => [
21
+ v("div", Y, [
22
+ v("h4", null, m(u.$t("@jnrs/vue-core.components.GlobalSetting.isMockServer")), 1),
23
+ t(e(D), {
24
+ modelValue: e(i),
25
+ "onUpdate:modelValue": d[0] || (d[0] = (l) => L(i) ? i.value = l : null),
26
+ size: "small"
27
+ }, null, 8, ["modelValue"])
28
+ ]),
29
+ v("div", ee, [
30
+ v("h4", null, m(u.$t("@jnrs/vue-core.components.GlobalSetting.language")), 1),
31
+ t(e(V), {
32
+ modelValue: e(a).locale,
33
+ "onUpdate:modelValue": d[1] || (d[1] = (l) => e(a).locale = l),
34
+ onChange: e(c)
24
35
  }, {
25
- default: r(() => [
26
- (n(!0), c(S, null, b(l(G), (e) => (n(), d(l(V), {
27
- key: e.value,
28
- value: e.value
36
+ default: n(() => [
37
+ (r(!0), g(C, null, p(e(H), (l) => (r(), k(e($), {
38
+ key: l.value,
39
+ value: l.value
29
40
  }, {
30
- default: r(() => [
31
- f(s(a.$t(e.label)), 1)
41
+ default: n(() => [
42
+ S(m(u.$t(l.label)), 1)
32
43
  ]),
33
44
  _: 2
34
45
  }, 1032, ["value"]))), 128))
@@ -36,20 +47,20 @@ const N = { class: "globalSetting_item" }, j = { class: "globalSetting_item" },
36
47
  _: 1
37
48
  }, 8, ["modelValue", "onChange"])
38
49
  ]),
39
- u("div", j, [
40
- u("h4", null, s(a.$t("@jnrs/vue-core.components.GlobalSetting.theme")), 1),
41
- _(l(C), {
42
- modelValue: l(o).mode,
43
- "onUpdate:modelValue": t[1] || (t[1] = (e) => l(o).mode = e),
44
- onChange: l(g)
50
+ v("div", le, [
51
+ v("h4", null, m(u.$t("@jnrs/vue-core.components.GlobalSetting.theme")), 1),
52
+ t(e(V), {
53
+ modelValue: e(a).mode,
54
+ "onUpdate:modelValue": d[2] || (d[2] = (l) => e(a).mode = l),
55
+ onChange: e(s)
45
56
  }, {
46
- default: r(() => [
47
- (n(!0), c(S, null, b(l($), (e) => (n(), d(l(V), {
48
- key: e.value,
49
- value: e.value
57
+ default: n(() => [
58
+ (r(!0), g(C, null, p(e(M), (l) => (r(), k(e($), {
59
+ key: l.value,
60
+ value: l.value
50
61
  }, {
51
- default: r(() => [
52
- f(s(a.$t(e.label)), 1)
62
+ default: n(() => [
63
+ S(m(u.$t(l.label)), 1)
53
64
  ]),
54
65
  _: 2
55
66
  }, 1032, ["value"]))), 128))
@@ -57,20 +68,20 @@ const N = { class: "globalSetting_item" }, j = { class: "globalSetting_item" },
57
68
  _: 1
58
69
  }, 8, ["modelValue", "onChange"])
59
70
  ]),
60
- u("div", w, [
61
- u("h4", null, s(a.$t("@jnrs/vue-core.components.GlobalSetting.primaryColor")), 1),
62
- _(l(C), {
63
- modelValue: l(o).primaryColor,
64
- "onUpdate:modelValue": t[2] || (t[2] = (e) => l(o).primaryColor = e),
65
- onChange: l(h)
71
+ v("div", te, [
72
+ v("h4", null, m(u.$t("@jnrs/vue-core.components.GlobalSetting.primaryColor")), 1),
73
+ t(e(V), {
74
+ modelValue: e(a).primaryColor,
75
+ "onUpdate:modelValue": d[3] || (d[3] = (l) => e(a).primaryColor = l),
76
+ onChange: e(_)
66
77
  }, {
67
- default: r(() => [
68
- (n(!0), c(S, null, b(l(L), (e) => (n(), d(l(V), {
69
- key: e.value,
70
- value: e.value
78
+ default: n(() => [
79
+ (r(!0), g(C, null, p(e(U), (l) => (r(), k(e($), {
80
+ key: l.value,
81
+ value: l.value
71
82
  }, {
72
- default: r(() => [
73
- f(s(a.$t(e.label)), 1)
83
+ default: n(() => [
84
+ S(m(u.$t(l.label)), 1)
74
85
  ]),
75
86
  _: 2
76
87
  }, 1032, ["value"]))), 128))
@@ -82,12 +93,172 @@ const N = { class: "globalSetting_item" }, j = { class: "globalSetting_item" },
82
93
  _: 1
83
94
  }, 8, ["modelValue", "title"]));
84
95
  }
85
- }), P = (m, i) => {
86
- const o = m.__vccOpts || m;
87
- for (const [v, g] of i)
88
- o[v] = g;
89
- return o;
90
- }, M = /* @__PURE__ */ P(I, [["__scopeId", "data-v-b0382b1b"]]);
96
+ }), b = (o, w) => {
97
+ const i = o.__vccOpts || o;
98
+ for (const [a, c] of w)
99
+ i[a] = c;
100
+ return i;
101
+ }, ge = /* @__PURE__ */ b(oe, [["__scopeId", "data-v-85ebefe8"]]), ne = {
102
+ key: 0,
103
+ class: "jnImageView_error"
104
+ }, ae = { key: 1 }, ie = /* @__PURE__ */ y({
105
+ __name: "JnImageView",
106
+ props: {
107
+ src: { default: "" },
108
+ previewSrcList: { default: () => [] },
109
+ preview: { type: Boolean, default: !1 },
110
+ maxHeight: { default: "200px" }
111
+ },
112
+ setup(o) {
113
+ const w = O(() => o.src || o.previewSrcList[0]?.src || ""), i = (a) => {
114
+ const c = o.previewSrcList[a].src, s = o.previewSrcList[a].fileName;
115
+ N(c, s);
116
+ };
117
+ return (a, c) => (r(), k(e(F), {
118
+ class: "jnImageView",
119
+ style: P({ maxHeight: o.maxHeight }),
120
+ src: w.value,
121
+ "preview-teleported": "",
122
+ "preview-src-list": o.preview ? o.previewSrcList.map((s) => s.src) : [],
123
+ fit: "cover",
124
+ "show-progress": ""
125
+ }, {
126
+ error: n(() => [
127
+ w.value ? (r(), g("span", ne, m(a.$t("@jnrs/vue-core.components.JnImageView.noDisplay")), 1)) : (r(), g("span", ae, " "))
128
+ ]),
129
+ toolbar: n(({ actions: s, prev: _, next: h, reset: j, activeIndex: u, setActiveItem: d }) => [
130
+ t(e(f), {
131
+ class: "jn_image_view_icon",
132
+ onClick: _
133
+ }, {
134
+ default: n(() => [
135
+ t(e(z))
136
+ ]),
137
+ _: 1
138
+ }, 8, ["onClick"]),
139
+ t(e(f), {
140
+ class: "jn_image_view_icon",
141
+ onClick: h
142
+ }, {
143
+ default: n(() => [
144
+ t(e(W))
145
+ ]),
146
+ _: 1
147
+ }, 8, ["onClick"]),
148
+ t(e(f), {
149
+ class: "jn_image_view_icon",
150
+ onClick: (l) => d(o.previewSrcList.length - 1)
151
+ }, {
152
+ default: n(() => [
153
+ t(e(A))
154
+ ]),
155
+ _: 1
156
+ }, 8, ["onClick"]),
157
+ t(e(f), {
158
+ class: "jn_image_view_icon",
159
+ onClick: (l) => s("zoomOut")
160
+ }, {
161
+ default: n(() => [
162
+ t(e(Z))
163
+ ]),
164
+ _: 1
165
+ }, 8, ["onClick"]),
166
+ t(e(f), {
167
+ class: "jn_image_view_icon",
168
+ onClick: (l) => s("zoomIn", { enableTransition: !1, zoomRate: 2 })
169
+ }, {
170
+ default: n(() => [
171
+ t(e(x))
172
+ ]),
173
+ _: 1
174
+ }, 8, ["onClick"]),
175
+ t(e(f), {
176
+ class: "jn_image_view_icon",
177
+ onClick: (l) => s("clockwise", { rotateDeg: 180, enableTransition: !1 })
178
+ }, {
179
+ default: n(() => [
180
+ t(e(q))
181
+ ]),
182
+ _: 1
183
+ }, 8, ["onClick"]),
184
+ t(e(f), {
185
+ class: "jn_image_view_icon",
186
+ onClick: (l) => s("anticlockwise")
187
+ }, {
188
+ default: n(() => [
189
+ t(e(K))
190
+ ]),
191
+ _: 1
192
+ }, 8, ["onClick"]),
193
+ t(e(f), {
194
+ class: "jn_image_view_icon",
195
+ onClick: j
196
+ }, {
197
+ default: n(() => [
198
+ t(e(Q))
199
+ ]),
200
+ _: 1
201
+ }, 8, ["onClick"]),
202
+ t(e(f), {
203
+ class: "jn_image_view_icon",
204
+ onClick: (l) => i(u)
205
+ }, {
206
+ default: n(() => [
207
+ t(e(X))
208
+ ]),
209
+ _: 1
210
+ }, 8, ["onClick"])
211
+ ]),
212
+ _: 1
213
+ }, 8, ["style", "src", "preview-src-list"]));
214
+ }
215
+ }), _e = /* @__PURE__ */ b(ie, [["__scopeId", "data-v-f05df144"]]), se = ["title", "onClick"], re = {
216
+ key: 0,
217
+ class: "jnFileView_fileName"
218
+ }, ce = /* @__PURE__ */ y({
219
+ __name: "JnPdfView",
220
+ props: {
221
+ fileList: { default: () => [] },
222
+ showFileName: { type: Boolean, default: !0 },
223
+ isPdf: { type: Boolean, default: !1 },
224
+ windowWidth: { default: 800 },
225
+ windowHeight: { default: 600 }
226
+ },
227
+ setup(o) {
228
+ const w = (i) => {
229
+ if (o.isPdf) {
230
+ const s = screen.width / 2 - o.windowWidth / 2, _ = screen.height / 2 - o.windowHeight / 2;
231
+ return window.open(
232
+ i.src,
233
+ "_blank",
234
+ `left=${s},top=${_},width=${o.windowWidth},height=${o.windowHeight}`
235
+ );
236
+ }
237
+ const a = i.src, c = i.fileName;
238
+ N(a, c);
239
+ };
240
+ return (i, a) => (r(!0), g(C, null, p(o.fileList, (c, s) => (r(), g("div", {
241
+ class: "jnFileView",
242
+ key: s,
243
+ title: c.fileName,
244
+ onClick: (_) => w(c)
245
+ }, [
246
+ o.showFileName ? (r(), g("div", re, m(c.fileName), 1)) : E("", !0),
247
+ t(e(G), {
248
+ class: "jnFileView_btn",
249
+ type: "primary",
250
+ text: ""
251
+ }, {
252
+ default: n(() => [
253
+ S(m(o.isPdf ? i.$t("@jnrs/vue-core.components.JnPdfView.viewPDF") : i.$t("@jnrs/vue-core.components.JnPdfView.downloadFile")), 1)
254
+ ]),
255
+ _: 1
256
+ })
257
+ ], 8, se))), 128));
258
+ }
259
+ }), he = /* @__PURE__ */ b(ce, [["__scopeId", "data-v-d17155ca"]]);
91
260
  export {
92
- M as GlobalSetting
261
+ ge as GlobalSetting,
262
+ _e as JnImageView,
263
+ he as JnPdfView
93
264
  };
@@ -0,0 +1,201 @@
1
+ import "pinia-plugin-persistedstate";
2
+ import { defineStore as p } from "pinia";
3
+ import { ref as s, computed as k, watch as S } from "vue";
4
+ import { Fullscreen as j } from "@jnrs/shared";
5
+ import { usePreferredDark as O } from "@vueuse/core";
6
+ import { a as C } from "./index-Ci9uljtG.js";
7
+ const M = p(
8
+ "jnrs-app-mock",
9
+ () => ({ isMock: s(!1) }),
10
+ {
11
+ persist: {
12
+ pick: ["isMock"]
13
+ }
14
+ }
15
+ ), w = [
16
+ { value: "zhCn", label: "@jnrs/vue-core.components.GlobalSetting.languageOptions.zhCn" },
17
+ { value: "en", label: "@jnrs/vue-core.components.GlobalSetting.languageOptions.en" }
18
+ ], G = [
19
+ { value: "auto", label: "@jnrs/vue-core.components.GlobalSetting.themeOptions.auto" },
20
+ { value: "light", label: "@jnrs/vue-core.components.GlobalSetting.themeOptions.light" },
21
+ { value: "dark", label: "@jnrs/vue-core.components.GlobalSetting.themeOptions.dark" }
22
+ ], U = [
23
+ { value: "oklch(0.6 0.19 41)", label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.jnrs" },
24
+ {
25
+ value: "oklch(0.51 0.21 264)",
26
+ label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.azure"
27
+ },
28
+ {
29
+ value: "oklch(0.90 0.16 98)",
30
+ label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.moonYellow"
31
+ },
32
+ { value: "oklch(0.63 0.25 27)", label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.jdRed" },
33
+ {
34
+ value: "oklch(0.65 0.24 33)",
35
+ label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.taobaoRed"
36
+ },
37
+ {
38
+ value: "oklch(0.61 0.20 261)",
39
+ label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.dingtalkBlue"
40
+ },
41
+ {
42
+ value: "oklch(0.70 0.12 152)",
43
+ label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.wechatGreen"
44
+ }
45
+ ];
46
+ function I(e) {
47
+ return e === "zhCn" || e === "en";
48
+ }
49
+ function x(e) {
50
+ return e === "light" || e === "dark" || e === "auto";
51
+ }
52
+ function L(e) {
53
+ return typeof e == "string" && e.trim() !== "";
54
+ }
55
+ const R = p(
56
+ "@jnrs/vue-core/pinia:system",
57
+ () => {
58
+ const e = s(!1), o = () => e.value = !e.value, a = new j(), n = s(!1), i = async () => {
59
+ await a.toggle(), n.value = a.isFullscreen();
60
+ }, l = s({
61
+ locale: w[0].value,
62
+ mode: G[0].value,
63
+ primaryColor: U[0].value
64
+ }), u = k(() => l.value.mode === "auto" ? d.value ? "dark" : "light" : l.value.mode), d = O();
65
+ return S(
66
+ [() => l.value.mode, d, () => l.value.primaryColor],
67
+ ([r, f, g]) => {
68
+ const m = document.documentElement;
69
+ m.classList.remove("light", "dark"), r === "auto" ? m.classList.add(f ? "dark" : "light") : m.classList.add(r), g ? m.style.setProperty("--jnrs-color-primary", g) : m.style.removeProperty("--jnrs-color-primary");
70
+ },
71
+ { immediate: !0 }
72
+ ), {
73
+ theme: l,
74
+ computedThemeMode: u,
75
+ menuCollapse: e,
76
+ documentFullscreen: n,
77
+ toggleCollapse: o,
78
+ toggleFullScreen: i,
79
+ setLocale: (r) => {
80
+ I(r) && (l.value.locale = r);
81
+ },
82
+ setMode: (r) => {
83
+ x(r) && (l.value.mode = r);
84
+ },
85
+ setPrimaryColor: (r) => {
86
+ L(r) && (l.value.primaryColor = r);
87
+ }
88
+ };
89
+ },
90
+ {
91
+ persist: {
92
+ pick: ["theme", "menuCollapse"]
93
+ }
94
+ }
95
+ ), D = p(
96
+ "@jnrs/vue-core/pinia:auth",
97
+ () => {
98
+ const e = s(!1), o = s(null), a = s(null), n = s(), i = s([]);
99
+ return {
100
+ hasAuthenticated: e,
101
+ token: o,
102
+ userInfo: a,
103
+ dict: n,
104
+ role: i,
105
+ setUserInfo: (c) => {
106
+ a.value = c;
107
+ },
108
+ setToken: (c) => {
109
+ o.value = c, e.value = !0;
110
+ },
111
+ setDict: (c) => {
112
+ n.value = c;
113
+ },
114
+ setRole: (c) => {
115
+ i.value = c;
116
+ },
117
+ clearAuth: () => {
118
+ o.value = null, a.value = null, n.value = void 0, i.value = [], e.value = !1;
119
+ }
120
+ };
121
+ },
122
+ {
123
+ persist: {
124
+ pick: ["hasAuthenticated", "token", "userInfo", "dict"]
125
+ }
126
+ }
127
+ ), t = [];
128
+ for (let e = 0; e < 256; ++e)
129
+ t.push((e + 256).toString(16).slice(1));
130
+ function P(e, o = 0) {
131
+ return (t[e[o + 0]] + t[e[o + 1]] + t[e[o + 2]] + t[e[o + 3]] + "-" + t[e[o + 4]] + t[e[o + 5]] + "-" + t[e[o + 6]] + t[e[o + 7]] + "-" + t[e[o + 8]] + t[e[o + 9]] + "-" + t[e[o + 10]] + t[e[o + 11]] + t[e[o + 12]] + t[e[o + 13]] + t[e[o + 14]] + t[e[o + 15]]).toLowerCase();
132
+ }
133
+ let v;
134
+ const T = new Uint8Array(16);
135
+ function A() {
136
+ if (!v) {
137
+ if (typeof crypto > "u" || !crypto.getRandomValues)
138
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
139
+ v = crypto.getRandomValues.bind(crypto);
140
+ }
141
+ return v(T);
142
+ }
143
+ const _ = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), h = { randomUUID: _ };
144
+ function z(e, o, a) {
145
+ e = e || {};
146
+ const n = e.random ?? e.rng?.() ?? A();
147
+ if (n.length < 16)
148
+ throw new Error("Random bytes length must be >= 16");
149
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, P(n);
150
+ }
151
+ function E(e, o, a) {
152
+ return h.randomUUID && !e ? h.randomUUID() : z(e);
153
+ }
154
+ const F = p(
155
+ "@jnrs/vue-core/pinia:menu",
156
+ () => {
157
+ const e = s(!1), o = s([]), a = async (l) => {
158
+ if (e.value)
159
+ return o.value;
160
+ n(l), o.value = l, e.value = !0;
161
+ try {
162
+ await C(o.value);
163
+ } catch (u) {
164
+ throw u;
165
+ }
166
+ return o.value;
167
+ }, n = (l) => {
168
+ for (const u of l)
169
+ u.meta.uuid = E(), u.children && n(u.children);
170
+ };
171
+ return { hasFetchedAsyncMenus: e, menus: o, asyncSetMenus: a, clearMenu: () => {
172
+ e.value = !1, o.value = [];
173
+ } };
174
+ }
175
+ // {
176
+ // persist: {
177
+ // pick: ['menus']
178
+ // }
179
+ // }
180
+ );
181
+ console.log(
182
+ "%c✨ 欢迎使用 @jnrs/vue-core/pinia",
183
+ 'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
184
+ );
185
+ const J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
186
+ __proto__: null,
187
+ useAuthStore: D,
188
+ useMenuStore: F,
189
+ useMockStore: M,
190
+ useSystemStore: R
191
+ }, Symbol.toStringTag, { value: "Module" }));
192
+ export {
193
+ U as C,
194
+ w as L,
195
+ G as M,
196
+ D as a,
197
+ R as b,
198
+ F as c,
199
+ J as i,
200
+ M as u
201
+ };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { h as Qt } from "./index-Ci9uljtG.js";
2
2
  import { c as Nr } from "./index-Ci9uljtG.js";
3
- import { u as Zt, a as es } from "./index-9Ug4oygq.js";
4
- import { i as kr } from "./index-9Ug4oygq.js";
3
+ import { u as Zt, a as es } from "./index-KdP2kDTZ.js";
4
+ import { i as kr } from "./index-KdP2kDTZ.js";
5
5
  import { ElMessage as ts } from "element-plus";
6
6
  function Lt(s, e) {
7
7
  return function() {
@@ -0,0 +1,35 @@
1
+ declare const _default: {
2
+ GlobalSetting: {
3
+ title: string;
4
+ isMockServer: string;
5
+ language: string;
6
+ languageOptions: {
7
+ zhCn: string;
8
+ en: string;
9
+ };
10
+ theme: string;
11
+ themeOptions: {
12
+ light: string;
13
+ dark: string;
14
+ auto: string;
15
+ };
16
+ primaryColor: string;
17
+ primaryColorOptions: {
18
+ jnrs: string;
19
+ azure: string;
20
+ moonYellow: string;
21
+ jdRed: string;
22
+ taobaoRed: string;
23
+ dingtalkBlue: string;
24
+ wechatGreen: string;
25
+ };
26
+ };
27
+ JnImageView: {
28
+ noDisplay: string;
29
+ };
30
+ JnPdfView: {
31
+ viewPDF: string;
32
+ downloadFile: string;
33
+ };
34
+ };
35
+ export default _default;
@@ -3,6 +3,7 @@ declare const _default: {
3
3
  components: {
4
4
  GlobalSetting: {
5
5
  title: string;
6
+ isMockServer: string;
6
7
  language: string;
7
8
  languageOptions: {
8
9
  zhCn: string;
@@ -25,6 +26,13 @@ declare const _default: {
25
26
  wechatGreen: string;
26
27
  };
27
28
  };
29
+ JnImageView: {
30
+ noDisplay: string;
31
+ };
32
+ JnPdfView: {
33
+ viewPDF: string;
34
+ downloadFile: string;
35
+ };
28
36
  };
29
37
  };
30
38
  };
@@ -1,63 +1,79 @@
1
1
  const e = {
2
- "@jnrs/vue-core": {
3
- components: {
4
- GlobalSetting: {
5
- title: "全局偏好设置",
6
- language: "语言",
7
- languageOptions: {
8
- zhCn: "简体中文",
9
- en: "English"
10
- },
11
- theme: "主题",
12
- themeOptions: {
13
- light: "浅色",
14
- dark: "深色",
15
- auto: "跟随系统"
16
- },
17
- primaryColor: "强调色",
18
- primaryColorOptions: {
19
- jnrs: "JNRS",
20
- azure: "蔚蓝",
21
- moonYellow: "月黄",
22
- jdRed: "京东红",
23
- taobaoRed: "淘宝红",
24
- dingtalkBlue: "钉钉蓝",
25
- wechatGreen: "微信绿"
26
- }
27
- }
2
+ GlobalSetting: {
3
+ title: "全局偏好设置",
4
+ isMockServer: "是否使用 mock 服务器",
5
+ language: "语言",
6
+ languageOptions: {
7
+ zhCn: "简体中文",
8
+ en: "English"
9
+ },
10
+ theme: "主题",
11
+ themeOptions: {
12
+ light: "浅色",
13
+ dark: "深色",
14
+ auto: "跟随系统"
15
+ },
16
+ primaryColor: "强调色",
17
+ primaryColorOptions: {
18
+ jnrs: "JNRS",
19
+ azure: "蔚蓝",
20
+ moonYellow: "月黄",
21
+ jdRed: "京东红",
22
+ taobaoRed: "淘宝红",
23
+ dingtalkBlue: "钉钉蓝",
24
+ wechatGreen: "微信绿"
28
25
  }
26
+ },
27
+ JnImageView: {
28
+ noDisplay: "无法显示"
29
+ },
30
+ JnPdfView: {
31
+ viewPDF: "预览PDF",
32
+ downloadFile: "下载文件"
29
33
  }
30
- }, o = {
34
+ }, n = {
31
35
  "@jnrs/vue-core": {
32
- components: {
33
- GlobalSetting: {
34
- title: "Global Preferences",
35
- language: "Language",
36
- languageOptions: {
37
- zhCn: "简体中文",
38
- en: "English"
39
- },
40
- theme: "Theme",
41
- themeOptions: {
42
- light: "Light",
43
- dark: "Dark",
44
- auto: "Follow System"
45
- },
46
- primaryColor: "Primary Color",
47
- primaryColorOptions: {
48
- jnrs: "JNRS",
49
- azure: "Azure",
50
- moonYellow: "Moon Yellow",
51
- jdRed: "JD Red",
52
- taobaoRed: "Taobao Red",
53
- dingtalkBlue: "DingTalk Blue",
54
- wechatGreen: "WeChat Green"
55
- }
56
- }
36
+ components: e
37
+ }
38
+ }, o = {
39
+ GlobalSetting: {
40
+ title: "Global Preferences",
41
+ isMockServer: "Use Mock Server",
42
+ language: "Language",
43
+ languageOptions: {
44
+ zhCn: "简体中文",
45
+ en: "English"
46
+ },
47
+ theme: "Theme",
48
+ themeOptions: {
49
+ light: "Light",
50
+ dark: "Dark",
51
+ auto: "Follow System"
52
+ },
53
+ primaryColor: "Primary Color",
54
+ primaryColorOptions: {
55
+ jnrs: "JNRS",
56
+ azure: "Azure",
57
+ moonYellow: "Moon Yellow",
58
+ jdRed: "JD Red",
59
+ taobaoRed: "Taobao Red",
60
+ dingtalkBlue: "DingTalk Blue",
61
+ wechatGreen: "WeChat Green"
57
62
  }
63
+ },
64
+ JnImageView: {
65
+ noDisplay: "Cannot Display"
66
+ },
67
+ JnPdfView: {
68
+ viewPDF: "Preview PDF",
69
+ downloadFile: "Download File"
70
+ }
71
+ }, a = {
72
+ "@jnrs/vue-core": {
73
+ components: o
58
74
  }
59
75
  };
60
76
  export {
61
- o as en,
62
- e as zhCn
77
+ a as en,
78
+ n as zhCn
63
79
  };
@@ -0,0 +1,35 @@
1
+ declare const _default: {
2
+ GlobalSetting: {
3
+ title: string;
4
+ isMockServer: string;
5
+ language: string;
6
+ languageOptions: {
7
+ zhCn: string;
8
+ en: string;
9
+ };
10
+ theme: string;
11
+ themeOptions: {
12
+ light: string;
13
+ dark: string;
14
+ auto: string;
15
+ };
16
+ primaryColor: string;
17
+ primaryColorOptions: {
18
+ jnrs: string;
19
+ azure: string;
20
+ moonYellow: string;
21
+ jdRed: string;
22
+ taobaoRed: string;
23
+ dingtalkBlue: string;
24
+ wechatGreen: string;
25
+ };
26
+ };
27
+ JnImageView: {
28
+ noDisplay: string;
29
+ };
30
+ JnPdfView: {
31
+ viewPDF: string;
32
+ downloadFile: string;
33
+ };
34
+ };
35
+ export default _default;
@@ -3,6 +3,7 @@ declare const _default: {
3
3
  components: {
4
4
  GlobalSetting: {
5
5
  title: string;
6
+ isMockServer: string;
6
7
  language: string;
7
8
  languageOptions: {
8
9
  zhCn: string;
@@ -25,6 +26,13 @@ declare const _default: {
25
26
  wechatGreen: string;
26
27
  };
27
28
  };
29
+ JnImageView: {
30
+ noDisplay: string;
31
+ };
32
+ JnPdfView: {
33
+ viewPDF: string;
34
+ downloadFile: string;
35
+ };
28
36
  };
29
37
  };
30
38
  };
@@ -1,9 +1,8 @@
1
1
  import "pinia-plugin-persistedstate";
2
- import { a as s, b as t, u } from "../index-9Ug4oygq.js";
3
- import { u as S } from "../system-KZETuQYC.js";
2
+ import { a as t, c as r, u, b as a } from "../index-KdP2kDTZ.js";
4
3
  export {
5
- s as useAuthStore,
6
- t as useMenuStore,
4
+ t as useAuthStore,
5
+ r as useMenuStore,
7
6
  u as useMockStore,
8
- S as useSystemStore
7
+ a as useSystemStore
9
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jnrs/vue-core",
3
- "version": "1.1.6",
3
+ "version": "1.2.1",
4
4
  "description": "巨能前端工程化开发,Vue 专用核心功能包。",
5
5
  "keywords": [
6
6
  "jnrs",
@@ -52,13 +52,14 @@
52
52
  "peerDependencies": {
53
53
  "@vueuse/core": "^14.1.0",
54
54
  "element-plus": "^2.11.9",
55
+ "@element-plus/icons-vue": "^2.3.2",
55
56
  "pinia": "^3.0.3",
56
57
  "pinia-plugin-persistedstate": "^4.7.1",
57
58
  "vue": "^3.5.22",
58
59
  "vue-router": "^4.5.1",
59
60
  "vue-i18n": "^9.14.5",
60
- "@jnrs/shared": "1.1.6",
61
- "@jnrs/core": "1.1.6"
61
+ "@jnrs/shared": "1.1.7",
62
+ "@jnrs/core": "1.1.7"
62
63
  },
63
64
  "devDependencies": {
64
65
  "@vitejs/plugin-vue": "^6.0.1",
@@ -1,116 +0,0 @@
1
- import "pinia-plugin-persistedstate";
2
- import { defineStore as d } from "pinia";
3
- import { ref as u } from "vue";
4
- import { u as m } from "./system-KZETuQYC.js";
5
- import { a as v } from "./index-Ci9uljtG.js";
6
- const y = d(
7
- "jnrs-app-mock",
8
- () => ({ isMock: u(!1) }),
9
- {
10
- persist: {
11
- pick: ["isMock"]
12
- }
13
- }
14
- ), h = d(
15
- "@jnrs/vue-core/pinia:auth",
16
- () => {
17
- const e = u(!1), t = u(null), r = u(null), o = u(), i = u([]);
18
- return {
19
- hasAuthenticated: e,
20
- token: t,
21
- userInfo: r,
22
- dict: o,
23
- role: i,
24
- setUserInfo: (s) => {
25
- r.value = s;
26
- },
27
- setToken: (s) => {
28
- t.value = s, e.value = !0;
29
- },
30
- setDict: (s) => {
31
- o.value = s;
32
- },
33
- setRole: (s) => {
34
- i.value = s;
35
- },
36
- clearAuth: () => {
37
- t.value = null, r.value = null, o.value = void 0, i.value = [], e.value = !1;
38
- }
39
- };
40
- },
41
- {
42
- persist: {
43
- pick: ["hasAuthenticated", "token", "userInfo", "dict"]
44
- }
45
- }
46
- ), n = [];
47
- for (let e = 0; e < 256; ++e)
48
- n.push((e + 256).toString(16).slice(1));
49
- function f(e, t = 0) {
50
- return (n[e[t + 0]] + n[e[t + 1]] + n[e[t + 2]] + n[e[t + 3]] + "-" + n[e[t + 4]] + n[e[t + 5]] + "-" + n[e[t + 6]] + n[e[t + 7]] + "-" + n[e[t + 8]] + n[e[t + 9]] + "-" + n[e[t + 10]] + n[e[t + 11]] + n[e[t + 12]] + n[e[t + 13]] + n[e[t + 14]] + n[e[t + 15]]).toLowerCase();
51
- }
52
- let l;
53
- const g = new Uint8Array(16);
54
- function b() {
55
- if (!l) {
56
- if (typeof crypto > "u" || !crypto.getRandomValues)
57
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
58
- l = crypto.getRandomValues.bind(crypto);
59
- }
60
- return l(g);
61
- }
62
- const U = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), p = { randomUUID: U };
63
- function k(e, t, r) {
64
- e = e || {};
65
- const o = e.random ?? e.rng?.() ?? b();
66
- if (o.length < 16)
67
- throw new Error("Random bytes length must be >= 16");
68
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, f(o);
69
- }
70
- function S(e, t, r) {
71
- return p.randomUUID && !e ? p.randomUUID() : k(e);
72
- }
73
- const x = d(
74
- "@jnrs/vue-core/pinia:menu",
75
- () => {
76
- const e = u(!1), t = u([]), r = async (a) => {
77
- if (e.value)
78
- return t.value;
79
- o(a), t.value = a, e.value = !0;
80
- try {
81
- await v(t.value);
82
- } catch (c) {
83
- throw c;
84
- }
85
- return t.value;
86
- }, o = (a) => {
87
- for (const c of a)
88
- c.meta.uuid = S(), c.children && o(c.children);
89
- };
90
- return { hasFetchedAsyncMenus: e, menus: t, asyncSetMenus: r, clearMenu: () => {
91
- e.value = !1, t.value = [];
92
- } };
93
- }
94
- // {
95
- // persist: {
96
- // pick: ['menus']
97
- // }
98
- // }
99
- );
100
- console.log(
101
- "%c✨ 欢迎使用 @jnrs/vue-core/pinia",
102
- 'background: #42B883; color: #39495C; font-weight: bold; padding: 4px 8px; border-radius: 4px; font-family: "Helvetica Neue", sans-serif;'
103
- );
104
- const T = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
105
- __proto__: null,
106
- useAuthStore: h,
107
- useMenuStore: x,
108
- useMockStore: y,
109
- useSystemStore: m
110
- }, Symbol.toStringTag, { value: "Module" }));
111
- export {
112
- h as a,
113
- x as b,
114
- T as i,
115
- y as u
116
- };
@@ -1,91 +0,0 @@
1
- import { ref as r, computed as v, watch as d } from "vue";
2
- import { defineStore as g } from "pinia";
3
- import { Fullscreen as h } from "@jnrs/shared";
4
- import { usePreferredDark as b } from "@vueuse/core";
5
- const O = [
6
- { value: "zhCn", label: "@jnrs/vue-core.components.GlobalSetting.languageOptions.zhCn" },
7
- { value: "en", label: "@jnrs/vue-core.components.GlobalSetting.languageOptions.en" }
8
- ], y = [
9
- { value: "auto", label: "@jnrs/vue-core.components.GlobalSetting.themeOptions.auto" },
10
- { value: "light", label: "@jnrs/vue-core.components.GlobalSetting.themeOptions.light" },
11
- { value: "dark", label: "@jnrs/vue-core.components.GlobalSetting.themeOptions.dark" }
12
- ], C = [
13
- { value: "oklch(0.6 0.19 41)", label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.jnrs" },
14
- {
15
- value: "oklch(0.51 0.21 264)",
16
- label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.azure"
17
- },
18
- {
19
- value: "oklch(0.90 0.16 98)",
20
- label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.moonYellow"
21
- },
22
- { value: "oklch(0.63 0.25 27)", label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.jdRed" },
23
- {
24
- value: "oklch(0.65 0.24 33)",
25
- label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.taobaoRed"
26
- },
27
- {
28
- value: "oklch(0.61 0.20 261)",
29
- label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.dingtalkBlue"
30
- },
31
- {
32
- value: "oklch(0.70 0.12 152)",
33
- label: "@jnrs/vue-core.components.GlobalSetting.primaryColorOptions.wechatGreen"
34
- }
35
- ];
36
- function f(e) {
37
- return e === "zhCn" || e === "en";
38
- }
39
- function S(e) {
40
- return e === "light" || e === "dark" || e === "auto";
41
- }
42
- function j(e) {
43
- return typeof e == "string" && e.trim() !== "";
44
- }
45
- const z = g(
46
- "@jnrs/vue-core/pinia:system",
47
- () => {
48
- const e = r(!1), c = () => e.value = !e.value, n = new h(), a = r(!1), u = async () => {
49
- await n.toggle(), a.value = n.isFullscreen();
50
- }, l = r({
51
- locale: O[0].value,
52
- mode: y[0].value,
53
- primaryColor: C[0].value
54
- }), m = v(() => l.value.mode === "auto" ? s.value ? "dark" : "light" : l.value.mode), s = b();
55
- return d(
56
- [() => l.value.mode, s, () => l.value.primaryColor],
57
- ([o, p, i]) => {
58
- const t = document.documentElement;
59
- t.classList.remove("light", "dark"), o === "auto" ? t.classList.add(p ? "dark" : "light") : t.classList.add(o), i ? t.style.setProperty("--jnrs-color-primary", i) : t.style.removeProperty("--jnrs-color-primary");
60
- },
61
- { immediate: !0 }
62
- ), {
63
- theme: l,
64
- computedThemeMode: m,
65
- menuCollapse: e,
66
- documentFullscreen: a,
67
- toggleCollapse: c,
68
- toggleFullScreen: u,
69
- setLocale: (o) => {
70
- f(o) && (l.value.locale = o);
71
- },
72
- setMode: (o) => {
73
- S(o) && (l.value.mode = o);
74
- },
75
- setPrimaryColor: (o) => {
76
- j(o) && (l.value.primaryColor = o);
77
- }
78
- };
79
- },
80
- {
81
- persist: {
82
- pick: ["theme", "menuCollapse"]
83
- }
84
- }
85
- );
86
- export {
87
- C,
88
- O as L,
89
- y as M,
90
- z as u
91
- };