@xingtukeji/micro 1.1.25 → 1.1.27
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/dist/index.js +9 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const CONSTANT = {
|
|
|
17
17
|
DOM_ID_PREFIX: "xt-micro-ifr-",
|
|
18
18
|
URL_PARAM_PREFIX: "__XT_MICRO_",
|
|
19
19
|
MICRO_VERSION: "__XT_MICRO_VERSION"
|
|
20
|
-
}, version = "1.1.
|
|
20
|
+
}, version = "1.1.27";
|
|
21
21
|
var utils_exports = /* @__PURE__ */ __export({
|
|
22
22
|
ConsoleUtil: () => ConsoleUtil,
|
|
23
23
|
addOrReplaceUrlParam: () => addOrReplaceUrlParam,
|
|
@@ -63,7 +63,7 @@ function addOrReplaceUrlParam(g, B, V) {
|
|
|
63
63
|
}
|
|
64
64
|
const ipcSyncAppInfo = async (g) => new Promise((B) => {
|
|
65
65
|
window.addEventListener("message", (V) => {
|
|
66
|
-
ConsoleUtil.trace("child ipcSyncAppInfo receive message", V.data), V.data.cmd === "$xt/micro/info" && (V.data.data.mainMicroVersion !== "1.1.
|
|
66
|
+
ConsoleUtil.trace("child ipcSyncAppInfo receive message", V.data), V.data.cmd === "$xt/micro/info" && (V.data.data.mainMicroVersion !== "1.1.27" && ConsoleUtil.warn(`子应用版本与主应用版本不一致,${g}子应用版本:${version},主应用版本:${V.data.data.mainMicroVersion}`), B(V.data.data));
|
|
67
67
|
}), ConsoleUtil.trace("child ipcSyncAppInfo send message", g), window.parent.postMessage({
|
|
68
68
|
cmd: "$xt/micro/info",
|
|
69
69
|
data: g
|
|
@@ -149,9 +149,10 @@ var generateId = (g) => `${CONSTANT.DOM_ID_PREFIX}${g}`, generateURL = (g, B = !
|
|
|
149
149
|
}
|
|
150
150
|
let H = typeof g.params == "function" ? g.params() : V(g.params) ? g.params : {}, U = typeof g.token == "function" ? g.token() : V(g.token) ? g.token : "", W = new URL(g.url.indexOf("http") > -1 ? g.url : window.location.origin + g.url), G = getQueryParameter(CONSTANT.URL_PARAM_PREFIX + g.name);
|
|
151
151
|
if (!B && G) {
|
|
152
|
-
let B = getAbsolutePath(G,
|
|
152
|
+
let B = getAbsolutePath(G, W.origin, !0);
|
|
153
153
|
if (B) {
|
|
154
|
-
|
|
154
|
+
ConsoleUtil.log("获取绝对路径", B, g), console.log("123123123================>");
|
|
155
|
+
let V = new URL(B, W.origin);
|
|
155
156
|
V.searchParams.forEach((g, B) => {
|
|
156
157
|
W.searchParams.set(B, g);
|
|
157
158
|
}), W.hash = V.hash;
|
|
@@ -189,7 +190,7 @@ var generateId = (g) => `${CONSTANT.DOM_ID_PREFIX}${g}`, generateURL = (g, B = !
|
|
|
189
190
|
loading;
|
|
190
191
|
loadingTimer;
|
|
191
192
|
constructor(g) {
|
|
192
|
-
return this.app = g, this.dom = void 0, this.panel = void 0,
|
|
193
|
+
return this.app = g, this.dom = void 0, this.panel = void 0, this;
|
|
193
194
|
}
|
|
194
195
|
mount(g, B = !1) {
|
|
195
196
|
let V;
|
|
@@ -293,8 +294,8 @@ const mainMicroInit = () => {
|
|
|
293
294
|
});
|
|
294
295
|
}, microInit = async (g = {}) => {
|
|
295
296
|
window[CONSTANT.MICRO_TYPE] = "child";
|
|
296
|
-
let B = getQueryParameter(CONSTANT.IS_MICRO), V = getQueryParameter(CONSTANT.MICRO_NAME);
|
|
297
|
-
if (ConsoleUtil.trace("child microInit", B, V), B && (window[CONSTANT.IS_MICRO] = B === "true", V && await syncAppInfo(V)), window[CONSTANT.IS_MICRO]) {
|
|
297
|
+
let B = getQueryParameter(CONSTANT.IS_MICRO), V = getQueryParameter(CONSTANT.MICRO_NAME), H = getQueryParameter(CONSTANT.MICRO_TOKEN);
|
|
298
|
+
if (g.authHandler && await g.authHandler(H), ConsoleUtil.trace("child microInit", B, V), B && (window[CONSTANT.IS_MICRO] = B === "true", V && await syncAppInfo(V)), window[CONSTANT.IS_MICRO]) {
|
|
298
299
|
function B(g) {
|
|
299
300
|
var B = document.styleSheets[0];
|
|
300
301
|
if (!B) {
|
|
@@ -308,8 +309,6 @@ const mainMicroInit = () => {
|
|
|
308
309
|
}) : B(`${g.hideHeaderCssSelector} { display: none !important; }`)), await patchIframeHistory(V, window), window.addEventListener("message", async (g) => {
|
|
309
310
|
g.data.cmd === `$xt/micro/${V}` && syncUrlToWindow(V);
|
|
310
311
|
});
|
|
311
|
-
let H = getQueryParameter(CONSTANT.MICRO_TOKEN);
|
|
312
|
-
g.authHandler && H && await g.authHandler(H);
|
|
313
312
|
} else ConsoleUtil.warn("当前环境非微应用环境");
|
|
314
313
|
};
|
|
315
314
|
function patchIframeHistory(g, B) {
|
|
@@ -337,7 +336,7 @@ var syncAppInfo = async (g) => await ipcSyncAppInfo(g).then((g) => {
|
|
|
337
336
|
};
|
|
338
337
|
});
|
|
339
338
|
async function syncUrlToWindow(g) {
|
|
340
|
-
ConsoleUtil.trace("syncUrlToWindow", g, window[CONSTANT.MICRO_APP]), window[CONSTANT.MICRO_APP] || syncAppInfo(g);
|
|
339
|
+
console.log("syncUrlToWindow", g, window[CONSTANT.MICRO_APP], window.location.href.match(/__XT_MICRO_([^=]+)=/), getQueryParameter(CONSTANT.MICRO_NAME)), ConsoleUtil.trace("syncUrlToWindow", g, window[CONSTANT.MICRO_APP]), window[CONSTANT.MICRO_APP] || await syncAppInfo(g);
|
|
341
340
|
let { name: B, sync: V, mainLocation: H } = window[CONSTANT.MICRO_APP], U = window.location.pathname + window.location.search + window.location.hash;
|
|
342
341
|
ConsoleUtil.trace("curUrl", U), ConsoleUtil.trace("child", "「$xt/micro/sync」", "send", B, U), window.parent.postMessage({
|
|
343
342
|
cmd: "$xt/micro/sync",
|