@chewel611/naive-ui-plus 0.0.42 → 0.0.44
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.js +712 -707
- package/dist/index.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/es/layout/content/PTabs.css +1 -1
- package/es/layout/content/PTabs.vue.js +1 -1
- package/es/layout/content/PTabs.vue2.js +2 -2
- package/es/layout/store.d.ts +8 -20939
- package/es/layout/store.js +81 -73
- package/es/modal/PModal.d.ts +1 -3
- package/es/modal/PModal.vue.js +49 -51
- package/es/modal/index.d.ts +1 -3
- package/es/modal/typing.d.ts +1 -2
- package/lib/layout/content/PTabs.css +1 -1
- package/lib/layout/content/PTabs.vue.cjs +1 -1
- package/lib/layout/content/PTabs.vue2.cjs +1 -1
- package/lib/layout/store.cjs +1 -1
- package/lib/layout/store.d.ts +8 -20939
- package/lib/modal/PModal.d.ts +1 -3
- package/lib/modal/PModal.vue.cjs +1 -1
- package/lib/modal/index.d.ts +1 -3
- package/lib/modal/typing.d.ts +1 -2
- package/package.json +1 -1
package/es/layout/store.js
CHANGED
|
@@ -1,78 +1,86 @@
|
|
|
1
1
|
import { defineStore as o } from "pinia";
|
|
2
2
|
import { reactive as n } from "vue";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const s = e.tabs.findIndex(
|
|
3
|
+
import { useRoute as i } from "vue-router";
|
|
4
|
+
const f = ["Redirect", "RedirectSon", "login"], y = o(
|
|
5
|
+
"p-layout",
|
|
6
|
+
() => {
|
|
7
|
+
const e = n({
|
|
8
|
+
collapsed: !1,
|
|
9
|
+
title: "输入项目名称",
|
|
10
|
+
logo: "https://picsum.photos/id/1/100/100",
|
|
11
|
+
avatar: "",
|
|
12
|
+
uid: "",
|
|
13
|
+
uname: "",
|
|
14
|
+
tabs: [],
|
|
15
|
+
cacheTabs: !1,
|
|
16
|
+
enableLanguage: !1
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
state: e,
|
|
20
|
+
initTabs: (t) => {
|
|
21
|
+
t.sort((s, a) => s.meta.affix && !a.meta.affix ? -1 : !s.meta.affix && a.meta.affix ? 1 : Number(a.meta.sort ?? 0) - Number(s.meta.sort ?? 0)), e.tabs = t;
|
|
22
|
+
},
|
|
23
|
+
addTab: (t) => f.includes(t.name) ? !1 : (e.tabs?.some(
|
|
25
24
|
(a) => a.fullPath == t.fullPath
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
25
|
+
) || e.tabs?.push(t), !0),
|
|
26
|
+
getCurrentTab: () => {
|
|
27
|
+
const t = i();
|
|
28
|
+
return e.tabs.find((s) => s.fullPath == t.fullPath);
|
|
29
|
+
},
|
|
30
|
+
closeCurrentTab: (t) => {
|
|
31
|
+
const s = e.tabs.findIndex(
|
|
32
|
+
(a) => a.fullPath == t.fullPath
|
|
33
|
+
);
|
|
34
|
+
e.tabs.splice(s, 1);
|
|
35
|
+
},
|
|
36
|
+
closeAllTabs: () => {
|
|
37
|
+
e.tabs = e.tabs.filter((t) => t?.meta?.affix ?? !1);
|
|
38
|
+
},
|
|
39
|
+
closeOtherTabs: (t) => {
|
|
40
|
+
e.tabs = e.tabs.filter(
|
|
41
|
+
(s) => s.fullPath == t.fullPath || (s?.meta?.affix ?? !1)
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
closeLeftTabs: (t) => {
|
|
45
|
+
const s = e.tabs.findIndex(
|
|
46
|
+
(a) => a.fullPath == t.fullPath
|
|
47
|
+
);
|
|
48
|
+
e.tabs = e.tabs.filter(
|
|
49
|
+
(a, l) => l >= s || (a?.meta?.affix ?? !1)
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
closeRightTabs: (t) => {
|
|
53
|
+
const s = e.tabs.findIndex(
|
|
54
|
+
(a) => a.fullPath == t.fullPath
|
|
55
|
+
);
|
|
56
|
+
e.tabs = e.tabs.filter(
|
|
57
|
+
(a, l) => l <= s || (a?.meta?.affix ?? !1)
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
collapse: () => {
|
|
61
|
+
e.collapsed = !e.collapsed;
|
|
62
|
+
},
|
|
63
|
+
setTitle: (t) => {
|
|
64
|
+
e.title = t;
|
|
65
|
+
},
|
|
66
|
+
setLogo: (t) => {
|
|
67
|
+
e.logo = t;
|
|
68
|
+
},
|
|
69
|
+
setUser: (t, s) => {
|
|
70
|
+
e.uid = t, e.uname = s;
|
|
71
|
+
},
|
|
72
|
+
setSettingPages: (t) => {
|
|
73
|
+
e.settingPages = t;
|
|
74
|
+
},
|
|
75
|
+
setLogout: (t) => {
|
|
76
|
+
e.logout = t;
|
|
77
|
+
},
|
|
78
|
+
enableLanguage: (t) => {
|
|
79
|
+
e.enableLanguage = t;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
);
|
|
76
84
|
export {
|
|
77
|
-
|
|
85
|
+
y as useLayoutStore
|
|
78
86
|
};
|
package/es/modal/PModal.d.ts
CHANGED
|
@@ -6,9 +6,7 @@ declare function __VLS_template(): {
|
|
|
6
6
|
'header-extra'?(_: {}): any;
|
|
7
7
|
default?(_: {}): any;
|
|
8
8
|
footer?(_: {}): any;
|
|
9
|
-
'action-extra'?(_: {
|
|
10
|
-
loading: boolean;
|
|
11
|
-
}): any;
|
|
9
|
+
'action-extra'?(_: {}): any;
|
|
12
10
|
};
|
|
13
11
|
refs: {
|
|
14
12
|
$modal: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').ExtractPropTypes<{
|
package/es/modal/PModal.vue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useMessage as w, NModal as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
const
|
|
1
|
+
import { useMessage as w, NModal as x, NSpace as S, NButton as k, NText as A } from "naive-ui";
|
|
2
|
+
import { defineComponent as N, ref as h, openBlock as i, createBlock as d, unref as V, mergeProps as _, withCtx as a, createVNode as L, createTextVNode as f, toDisplayString as c, createCommentVNode as u, renderSlot as n, createElementVNode as T, normalizeStyle as E } from "vue";
|
|
3
|
+
const z = /* @__PURE__ */ N({
|
|
4
4
|
__name: "PModal",
|
|
5
5
|
props: {
|
|
6
6
|
saveBtnText: { default: "保存" },
|
|
@@ -11,43 +11,41 @@ const j = /* @__PURE__ */ x({
|
|
|
11
11
|
width: { default: 800 },
|
|
12
12
|
height: { default: 500 },
|
|
13
13
|
visible: { type: Boolean },
|
|
14
|
-
loading: { type: Boolean },
|
|
15
14
|
onSave: {},
|
|
16
15
|
onClose: {},
|
|
17
16
|
onAfterEnter: {},
|
|
18
17
|
onAfterLeave: {},
|
|
19
|
-
|
|
18
|
+
onUpdateVisible: {}
|
|
20
19
|
},
|
|
21
20
|
emits: ["update:visible", "update:loading"],
|
|
22
|
-
setup(
|
|
23
|
-
const
|
|
24
|
-
a("update:loading", !0);
|
|
21
|
+
setup(r, { expose: y, emit: g }) {
|
|
22
|
+
const v = w(), o = h(!1), l = h(!1), p = g, e = r, b = async () => {
|
|
25
23
|
try {
|
|
26
|
-
e.onSave && await e.onSave() && s();
|
|
24
|
+
o.value = !0, e.onSave && await e.onSave() && s();
|
|
27
25
|
} catch (t) {
|
|
28
|
-
|
|
26
|
+
v.error(t.message);
|
|
29
27
|
} finally {
|
|
30
|
-
|
|
28
|
+
o.value = !1;
|
|
31
29
|
}
|
|
32
30
|
}, s = () => {
|
|
33
|
-
|
|
34
|
-
},
|
|
31
|
+
o.value = !1, l.value = !1, p("update:visible", !1);
|
|
32
|
+
}, B = async () => {
|
|
35
33
|
try {
|
|
36
|
-
e.onClose ? await e.onClose() && s() : s();
|
|
34
|
+
l.value = !0, e.onClose ? await e.onClose() && s() : s();
|
|
37
35
|
} catch (t) {
|
|
38
|
-
|
|
36
|
+
v.error(t.message);
|
|
37
|
+
} finally {
|
|
38
|
+
l.value = !1;
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
return
|
|
41
|
+
return y({
|
|
42
42
|
open: () => {
|
|
43
|
-
|
|
43
|
+
o.value = !1, l.value = !1, p("update:visible", !0);
|
|
44
44
|
},
|
|
45
|
-
close:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const v = $, p = b, B = C;
|
|
50
|
-
return d(), r(k(S), A({
|
|
45
|
+
close: s
|
|
46
|
+
}), (t, M) => {
|
|
47
|
+
const C = A, m = k, $ = S;
|
|
48
|
+
return i(), d(V(x), _({
|
|
51
49
|
ref: "$modal",
|
|
52
50
|
preset: "card"
|
|
53
51
|
}, t.$attrs, {
|
|
@@ -62,52 +60,52 @@ const j = /* @__PURE__ */ x({
|
|
|
62
60
|
onClose: s,
|
|
63
61
|
onAfterEnter: e.onAfterEnter,
|
|
64
62
|
onAfterLeave: e.onAfterLeave,
|
|
65
|
-
|
|
63
|
+
onUpdateVisible: e.onUpdateVisible
|
|
66
64
|
}), {
|
|
67
|
-
header:
|
|
68
|
-
t.$slots.header ?
|
|
69
|
-
default:
|
|
70
|
-
|
|
65
|
+
header: a(() => [
|
|
66
|
+
t.$slots.header ? n(t.$slots, "header", { key: 0 }) : e.title ? (i(), d(C, { key: 1 }, {
|
|
67
|
+
default: a(() => [
|
|
68
|
+
f(c(r.title), 1)
|
|
71
69
|
]),
|
|
72
70
|
_: 1
|
|
73
|
-
})) :
|
|
71
|
+
})) : u("", !0)
|
|
74
72
|
]),
|
|
75
|
-
"header-extra":
|
|
76
|
-
|
|
73
|
+
"header-extra": a(() => [
|
|
74
|
+
n(t.$slots, "header-extra")
|
|
77
75
|
]),
|
|
78
|
-
default:
|
|
76
|
+
default: a(() => [
|
|
79
77
|
T("div", {
|
|
80
78
|
class: "overflow-y-auto overflow-hidden mt-5",
|
|
81
79
|
style: E({ maxHeight: `${e.height}px` })
|
|
82
80
|
}, [
|
|
83
|
-
|
|
81
|
+
n(t.$slots, "default")
|
|
84
82
|
], 4)
|
|
85
83
|
]),
|
|
86
|
-
footer:
|
|
87
|
-
|
|
84
|
+
footer: a(() => [
|
|
85
|
+
n(t.$slots, "footer")
|
|
88
86
|
]),
|
|
89
|
-
action:
|
|
90
|
-
|
|
91
|
-
default:
|
|
92
|
-
e.hideSaveBtn ?
|
|
87
|
+
action: a(() => [
|
|
88
|
+
L($, { justify: "end" }, {
|
|
89
|
+
default: a(() => [
|
|
90
|
+
e.hideSaveBtn ? u("", !0) : (i(), d(m, {
|
|
93
91
|
key: 0,
|
|
94
92
|
type: "primary",
|
|
95
|
-
loading:
|
|
96
|
-
onClick:
|
|
93
|
+
loading: o.value,
|
|
94
|
+
onClick: b
|
|
97
95
|
}, {
|
|
98
|
-
default:
|
|
99
|
-
|
|
96
|
+
default: a(() => [
|
|
97
|
+
f(c(r.saveBtnText), 1)
|
|
100
98
|
]),
|
|
101
99
|
_: 1
|
|
102
100
|
}, 8, ["loading"])),
|
|
103
|
-
|
|
104
|
-
e.hideCancelBtn ?
|
|
101
|
+
n(t.$slots, "action-extra"),
|
|
102
|
+
e.hideCancelBtn ? u("", !0) : (i(), d(m, {
|
|
105
103
|
key: 1,
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
loading: l.value,
|
|
105
|
+
onClick: B
|
|
108
106
|
}, {
|
|
109
|
-
default:
|
|
110
|
-
|
|
107
|
+
default: a(() => [
|
|
108
|
+
f(c(r.cancelBtnText), 1)
|
|
111
109
|
]),
|
|
112
110
|
_: 1
|
|
113
111
|
}, 8, ["loading"]))
|
|
@@ -116,10 +114,10 @@ const j = /* @__PURE__ */ x({
|
|
|
116
114
|
})
|
|
117
115
|
]),
|
|
118
116
|
_: 3
|
|
119
|
-
}, 16, ["show", "style", "onAfterEnter", "onAfterLeave", "
|
|
117
|
+
}, 16, ["show", "style", "onAfterEnter", "onAfterLeave", "onUpdateVisible"]);
|
|
120
118
|
};
|
|
121
119
|
}
|
|
122
120
|
});
|
|
123
121
|
export {
|
|
124
|
-
|
|
122
|
+
z as default
|
|
125
123
|
};
|
package/es/modal/index.d.ts
CHANGED
|
@@ -2149,8 +2149,6 @@ export declare const PModalPlugin: {
|
|
|
2149
2149
|
'header-extra'?(_: {}): any;
|
|
2150
2150
|
default?(_: {}): any;
|
|
2151
2151
|
footer?(_: {}): any;
|
|
2152
|
-
'action-extra'?(_: {
|
|
2153
|
-
loading: boolean;
|
|
2154
|
-
}): any;
|
|
2152
|
+
'action-extra'?(_: {}): any;
|
|
2155
2153
|
};
|
|
2156
2154
|
}) & import('vue').Plugin;
|
package/es/modal/typing.d.ts
CHANGED
|
@@ -7,12 +7,11 @@ export type ModalProps = {
|
|
|
7
7
|
width?: number;
|
|
8
8
|
height?: number;
|
|
9
9
|
visible: boolean;
|
|
10
|
-
loading: boolean;
|
|
11
10
|
onSave?: () => Promise<boolean> | boolean;
|
|
12
11
|
onClose?: () => Promise<boolean> | boolean;
|
|
13
12
|
onAfterEnter?: () => void;
|
|
14
13
|
onAfterLeave?: () => void;
|
|
15
|
-
|
|
14
|
+
onUpdateVisible?: (value: boolean) => void;
|
|
16
15
|
};
|
|
17
16
|
export type ModalMethods = {
|
|
18
17
|
open: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.tabs-view[data-v-
|
|
1
|
+
.tabs-view[data-v-50f5202c]{width:100%;padding:6px 0;display:flex;transition:all .2s ease-in-out}.tabs-view-main[data-v-50f5202c]{height:32px;display:flex;max-width:100%;min-width:100%}.tabs-view-main .tabs-card[data-v-50f5202c]{-webkit-box-flex:1;flex-grow:1;flex-shrink:1;overflow:hidden;position:relative}.tabs-view-main .tabs-card .tabs-card-prev[data-v-50f5202c],.tabs-view-main .tabs-card .tabs-card-next[data-v-50f5202c]{width:32px;text-align:center;position:absolute;line-height:32px;cursor:pointer}.tabs-view-main .tabs-card .tabs-card-prev .n-icon[data-v-50f5202c],.tabs-view-main .tabs-card .tabs-card-next .n-icon[data-v-50f5202c]{display:flex;align-items:center;justify-content:center;height:32px;width:32px}.tabs-view-main .tabs-card .tabs-card-prev[data-v-50f5202c]{left:0}.tabs-view-main .tabs-card .tabs-card-next[data-v-50f5202c]{right:0}.tabs-view-main .tabs-card .tabs-card-next-hide[data-v-50f5202c],.tabs-view-main .tabs-card .tabs-card-prev-hide[data-v-50f5202c]{display:none}.tabs-view-main .tabs-card-scroll[data-v-50f5202c]{white-space:nowrap;overflow:hidden}.tabs-view-main .tabs-card-scroll-item[data-v-50f5202c]{background:var(--v4f917f8c);color:var(--v1c2fb72a);height:32px;padding:6px 16px 4px;border-radius:3px;margin-right:6px;cursor:pointer;display:inline-block;position:relative;flex:0 0 auto}.tabs-view-main .tabs-card-scroll-item span[data-v-50f5202c]{float:left;vertical-align:middle}.tabs-view-main .tabs-card-scroll-item[data-v-50f5202c]:hover{color:#515a6e}.tabs-view-main .tabs-card-scroll-item .n-icon[data-v-50f5202c]{height:22px;width:21px;margin-right:-6px;position:relative;vertical-align:middle;text-align:center;color:#808695}.tabs-view-main .tabs-card-scroll-item .n-icon[data-v-50f5202c]:hover{color:#515a6e!important}.tabs-view-main .tabs-card-scroll-item .n-icon svg[data-v-50f5202c]{height:21px;display:inline-block}.tabs-view-main .tabs-card-scroll .active-item[data-v-50f5202c]{color:#2d8cf0}.tabs-view-main .tabs-card-scrollable[data-v-50f5202c]{padding:0 32px;overflow:hidden}.tabs-view .tabs-close[data-v-50f5202c]{min-width:32px;width:32px;height:32px;line-height:32px;text-align:center;background:var(--color);border-radius:2px;cursor:pointer}.tabs-view .tabs-close-btn[data-v-50f5202c]{color:var(--color);height:100%;display:flex;align-items:center;justify-content:center}.tabs-view-default-background[data-v-50f5202c]{background:#f5f7f9}.tabs-view-dark-background[data-v-50f5202c]{background:#101014}.tabs-view-fix[data-v-50f5202c]{position:fixed;z-index:5;padding:6px 10px;left:200px}.tabs-view-fixed-header[data-v-50f5202c]{top:0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./PTabs.vue2.cjs");;/* empty css */const t=require("../../_virtual/_plugin-vue_export-helper.cjs"),u=t.default(e.default,[["__scopeId","data-v-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./PTabs.vue2.cjs");;/* empty css */const t=require("../../_virtual/_plugin-vue_export-helper.cjs"),u=t.default(e.default,[["__scopeId","data-v-50f5202c"]]);exports.default=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),B=require("element-resize-detector"),j=require("vuedraggable"),u=require("@vicons/antd"),S=require("vue-router"),r=require("naive-ui"),Y=require("../store.cjs"),F={class:"tabs-view-main"},U=["id","onClick","onContextmenu"],X={class:"tabs-close"},H={class:"tabs-close-btn"},J=t.defineComponent({__name:"PTabs",setup(G){t.useCssVars(e=>({
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),B=require("element-resize-detector"),j=require("vuedraggable"),u=require("@vicons/antd"),S=require("vue-router"),r=require("naive-ui"),Y=require("../store.cjs"),F={class:"tabs-view-main"},U=["id","onClick","onContextmenu"],X={class:"tabs-close"},H={class:"tabs-close-btn"},J=t.defineComponent({__name:"PTabs",setup(G){t.useCssVars(e=>({v4f917f8c:x.value,v1c2fb72a:T.value}));const b=r.useThemeVars(),x=t.computed(()=>b.value.cardColor),T=t.computed(()=>b.value.textColor1),k=r.useMessage(),c=S.useRoute(),f=S.useRouter(),s=t.ref(null),w=t.ref(null),g=t.ref(!1),i=Y.useLayoutStore(),d=t.computed(()=>i.state.tabs),l=t.reactive({activeKey:c.fullPath,scrollable:!0,dropdownX:0,dropdownY:0,showDropdown:!1,isMultiHeaderFixed:!0,multiTabsSetting:!0}),_=["Login","Redirect","ErrorPage"],v=e=>({meta:e.meta,name:e.name,fullPath:e.fullPath??e.path,path:e.path,hash:e.hash??"",query:e.query??{},params:e.params??{}}),V=t.computed(()=>{const a=i.state.collapsed?"64px":"272px";return{left:a,width:`calc(100% - ${a})`}}),C=t.computed(()=>{const e=d.value.length<=1;return[{label:"刷新当前",key:"1",icon:()=>t.h(r.NIcon,null,{default:()=>t.h(u.ReloadOutlined)})},{label:"关闭当前",key:"2",disabled:g.value||e,icon:()=>t.h(r.NIcon,null,{default:()=>t.h(u.CloseOutlined)})},{label:"关闭其他",key:"3",disabled:e,icon:()=>t.h(r.NIcon,null,{default:()=>t.h(u.ColumnWidthOutlined)})},{label:"关闭全部",key:"4",disabled:e,icon:()=>t.h(r.NIcon,null,{default:()=>t.h(u.MinusOutlined)})}]}),P=()=>{let e=[v(c)];f.getRoutes().filter(o=>o.meta.affix).forEach(o=>{const a=v(o);e.every(n=>n.name!==a.name)&&e.push(a)});try{if(i.state.cacheTabs){const o=localStorage.getItem("TABS_ROUTES");e=o?JSON.parse(o):e}}finally{return e}},E=e=>{const o=f.getRoutes();e.forEach(a=>{const n=o.find(m=>m.path===a.path);n&&(a.meta=n.meta||a.meta,a.name=n.name||a.name)}),i.state.cacheTabs&&localStorage.setItem("TABS_ROUTES",JSON.stringify(e))},O=()=>{const e=P();E(e),i.initTabs(e)},h=async e=>{if(await t.nextTick(),!s.value)return;const o=s.value.offsetWidth,a=s.value.scrollWidth;o<a?(l.scrollable=!0,e&&[...s.value.querySelectorAll(".tabs-card-scroll-item")||[]].forEach(m=>{m.id===`tag${l.activeKey.split("/").join("/")}`&&m.scrollIntoView&&m.scrollIntoView()})):l.scrollable=!1},W=e=>!(e.draggedContext.element.meta.affix||e.relatedContext.element.meta.affix),M=()=>{let e;e=B(),e.listenTo(w.value,()=>h(!0))},R=e=>{if(!e||e.fullPath===c.fullPath)return;if(l.activeKey=e.fullPath,toString.call(e)==="[object String]"){f.replace(e).catch(console.error);return}const o=e;f.replace(o).catch(console.error)},D=(e,o)=>{e.preventDefault(),g.value=o.path==="/home",l.showDropdown=!1,t.nextTick().then(()=>{l.showDropdown=!0,l.dropdownX=e.clientX,l.dropdownY=e.clientY})},I=()=>{if(c.meta.keepAlive){var e=f.currentRoute.value.matched.find(o=>o.name==c.name);e&&e.components?.default?.name}},N=e=>{if(d.value.length===1)return k.warning("这已经是最后一页,不能再关闭了!");if(I(),i.closeCurrentTab(e),l.activeKey===e.fullPath){const o=d.value[Math.max(0,d.value.length-1)];l.activeKey=o.fullPath,f.push(o)}h()},L=e=>{const o=d.value.find(a=>a.fullPath==e.fullPath);o&&N(o)},q=e=>{i.closeOtherTabs(e),l.activeKey=e.fullPath,h()},z=()=>{i.closeAllTabs(),h()},A=t.inject("reloadPage"),y=e=>{switch(e){case"1":A();break;case"2":N(c);break;case"3":q(c);break;case"4":z();break}h(),l.showDropdown=!1},p=(e,o)=>{const a=s.value.scrollLeft,n=o>0&&a+o>=e||o<0&&a+o<=e?e:a+o;if(s.value&&s.value.scrollTo(n,0),n!==e)return window.requestAnimationFrame(()=>p(e,o))},K=()=>{const e=s.value.offsetWidth,o=s.value.scrollLeft;if(!o)return;const a=o>e?o-e:0;p(a,(a-o)/20)},$=()=>{const e=s.value.offsetWidth,o=s.value.scrollWidth,a=s.value.scrollLeft;if(o-a<=e)return;const n=o-a>e*2?a+e:o-e;p(n,(n-a)/20)};return window.addEventListener("beforeunload",()=>{i.state.cacheTabs&&localStorage.setItem("TABS_ROUTES",JSON.stringify(d.value))}),window.addEventListener("scroll",e=>{let o=e.target.scrollTop||document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop;l.isMultiHeaderFixed=o>=64},!0),t.watch(()=>c.fullPath,e=>{_.includes(c.name)||(l.activeKey=e,i.addTab(v(c)),h(!0))},{immediate:!0}),O(),t.onMounted(()=>M()),(e,o)=>(t.openBlock(),t.createElementBlock("div",{class:"box-border tabs-view tabs-view-fix tabs-view-default-background",style:t.normalizeStyle(V.value)},[t.createElementVNode("div",F,[t.createElementVNode("div",{ref_key:"navWrap",ref:w,class:t.normalizeClass(["tabs-card",{"tabs-card-scrollable":l.scrollable}])},[t.createElementVNode("span",{class:t.normalizeClass(["tabs-card-prev",{"tabs-card-prev-hide":!l.scrollable}]),onClick:K},[t.createVNode(t.unref(r.NIcon),{size:"16",color:"#515a6e"},{default:t.withCtx(()=>[t.createVNode(t.unref(u.LeftOutlined))]),_:1})],2),t.createElementVNode("span",{class:t.normalizeClass(["tabs-card-next",{"tabs-card-next-hide":!l.scrollable}]),onClick:$},[t.createVNode(t.unref(r.NIcon),{size:"16",color:"#515a6e"},{default:t.withCtx(()=>[t.createVNode(t.unref(u.RightOutlined))]),_:1})],2),t.createElementVNode("div",{ref_key:"navScroll",ref:s,class:"tabs-card-scroll"},[t.createVNode(t.unref(j),{animation:"300","item-key":"fullPath",class:"flex",list:d.value,move:W},{item:t.withCtx(({element:a})=>[t.createElementVNode("div",{class:t.normalizeClass(["tabs-card-scroll-item",{"active-item":l.activeKey===a.fullPath}]),id:`tag${a.fullPath.split("/").join("/")}`,onClick:t.withModifiers(n=>R(a),["stop"]),onContextmenu:n=>D(n,a)},[t.createElementVNode("span",null,t.toDisplayString(a.meta.title),1),a.meta.affix?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(r.NIcon),{key:0,size:"14",onClick:t.withModifiers(n=>L(a),["stop"])},{default:t.withCtx(()=>[t.createVNode(t.unref(u.CloseOutlined))]),_:1},8,["onClick"]))],42,U)]),_:1},8,["list"])],512)],2),t.createElementVNode("div",X,[t.createVNode(t.unref(r.NDropdown),{trigger:"hover",placement:"bottom-end",options:C.value,onSelect:y},{default:t.withCtx(()=>[t.createElementVNode("div",H,[t.createVNode(t.unref(r.NIcon),{size:"16",color:"#515a6e"},{default:t.withCtx(()=>[t.createVNode(t.unref(u.DownOutlined))]),_:1})])]),_:1},8,["options"])]),t.createVNode(t.unref(r.NDropdown),{placement:"bottom-start",show:l.showDropdown,x:l.dropdownX,y:l.dropdownY,options:C.value,onClickoutside:o[0]||(o[0]=a=>l.showDropdown=!1),onSelect:y},null,8,["show","x","y","options"])])],4))}});exports.default=J;
|
package/lib/layout/store.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("pinia"),n=require("vue"),i=["Redirect","RedirectSon","login"],f=o.defineStore("p-layout",()=>{const e=n.reactive({collapsed:!1,title:"输入项目名称",logo:"https://picsum.photos/id/1/100/100",avatar:"",uid:"",uname:"",tabs:[],cacheTabs:!1,enableLanguage:!1});return{state:e,initTabs:t=>{t.sort((s,a)=>s.meta.affix&&!a.meta.affix?-1:!s.meta.affix&&a.meta.affix?1:Number(a.meta.sort??0)-Number(s.meta.sort??0)),e.tabs=t},addTab:t=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("pinia"),n=require("vue"),i=require("vue-router"),u=["Redirect","RedirectSon","login"],f=o.defineStore("p-layout",()=>{const e=n.reactive({collapsed:!1,title:"输入项目名称",logo:"https://picsum.photos/id/1/100/100",avatar:"",uid:"",uname:"",tabs:[],cacheTabs:!1,enableLanguage:!1});return{state:e,initTabs:t=>{t.sort((s,a)=>s.meta.affix&&!a.meta.affix?-1:!s.meta.affix&&a.meta.affix?1:Number(a.meta.sort??0)-Number(s.meta.sort??0)),e.tabs=t},addTab:t=>u.includes(t.name)?!1:(e.tabs?.some(a=>a.fullPath==t.fullPath)||e.tabs?.push(t),!0),getCurrentTab:()=>{const t=i.useRoute();return e.tabs.find(s=>s.fullPath==t.fullPath)},closeCurrentTab:t=>{const s=e.tabs.findIndex(a=>a.fullPath==t.fullPath);e.tabs.splice(s,1)},closeAllTabs:()=>{e.tabs=e.tabs.filter(t=>t?.meta?.affix??!1)},closeOtherTabs:t=>{e.tabs=e.tabs.filter(s=>s.fullPath==t.fullPath||(s?.meta?.affix??!1))},closeLeftTabs:t=>{const s=e.tabs.findIndex(a=>a.fullPath==t.fullPath);e.tabs=e.tabs.filter((a,l)=>l>=s||(a?.meta?.affix??!1))},closeRightTabs:t=>{const s=e.tabs.findIndex(a=>a.fullPath==t.fullPath);e.tabs=e.tabs.filter((a,l)=>l<=s||(a?.meta?.affix??!1))},collapse:()=>{e.collapsed=!e.collapsed},setTitle:t=>{e.title=t},setLogo:t=>{e.logo=t},setUser:(t,s)=>{e.uid=t,e.uname=s},setSettingPages:t=>{e.settingPages=t},setLogout:t=>{e.logout=t},enableLanguage:t=>{e.enableLanguage=t}}});exports.useLayoutStore=f;
|