@skyfox2000/microbase 1.0.3 → 1.0.5
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 +1 -11
- package/lib/microbase.es.js +47 -64
- package/package.json +1 -1
- package/src/router/loader-router.ts +0 -52
- package/src/utils/data.ts +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -109,17 +109,7 @@ export declare enum AppSource {
|
|
|
109
109
|
/**
|
|
110
110
|
* 深度合并QOD参数
|
|
111
111
|
*/
|
|
112
|
-
export declare const combineParams: (...args: ReqParams[]) => ReqParams;
|
|
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;
|
|
112
|
+
export declare const combineParams: (...args: (ReqParams | undefined)[]) => ReqParams;
|
|
123
113
|
|
|
124
114
|
/**
|
|
125
115
|
* 启动配置信息
|
package/lib/microbase.es.js
CHANGED
|
@@ -1,65 +1,49 @@
|
|
|
1
|
-
import { deepClone as
|
|
2
|
-
import { ref as
|
|
3
|
-
import { createRouter as
|
|
4
|
-
var
|
|
5
|
-
const
|
|
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]) ?
|
|
9
|
-
},
|
|
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 = {}),
|
|
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 = {}),
|
|
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 ?
|
|
16
|
+
t.Data = n != null && n.Data ? u(n.Data) : {};
|
|
17
17
|
return t;
|
|
18
|
-
},
|
|
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
|
-
|
|
23
|
-
},
|
|
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
|
-
],
|
|
30
|
-
history:
|
|
31
|
-
routes:
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
56
|
-
|
|
57
|
-
const t =
|
|
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
|
-
|
|
44
|
+
s.value = p(n.default), l.replace("/" + e);
|
|
61
45
|
} else
|
|
62
|
-
console.error("加载微模块" + e + "失败"),
|
|
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
|
-
[
|
|
59
|
+
[a("div", "404 NOT FOUND")]
|
|
76
60
|
);
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
if (t.pageUrl ===
|
|
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
|
-
|
|
65
|
+
w(n);
|
|
82
66
|
}, !0);
|
|
83
67
|
};
|
|
84
68
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
@@ -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
|
*/
|
package/src/utils/data.ts
CHANGED