@ditari/bsui 1.0.39 → 1.0.40

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.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,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.40",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -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