cosey 0.6.23 → 0.6.24

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/config/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export interface LayoutSlots {
44
44
  authWidget?: () => VNodeChild;
45
45
  userMenu?: () => VNodeChild;
46
46
  }
47
+ type FilterRouteHandler = (route: RouteRecordRaw) => RouteRecordRaw | void | boolean | undefined | null;
47
48
  export type CoseyOptions = {
48
49
  router?: CoseyRouterOptions & RouterConfig;
49
50
  persist?: PersistConfig;
@@ -51,7 +52,9 @@ export type CoseyOptions = {
51
52
  layout?: LayoutConfig;
52
53
  site?: SiteConfig;
53
54
  api?: ApiConfig;
54
- filterRoute?: (route: RouteRecordRaw) => RouteRecordRaw | void | boolean | undefined;
55
+ filterRoute?: {
56
+ hook: () => FilterRouteHandler;
57
+ } | FilterRouteHandler;
55
58
  defineAuthority?: (userInfo: Record<any, any>) => void | Promise<void>;
56
59
  components?: LayoutComponents;
57
60
  slots?: LayoutSlots;
@@ -69,3 +72,4 @@ export interface GlobalConfig {
69
72
  }
70
73
  export declare function provideGlobalConfig(app: App, options: CoseyOptions): void;
71
74
  export declare function useGlobalConfig(): GlobalConfig;
75
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.6.23",
3
+ "version": "0.6.24",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/store/user.js CHANGED
@@ -6,6 +6,7 @@ import { TOKEN_NAME } from '../constant.js';
6
6
  import { useGlobalConfig } from '../config/index.js';
7
7
  import { NOT_FOUND_ROUTE_NAME, NotFoundRoute } from '../router/not-found.js';
8
8
  import { usePersist } from '../hooks/usePersist.js';
9
+ import { isFunction } from '../utils/is.js';
9
10
  import { warningOnce } from '../utils/warning.js';
10
11
 
11
12
  const useUserStore = defineStore("cosey-user", () => {
@@ -18,6 +19,7 @@ const useUserStore = defineStore("cosey-user", () => {
18
19
  filterRoute,
19
20
  defineAuthority
20
21
  } = useGlobalConfig() || {};
22
+ const filterRouteHandler = isFunction(filterRoute) ? filterRoute : filterRoute.hook();
21
23
  if (!apiConfig?.login) {
22
24
  warningOnce(!!apiConfig?.login, 'The "login" api is required.');
23
25
  }
@@ -59,7 +61,7 @@ const useUserStore = defineStore("cosey-user", () => {
59
61
  };
60
62
  const mapRoute = (routes) => {
61
63
  return routes.map((route2) => {
62
- const result = filterRoute?.(route2);
64
+ const result = filterRouteHandler(route2);
63
65
  const node = result === true ? route2 : result;
64
66
  if (node && node.children && node.children.length) {
65
67
  node.children = mapRoute(node.children);