@indfnd/common 1.0.88 → 1.0.90

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/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.90](http://git.inspur.com/imp-ec/ind-front/ind-common-front/compare/v1.0.89...v1.0.90) (2025-02-06)
6
+
7
+
8
+ ### Features
9
+
10
+ * 给IndTree增加api ([1ef72f3](http://git.inspur.com/imp-ec/ind-front/ind-common-front/commit/1ef72f39d4ecda9c79ad6f3b07c4a3b8025a749c))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * router组织路由修改 ([c982f4e](http://git.inspur.com/imp-ec/ind-front/ind-common-front/commit/c982f4e28370c7aabcdad9a0062ba12c35e04b6a))
16
+
17
+ ### [1.0.89](http://git.inspur.com/imp-ec/ind-front/ind-common-front/compare/v1.0.88...v1.0.89) (2025-01-23)
18
+
19
+
20
+ ### Features
21
+
22
+ * 增加属性 ([c1abccd](http://git.inspur.com/imp-ec/ind-front/ind-common-front/commit/c1abccdc20c72fa310d343b07735eb49a808e565))
23
+
5
24
  ### [1.0.88](http://git.inspur.com/imp-ec/ind-front/ind-common-front/compare/v1.0.87...v1.0.88) (2025-01-23)
6
25
 
7
26
 
@@ -5460,7 +5460,7 @@ var lodash = { exports: {} };
5460
5460
  })(lodash, lodash.exports);
5461
5461
  var _ = lodash.exports;
5462
5462
  const name$1 = "@indfnd/common";
5463
- const version = "1.0.87";
5463
+ const version = "1.0.89";
5464
5464
  const author = "huxuetong";
5465
5465
  const publishConfig = {
5466
5466
  registry: "https://registry.npmjs.org/"
@@ -57198,6 +57198,28 @@ const __vue2_script$Y = {
57198
57198
  }
57199
57199
  }
57200
57200
  return list;
57201
+ },
57202
+ addNode(params) {
57203
+ var _a;
57204
+ let { parentId } = params;
57205
+ let node = this.getNodeById(parentId);
57206
+ if ((_a = node == null ? void 0 : node.children) == null ? void 0 : _a.length) {
57207
+ node.children.push(params);
57208
+ } else {
57209
+ node.children = [params];
57210
+ }
57211
+ },
57212
+ updateNode(params) {
57213
+ let { id } = params;
57214
+ let node = this.getNodeById(id);
57215
+ _.merge(node, params);
57216
+ },
57217
+ deleteNode(params) {
57218
+ let { id, parentId } = params;
57219
+ let node = this.getNodeById(parentId);
57220
+ node.children = node.children.filter((item2) => item2.id !== id);
57221
+ node.selected = true;
57222
+ this.$emit("on-select-change", this.getSelectedNodes(), null, true);
57201
57223
  }
57202
57224
  }
57203
57225
  };
