bmp-layout 0.0.25-beta.5 → 0.0.25-beta.7

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/bmp-layout.es.js CHANGED
@@ -1214,7 +1214,31 @@ function buildChildPaths(router) {
1214
1214
  const parentPath = router.path ? router.path.startsWith("/") ? router.path : `/${router.path}` : "";
1215
1215
  return (router.children || []).map((child) => {
1216
1216
  const childPath = child.path ? parentPath.endsWith("/") ? child.path.startsWith("/") ? child.path.substring(1) : child.path : child.path.startsWith("/") ? child.path : `/${child.path}` : "";
1217
- return { ...child, path: `${parentPath}${childPath}` };
1217
+ let fullPath = `${parentPath}${childPath}`;
1218
+ if (fullPath.length > 1 && fullPath.endsWith("/")) {
1219
+ fullPath = fullPath.slice(0, -1);
1220
+ }
1221
+ return { ...child, path: fullPath };
1222
+ });
1223
+ }
1224
+ function prependPathToRoutes(routes, parentPath) {
1225
+ if (!parentPath || !routes)
1226
+ return routes;
1227
+ return routes.map((route) => {
1228
+ let newPath;
1229
+ if (!route.path) {
1230
+ newPath = parentPath;
1231
+ } else {
1232
+ newPath = parentPath + (route.path.startsWith("/") ? route.path : `/${route.path}`);
1233
+ }
1234
+ if (newPath.length > 1 && newPath.endsWith("/")) {
1235
+ newPath = newPath.slice(0, -1);
1236
+ }
1237
+ return {
1238
+ ...route,
1239
+ path: newPath,
1240
+ children: route.children ? prependPathToRoutes(route.children, newPath) : route.children
1241
+ };
1218
1242
  });
1219
1243
  }
1220
1244
  function mergeExampleRoutes(targetModule, exampleRoutes, position = "start") {
@@ -1303,14 +1327,19 @@ const usePermissionStore = defineStore("layout-permission", {
1303
1327
  this.leftMenuRouters = routers;
1304
1328
  },
1305
1329
  // 处理模块对应菜单
1330
+ // 返回修改后的 exampleRoutes(已拼接模块路径前缀),供路由注册使用
1306
1331
  setModuleRouters(menuId, exampleRoutes = [], examplePosition = "start") {
1307
1332
  const findRouter = findRouterBy(this.getRoleRouters, "id", menuId);
1308
1333
  if (findRouter) {
1309
1334
  this.moduleId = findRouter.id;
1310
1335
  this.moduleName = findRouter.name;
1311
1336
  this.moduleRouters = buildChildPaths(findRouter);
1312
- mergeExampleRoutes(findRouter, exampleRoutes, examplePosition);
1337
+ const parentPath = findRouter.path || "";
1338
+ const prefixedExampleRoutes = prependPathToRoutes(exampleRoutes, parentPath);
1339
+ mergeExampleRoutes(findRouter, prefixedExampleRoutes, examplePosition);
1340
+ return prefixedExampleRoutes;
1313
1341
  }
1342
+ return exampleRoutes;
1314
1343
  },
1315
1344
  resetState() {
1316
1345
  this.routers = [];
@@ -1323,14 +1352,19 @@ const usePermissionStore = defineStore("layout-permission", {
1323
1352
  this.roleRouters = [];
1324
1353
  },
1325
1354
  // 处理模块对应菜单(通过模块code)
1355
+ // 返回修改后的 exampleRoutes(已拼接模块路径前缀),供路由注册使用
1326
1356
  setModuleRoutersByCode(moduleCode, exampleRoutes = [], examplePosition = "start") {
1327
1357
  const findRouter = findRouterBy(this.getRoleRouters, "moduleCode", moduleCode);
1328
1358
  if (findRouter) {
1329
1359
  this.moduleId = findRouter.id;
1330
1360
  this.moduleName = findRouter.name;
1331
1361
  this.moduleRouters = buildChildPaths(findRouter);
1332
- mergeExampleRoutes(findRouter, exampleRoutes, examplePosition);
1362
+ const parentPath = findRouter.path || "";
1363
+ const prefixedExampleRoutes = prependPathToRoutes(exampleRoutes, parentPath);
1364
+ mergeExampleRoutes(findRouter, prefixedExampleRoutes, examplePosition);
1365
+ return prefixedExampleRoutes;
1333
1366
  }
1367
+ return exampleRoutes;
1334
1368
  }
1335
1369
  },
1336
1370
  persist: false
@@ -8711,7 +8745,8 @@ const _sfc_main$r = /* @__PURE__ */ Object.assign({ name: "ProductServicePanel"
8711
8745
  } else {
8712
8746
  const currentOrigin = window.location.origin;
8713
8747
  const modulePath = ((_d = (_c = productList.value[activeProductIndex.value]) == null ? void 0 : _c.children[activeModuleIndex.value]) == null ? void 0 : _d.modulePath) || "";
8714
- const finalPath = modulePath && !fullPath.startsWith(modulePath) ? `${modulePath}${fullPath.startsWith("/") ? fullPath : `/${fullPath}`}` : normalizedPath;
8748
+ const hasModulePrefix = modulePath && (fullPath === modulePath || fullPath.startsWith(modulePath + "/"));
8749
+ const finalPath = hasModulePrefix ? normalizedPath : `${modulePath}${normalizedPath}`;
8715
8750
  const targetUrl = `${currentOrigin}${finalPath.startsWith("/") ? finalPath : `/${finalPath}`}`;
8716
8751
  window.location.href = targetUrl;
8717
8752
  }
@@ -8968,7 +9003,7 @@ const _sfc_main$r = /* @__PURE__ */ Object.assign({ name: "ProductServicePanel"
8968
9003
  };
8969
9004
  }
8970
9005
  });
8971
- const ProductServicePanel = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__scopeId", "data-v-47667fb6"]]);
9006
+ const ProductServicePanel = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__scopeId", "data-v-808cd98e"]]);
8972
9007
  const _sfc_main$q = /* @__PURE__ */ Object.assign({ name: "Logo" }, {
8973
9008
  __name: "Logo",
8974
9009
  emits: ["logo-click"],