@ditari/bsui 1.0.39 → 1.0.41
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/cjs/components/layout/NavTabs.vue.cjs.js +1 -1
- package/dist/cjs/hooks/route/index.cjs.js +1 -1
- package/dist/cjs/hooks/route/index.d.ts +1 -2
- package/dist/esm/components/layout/NavTabs.vue.esm.js +7 -7
- package/dist/esm/hooks/route/index.d.ts +1 -2
- package/dist/esm/hooks/route/index.esm.js +24 -27
- package/package.json +1 -1
- package/src/components/layout/NavTabs.vue +3 -2
- package/src/hooks/route/index.ts +4 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),_=require("vue-router"),C=require("@ant-design/icons-vue"),y=require("pinia"),S=require("../../store/modules/NavTab.cjs.js"),g=require("../../store/modules/KeepAlive.cjs.js"),q=require("../../store/modules/Menu.cjs.js"),N={class:"ditari-nav"},T=e.createElementVNode("div",{class:"tab-dividers"},null,-1),B={key:0,class:"tab-close"},K={name:"DNavTabs"},E=e.defineComponent({...K,setup(V){const l=_.useRoute(),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),_=require("vue-router"),C=require("@ant-design/icons-vue"),y=require("pinia"),S=require("../../store/modules/NavTab.cjs.js"),g=require("../../store/modules/KeepAlive.cjs.js"),q=require("../../store/modules/Menu.cjs.js"),N={class:"ditari-nav"},T=e.createElementVNode("div",{class:"tab-dividers"},null,-1),B={key:0,class:"tab-close"},K={name:"DNavTabs"},E=e.defineComponent({...K,setup(V){const l=_.useRoute(),v=_.useRouter(),c=S.useNavTabsStore(),p=g.useKeepAliveStore(),h=q.useMenuStore(),n=e.computed(()=>c.getList),{selectedMenuKeys:u}=y.storeToRefs(h),r=e.ref("");e.watchEffect(()=>{r.value=u.value.length>0?u.value[0]:""}),d(),e.watch(()=>l.path,()=>{d()});function d(){c.save(l),u.value=[l.path],p.save(l)}const m=a=>{if(a!==l.path){const t=n.value.filter(s=>s.path===a)[0];v.push({path:t.path,query:t.query,params:t.params})}},f=(a,t)=>{const s=n.value.filter(i=>i.fullPath===t)[0];a.stopPropagation(),c.deleteTabs(t),v.push(n.value[n.value.length-1].fullPath),s.name&&p.deleteKeepAlive(s.name)},b=a=>{var t;return!((t=a.meta)!=null&&t.keepOpen)||n.value.length===1};return(a,t)=>{const s=e.resolveComponent("a-tab-pane"),i=e.resolveComponent("a-tabs");return e.openBlock(),e.createElementBlock("div",N,[e.createVNode(i,{activeKey:r.value,"onUpdate:activeKey":t[0]||(t[0]=o=>r.value=o),type:"card",onTabClick:m},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),o=>(e.openBlock(),e.createBlock(s,{key:o.path},{tab:e.withCtx(()=>[T,e.createElementVNode("div",{class:e.normalizeClass(["tab-item",{active:r.value===o.path}])},e.toDisplayString(o.meta.title),3),b(o)?(e.openBlock(),e.createElementBlock("div",B,[e.createVNode(e.unref(C.CloseOutlined),{onClick:k=>f(k,o.fullPath)},null,8,["onClick"])])):e.createCommentVNode("",!0)]),_:2},1024))),128))]),_:1},8,["activeKey"])])}}});exports.default=E;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),v=require("vue-router"),m=require("../../store/modules/Breadcrumb.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),v=require("vue-router"),m=require("../../store/modules/Breadcrumb.cjs.js"),g=()=>{const{saveBreadcrumb:a}=m.useBreadcrumbStore(),e=d.ref(null);return{getRoutes:async c=>{const r=[];for await(const o of Object.values(c)){const u=await o();r.push(...u.default)}return e.value=v.createRouterMatcher(r,{}),f(r)},setMatched:(c,r)=>{var u;const o=d.ref([]);try{const n=((u=e.value)==null?void 0:u.resolve(c,r).matched)??[];o.value=n.reduce((h,i)=>{var l;return h.some(p=>p.path===i.path)||h.push({path:i.path,title:((l=i.meta)==null?void 0:l.title)??"未设置标题"}),h},[])}catch(n){console.log(n),o.value=[]}a(o.value)}}};function f(a,e=""){const s=[];for(const t of a)t.path===""?t.path=e:t.path.startsWith("/")||(t.path=`${e}/${t.path}`),t.children&&(s.push(...f(t.children,t.path)),delete t.children),s.push(t);return s}exports.useDitariRoute=g;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RouteLocationNormalized
|
|
1
|
+
import { RouteLocationNormalized } from "vue-router";
|
|
2
2
|
/**
|
|
3
3
|
* 路由处理
|
|
4
4
|
*/
|
|
5
5
|
export declare const useDitariRoute: () => {
|
|
6
6
|
getRoutes: (routeFiles: Record<string, () => Promise<unknown>>) => Promise<any>;
|
|
7
7
|
setMatched: (to: RouteLocationNormalized, from: RouteLocationNormalized) => void;
|
|
8
|
-
createMatcher: (routes: RouteRecordRaw[]) => void;
|
|
9
8
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as T, computed as N, ref as
|
|
1
|
+
import { defineComponent as T, computed as N, ref as P, watchEffect as w, watch as x, resolveComponent as f, openBlock as l, createElementBlock as p, createVNode as _, withCtx as h, Fragment as A, renderList as B, unref as b, createBlock as E, createElementVNode as C, normalizeClass as R, toDisplayString as V, createCommentVNode as q } from "vue";
|
|
2
2
|
import { useRoute as D, useRouter as L } from "vue-router";
|
|
3
3
|
import { CloseOutlined as M } from "@ant-design/icons-vue";
|
|
4
4
|
import { storeToRefs as O } from "pinia";
|
|
@@ -13,10 +13,10 @@ const j = { class: "ditari-nav" }, G = /* @__PURE__ */ C("div", { class: "tab-di
|
|
|
13
13
|
}, te = /* @__PURE__ */ T({
|
|
14
14
|
...I,
|
|
15
15
|
setup(J) {
|
|
16
|
-
const n = D(), v = L(), c = z(), m = F(), k = U(), o = N(() => c.getList), { selectedMenuKeys: u } = O(k), r =
|
|
17
|
-
|
|
16
|
+
const n = D(), v = L(), c = z(), m = F(), k = U(), o = N(() => c.getList), { selectedMenuKeys: u } = O(k), r = P("");
|
|
17
|
+
w(() => {
|
|
18
18
|
r.value = u.value.length > 0 ? u.value[0] : "";
|
|
19
|
-
}), d(),
|
|
19
|
+
}), d(), x(
|
|
20
20
|
() => n.path,
|
|
21
21
|
() => {
|
|
22
22
|
d();
|
|
@@ -35,11 +35,11 @@ const j = { class: "ditari-nav" }, G = /* @__PURE__ */ C("div", { class: "tab-di
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}, S = (t, e) => {
|
|
38
|
-
const s = o.value.filter((i) => i.
|
|
38
|
+
const s = o.value.filter((i) => i.fullPath === e)[0];
|
|
39
39
|
t.stopPropagation(), c.deleteTabs(e), v.push(o.value[o.value.length - 1].fullPath), s.name && m.deleteKeepAlive(s.name);
|
|
40
40
|
}, g = (t) => {
|
|
41
41
|
var e;
|
|
42
|
-
return !((e = t.meta) != null && e.keepOpen) || o.value.length ===
|
|
42
|
+
return !((e = t.meta) != null && e.keepOpen) || o.value.length === 1;
|
|
43
43
|
};
|
|
44
44
|
return (t, e) => {
|
|
45
45
|
const s = f("a-tab-pane"), i = f("a-tabs");
|
|
@@ -51,7 +51,7 @@ const j = { class: "ditari-nav" }, G = /* @__PURE__ */ C("div", { class: "tab-di
|
|
|
51
51
|
onTabClick: y
|
|
52
52
|
}, {
|
|
53
53
|
default: h(() => [
|
|
54
|
-
(l(!0), p(
|
|
54
|
+
(l(!0), p(A, null, B(b(o), (a) => (l(), E(s, {
|
|
55
55
|
key: a.path
|
|
56
56
|
}, {
|
|
57
57
|
tab: h(() => [
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RouteLocationNormalized
|
|
1
|
+
import { RouteLocationNormalized } from "vue-router";
|
|
2
2
|
/**
|
|
3
3
|
* 路由处理
|
|
4
4
|
*/
|
|
5
5
|
export declare const useDitariRoute: () => {
|
|
6
6
|
getRoutes: (routeFiles: Record<string, () => Promise<unknown>>) => Promise<any>;
|
|
7
7
|
setMatched: (to: RouteLocationNormalized, from: RouteLocationNormalized) => void;
|
|
8
|
-
createMatcher: (routes: RouteRecordRaw[]) => void;
|
|
9
8
|
};
|
|
@@ -1,47 +1,44 @@
|
|
|
1
1
|
import { ref as f } from "vue";
|
|
2
2
|
import { createRouterMatcher as m } from "vue-router";
|
|
3
3
|
import { useBreadcrumbStore as v } from "../../store/modules/Breadcrumb.esm.js";
|
|
4
|
-
const
|
|
5
|
-
const { saveBreadcrumb:
|
|
4
|
+
const w = () => {
|
|
5
|
+
const { saveBreadcrumb: c } = v(), e = f(null);
|
|
6
6
|
return {
|
|
7
|
-
getRoutes: async (
|
|
8
|
-
const
|
|
9
|
-
for await (const r of Object.values(
|
|
10
|
-
const
|
|
11
|
-
|
|
7
|
+
getRoutes: async (u) => {
|
|
8
|
+
const o = [];
|
|
9
|
+
for await (const r of Object.values(u)) {
|
|
10
|
+
const a = await r();
|
|
11
|
+
o.push(...a.default);
|
|
12
12
|
}
|
|
13
|
-
return p(
|
|
13
|
+
return e.value = m(o, {}), p(o);
|
|
14
14
|
},
|
|
15
|
-
setMatched: (
|
|
16
|
-
var
|
|
15
|
+
setMatched: (u, o) => {
|
|
16
|
+
var a;
|
|
17
17
|
const r = f([]);
|
|
18
18
|
try {
|
|
19
|
-
const
|
|
20
|
-
r.value =
|
|
19
|
+
const n = ((a = e.value) == null ? void 0 : a.resolve(u, o).matched) ?? [];
|
|
20
|
+
r.value = n.reduce((h, l) => {
|
|
21
21
|
var i;
|
|
22
|
-
return
|
|
22
|
+
return h.some(
|
|
23
23
|
(d) => d.path === l.path
|
|
24
|
-
) ||
|
|
24
|
+
) || h.push({
|
|
25
25
|
path: l.path,
|
|
26
26
|
title: ((i = l.meta) == null ? void 0 : i.title) ?? "未设置标题"
|
|
27
|
-
}),
|
|
27
|
+
}), h;
|
|
28
28
|
}, []);
|
|
29
|
-
} catch (
|
|
30
|
-
console.log(
|
|
29
|
+
} catch (n) {
|
|
30
|
+
console.log(n), r.value = [];
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
createMatcher: (o) => {
|
|
35
|
-
e.value = m(o, {});
|
|
32
|
+
c(r.value);
|
|
36
33
|
}
|
|
37
34
|
};
|
|
38
35
|
};
|
|
39
|
-
function p(
|
|
40
|
-
const
|
|
41
|
-
for (const t of
|
|
42
|
-
t.path === "" ? t.path = e : t.path.startsWith("/") || (t.path = `${e}/${t.path}`), t.children && (
|
|
43
|
-
return
|
|
36
|
+
function p(c, e = "") {
|
|
37
|
+
const s = [];
|
|
38
|
+
for (const t of c)
|
|
39
|
+
t.path === "" ? t.path = e : t.path.startsWith("/") || (t.path = `${e}/${t.path}`), t.children && (s.push(...p(t.children, t.path)), delete t.children), s.push(t);
|
|
40
|
+
return s;
|
|
44
41
|
}
|
|
45
42
|
export {
|
|
46
|
-
|
|
43
|
+
w as useDitariRoute
|
|
47
44
|
};
|
package/package.json
CHANGED
|
@@ -72,7 +72,7 @@ const onClick = (key: string) => {
|
|
|
72
72
|
* @param targetKey
|
|
73
73
|
*/
|
|
74
74
|
const onClose = ($event: any, key: string) => {
|
|
75
|
-
const rs = navTabs.value.filter((item) => item.
|
|
75
|
+
const rs = navTabs.value.filter((item) => item.fullPath === key)[0];
|
|
76
76
|
//阻止冒泡
|
|
77
77
|
$event.stopPropagation();
|
|
78
78
|
// 删除标签
|
|
@@ -92,7 +92,8 @@ const onClose = ($event: any, key: string) => {
|
|
|
92
92
|
* 根据item和当前 navTabs 长度来判断是否要隐藏关闭标签按钮
|
|
93
93
|
*/
|
|
94
94
|
const closeStatus = (item: INavTab) => {
|
|
95
|
-
|
|
95
|
+
// 如果meta有设置keepOpen或者当前打开的标签只有一个的话不显示关闭按钮
|
|
96
|
+
return !item.meta?.keepOpen || navTabs.value.length === 1;
|
|
96
97
|
};
|
|
97
98
|
</script>
|
|
98
99
|
<script lang="ts">
|
package/src/hooks/route/index.ts
CHANGED
|
@@ -17,14 +17,6 @@ export const useDitariRoute = () => {
|
|
|
17
17
|
// 路由匹配器
|
|
18
18
|
const routerMatcher = ref<RouterMatcher | null>(null);
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* 创建匹配器
|
|
22
|
-
* @param routes 路由信息
|
|
23
|
-
*/
|
|
24
|
-
const createMatcher = (routes: RouteRecordRaw[]) => {
|
|
25
|
-
routerMatcher.value = createRouterMatcher(routes, {});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
20
|
const setMatched = (
|
|
29
21
|
to: RouteLocationNormalized,
|
|
30
22
|
from: RouteLocationNormalized
|
|
@@ -66,14 +58,15 @@ export const useDitariRoute = () => {
|
|
|
66
58
|
const routeModule: any = await routeFile();
|
|
67
59
|
routes.push(...routeModule.default);
|
|
68
60
|
}
|
|
69
|
-
//
|
|
61
|
+
// 创建路由匹配器
|
|
62
|
+
routerMatcher.value = createRouterMatcher(routes, {});
|
|
63
|
+
// 数组打平返回
|
|
70
64
|
return flattenRoutes(routes);
|
|
71
65
|
};
|
|
72
66
|
|
|
73
67
|
return {
|
|
74
68
|
getRoutes,
|
|
75
|
-
setMatched
|
|
76
|
-
createMatcher
|
|
69
|
+
setMatched
|
|
77
70
|
};
|
|
78
71
|
};
|
|
79
72
|
|