@@ -67420,7 +67442,7 @@ var routerPlugin = {
67420
67442
  install(Vue2, { router, store: store2 }) {
67421
67443
  Vue2.prototype.$backToMenu = function() {
67422
67444
  console.log("trigger $backToMenu");
67423
- if (this.$config.showMenus) {
67445
+ if (top == self) {
67424
67446
  const breadCrumbList = store2.state.app.breadCrumbList;
67425
67447
  store2.commit("closeTag", {
67426
67448
  $router: router,
@@ -67536,9 +67558,37 @@ const PERMISSION_TYPE = {
67536
67558
  function isMenuPermissionType(type) {
67537
67559
  return [PERMISSION_TYPE.DIRECTORY, PERMISSION_TYPE.MENU].includes(type);
67538
67560
  }
67561
+ function getPermissionType(type) {
67562
+ return Object.keys(PERMISSION_TYPE).find((key) => PERMISSION_TYPE[key] === type);
67563
+ }
67539
67564
  function filterMicroPermissionList(microType, permissionList = []) {
67540
67565
  return permissionList;
67541
67566
  }
67567
+ function permission2Router(list, microType) {
67568
+ if (!list) {
67569
+ return [];
67570
+ }
67571
+ let tempList = [];
67572
+ for (const item2 of list) {
67573
+ tempList.push({
67574
+ path: dealRoutePath(item2.uri, microType),
67575
+ name: item2.permissionValue,
67576
+ meta: {
67577
+ appId: item2.appId,
67578
+ permissionId: item2.permissionId,
67579
+ title: item2.label,
67580
+ icon: item2.icon,
67581
+ crumbs: [
67582
+ { icon: item2.icon, name: item2.permissionValue, title: item2.label, type: item2.type }
67583
+ ],
67584
+ activeName: item2.permissionValue,
67585
+ data: item2
67586
+ },
67587
+ component: item2.permissionValue
67588
+ });
67589
+ }
67590
+ return tempList;
67591
+ }
67542
67592
  function listToMenuTree({ list, menuTree, pageNode, parentId, crumbs, root, microType }) {
67543
67593
  if (!list)
67544
67594
  return;
@@ -67639,29 +67689,6 @@ function generatorMenuTree(permissionList = []) {
67639
67689
  });
67640
67690
  return menuTree;
67641
67691
  }
67642
- function generatorDynamicRouter(permissionList = [], microType) {
67643
- const menuTree = [];
67644
- const pageNode = {
67645
- path: "/page",
67646
- name: "page",
67647
- meta: { hideInMenu: true, notCache: true },
67648
- component: "EmptyLayoutNotCache",
67649
- children: []
67650
- };
67651
- listToMenuTree({
67652
- list: permissionList,
67653
- menuTree,
67654
- pageNode,
67655
- parentId: "0",
67656
- crumbs: [],
67657
- root: true,
67658
- microType
67659
- });
67660
- if (pageNode.children.length) {
67661
- menuTree.push(pageNode);
67662
- }
67663
- return generator(menuTree);
67664
- }
67665
67692
  function generator(menuData = []) {
67666
67693
  for (let item2 of menuData) {
67667
67694
  if (item2.component) {
@@ -67683,20 +67710,51 @@ function generator(menuData = []) {
67683
67710
  }
67684
67711
  return menuData;
67685
67712
  }
67686
- async function renderRoutes({ router, store: store2, microType, allowPermissionList, routerOptionsBak }) {
67713
+ async function renderRoutes({
67714
+ router,
67715
+ store: store2,
67716
+ microType,
67717
+ allowPermissionList,
67718
+ routerOptionsBak,
67719
+ to
67720
+ }) {
67721
+ var _a;
67687
67722
  store2.dispatch("getIndexInfo");
67688
67723
  await store2.dispatch("getUserInfo");
67689
67724
  await store2.dispatch("getAppListData");
67690
67725
  const permissionData = await store2.dispatch("getPermissionData");
67691
67726
  router.options = _.cloneDeep(routerOptionsBak);
67692
67727
  const microPermissionData = filterMicroPermissionList(microType, permissionData);
67693
- const dynamicRouters = generatorDynamicRouter(microPermissionData, microType);
67694
- console.log("dynamicROuters", dynamicRouters);
67728
+ const tempPerList = microPermissionData.filter((item2) => item2.uri.includes(to.path));
67729
+ const perType = getPermissionType(tempPerList[0].type || "");
67730
+ let dynamicRouters = [];
67731
+ dynamicRouters.push({
67732
+ path: "/page",
67733
+ name: "page",
67734
+ meta: { hideInMenu: true, notCache: true },
67735
+ component: "EmptyLayoutNotCache",
67736
+ children: []
67737
+ });
67738
+ if (perType == "PAGE") {
67739
+ dynamicRouters[dynamicRouters.length - 1].children = dynamicRouters[dynamicRouters.length - 1].children.concat(tempPerList);
67740
+ }
67741
+ if (perType == "MENU") {
67742
+ const tempPerId = ((_a = tempPerList[0]) == null ? void 0 : _a.permissionId) || "";
67743
+ const tempChildren = microPermissionData.filter((item2) => item2.pid == tempPerId);
67744
+ dynamicRouters.unshift(...permission2Router(tempPerList, microType));
67745
+ dynamicRouters[dynamicRouters.length - 1].children = permission2Router(
67746
+ dynamicRouters[dynamicRouters.length - 1].children.concat(tempChildren),
67747
+ microType
67748
+ );
67749
+ }
67750
+ console.log("dynamicROuters111", dynamicRouters);
67695
67751
  const rootRoute2 = router.options.routes.find((item2) => item2.path === "/");
67696
- for (const item2 of dynamicRouters) {
67752
+ const dynamicRouters1 = generator(dynamicRouters);
67753
+ for (const item2 of dynamicRouters1) {
67697
67754
  router.addRoute(rootRoute2.name, item2);
67698
67755
  rootRoute2.children.push(item2);
67699
67756
  }
67757
+ console.log("router after render", router);
67700
67758
  const microAllowPermissionList = filterMicroPermissionList(microType, allowPermissionList);
67701
67759
  const needAddRoutes = microAllowPermissionList.filter((permission2) => {
67702
67760
  return router.options.routes.findIndex((route) => permission2.name === route.name) === -1;
@@ -67786,7 +67844,8 @@ function addRouterGuards({ router, store: store2, microType, allowPermissionList
67786
67844
  store: store2,
67787
67845
  microType,
67788
67846
  allowPermissionList,
67789
- routerOptionsBak
67847
+ routerOptionsBak,
67848
+ to
67790
67849
  });
67791
67850
  next({ ...to, replace: true });
67792
67851
  } catch (error) {