@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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * layout模式
3
+ */
4
+ export declare enum ProLayoutMode {
5
+ /** 混合菜单模式(包含侧边栏和顶部菜单) */
6
+ mix = "mix",
7
+ /** 侧边栏菜单模式 */
8
+ side = "side"
9
+ }
10
+ /**
11
+ * 菜单类型
12
+ */
13
+ export declare enum ProLayoutMenuType {
14
+ top = "top",
15
+ side = "side"
16
+ }
@@ -0,0 +1,5 @@
1
+ var r = /* @__PURE__ */ ((i) => (i.mix = "mix", i.side = "side", i))(r || {}), e = /* @__PURE__ */ ((i) => (i.top = "top", i.side = "side", i))(e || {});
2
+ export {
3
+ e as ProLayoutMenuType,
4
+ r as ProLayoutMode
5
+ };
@@ -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
- export declare function useHooks(menuItems: Ref<IProMenuItem[]>, options: {
5
- hideTabs: boolean;
6
- disableKeepAlive: boolean;
7
- }): {
8
- menuSelectedKeys: Ref<string[], string[]>;
9
- activeMenuItem: Ref<IProMenuItem | undefined, IProMenuItem | undefined>;
10
- menuItemMap: Ref<Record<string, IProMenuItem>, Record<string, IProMenuItem>>;
11
- breadcrumbItems: Ref<{
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
- onMenuItemClick: (key: string) => void;
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
  };
@@ -1,106 +1,146 @@
1
- import { ref as i, watch as T } from "vue";
2
- import { useRoute as S, useRouter as x } from "vue-router";
3
- function J(h, o) {
4
- const r = S(), b = x(), m = i([]), P = (t) => {
5
- m.value = [t];
6
- }, u = i(), v = i([]), d = i({}), p = i([]), c = i([]), f = i([]), N = () => {
7
- const t = [], l = (a) => {
8
- var n;
9
- for (const e in a) {
10
- const s = a[e];
11
- if (s.name === ((n = u == null ? void 0 : u.value) == null ? void 0 : n.name) || s.children && s.children.length > 0 && l(s.children))
12
- return delete s.children, t.unshift(s), !0;
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
- l(JSON.parse(JSON.stringify(h.value))), v.value = t;
17
- }, k = () => {
18
- var l, a, n;
19
- const t = (l = v.value) == null ? void 0 : l.map((e) => ({ path: e == null ? void 0 : e.path, label: e == null ? void 0 : e.title }));
20
- p.value = (a = u.value) != null && a.breadcrumbs ? (n = u.value) == null ? void 0 : n.breadcrumbs : t.length !== 0 ? t : [];
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 y() {
23
- if (!u.value || u.value.noAffix) {
24
- c.value.forEach((e) => {
25
- e.active = !1;
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: t, title: l } = u.value;
30
- let a = -1;
31
- c.value.forEach((e, s) => {
32
- e.active = !1, e.name === t && (a = s);
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 n = {
35
- name: t,
36
- parentNames: v.value.map((e) => e.name),
37
- title: l ?? t,
38
- fullPath: r.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 (~a) {
42
- const e = c.value[a];
43
- e.fullPath === r.fullPath ? (e.active = !0, e.fullPath = r.fullPath) : (c.value.splice(a, 1), setTimeout(() => {
44
- c.value.push(n);
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
- c.value.push(n);
74
+ s.value.push(l);
48
75
  }
49
- const A = (t) => {
50
- const l = c.value.findIndex((n) => n.name === t), a = c.value[l];
51
- b.push(a.fullPath);
52
- }, E = (t) => {
53
- let l = -1, a = -1;
54
- if (c.value.forEach((e, s) => {
55
- e.name === t && (a = s), e.active && (l = s);
56
- }), l === a) {
57
- let e;
58
- a === 0 ? e = c.value[a + 1] : e = c.value[a - 1], e.active = !0, b.push(e.fullPath);
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 n = c.value.splice(a, 1);
61
- I(n[0]);
62
- }, g = () => {
63
- var l;
64
- if (o != null && o.disableKeepAlive || (l = r == null ? void 0 : r.meta) != null && l.ignoreCache)
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 t = new Set(f.value);
67
- v.value.forEach((a) => {
68
- a.name && t.add(a.name);
69
- }), f.value = Array.from(t.values());
70
- }, I = (t) => {
71
- const l = new Set(f.value);
72
- t.parentNames.forEach((a) => {
73
- l.delete(a);
74
- }), c.value.forEach((a) => {
75
- a.parentNames.forEach((n) => {
76
- const e = d.value[n];
77
- e != null && e.ignoreCache || l.add(e.name);
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
- }), f.value = Array.from(l.values());
106
+ }), p.value = Array.from(e.values());
80
107
  };
81
- return T(h, () => {
82
- const t = {}, l = (a) => {
83
- a.forEach((n) => {
84
- n.children && n.children.length > 0 && l(n.children), delete n.children, t[n.name] = n;
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
- l(JSON.parse(JSON.stringify(h.value))), d.value = t;
88
- }, { immediate: !0 }), T(() => r == null ? void 0 : r.name, () => {
89
- var l;
90
- const t = r == null ? void 0 : r.name;
91
- u.value = d.value[t], m.value = u != null && u.value ? [u.value.name, ...((l = u.value) == null ? void 0 : l.activatedKeys) || []] : [], N(), k(), o.hideTabs || y(), g();
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
- menuSelectedKeys: m,
94
- activeMenuItem: u,
95
- menuItemMap: d,
96
- breadcrumbItems: p,
97
- tabs: c,
98
- keepAliveInclude: f,
99
- onMenuItemClick: P,
100
- onTabClick: A,
101
- onTabDelete: E
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
- J as useHooks
145
+ z as useHooks
106
146
  };