cloud-web-corejs 1.0.54-dev.777 → 1.0.54-dev.779

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.54-dev.777",
4
+ "version": "1.0.54-dev.779",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "dev:micro": "vue-cli-service serve --port 17527",
@@ -21,6 +21,18 @@ import MenuFallback from "@base/views/user/menuFallback/index.vue";
21
21
  let hostRegistryApps = [];
22
22
  let hostMicroRoutes = [];
23
23
 
24
+ /**
25
+ * 本应用(渲染方)在微前端命名空间里的身份。
26
+ * 子应用取 settings.appCode(派生自各自 WEB_PREFIX);主应用 appCode 恒空,
27
+ * 但它的身份就是 WEB_PREFIX 去斜杠(/sys → sys)——故回落 WEB_PREFIX 派生。
28
+ * 用于:① 宿主自排除(不装载自己);② 组件路径解析剥归属前缀,使
29
+ * /micro/sys/base/user/user/list 等同于 /base/user/user/list(主应用把归属自己的
30
+ * 访问路径剥掉 /micro/<自己> 两段后按常规解析)。
31
+ */
32
+ function getOwnAppCode() {
33
+ return settings.appCode || (window.WEB_PREFIX || "").replace(/^\/+/, "");
34
+ }
35
+
24
36
  // 子应用被"本地调试覆盖"装载时置 true:启用按访问路径直接解析组件的兜底路由,
25
37
  // 使联调期可用 URL 直达尚未配置菜单的页面。正式注册表装载时恒为 false——
26
38
  // 菜单即权限边界,不能让任意路径都能打开组件
@@ -45,7 +57,7 @@ function createDebugPathRoute() {
45
57
  const path = (this.$route && this.$route.path) || "";
46
58
  const componentPath = resolveComponentPath(
47
59
  { url: path },
48
- settings.appCode || ""
60
+ getOwnAppCode()
49
61
  );
50
62
  if (!componentPath) {
51
63
  return h(MenuFallback, { props: { componentPath: path } });
@@ -242,7 +254,7 @@ const actions = {
242
254
  // 主应用 appCode 恒为空(WEB_PREFIX===MAIN_WEB_PREFIX 不派生),但它在注册表里的
243
255
  // 身份是 WEB_PREFIX 去斜杠(/sys → sys)——故回落到 WEB_PREFIX 派生,
244
256
  // 否则注册表误配了主应用自身条目时排不掉、导致主应用自嵌套。
245
- let ownAppCode = settings.appCode || (window.WEB_PREFIX || "").replace(/^\/+/, "");
257
+ let ownAppCode = getOwnAppCode();
246
258
  hostRegistryApps = (apps || []).filter(
247
259
  (app) => app.appCode !== ownAppCode
248
260
  );
@@ -365,8 +377,8 @@ function createRoute3(route3, flag) {
365
377
  param = getUrlParams(path);
366
378
  path = path.substring(0, pIndex);
367
379
  }
368
- // 三步解析第 3 步:/base/ 命名空间转 @base/views;url 首段为本应用 appCode 时剥掉
369
- componentPath = resolveComponentPath(route3, settings.appCode || "");
380
+ // 三步解析第 3 步:/base/ 命名空间转 @base/views;访问路径首段为本应用(含主应用 WEB_PREFIX 身份)时剥 /micro/<自己>
381
+ componentPath = resolveComponentPath(route3, getOwnAppCode());
370
382
  menuCode = route3.menuCode;
371
383
  }
372
384
  } else {
@@ -146,13 +146,20 @@ function requireAppView(rel) {
146
146
  return require("@/views" + rel);
147
147
  }
148
148
 
149
- /** 惰性读取本应用 appCode,避免把整个 store 拉进 resolveViewPath 的单测 */
149
+ /**
150
+ * 惰性读取本应用(渲染方)appCode,避免把 settings 拉进 resolveViewPath 的纯函数单测。
151
+ * 子应用取 settings.appCode(qiankun mount 会写入 props.appCode,与派生一致);
152
+ * 主应用 appCode 恒空、身份是 WEB_PREFIX 去斜杠(/sys → sys)——故回落 WEB_PREFIX。
153
+ * 与 store/modules/permission.js 的 getOwnAppCode 同口径:使 /micro/<自己>/... 被判成本地,
154
+ * 不误判成 remote 去自装载(也修掉子应用独立运行时 micro.appCode 为空的老坑)。
155
+ */
150
156
  function getRendererAppCode() {
157
+ const webPrefix = (window.WEB_PREFIX || "").replace(/^\/+/, "");
151
158
  try {
152
- const store = require("@base/store").default;
153
- return (store && store.state && store.state.micro && store.state.micro.appCode) || "";
159
+ const settings = require("@/settings").default;
160
+ return (settings && settings.appCode) || webPrefix;
154
161
  } catch (e) {
155
- return "";
162
+ return webPrefix;
156
163
  }
157
164
  }
158
165