@skyfox2000/microbase 1.0.6 → 1.0.8
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/microbase.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { deepClone as
|
|
1
|
+
import { deepClone as l } from "@skyfox2000/fapi";
|
|
2
2
|
import { ref as o, markRaw as p, h as a } from "vue";
|
|
3
3
|
import { createRouter as m, createWebHashHistory as d } from "vue-router";
|
|
4
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 || {});
|
|
5
5
|
const r = (e, n) => {
|
|
6
6
|
if (!(!n || !e))
|
|
7
7
|
for (const t in n)
|
|
8
|
-
t in e && typeof e[t] == "object" && typeof n[t] == "object" && !Array.isArray(n[t]) ? r(e[t], n[t]) : e[t] =
|
|
8
|
+
t in e && typeof e[t] == "object" && typeof n[t] == "object" && !Array.isArray(n[t]) ? r(e[t], n[t]) : e[t] = l(n[t]);
|
|
9
9
|
}, P = (...e) => {
|
|
10
10
|
const n = {};
|
|
11
11
|
for (const t of e)
|
|
@@ -13,24 +13,24 @@ const r = (e, n) => {
|
|
|
13
13
|
for (const t of e)
|
|
14
14
|
t != null && t.Query && !n.Query && (n.Query = {}), r(n.Query, t == null ? void 0 : t.Query);
|
|
15
15
|
for (const t of e)
|
|
16
|
-
n.Data = t != null && t.Data ?
|
|
16
|
+
n.Data = t != null && t.Data ? l(t.Data) : {};
|
|
17
17
|
return n;
|
|
18
18
|
}, I = () => !!window.__MICRO_APP_ENVIRONMENT__, k = () => !!window.__MICRO_APP_BASE_APPLICATION__, i = o(), A = o(), M = o(), R = () => {
|
|
19
19
|
const e = window.microApp.getData(
|
|
20
20
|
!0
|
|
21
21
|
);
|
|
22
|
-
i.value = e.MainApis, A.value = e.MainEvents, M.value = e.pageUrl;
|
|
22
|
+
e && (i.value = e.MainApis, A.value = e.MainEvents, M.value = e.pageUrl);
|
|
23
23
|
}, w = [
|
|
24
24
|
{
|
|
25
25
|
path: "/:page(.*)",
|
|
26
26
|
name: "默认页面",
|
|
27
27
|
component: () => import("./assets/modules/index-DQ8DfP_z.js")
|
|
28
28
|
}
|
|
29
|
-
],
|
|
29
|
+
], u = m({
|
|
30
30
|
history: d(void 0),
|
|
31
31
|
routes: w
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
u.afterEach((e) => {
|
|
34
34
|
if (i.value) {
|
|
35
35
|
const { mainAppPush: n } = i.value;
|
|
36
36
|
n && n(e.hash);
|
|
@@ -41,7 +41,7 @@ const C = o({}), c = o(""), f = o({}), s = o(null), _ = async (e) => {
|
|
|
41
41
|
const n = f.value[`./views/${e}.vue`];
|
|
42
42
|
if (n) {
|
|
43
43
|
const t = await n();
|
|
44
|
-
s.value = p(t.default),
|
|
44
|
+
s.value = p(t.default), u.replace("/" + e);
|
|
45
45
|
} else
|
|
46
46
|
console.error("加载微模块" + e + "失败"), s.value = a(
|
|
47
47
|
"div",
|
|
@@ -62,13 +62,13 @@ const C = o({}), c = o(""), f = o({}), s = o(null), _ = async (e) => {
|
|
|
62
62
|
f.value = e, window.microApp && window.microApp.addDataListener(async (n) => {
|
|
63
63
|
if (n.pageUrl === c.value) return;
|
|
64
64
|
let t = n.pageUrl;
|
|
65
|
-
_(t);
|
|
65
|
+
t ? _(t) : console.error("微模块地址为空");
|
|
66
66
|
}, !0);
|
|
67
67
|
};
|
|
68
68
|
export {
|
|
69
69
|
y as AppAction,
|
|
70
70
|
v as AppSource,
|
|
71
|
-
|
|
71
|
+
u as LoaderRouter,
|
|
72
72
|
P as combineParams,
|
|
73
73
|
R as initMainAppData,
|
|
74
74
|
E as initModuleLoader,
|
package/package.json
CHANGED
|
@@ -64,7 +64,8 @@ export const initModuleLoader = (
|
|
|
64
64
|
window.microApp.addDataListener(async (data: MainAppData) => {
|
|
65
65
|
if (data.pageUrl === moduleUrl.value) return;
|
|
66
66
|
let page = data.pageUrl as string;
|
|
67
|
-
loadModule(page);
|
|
67
|
+
if (page) loadModule(page);
|
|
68
|
+
else console.error("微模块地址为空");
|
|
68
69
|
}, true);
|
|
69
70
|
}
|
|
70
71
|
};
|
package/src/utils/micro-app.ts
CHANGED
|
@@ -100,7 +100,9 @@ export const initMainAppData = () => {
|
|
|
100
100
|
const mainAppData: MainAppData = window.microApp.getData(
|
|
101
101
|
true
|
|
102
102
|
) as unknown as MainAppData;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
if (mainAppData) {
|
|
104
|
+
mainAppApis.value = mainAppData.MainApis;
|
|
105
|
+
mainAppEvents.value = mainAppData.MainEvents;
|
|
106
|
+
mainPageUrl.value = mainAppData.pageUrl;
|
|
107
|
+
}
|
|
106
108
|
};
|