@ditari/bsui 1.0.70 → 1.0.72

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"),m=require("vue-router"),N=require("@ant-design/icons-vue"),q=require("pinia"),y=require("../../store/modules/NavTab.cjs.js"),S=require("../../store/modules/KeepAlive.cjs.js"),g=require("../../store/modules/Menu.cjs.js"),T=require("../theme/index.cjs.js"),B=e.createElementVNode("div",{class:"tab-dividers"},null,-1),K={key:0,class:"tab-close"},E={name:"DNavTabs"},V=e.defineComponent({...E,setup(x){const l=m.useRoute(),p=m.useRouter(),c=y.useNavTabsStore(),v=S.useKeepAliveStore(),f=g.useMenuStore(),_=`${T.prefixName}-nav`,n=e.computed(()=>c.getList),{selectedMenuKeys:u}=q.storeToRefs(f),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 h=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})}},b=(a,t)=>{const s=n.value.find(i=>i.fullPath===t);a.stopPropagation(),c.deleteTabs(t),p.push(n.value[n.value.length-1].fullPath),s.name&&v.deleteKeepAlive(s.name)},C=a=>{var t;return(t=a.meta)!=null&&t.keepOpen?!1: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",{class:e.normalizeClass(_)},[e.createVNode(i,{activeKey:r.value,"onUpdate:activeKey":t[0]||(t[0]=o=>r.value=o),type:"card",onTabClick:h},{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(()=>[B,e.createElementVNode("div",{class:e.normalizeClass(["tab-item",{active:r.value===o.path}])},e.toDisplayString(o.meta.title),3),C(o)?(e.openBlock(),e.createElementBlock("div",K,[e.createVNode(e.unref(N.CloseOutlined),{onClick:k=>b(k,o.fullPath)},null,8,["onClick"])])):e.createCommentVNode("",!0)]),_:2},1024))),128))]),_:1},8,["activeKey"])])}}});exports.default=V;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),f=require("vue-router"),N=require("@ant-design/icons-vue"),q=require("pinia"),y=require("../../store/modules/NavTab.cjs.js"),S=require("../../store/modules/KeepAlive.cjs.js"),g=require("../../store/modules/Menu.cjs.js"),T=require("../theme/index.cjs.js"),B=e.createElementVNode("div",{class:"tab-dividers"},null,-1),K={key:0,class:"tab-close"},P={name:"DNavTabs"},E=e.defineComponent({...P,setup(V){const l=f.useRoute(),p=f.useRouter(),u=y.useNavTabsStore(),v=S.useKeepAliveStore(),m=g.useMenuStore(),h=`${T.prefixName}-nav`,n=e.computed(()=>u.getList),{selectedMenuKeys:c}=q.storeToRefs(m),r=e.ref("");e.watchEffect(()=>{r.value=c.value.length>0?c.value[0]:""}),d(),e.watch(()=>l.path,()=>{d()});function d(){u.save(l),c.value=[l.path],v.save(l)}const _=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,fullPath:t.fullPath})}},b=(a,t)=>{const s=n.value.find(i=>i.fullPath===t);a.stopPropagation(),u.deleteTabs(t),p.push(n.value[n.value.length-1].fullPath),s.name&&v.deleteKeepAlive(s.name)},C=a=>{var t;return(t=a.meta)!=null&&t.keepOpen?!1: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",{class:e.normalizeClass(h)},[e.createVNode(i,{activeKey:r.value,"onUpdate:activeKey":t[0]||(t[0]=o=>r.value=o),type:"card",onTabClick:_},{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(()=>[B,e.createElementVNode("div",{class:e.normalizeClass(["tab-item",{active:r.value===o.path}])},e.toDisplayString(o.meta.title),3),C(o)?(e.openBlock(),e.createElementBlock("div",K,[e.createVNode(e.unref(N.CloseOutlined),{onClick:k=>b(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 a=require("pinia"),l=require("../types.cjs.js"),r=a.defineStore(l.NAV_TAB_ID,{state:()=>({list:[],activeKey:""}),getters:{getList:t=>t.list,getActiveKey:t=>t.activeKey},actions:{setActiveKey(t){this.activeKey=t},save(t){if(!t.meta.title||this.list.some(i=>i.fullPath===t.fullPath))return;const e={path:t.path,fullPath:t.fullPath,query:t.query,params:t.params,meta:t.meta,name:t.name||""};this.list.push(e)},deleteTabs(t){this.list.splice(this.list.findIndex(s=>s.fullPath===t),1)},setNavTitle(t,s){for(let e=0;e<this.list.length;e++)if(this.list[e].fullPath===s){this.list[e].meta.title=t;break}}},persist:!0});exports.useNavTabsStore=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("pinia"),h=require("../types.cjs.js"),n=l.defineStore(h.NAV_TAB_ID,{state:()=>({list:[],activeKey:""}),getters:{getList:t=>t.list,getActiveKey:t=>t.activeKey},actions:{setActiveKey(t){this.activeKey=t},save(t){var i;if(!((i=t.meta)!=null&&i.title))return;if(this.list.some(e=>e.path===t.path)){this.list.forEach(e=>{e.path===t.path&&(e.query=t.query,e.fullPath=t.fullPath,e.params=t.params,e.meta=t.meta,e.name=t.name||"")});return}const a={path:t.path,fullPath:t.fullPath,query:t.query,params:t.params,meta:t.meta,name:t.name||""};this.list.push(a)},deleteTabs(t){this.list.splice(this.list.findIndex(s=>s.fullPath===t),1)},setNavTitle(t,s){for(let a=0;a<this.list.length;a++)if(this.list[a].fullPath===s){this.list[a].meta.title=t;break}}},persist:!0});exports.useNavTabsStore=n;
@@ -1,4 +1,4 @@
1
- import { defineComponent as x, computed as P, ref as w, watchEffect as A, watch as B, resolveComponent as d, openBlock as l, createElementBlock as p, normalizeClass as _, createVNode as h, withCtx as b, Fragment as E, renderList as R, unref as C, createBlock as V, createElementVNode as k, toDisplayString as q, createCommentVNode as D } from "vue";
1
+ import { defineComponent as P, computed as x, ref as w, watchEffect as A, watch as B, resolveComponent as d, openBlock as r, createElementBlock as p, normalizeClass as h, createVNode as _, withCtx as b, Fragment as E, renderList as R, unref as C, createBlock as V, createElementVNode as k, toDisplayString as q, createCommentVNode as D } from "vue";
2
2
  import { useRoute as L, useRouter as M } from "vue-router";
3
3
  import { CloseOutlined as O } from "@ant-design/icons-vue";
4
4
  import { storeToRefs as z } from "pinia";
@@ -11,12 +11,12 @@ const G = /* @__PURE__ */ k("div", { class: "tab-dividers" }, null, -1), H = {
11
11
  class: "tab-close"
12
12
  }, I = {
13
13
  name: "DNavTabs"
14
- }, oe = /* @__PURE__ */ x({
14
+ }, oe = /* @__PURE__ */ P({
15
15
  ...I,
16
16
  setup(J) {
17
- const n = L(), m = M(), c = F(), v = U(), y = $(), N = `${j}-nav`, o = P(() => c.getList), { selectedMenuKeys: u } = z(y), r = w("");
17
+ const n = L(), m = M(), u = F(), v = U(), y = $(), N = `${j}-nav`, o = x(() => u.getList), { selectedMenuKeys: c } = z(y), l = w("");
18
18
  A(() => {
19
- r.value = u.value.length > 0 ? u.value[0] : "";
19
+ l.value = c.value.length > 0 ? c.value[0] : "";
20
20
  }), f(), B(
21
21
  () => n.path,
22
22
  () => {
@@ -24,7 +24,7 @@ const G = /* @__PURE__ */ k("div", { class: "tab-dividers" }, null, -1), H = {
24
24
  }
25
25
  );
26
26
  function f() {
27
- c.save(n), u.value = [n.path], v.save(n);
27
+ u.save(n), c.value = [n.path], v.save(n);
28
28
  }
29
29
  const S = (t) => {
30
30
  if (t !== n.path) {
@@ -32,38 +32,39 @@ const G = /* @__PURE__ */ k("div", { class: "tab-dividers" }, null, -1), H = {
32
32
  m.push({
33
33
  path: e.path,
34
34
  query: e.query,
35
- params: e.params
35
+ params: e.params,
36
+ fullPath: e.fullPath
36
37
  });
37
38
  }
38
39
  }, g = (t, e) => {
39
40
  const s = o.value.find((i) => i.fullPath === e);
40
- t.stopPropagation(), c.deleteTabs(e), m.push(o.value[o.value.length - 1].fullPath), s.name && v.deleteKeepAlive(s.name);
41
+ t.stopPropagation(), u.deleteTabs(e), m.push(o.value[o.value.length - 1].fullPath), s.name && v.deleteKeepAlive(s.name);
41
42
  }, K = (t) => {
42
43
  var e;
43
44
  return (e = t.meta) != null && e.keepOpen ? !1 : o.value.length !== 1;
44
45
  };
45
46
  return (t, e) => {
46
47
  const s = d("a-tab-pane"), i = d("a-tabs");
47
- return l(), p("div", {
48
- class: _(N)
48
+ return r(), p("div", {
49
+ class: h(N)
49
50
  }, [
50
- h(i, {
51
- activeKey: r.value,
52
- "onUpdate:activeKey": e[0] || (e[0] = (a) => r.value = a),
51
+ _(i, {
52
+ activeKey: l.value,
53
+ "onUpdate:activeKey": e[0] || (e[0] = (a) => l.value = a),
53
54
  type: "card",
54
55
  onTabClick: S
55
56
  }, {
56
57
  default: b(() => [
57
- (l(!0), p(E, null, R(C(o), (a) => (l(), V(s, {
58
+ (r(!0), p(E, null, R(C(o), (a) => (r(), V(s, {
58
59
  key: a.path
59
60
  }, {
60
61
  tab: b(() => [
61
62
  G,
62
63
  k("div", {
63
- class: _(["tab-item", { active: r.value === a.path }])
64
+ class: h(["tab-item", { active: l.value === a.path }])
64
65
  }, q(a.meta.title), 3),
65
- K(a) ? (l(), p("div", H, [
66
- h(C(O), {
66
+ K(a) ? (r(), p("div", H, [
67
+ _(C(O), {
67
68
  onClick: (T) => g(T, a.fullPath)
68
69
  }, null, 8, ["onClick"])
69
70
  ])) : D("", !0)
@@ -1,6 +1,6 @@
1
- import { defineStore as a } from "pinia";
2
- import { NAV_TAB_ID as l } from "../types.esm.js";
3
- const f = a(l, {
1
+ import { defineStore as l } from "pinia";
2
+ import { NAV_TAB_ID as h } from "../types.esm.js";
3
+ const n = l(h, {
4
4
  state: () => ({
5
5
  // 多标签列表
6
6
  list: [],
@@ -24,9 +24,16 @@ const f = a(l, {
24
24
  * @param route
25
25
  */
26
26
  save(t) {
27
- if (!t.meta.title || this.list.some((s) => s.fullPath === t.fullPath))
27
+ var i;
28
+ if (!((i = t.meta) != null && i.title))
28
29
  return;
29
- const e = {
30
+ if (this.list.some((a) => a.path === t.path)) {
31
+ this.list.forEach((a) => {
32
+ a.path === t.path && (a.query = t.query, a.fullPath = t.fullPath, a.params = t.params, a.meta = t.meta, a.name = t.name || "");
33
+ });
34
+ return;
35
+ }
36
+ const s = {
30
37
  path: t.path,
31
38
  fullPath: t.fullPath,
32
39
  query: t.query,
@@ -34,7 +41,7 @@ const f = a(l, {
34
41
  meta: t.meta,
35
42
  name: t.name || ""
36
43
  };
37
- this.list.push(e);
44
+ this.list.push(s);
38
45
  },
39
46
  /**
40
47
  * 删除标签
@@ -42,7 +49,7 @@ const f = a(l, {
42
49
  */
43
50
  deleteTabs(t) {
44
51
  this.list.splice(
45
- this.list.findIndex((i) => i.fullPath === t),
52
+ this.list.findIndex((e) => e.fullPath === t),
46
53
  1
47
54
  );
48
55
  },
@@ -51,10 +58,10 @@ const f = a(l, {
51
58
  * @param title 标题
52
59
  * @param path url
53
60
  */
54
- setNavTitle(t, i) {
55
- for (let e = 0; e < this.list.length; e++)
56
- if (this.list[e].fullPath === i) {
57
- this.list[e].meta.title = t;
61
+ setNavTitle(t, e) {
62
+ for (let s = 0; s < this.list.length; s++)
63
+ if (this.list[s].fullPath === e) {
64
+ this.list[s].meta.title = t;
58
65
  break;
59
66
  }
60
67
  }
@@ -62,5 +69,5 @@ const f = a(l, {
62
69
  persist: !0
63
70
  });
64
71
  export {
65
- f as useNavTabsStore
72
+ n as useNavTabsStore
66
73
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -66,8 +66,9 @@ const onClick = (key: string) => {
66
66
  router.push({
67
67
  path: rs.path,
68
68
  query: rs.query,
69
- params: rs.params
70
- });
69
+ params: rs.params,
70
+ fullPath: rs.fullPath
71
+ } as any);
71
72
  }
72
73
  };
73
74
 
@@ -4,7 +4,6 @@ import {
4
4
  RouteLocationMatched,
5
5
  RouteLocationNormalized,
6
6
  RouteRecord,
7
- RouteRecordRaw,
8
7
  RouterMatcher
9
8
  } from "vue-router";
10
9
  import { useBreadcrumbStore } from "../../store/modules/Breadcrumb";
@@ -50,14 +50,22 @@ export const useNavTabsStore = defineStore(NAV_TAB_ID, {
50
50
  * @param route
51
51
  */
52
52
  save(route: RouteLocationNormalized) {
53
- if (!route.meta.title) {
53
+ if (!route.meta?.title) {
54
54
  // 没有设置title,则不进入缓存
55
55
  return;
56
56
  }
57
- const flag = this.list.some(
58
- (item: INavTab) => item.fullPath === route.fullPath
59
- );
57
+ const flag = this.list.some((item: INavTab) => item.path === route.path);
60
58
  if (flag) {
59
+ // 如果有相同的路由变化,更新对应的参数信息
60
+ this.list.forEach((item: INavTab) => {
61
+ if (item.path === route.path) {
62
+ item.query = route.query;
63
+ item.fullPath = route.fullPath;
64
+ item.params = route.params;
65
+ item.meta = route.meta;
66
+ item.name = <string>route.name || "";
67
+ }
68
+ });
61
69
  return;
62
70
  }
63
71
  const data: INavTab = {
package/src/tsconfig.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "moduleResolution": "Node",
11
11
  "allowJs": true,
12
12
  "lib": ["esnext", "dom"],
13
- "types": ["pinia-plugin-persist"],
13
+ "types": [],
14
14
  "paths": {}
15
15
  },
16
16
  "include": []