@keyblade/pro-components 1.12.17 → 1.13.0
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/es/pro-layout/enum.d.ts +16 -0
- package/es/pro-layout/enum.js +5 -0
- package/es/pro-layout/hooks.d.ts +89 -12
- package/es/pro-layout/hooks.js +122 -82
- package/es/pro-layout/index.d.ts +19 -284
- package/es/pro-layout/pro-layout.vue.d.ts +14 -236
- package/es/pro-layout/pro-layout.vue.js +150 -233
- package/es/pro-layout/type.d.ts +83 -0
- package/es/pro-menu/index.d.ts +3 -3
- package/es/pro-menu/interface.d.ts +11 -0
- package/es/pro-menu/pro-menu.vue.d.ts +2 -2
- package/es/pro-menu/pro-menu.vue.js +43 -41
- package/es/style.css +1 -1
- package/package.json +1 -1
package/es/pro-layout/hooks.d.ts
CHANGED
|
@@ -1,14 +1,91 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
1
|
import { IProMenuItem } from '../pro-menu';
|
|
3
2
|
import { IProTab } from '../pro-reuse-tabs';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import { ProLayoutMenuType } from './enum.ts';
|
|
4
|
+
import { IProLayoutProps } from './type.ts';
|
|
5
|
+
export declare function useHooks(props: IProLayoutProps): {
|
|
6
|
+
topMenuItems: import('vue').Ref<{
|
|
7
|
+
name: string;
|
|
8
|
+
path: string;
|
|
9
|
+
title: string;
|
|
10
|
+
topMenu?: boolean | undefined;
|
|
11
|
+
topChildrenMenu?: boolean | undefined;
|
|
12
|
+
activatedKeys?: string[] | undefined;
|
|
13
|
+
icon?: string | undefined;
|
|
14
|
+
selectedIcon?: string | undefined;
|
|
15
|
+
hideInMenu?: boolean | undefined;
|
|
16
|
+
hideChildrenInMenu?: boolean | undefined;
|
|
17
|
+
noAffix?: boolean | undefined;
|
|
18
|
+
breadcrumbs?: {
|
|
19
|
+
path?: string | undefined;
|
|
20
|
+
label: string;
|
|
21
|
+
}[] | undefined;
|
|
22
|
+
ignoreCache?: boolean | undefined;
|
|
23
|
+
componentKey?: "path" | "fullPath" | undefined;
|
|
24
|
+
children?: /*elided*/ any[] | undefined;
|
|
25
|
+
}[], IProMenuItem[] | {
|
|
26
|
+
name: string;
|
|
27
|
+
path: string;
|
|
28
|
+
title: string;
|
|
29
|
+
topMenu?: boolean | undefined;
|
|
30
|
+
topChildrenMenu?: boolean | undefined;
|
|
31
|
+
activatedKeys?: string[] | undefined;
|
|
32
|
+
icon?: string | undefined;
|
|
33
|
+
selectedIcon?: string | undefined;
|
|
34
|
+
hideInMenu?: boolean | undefined;
|
|
35
|
+
hideChildrenInMenu?: boolean | undefined;
|
|
36
|
+
noAffix?: boolean | undefined;
|
|
37
|
+
breadcrumbs?: {
|
|
38
|
+
path?: string | undefined;
|
|
39
|
+
label: string;
|
|
40
|
+
}[] | undefined;
|
|
41
|
+
ignoreCache?: boolean | undefined;
|
|
42
|
+
componentKey?: "path" | "fullPath" | undefined;
|
|
43
|
+
children?: /*elided*/ any[] | undefined;
|
|
44
|
+
}[]>;
|
|
45
|
+
siderMenuItems: import('vue').Ref<{
|
|
46
|
+
name: string;
|
|
47
|
+
path: string;
|
|
48
|
+
title: string;
|
|
49
|
+
topMenu?: boolean | undefined;
|
|
50
|
+
topChildrenMenu?: boolean | undefined;
|
|
51
|
+
activatedKeys?: string[] | undefined;
|
|
52
|
+
icon?: string | undefined;
|
|
53
|
+
selectedIcon?: string | undefined;
|
|
54
|
+
hideInMenu?: boolean | undefined;
|
|
55
|
+
hideChildrenInMenu?: boolean | undefined;
|
|
56
|
+
noAffix?: boolean | undefined;
|
|
57
|
+
breadcrumbs?: {
|
|
58
|
+
path?: string | undefined;
|
|
59
|
+
label: string;
|
|
60
|
+
}[] | undefined;
|
|
61
|
+
ignoreCache?: boolean | undefined;
|
|
62
|
+
componentKey?: "path" | "fullPath" | undefined;
|
|
63
|
+
children?: /*elided*/ any[] | undefined;
|
|
64
|
+
}[], IProMenuItem[] | {
|
|
65
|
+
name: string;
|
|
66
|
+
path: string;
|
|
67
|
+
title: string;
|
|
68
|
+
topMenu?: boolean | undefined;
|
|
69
|
+
topChildrenMenu?: boolean | undefined;
|
|
70
|
+
activatedKeys?: string[] | undefined;
|
|
71
|
+
icon?: string | undefined;
|
|
72
|
+
selectedIcon?: string | undefined;
|
|
73
|
+
hideInMenu?: boolean | undefined;
|
|
74
|
+
hideChildrenInMenu?: boolean | undefined;
|
|
75
|
+
noAffix?: boolean | undefined;
|
|
76
|
+
breadcrumbs?: {
|
|
77
|
+
path?: string | undefined;
|
|
78
|
+
label: string;
|
|
79
|
+
}[] | undefined;
|
|
80
|
+
ignoreCache?: boolean | undefined;
|
|
81
|
+
componentKey?: "path" | "fullPath" | undefined;
|
|
82
|
+
children?: /*elided*/ any[] | undefined;
|
|
83
|
+
}[]>;
|
|
84
|
+
topMenuSelectedKeys: import('vue').Ref<string[], string[]>;
|
|
85
|
+
siderMenuSelectedKeys: import('vue').Ref<string[], string[]>;
|
|
86
|
+
activeMenuItem: import('vue').Ref<IProMenuItem | undefined, IProMenuItem | undefined>;
|
|
87
|
+
menuItemMap: import('vue').Ref<Record<string, IProMenuItem>, Record<string, IProMenuItem>>;
|
|
88
|
+
breadcrumbItems: import('vue').Ref<{
|
|
12
89
|
path?: string | undefined;
|
|
13
90
|
label: string;
|
|
14
91
|
}[], {
|
|
@@ -18,7 +95,7 @@ export declare function useHooks(menuItems: Ref<IProMenuItem[]>, options: {
|
|
|
18
95
|
path?: string | undefined;
|
|
19
96
|
label: string;
|
|
20
97
|
}[]>;
|
|
21
|
-
tabs: Ref<{
|
|
98
|
+
tabs: import('vue').Ref<{
|
|
22
99
|
name: string;
|
|
23
100
|
parentNames: string[];
|
|
24
101
|
title: string;
|
|
@@ -31,8 +108,8 @@ export declare function useHooks(menuItems: Ref<IProMenuItem[]>, options: {
|
|
|
31
108
|
fullPath: string;
|
|
32
109
|
active: boolean;
|
|
33
110
|
}[]>;
|
|
34
|
-
keepAliveInclude: Ref<string[], string[]>;
|
|
35
|
-
|
|
111
|
+
keepAliveInclude: import('vue').Ref<string[], string[]>;
|
|
112
|
+
onProMenuItemClick: (menuType: ProLayoutMenuType, item: IProMenuItem) => Promise<void>;
|
|
36
113
|
onTabClick: (key: string) => void;
|
|
37
114
|
onTabDelete: (key: string) => void;
|
|
38
115
|
};
|
package/es/pro-layout/hooks.js
CHANGED
|
@@ -1,106 +1,146 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useRoute as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { ref as r, computed as L, watch as g } from "vue";
|
|
2
|
+
import { useRoute as R, useRouter as W } from "vue-router";
|
|
3
|
+
import { ProLayoutMode as P, ProLayoutMenuType as B } from "./enum.js";
|
|
4
|
+
function z(u) {
|
|
5
|
+
const o = R(), h = W(), y = r([]), T = r([]), i = r(), v = r([]), M = r({}), k = r([]), s = r([]), p = r([]), b = r([]), f = r([]), d = L(() => {
|
|
6
|
+
const a = [...u.menuItems], e = (n) => {
|
|
7
|
+
n.forEach((l) => {
|
|
8
|
+
if (l != null && l.children && l.children.length > 0) {
|
|
9
|
+
if ((l == null ? void 0 : l.topChildrenMenu) !== void 0)
|
|
10
|
+
l.children = l.children.map((t) => ({ ...t, topMenu: l == null ? void 0 : l.topChildrenMenu }));
|
|
11
|
+
else {
|
|
12
|
+
const t = l.children.find((c) => c.topMenu !== void 0);
|
|
13
|
+
t && (l.topChildrenMenu = t.topMenu, l.children = l.children.map((c) => ({ ...c, topMenu: t.topMenu })));
|
|
14
|
+
}
|
|
15
|
+
e(l.children);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
return u.layout === P.mix && e(a), a;
|
|
20
|
+
}), C = (a) => {
|
|
21
|
+
var e;
|
|
22
|
+
y.value = [a.name], !(a != null && a.children) || ((e = a == null ? void 0 : a.children) == null ? void 0 : e.length) === 0 ? (f.value = [], h == null || h.push({ path: a.path })) : f.value = a.children;
|
|
23
|
+
}, E = (a) => {
|
|
24
|
+
h == null || h.push({ path: a.path }), T.value = [a.name];
|
|
25
|
+
}, N = async (a, e) => {
|
|
26
|
+
if (e != null && e.path && !(u != null && u.onMenuItemClick && !await u.onMenuItemClick(e))) {
|
|
27
|
+
if (e.path.startsWith("http") || e.path.startsWith("https")) {
|
|
28
|
+
window.open(e.path);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
a === B.top ? C(e) : E(e);
|
|
32
|
+
}
|
|
33
|
+
}, S = () => {
|
|
34
|
+
const a = [], e = (n) => {
|
|
35
|
+
var l;
|
|
36
|
+
for (const t in n) {
|
|
37
|
+
const c = n[t];
|
|
38
|
+
if (c.name === ((l = i == null ? void 0 : i.value) == null ? void 0 : l.name) || c.children && c.children.length > 0 && e(c.children))
|
|
39
|
+
return a.unshift(c), !0;
|
|
13
40
|
}
|
|
14
41
|
return !1;
|
|
15
42
|
};
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
var
|
|
19
|
-
const
|
|
20
|
-
|
|
43
|
+
e(JSON.parse(JSON.stringify(d.value))), v.value = a;
|
|
44
|
+
}, x = () => {
|
|
45
|
+
var e, n, l;
|
|
46
|
+
const a = (e = v.value) == null ? void 0 : e.map((t) => ({ path: t == null ? void 0 : t.path, label: t == null ? void 0 : t.title }));
|
|
47
|
+
k.value = (n = i.value) != null && n.breadcrumbs ? (l = i.value) == null ? void 0 : l.breadcrumbs : a.length !== 0 ? a : [];
|
|
21
48
|
};
|
|
22
|
-
function
|
|
23
|
-
if (!
|
|
24
|
-
|
|
25
|
-
|
|
49
|
+
function A() {
|
|
50
|
+
if (!i.value || i.value.noAffix) {
|
|
51
|
+
s.value.forEach((t) => {
|
|
52
|
+
t.active = !1;
|
|
26
53
|
});
|
|
27
54
|
return;
|
|
28
55
|
}
|
|
29
|
-
const { name:
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
const { name: a, title: e } = i.value;
|
|
57
|
+
let n = -1;
|
|
58
|
+
s.value.forEach((t, c) => {
|
|
59
|
+
t.active = !1, t.name === a && (n = c);
|
|
33
60
|
});
|
|
34
|
-
const
|
|
35
|
-
name:
|
|
36
|
-
parentNames: v.value.map((
|
|
37
|
-
title:
|
|
38
|
-
fullPath:
|
|
61
|
+
const l = {
|
|
62
|
+
name: a,
|
|
63
|
+
parentNames: v.value.map((t) => t.name),
|
|
64
|
+
title: e ?? a,
|
|
65
|
+
fullPath: o.fullPath,
|
|
39
66
|
active: !0
|
|
40
67
|
};
|
|
41
|
-
if (~
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
if (~n) {
|
|
69
|
+
const t = s.value[n];
|
|
70
|
+
t.fullPath === o.fullPath ? (t.active = !0, t.fullPath = o.fullPath) : (s.value.splice(n, 1), setTimeout(() => {
|
|
71
|
+
s.value.push(l);
|
|
45
72
|
}));
|
|
46
73
|
} else
|
|
47
|
-
|
|
74
|
+
s.value.push(l);
|
|
48
75
|
}
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
let
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
}),
|
|
57
|
-
let
|
|
58
|
-
|
|
76
|
+
const w = (a) => {
|
|
77
|
+
const e = s.value.findIndex((l) => l.name === a), n = s.value[e];
|
|
78
|
+
h.push(n.fullPath);
|
|
79
|
+
}, K = (a) => {
|
|
80
|
+
let e = -1, n = -1;
|
|
81
|
+
if (s.value.forEach((t, c) => {
|
|
82
|
+
t.name === a && (n = c), t.active && (e = c);
|
|
83
|
+
}), e === n) {
|
|
84
|
+
let t;
|
|
85
|
+
n === 0 ? t = s.value[n + 1] : t = s.value[n - 1], t.active = !0, h.push(t.fullPath);
|
|
59
86
|
}
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
var
|
|
64
|
-
if (
|
|
87
|
+
const l = s.value.splice(n, 1);
|
|
88
|
+
O(l[0]);
|
|
89
|
+
}, J = () => {
|
|
90
|
+
var e;
|
|
91
|
+
if (u != null && u.disableKeepAlive || (e = o == null ? void 0 : o.meta) != null && e.ignoreCache)
|
|
65
92
|
return;
|
|
66
|
-
const
|
|
67
|
-
v.value.forEach((
|
|
68
|
-
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}),
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
93
|
+
const a = new Set(p.value);
|
|
94
|
+
v.value.forEach((n) => {
|
|
95
|
+
n.name && a.add(n.name);
|
|
96
|
+
}), p.value = Array.from(a.values());
|
|
97
|
+
}, O = (a) => {
|
|
98
|
+
const e = new Set(p.value);
|
|
99
|
+
a.parentNames.forEach((n) => {
|
|
100
|
+
e.delete(n);
|
|
101
|
+
}), s.value.forEach((n) => {
|
|
102
|
+
n.parentNames.forEach((l) => {
|
|
103
|
+
const t = M.value[l];
|
|
104
|
+
t != null && t.ignoreCache || e.add(t.name);
|
|
78
105
|
});
|
|
79
|
-
}),
|
|
106
|
+
}), p.value = Array.from(e.values());
|
|
80
107
|
};
|
|
81
|
-
return
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
108
|
+
return g(() => d.value, () => {
|
|
109
|
+
const a = {}, e = (n) => {
|
|
110
|
+
n.forEach((l) => {
|
|
111
|
+
l.children && l.children.length > 0 && e(l.children), delete l.children, a[l.name] = l;
|
|
85
112
|
});
|
|
86
113
|
};
|
|
87
|
-
|
|
88
|
-
}, { immediate: !0 }),
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
114
|
+
e(JSON.parse(JSON.stringify(d.value))), M.value = a;
|
|
115
|
+
}, { immediate: !0 }), g(() => [u.layout, d.value], () => {
|
|
116
|
+
var a;
|
|
117
|
+
if (b.value = [], f.value = [], u.layout === P.side)
|
|
118
|
+
f.value = d.value;
|
|
119
|
+
else if (u.layout === P.mix) {
|
|
120
|
+
const e = (a = d.value) == null ? void 0 : a.filter((n) => n.topMenu);
|
|
121
|
+
(e == null ? void 0 : e.length) === 0 ? f.value = d.value : b.value = e;
|
|
122
|
+
}
|
|
123
|
+
}, { immediate: !0 }), g(() => o == null ? void 0 : o.name, () => {
|
|
124
|
+
var n, l, t;
|
|
125
|
+
const a = o == null ? void 0 : o.name;
|
|
126
|
+
i.value = M.value[a], S();
|
|
127
|
+
const e = v.value.filter((c) => c.topMenu);
|
|
128
|
+
e.length > 0 && b.value.length > 0 && (f.value = ((n = e[e.length - 1]) == null ? void 0 : n.children) || []), y.value = i != null && i.value ? [...e.map((c) => c.name), ...((l = i.value) == null ? void 0 : l.activatedKeys) || []] : [], T.value = i != null && i.value ? [i.value.name, ...((t = i.value) == null ? void 0 : t.activatedKeys) || []] : [], x(), u.hideTabs || A(), J();
|
|
92
129
|
}, { immediate: !0 }), {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
130
|
+
topMenuItems: b,
|
|
131
|
+
siderMenuItems: f,
|
|
132
|
+
topMenuSelectedKeys: y,
|
|
133
|
+
siderMenuSelectedKeys: T,
|
|
134
|
+
activeMenuItem: i,
|
|
135
|
+
menuItemMap: M,
|
|
136
|
+
breadcrumbItems: k,
|
|
137
|
+
tabs: s,
|
|
138
|
+
keepAliveInclude: p,
|
|
139
|
+
onProMenuItemClick: N,
|
|
140
|
+
onTabClick: w,
|
|
141
|
+
onTabDelete: K
|
|
102
142
|
};
|
|
103
143
|
}
|
|
104
144
|
export {
|
|
105
|
-
|
|
145
|
+
z as useHooks
|
|
106
146
|
};
|