@skyfox2000/microbase 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # 〇克微前端通用功能与数据类型定义
1
+ # 微前端通用功能与数据类型定义
2
2
 
3
3
  ## 项目简介
4
4
 
@@ -0,0 +1,12 @@
1
+ import { defineComponent as r, createBlock as t, createCommentVNode as n, unref as e, openBlock as m, resolveDynamicComponent as u, normalizeProps as p, mergeProps as a } from "vue";
2
+ import { loadModule as l, LoaderRouter as c, moduleCom as o, moduleAttrs as i } from "../../microbase.es.js";
3
+ import "@skyfox2000/fapi";
4
+ const x = /* @__PURE__ */ r({
5
+ __name: "index",
6
+ setup(d) {
7
+ return window.microApp || l(c.currentRoute.value.path), (s, _) => e(o) != null ? (m(), t(u(e(o)), p(a({ key: 0 }, e(i))), null, 16)) : n("", !0);
8
+ }
9
+ });
10
+ export {
11
+ x as default
12
+ };
package/lib/index.d.ts CHANGED
@@ -5,7 +5,11 @@ import { Router } from 'vue-router';
5
5
  import { RouteRecordRaw } from 'vue-router';
6
6
 
7
7
  /**
8
- * 应用动作: App | Open | Iframe
8
+ * 应用动作:
9
+ * - App 应用模式加载
10
+ * - MenuApp 托管应用模式加载
11
+ * - Link 链接,弹出窗口打开
12
+ * - Iframe Iframe内嵌方式打开
9
13
  */
10
14
  export declare enum AppAction {
11
15
  /**
@@ -24,7 +28,7 @@ export declare enum AppAction {
24
28
  /**
25
29
  * Iframe内嵌方式打开
26
30
  */
27
- "Iframe" = "Iframe"
31
+ "Iframe" = "Iframe",
28
32
  }
29
33
 
30
34
  /**
@@ -34,38 +38,38 @@ export declare interface AppInfo {
34
38
  /**
35
39
  * 主键
36
40
  */
37
- Id: string;
41
+ readonly Id: string;
38
42
  /**
39
43
  * 名称
40
44
  */
41
- Name: string;
45
+ readonly Name: string;
42
46
  /**
43
47
  * 唯一编码
44
48
  * - 路由前缀地址
45
49
  */
46
- AppCode: string;
50
+ readonly AppCode: string;
47
51
  /**
48
52
  * 版本号
49
53
  */
50
- Version: string;
54
+ readonly Version: string;
51
55
  /**
52
56
  * 图标
53
57
  */
54
- Icon: string;
58
+ readonly Icon: string;
55
59
  /**
56
60
  * 来源: Market | Manual
57
61
  */
58
- Source: AppSource;
62
+ readonly Source: AppSource;
59
63
  /**
60
64
  * 动作: App | MenuApp | Open | Iframe
61
65
  */
62
- Action: AppAction;
66
+ readonly Action: AppAction;
63
67
  /**
64
68
  * 应用加载地址
65
69
  * - http开头地址
66
70
  * - SERVER_HOST配置
67
71
  */
68
- Host: string;
72
+ readonly Host: string;
69
73
  /**
70
74
  * 默认页面
71
75
  */
@@ -84,7 +88,7 @@ export declare interface AppInfo {
84
88
  * - 启用 true 1
85
89
  * - 停用 false 0
86
90
  */
87
- Enabled: boolean | number;
91
+ readonly Enabled: boolean | number;
88
92
  [key: string]: any;
89
93
  }
90
94
 
@@ -99,7 +103,7 @@ export declare enum AppSource {
99
103
  /**
100
104
  * 手动输入
101
105
  */
102
- "Manual" = "Manual"
106
+ "Manual" = "Manual",
103
107
  }
104
108
 
105
109
  /**
@@ -126,15 +130,15 @@ export declare interface HostInfo {
126
130
  /**
127
131
  * 网站地址,配置码
128
132
  */
