@skyfox2000/microbase 1.0.3 → 1.0.4

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/lib/index.d.ts CHANGED
@@ -111,16 +111,6 @@ export declare enum AppSource {
111
111
  */
112
112
  export declare const combineParams: (...args: ReqParams[]) => ReqParams;
113
113
 
114
- /**
115
- * 路由权限判断
116
- * @param route 指定路由
117
- * @param isLogin 是否已登录
118
- * @param userRoles 用户角色
119
- * @param userPermits 用户权限
120
- * @returns 权限判断结果
121
- */
122
- export declare const hasPermission: (route: RouteRecord, isLogin: boolean, userRoles: string[], userPermits: string[]) => boolean;
123
-
124
114
  /**
125
115
  * 启动配置信息
126
116
  * - 网站配置信息
@@ -1,65 +1,49 @@
1
- import { deepClone as d } from "@skyfox2000/fapi";
2
- import { ref as i, markRaw as A, h as m } from "vue";
3
- import { createRouter as M, createWebHashHistory as _ } from "vue-router";
4
- var w = /* @__PURE__ */ ((e) => (e.Market = "Market", e.Manual = "Manual", e))(w || {}), D = /* @__PURE__ */ ((e) => (e.App = "App", e.MenuApp = "MenuApp", e.Link = "Link", e.Iframe = "Iframe", e))(D || {}), I = /* @__PURE__ */ ((e) => (e[e.LEFT = 1] = "LEFT", e[e.RIGHT = 2] = "RIGHT", e))(I || {});
5
- const l = (e, t) => {
1
+ import { deepClone as u } from "@skyfox2000/fapi";
2
+ import { ref as o, markRaw as p, h as a } from "vue";
3
+ import { createRouter as m, createWebHashHistory as d } from "vue-router";
4
+ var v = /* @__PURE__ */ ((e) => (e.Market = "Market", e.Manual = "Manual", e))(v || {}), y = /* @__PURE__ */ ((e) => (e.App = "App", e.MenuApp = "MenuApp", e.Link = "Link", e.Iframe = "Iframe", e))(y || {}), A = /* @__PURE__ */ ((e) => (e[e.LEFT = 1] = "LEFT", e[e.RIGHT = 2] = "RIGHT", e))(A || {});
5
+ const r = (e, t) => {
6
6
  if (!(!t || !e))
7
7
  for (const n in t)
8
- n in e && typeof e[n] == "object" && typeof t[n] == "object" && !Array.isArray(t[n]) ? l(e[n], t[n]) : e[n] = d(t[n]);
9
- }, C = (...e) => {
8
+ n in e && typeof e[n] == "object" && typeof t[n] == "object" && !Array.isArray(t[n]) ? r(e[n], t[n]) : e[n] = u(t[n]);
9
+ }, E = (...e) => {
10
10
  const t = {};
11
11
  for (const n of e)
12
- n != null && n.Option && !t.Option && (t.Option = {}), l(t.Option, n == null ? void 0 : n.Option);
12
+ n != null && n.Option && !t.Option && (t.Option = {}), r(t.Option, n == null ? void 0 : n.Option);
13
13
  for (const n of e)
14
- n != null && n.Query && !t.Query && (t.Query = {}), l(t.Query, n == null ? void 0 : n.Query);
14
+ n != null && n.Query && !t.Query && (t.Query = {}), r(t.Query, n == null ? void 0 : n.Query);
15
15
  for (const n of e)
16
- t.Data = n != null && n.Data ? d(n.Data) : {};
16
+ t.Data = n != null && n.Data ? u(n.Data) : {};
17
17
  return t;
18
- }, N = () => !!window.__MICRO_APP_ENVIRONMENT__, U = () => !!window.__MICRO_APP_BASE_APPLICATION__, u = i(), P = i(), E = i(), b = () => {
18
+ }, L = () => !!window.__MICRO_APP_ENVIRONMENT__, O = () => !!window.__MICRO_APP_BASE_APPLICATION__, i = o(), M = o(), _ = o(), k = () => {
19
19
  const e = window.microApp.getData(
20
20
  !0
21
21
  );
22
- u.value = e.MainApis, P.value = e.MainEvents, E.value = e.pageUrl;
23
- }, O = [
22
+ i.value = e.MainApis, M.value = e.MainEvents, _.value = e.pageUrl;
23
+ }, h = [
24
24
  {
25
25
  path: "/:page(.*)",
26
26
  name: "默认页面",
27
27
  component: () => import("./assets/modules/index-DQ8DfP_z.js")
28
28
  }
29
- ], v = M({
30
- history: _(void 0),
31
- routes: O
32
- }), Q = (e, t, n, s) => {
33
- var c, f;
34
- const o = ((c = e.meta) == null ? void 0 : c.roles) ?? [], r = (f = e.meta) == null ? void 0 : f.permission;
35
- if (!t)
36
- return o.length === 0 && !r;
37
- if (t && (n.length > 0 || s.length > 0)) {
38
- if (o.length === 0 && !r)
39
- return !0;
40
- if (o.length && !r)
41
- return o.some((a) => n.includes(a));
42
- if (!o.length && r)
43
- return s.includes(r);
44
- if (o.length && r)
45
- return o.some((a) => n.includes(a)) && s.includes(r);
46
- }
47
- return !1;
48
- };
49
- v.afterEach((e) => {
50
- if (u.value) {
51
- const { mainAppPush: t } = u.value;
29
+ ], l = m({
30
+ history: d(void 0),
31
+ routes: h
32
+ });
33
+ l.afterEach((e) => {
34
+ if (i.value) {
35
+ const { mainAppPush: t } = i.value;
52
36
  t && t(e.hash);
53
37
  }
54
38
  });
55
- const H = i({}), h = i(""), y = i({}), p = i(null), k = async (e) => {
56
- h.value = e, e.startsWith("/") && (e = e.substring(1));
57
- const t = y.value[`./views/${e}.vue`];
39
+ const T = o({}), c = o(""), f = o({}), s = o(null), w = async (e) => {
40
+ c.value = e, e.startsWith("/") && (e = e.substring(1));
41
+ const t = f.value[`./views/${e}.vue`];
58
42
  if (t) {
59
43
  const n = await t();
60
- p.value = A(n.default), v.replace("/" + e);
44
+ s.value = p(n.default), l.replace("/" + e);
61
45
  } else
62
- console.error("加载微模块" + e + "失败"), p.value = m(
46
+ console.error("加载微模块" + e + "失败"), s.value = a(
63
47
  "div",
64
48
  {
65
49
  style: {
@@ -72,32 +56,31 @@ const H = i({}), h = i(""), y = i({}), p = i(null), k = async (e) => {
72
56
  // 使文本垂直居中
73
57
  }
74
58
  },
75
- [m("div", "404 NOT FOUND")]
59
+ [a("div", "404 NOT FOUND")]
76
60
  );
77
- }, R = (e) => {
78
- y.value = e, window.microApp && window.microApp.addDataListener(async (t) => {
79
- if (t.pageUrl === h.value) return;
61
+ }, C = (e) => {
62
+ f.value = e, window.microApp && window.microApp.addDataListener(async (t) => {
63
+ if (t.pageUrl === c.value) return;
80
64
  let n = t.pageUrl;
81
- k(n);
65
+ w(n);
82
66
  }, !0);
83
67
  };
84
68
  export {
85
- D as AppAction,
86
- w as AppSource,
87
- v as LoaderRouter,
88
- I as RowOperate,
89
- C as combineParams,
90
- Q as hasPermission,
91
- b as initMainAppData,
92
- R as initModuleLoader,
93
- U as isBaseMicroApp,
94
- N as isMicroApp,
95
- k as loadModule,
96
- u as mainAppApis,
97
- P as mainAppEvents,
98
- E as mainPageUrl,
99
- H as moduleAttrs,
100
- p as moduleCom,
101
- y as moduleRecords,
102
- h as moduleUrl
69
+ y as AppAction,
70
+ v as AppSource,
71
+ l as LoaderRouter,
72
+ A as RowOperate,
73
+ E as combineParams,
74
+ k as initMainAppData,
75
+ C as initModuleLoader,
76
+ O as isBaseMicroApp,
77
+ L as isMicroApp,
78
+ w as loadModule,
79
+ i as mainAppApis,
80
+ M as mainAppEvents,
81
+ _ as mainPageUrl,
82
+ T as moduleAttrs,
83
+ s as moduleCom,
84
+ f as moduleRecords,
85
+ c as moduleUrl
103
86
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyfox2000/microbase",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "微前端通用功能与数据类型定义",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -88,58 +88,6 @@ const router: Router = createRouter({
88
88
  routes: routes
89
89
  });
90
90
 
91
- /**
92
- * 路由权限判断
93
- * @param route 指定路由
94
- * @param isLogin 是否已登录
95
- * @param userRoles 用户角色
96
- * @param userPermits 用户权限
97
- * @returns 权限判断结果
98
- */
99
- export const hasPermission = (
100
- route: RouteRecord,
101
- isLogin: boolean,
102
- userRoles: string[],
103
- userPermits: string[]
104
- ): boolean => {
105
- const roles = route.meta?.roles ?? [];
106
- const permission = route.meta?.permission;
107
-
108
- // 如果用户未登录,且路由没有角色和权限要求,则允许访问
109
- if (!isLogin) {
110
- return roles.length === 0 && !permission;
111
- }
112
-
113
- // 如果用户已登录或有角色和权限信息
114
- if (isLogin && (userRoles.length > 0 || userPermits.length > 0)) {
115
- // 没有角色码和权限码,都可以访问
116
- if (roles.length === 0 && !permission) {
117
- return true;
118
- }
119
-
120
- // 路由有角色码无权限码,符合任何一个角色都可以访问
121
- if (roles.length && !permission) {
122
- return roles.some((role) => userRoles.includes(role));
123
- }
124
-
125
- // 路由无角色码有权限码,符合权限码即可访问
126
- if (!roles.length && permission) {
127
- return userPermits.includes(permission);
128
- }
129
-
130
- // 路由同时有角色码和权限码,必须用户角色和权限同时满足才可访问
131
- if (roles.length && permission) {
132
- return (
133
- roles.some((role) => userRoles.includes(role)) &&
134
- userPermits.includes(permission)
135
- );
136
- }
137
- }
138
-
139
- // 默认返回 false,即无匹配条件时不允许访问
140
- return false;
141
- };
142
-
143
91
  /**
144
92
  * 子应用更新主应用路由
145
93
  */