@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.
@@ -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(),p=_.useRouter(),c=S.useNavTabsStore(),v=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],v.save(l)}const m=a=>{if(a!==l.path){const t=n.value.filter(s=>s.path===a)[0];p.push({path:t.path,query:t.query,params:t.params})}},f=(a,t)=>{const s=n.value.filter(i=>i.path===t)[0];a.stopPropagation(),c.deleteTabs(t),p.push(n.value[n.value.length-1].fullPath),s.name&&v.deleteKeepAlive(s.name)},b=a=>{var t;return!((t=a.meta)!=null&&t.keepOpen)||n.value.length===0};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
+ "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"),M=()=>{const{saveBreadcrumb:u}=m.useBreadcrumbStore(),e=d.ref(null);return{getRoutes:async r=>{const a=[];for await(const o of Object.values(r)){const c=await o();a.push(...c.default)}return f(a)},setMatched:(r,a)=>{var c;const o=d.ref([]);try{const n=((c=e.value)==null?void 0:c.resolve(r,a).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=[]}u(o.value)},createMatcher:r=>{e.value=v.createRouterMatcher(r,{})}}};function f(u,e=""){const s=[];for(const t of u)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=M;
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, RouteRecordRaw } from "vue-router";
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 w, watchEffect as x, watch as A, resolveComponent as f, openBlock as l, createElementBlock as p, createVNode as _, withCtx as h, Fragment as B, renderList as E, unref as b, createBlock as P, createElementVNode as C, normalizeClass as R, toDisplayString as V, createCommentVNode as q } from "vue";
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 = w("");
17
- x(() => {
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(), A(
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.path === e)[0];
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 === 0;
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(B, null, E(b(o), (a) => (l(), P(s, {
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, RouteRecordRaw } from "vue-router";
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 y = () => {
5
- const { saveBreadcrumb: u } = v(), e = f(null);
4
+ const w = () => {
5
+ const { saveBreadcrumb: c } = v(), e = f(null);
6
6
  return {
7
- getRoutes: async (o) => {
8
- const s = [];
9
- for await (const r of Object.values(o)) {
10
- const c = await r();
11
- s.push(...c.default);
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(s);
13
+ return e.value = m(o, {}), p(o);
14
14
  },
15
- setMatched: (o, s) => {
16
- var c;
15
+ setMatched: (u, o) => {
16
+ var a;
17
17
  const r = f([]);
18
18
  try {
19
- const h = ((c = e.value) == null ? void 0 : c.resolve(o, s).matched) ?? [];
20
- r.value = h.reduce((n, l) => {
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 n.some(
22
+ return h.some(
23
23
  (d) => d.path === l.path
24
- ) || n.push({
24
+ ) || h.push({
25
25
  path: l.path,
26
26
  title: ((i = l.meta) == null ? void 0 : i.title) ?? "未设置标题"
27
- }), n;
27
+ }), h;
28
28
  }, []);
29
- } catch (h) {
30
- console.log(h), r.value = [];
29
+ } catch (n) {
30
+ console.log(n), r.value = [];
31
31
  }
32
- u(r.value);
33
- },
34
- createMatcher: (o) => {
35
- e.value = m(o, {});
32
+ c(r.value);
36
33
  }
37
34
  };
38
35
  };
39
- function p(u, e = "") {
40
- const a = [];
41
- for (const t of u)
42
- t.path === "" ? t.path = e : t.path.startsWith("/") || (t.path = `${e}/${t.path}`), t.children && (a.push(...p(t.children, t.path)), delete t.children), a.push(t);
43
- return a;
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
- y as useDitariRoute
43
+ w as useDitariRoute
47
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -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.path === key)[0];
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
- return !item.meta?.keepOpen || navTabs.value.length === 0;
95
+ // 如果meta有设置keepOpen或者当前打开的标签只有一个的话不显示关闭按钮
96
+ return !item.meta?.keepOpen || navTabs.value.length === 1;
96
97
  };
97
98
  </script>
98
99
  <script lang="ts">
@@ -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