129
- Host: string;
133
+ readonly Host: string;
130
134
  /**
131
135
  * 短名称
132
136
  */
133
- Title: string;
137
+ readonly Title: string;
134
138
  /**
135
139
  * 网站全名称
136
140
  */
137
- FullTitle?: string;
141
+ readonly FullTitle?: string;
138
142
  /**
139
143
  * Logo图标地址
140
144
  */
@@ -154,21 +158,21 @@ export declare interface HostInfo {
154
158
  /**
155
159
  * 接口域名地址
156
160
  */
157
- API_HOST?: {
161
+ readonly API_HOST?: {
158
162
  [key: string]: string;
159
163
  } | null;
160
164
  /**
161
165
  * 网站服务器地址
162
166
  */
163
- SERVER_HOST?: Record<string, string>;
167
+ readonly SERVER_HOST?: Record<string, string>;
164
168
  /**
165
169
  * 扩展属性配置
166
170
  */
167
- ExtraPropLines?: Record<string, any>[];
171
+ readonly ExtraPropLines?: Record<string, any>[];
168
172
  /**
169
173
  * 扩展属性
170
174
  */
171
- ExtraProps?: {
175
+ readonly ExtraProps?: {
172
176
  [key: string]: string;
173
177
  };
174
178
  [key: string]: any;
@@ -224,11 +228,11 @@ export declare interface LoginInfo {
224
228
  /**
225
229
  * 登录获取的授权token
226
230
  */
227
- token?: string;
231
+ readonly token?: string;
228
232
  /**
229
233
  * 登录获取的刷新token
230
234
  */
231
- refreshToken?: string;
235
+ readonly refreshToken?: string;
232
236
  }
233
237
 
234
238
  export declare const mainAppApis: Ref<MainOpenApis | undefined, MainOpenApis | undefined>;
@@ -390,7 +394,7 @@ export declare type RouteRecord = RouteRecordRaw & {
390
394
  */
391
395
  export declare enum RowOperate {
392
396
  LEFT = 1,
393
- RIGHT = 2
397
+ RIGHT = 2,
394
398
  }
395
399
 
396
400
  /**
@@ -400,27 +404,27 @@ export declare interface SettingInfo {
400
404
  /**
401
405
  * 全屏显示
402
406
  */
403
- readonly fullscreen: boolean;
407
+ fullscreen: boolean;
404
408
  /**
405
409
  * 主菜单区折叠
406
410
  */
407
- readonly menuCollapse: boolean;
411
+ menuCollapse: boolean;
408
412
  /**
409
413
  * 表格行操作区位置
410
414
  */
411
- readonly rowOperate: RowOperate;
415
+ rowOperate: RowOperate;
412
416
  /**
413
417
  * 使用语言
414
418
  */
415
- readonly language?: string;
419
+ language?: string;
416
420
  /**
417
421
  * 主题模式
418
422
  */
419
- readonly theme?: string;
423
+ theme?: string;
420
424
  /**
421
425
  * 主题颜色
422
426
  */
423
- readonly themeColor?: string;
427
+ themeColor?: string;
424
428
  }
425
429
 
426
430
  /**
@@ -430,23 +434,23 @@ export declare interface UserInfo {
430
434
  /**
431
435
  * 主键
432
436
  */
433
- Id: string;
437
+ readonly Id: string;
434
438
  /**
435
439
  * 名称
436
440
  */
437
- Name: string;
441
+ readonly Name: string;
438
442
  /**
439
443
  * 用户码
440
444
  */
441
- Code: string;
445
+ readonly Code: string;
442
446
  /**
443
- * 角色
447
+ * 租户Id
444
448
  */
445
- Roles: string[];
449
+ readonly TenantId: string;
446
450
  /**
447
- * 权限
451
+ * 用户级别
448
452
  */
449
- Permissions: string[];
453
+ readonly UserLevel: string;
450
454
  }
451
455
 
452
456
  export { }
@@ -1,71 +1,65 @@
1
- import { ref as o, markRaw as A, h as d } from "vue";
1
+ import { deepClone as d } from "@skyfox2000/fapi";
2
+ import { ref as i, markRaw as A, h as m } from "vue";
2
3
  import { createRouter as M, createWebHashHistory as _ } from "vue-router";
3
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 || {});
4
- const a = (e, t) => {
5
+ const l = (e, t) => {
5
6
  if (!(!t || !e))
6
7
  for (const n in t)
7
- n in e && typeof e[n] == "object" && typeof t[n] == "object" && !Array.isArray(t[n]) ? a(e[n], t[n]) : e[n] = c(t[n]);
8
- }, c = (e) => {
9
- if (e === null || typeof e != "object")
10
- return e;
11
- let t = Array.isArray(e) ? [] : {};
12
- for (let n in e)
13
- e.hasOwnProperty(n) && (t[n] = c(e[n]));
14
- return t;
15
- }, g = (...e) => {
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) => {
16
10
  const t = {};
17
11
  for (const n of e)
18
- n != null && n.Option && !t.Option && (t.Option = {}), a(t.Option, n == null ? void 0 : n.Option);
12
+ n != null && n.Option && !t.Option && (t.Option = {}), l(t.Option, n == null ? void 0 : n.Option);
19
13
  for (const n of e)
20
- n != null && n.Query && !t.Query && (t.Query = {}), a(t.Query, n == null ? void 0 : n.Query);
14
+ n != null && n.Query && !t.Query && (t.Query = {}), l(t.Query, n == null ? void 0 : n.Query);
21
15
  for (const n of e)
22
- t.Data = n != null && n.Data ? c(n.Data) : {};
16
+ t.Data = n != null && n.Data ? d(n.Data) : {};
23
17
  return t;
24
- }, C = () => !!window.__MICRO_APP_ENVIRONMENT__, N = () => !!window.__MICRO_APP_BASE_APPLICATION__, u = o(), O = o(), P = o(), U = () => {
18
+ }, N = () => !!window.__MICRO_APP_ENVIRONMENT__, U = () => !!window.__MICRO_APP_BASE_APPLICATION__, u = i(), P = i(), E = i(), b = () => {
25
19
  const e = window.microApp.getData(
26
20
  !0
27
21
  );
28
- u.value = e.MainApis, O.value = e.MainEvents, P.value = e.pageUrl;
29
- }, k = [
22
+ u.value = e.MainApis, P.value = e.MainEvents, E.value = e.pageUrl;
23
+ }, O = [
30
24
  {
31
25
  path: "/:page(.*)",
32
26
  name: "默认页面",
33
- component: () => import("./assets/modules/index-yUrmSBei.js")
27
+ component: () => import("./assets/modules/index-DQ8DfP_z.js")
34
28
  }
35
- ], y = M({
29
+ ], v = M({
36
30
  history: _(void 0),
37
- routes: k
38
- }), Q = (e, t, n, l) => {
39
- var f, p;
40
- const r = ((f = e.meta) == null ? void 0 : f.roles) ?? [], i = (p = e.meta) == null ? void 0 : p.permission;
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;
41
35
  if (!t)
42
- return r.length === 0 && !i;
43
- if (t && (n.length > 0 || l.length > 0)) {
44
- if (r.length === 0 && !i)
36
+ return o.length === 0 && !r;
37
+ if (t && (n.length > 0 || s.length > 0)) {
38
+ if (o.length === 0 && !r)
45
39
  return !0;
46
- if (r.length && !i)
47
- return r.some((s) => n.includes(s));
48
- if (!r.length && i)
49
- return l.includes(i);
50
- if (r.length && i)
51
- return r.some((s) => n.includes(s)) && l.includes(i);
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);
52
46
  }
53
47
  return !1;
54
48
  };
55
- y.afterEach((e) => {
49
+ v.afterEach((e) => {
56
50
  if (u.value) {
57
51
  const { mainAppPush: t } = u.value;
58
52
  t && t(e.hash);
59
53
  }
60
54
  });
61
- const H = o({}), h = o(""), v = o({}), m = o(null), E = async (e) => {
55
+ const H = i({}), h = i(""), y = i({}), p = i(null), k = async (e) => {
62
56
  h.value = e, e.startsWith("/") && (e = e.substring(1));
63
- const t = v.value[`./views/${e}.vue`];
57
+ const t = y.value[`./views/${e}.vue`];
64
58
  if (t) {
65
59
  const n = await t();
66
- m.value = A(n.default), y.replace("/" + e);
60
+ p.value = A(n.default), v.replace("/" + e);
67
61
  } else
68
- console.error("加载微模块" + e + "失败"), m.value = d(
62
+ console.error("加载微模块" + e + "失败"), p.value = m(
69
63
  "div",
70
64
  {
71
65
  style: {
@@ -78,32 +72,32 @@ const H = o({}), h = o(""), v = o({}), m = o(null), E = async (e) => {
78
72
  // 使文本垂直居中
79
73
  }
80
74
  },
81
- [d("div", "404 NOT FOUND")]
75
+ [m("div", "404 NOT FOUND")]
82
76
  );
83
77
  }, R = (e) => {
84
- v.value = e, window.microApp && window.microApp.addDataListener(async (t) => {
78
+ y.value = e, window.microApp && window.microApp.addDataListener(async (t) => {
85
79
  if (t.pageUrl === h.value) return;
86
80
  let n = t.pageUrl;
87
- E(n);
81
+ k(n);
88
82
  }, !0);
89
83
  };
90
84
  export {
91
85
  D as AppAction,
92
86
  w as AppSource,
93
- y as LoaderRouter,
87
+ v as LoaderRouter,
94
88
  I as RowOperate,
95
- g as combineParams,
89
+ C as combineParams,
96
90
  Q as hasPermission,
97
- U as initMainAppData,
91
+ b as initMainAppData,
98
92
  R as initModuleLoader,
99
- N as isBaseMicroApp,
100
- C as isMicroApp,
101
- E as loadModule,
93
+ U as isBaseMicroApp,
94
+ N as isMicroApp,
95
+ k as loadModule,
102
96
  u as mainAppApis,
103
- O as mainAppEvents,
104
- P as mainPageUrl,
97
+ P as mainAppEvents,
98
+ E as mainPageUrl,
105
99
  H as moduleAttrs,
106
- m as moduleCom,
107
- v as moduleRecords,
100
+ p as moduleCom,
101
+ y as moduleRecords,
108
102
  h as moduleUrl
109
103
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@skyfox2000/microbase",
3
- "version": "1.0.0",
4
- "description": "〇克微前端通用功能与数据类型定义",
3
+ "version": "1.0.2",
4
+ "description": "微前端通用功能与数据类型定义",
5
5
  "type": "module",
6
6
  "keywords": [],
7
7
  "author": "skyfox2000@github.com",
@@ -33,7 +33,7 @@
33
33
  "rollup": "^4.28.1",
34
34
  "rollup-plugin-gzip": "^4.0.1",
35
35
  "typescript": "^5.7.2",
36
- "vite": "^6.0.3",
36
+ "vite": "^6.2.3",
37
37
  "vite-plugin-dts": "^4.3.0",
38
38
  "vue-tsc": "^2.1.10"
39
39
  }
@@ -9,10 +9,14 @@ export enum AppSource {
9
9
  /**
10
10
  * 手动输入
11
11
  */
12
- "Manual" = "Manual"
12
+ "Manual" = "Manual",
13
13
  }
14
14
  /**
15
- * 应用动作: App | Open | Iframe
15
+ * 应用动作:
16
+ * - App 应用模式加载
17
+ * - MenuApp 托管应用模式加载
18
+ * - Link 链接,弹出窗口打开
19
+ * - Iframe Iframe内嵌方式打开
16
20
  */
17
21
  export enum AppAction {
18
22
  /**
@@ -31,7 +35,7 @@ export enum AppAction {
31
35
  /**
32
36
  * Iframe内嵌方式打开
33
37
  */
34
- "Iframe" = "Iframe"
38
+ "Iframe" = "Iframe",
35
39
  }
36
40
  /**
37
41
  * 应用信息
@@ -40,38 +44,38 @@ export interface AppInfo {
40
44
  /**
41
45
  * 主键
42
46
  */
43
- Id: string;
47
+ readonly Id: string;
44
48
  /**
45
49
  * 名称
46
50
  */
47
- Name: string;
51
+ readonly Name: string;
48
52
  /**
49
53
  * 唯一编码
50
54
  * - 路由前缀地址
51
55
  */
52
- AppCode: string;
56
+ readonly AppCode: string;
53
57
  /**
54
58
  * 版本号
55
59
  */
56
- Version: string;
60
+ readonly Version: string;
57
61
  /**
58
62
  * 图标
59
63
  */
60
- Icon: string;
64
+ readonly Icon: string;
61
65
  /**
62
66
  * 来源: Market | Manual
63
67
  */
64
- Source: AppSource;
68
+ readonly Source: AppSource;
65
69
  /**
66
70
  * 动作: App | MenuApp | Open | Iframe
67
71
  */
68
- Action: AppAction;
72
+ readonly Action: AppAction;
69
73
  /**
70
74
  * 应用加载地址
71
75
  * - http开头地址
72
76
  * - SERVER_HOST配置
73
77
  */
74
- Host: string;
78
+ readonly Host: string;
75
79
  /**
76
80
  * 默认页面
77
81
  */
@@ -90,6 +94,6 @@ export interface AppInfo {
90
94
  * - 启用 true 1
91
95
  * - 停用 false 0
92
96
  */
93
- Enabled: boolean | number;
97
+ readonly Enabled: boolean | number;
94
98
  [key: string]: any;
95
99
  }
@@ -7,15 +7,15 @@ export interface HostInfo {
7
7
  /**
8
8
  * 网站地址,配置码
9
9
  */
10
- Host: string;
10
+ readonly Host: string;
11
11
  /**
12
12
  * 短名称
13
13
  */
14
- Title: string;
14
+ readonly Title: string;
15
15
  /**
16
16
  * 网站全名称
17
17
  */
18
- FullTitle?: string;
18
+ readonly FullTitle?: string;
19
19
  /**
20
20
  * Logo图标地址
21
21
  */
@@ -35,21 +35,21 @@ export interface HostInfo {
35
35
  /**
36
36
  * 接口域名地址
37
37
  */
38
- API_HOST?: {
38
+ readonly API_HOST?: {
39
39
  [key: string]: string;
40
40
  } | null;
41
41
  /**
42
42
  * 网站服务器地址
43
43
  */
44
- SERVER_HOST?: Record<string, string>;
44
+ readonly SERVER_HOST?: Record<string, string>;
45
45
  /**
46
46
  * 扩展属性配置
47
47
  */
48
- ExtraPropLines?: Record<string, any>[];
48
+ readonly ExtraPropLines?: Record<string, any>[];
49
49
  /**
50
50
  * 扩展属性
51
51
  */
52
- ExtraProps?: {
52
+ readonly ExtraProps?: {
53
53
  [key: string]: string;
54
54
  };
55
55
  [key: string]: any;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export enum RowOperate {
5
5
  LEFT = 1,
6
- RIGHT = 2
6
+ RIGHT = 2,
7
7
  }
8
8
  /**
9
9
  * 前端个性化配置
@@ -12,25 +12,25 @@ export interface SettingInfo {
12
12
  /**
13
13
  * 全屏显示
14
14
  */
15
- readonly fullscreen: boolean;
15
+ fullscreen: boolean;
16
16
  /**
17
17
  * 主菜单区折叠
18
18
  */
19
- readonly menuCollapse: boolean;
19
+ menuCollapse: boolean;
20
20
  /**
21
21
  * 表格行操作区位置
22
22
  */
23
- readonly rowOperate: RowOperate;
23
+ rowOperate: RowOperate;
24
24
  /**
25
25
  * 使用语言
26
26
  */
27
- readonly language?: string;
27
+ language?: string;
28
28
  /**
29
29
  * 主题模式
30
30
  */
31
- readonly theme?: string;
31
+ theme?: string;
32
32
  /**
33
33
  * 主题颜色
34
34
  */
35
- readonly themeColor?: string;
35
+ themeColor?: string;
36
36
  }
@@ -5,23 +5,23 @@ export interface UserInfo {
5
5
  /**
6
6
  * 主键
7
7
  */
8
- Id: string;
8
+ readonly Id: string;
9
9
  /**
10
10
  * 名称
11
11
  */
12
- Name: string;
12
+ readonly Name: string;
13
13
  /**
14
14
  * 用户码
15
15
  */
16
- Code: string;
16
+ readonly Code: string;
17
17
  /**
18
- * 角色
18
+ * 租户Id
19
19
  */
20
- Roles: string[];
20
+ readonly TenantId: string;
21
21
  /**
22
- * 权限
22
+ * 用户级别
23
23
  */
24
- Permissions: string[];
24
+ readonly UserLevel: string;
25
25
  }
26
26
 
27
27
  /**
@@ -43,9 +43,9 @@ export interface LoginInfo {
43
43
  /**
44
44
  * 登录获取的授权token
45
45
  */
46
- token?: string;
46
+ readonly token?: string;
47
47
  /**
48
48
  * 登录获取的刷新token
49
49
  */
50
- refreshToken?: string;
50
+ readonly refreshToken?: string;
51
51
  }
package/src/utils/data.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * QOD数据处理方法
3
3
  */
4
4
 
5
- import { ReqParams } from "@skyfox2000/fapi";
5
+ import { deepClone, ReqParams } from "@skyfox2000/fapi";
6
6
 
7
7
  const mergeDeep = (
8
8
  target?: Record<string, any>,
@@ -23,20 +23,6 @@ const mergeDeep = (
23
23
  }
24
24
  };
25
25
 
26
- // 深拷贝函数,用于创建对象的深拷贝
27
- const deepClone = (obj: any) => {
28
- if (obj === null || typeof obj !== "object") {
29
- return obj;
30
- }
31
- let cloneObj: any = Array.isArray(obj) ? [] : {};
32
- for (let key in obj) {
33
- if (obj.hasOwnProperty(key)) {
34
- cloneObj[key] = deepClone(obj[key]);
35
- }
36
- }
37
- return cloneObj;
38
- };
39
-
40
26
  /**
41
27
  * 深度合并QOD参数
42
28
  */
@@ -1,11 +0,0 @@
1
- import { defineComponent as r, unref as e, openBlock as t, createBlock as n, resolveDynamicComponent as m, normalizeProps as u, mergeProps as a, createCommentVNode as l } from "vue";
2
- import { loadModule as p, LoaderRouter as c, moduleCom as o, moduleAttrs as d } from "../../microbase.es.js";
3
- const k = /* @__PURE__ */ r({
4
- __name: "index",
5
- setup(i) {
6
- return window.microApp || p(c.currentRoute.value.path), (s, _) => e(o) != null ? (t(), n(m(e(o)), u(a({ key: 0 }, e(d))), null, 16)) : l("", !0);
7
- }
8
- });
9
- export {
10
- k as default
11
- };