@bit-sun/business-component 2.4.31-alpha.0 → 2.4.31-alpha.2
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.esm.js +59 -14
- package/dist/index.js +59 -14
- package/package.json +1 -1
- package/src/components/Business/BsLayouts/index.tsx +61 -19
package/dist/index.esm.js
CHANGED
|
@@ -16512,8 +16512,47 @@ var NoFoundPage = function NoFoundPage(props) {
|
|
|
16512
16512
|
|
|
16513
16513
|
var _excluded$g = ["route"];
|
|
16514
16514
|
var TabPane = Tabs.TabPane;
|
|
16515
|
+
var getId = function getId(str) {
|
|
16516
|
+
// 找到最后一个 / 的位置
|
|
16517
|
+
var lastSlashIndex = str.lastIndexOf("/");
|
|
16518
|
+
// 如果找到了 /,则返回它后面的部分
|
|
16519
|
+
if (lastSlashIndex !== -1) {
|
|
16520
|
+
return str.substring(lastSlashIndex + 1);
|
|
16521
|
+
} else {
|
|
16522
|
+
// 如果没有找到 /,则返回整个字符串
|
|
16523
|
+
return null;
|
|
16524
|
+
}
|
|
16525
|
+
};
|
|
16526
|
+
// 获取权限菜单path&通用单据id
|
|
16527
|
+
var getAuthMenuPathAndDocsId = function getAuthMenuPathAndDocsId(pathToRegexp) {
|
|
16528
|
+
var limitedMenuData = localStorage.getItem(getLimitMenuDataKey()) ? JSON.parse(localStorage.getItem(getLimitMenuDataKey())) : [];
|
|
16529
|
+
var menuKeys = [];
|
|
16530
|
+
var docsId = [];
|
|
16531
|
+
var getLimitedMenuKeys = function getLimitedMenuKeys(data) {
|
|
16532
|
+
data.forEach(function (item) {
|
|
16533
|
+
if (item.children && item.children.length > 0) {
|
|
16534
|
+
getLimitedMenuKeys(item.children);
|
|
16535
|
+
} else {
|
|
16536
|
+
var originPath = item.path.replace(/^\/\w+\//, '/');
|
|
16537
|
+
menuKeys.push(originPath);
|
|
16538
|
+
if (pathToRegexp('/operation-and-maintenance-center/configuration-management/all-general-documents-specific/:id').test(originPath)) {
|
|
16539
|
+
getId(originPath) && docsId.push(getId(originPath));
|
|
16540
|
+
}
|
|
16541
|
+
}
|
|
16542
|
+
});
|
|
16543
|
+
};
|
|
16544
|
+
try {
|
|
16545
|
+
getLimitedMenuKeys(limitedMenuData);
|
|
16546
|
+
} catch (e) {}
|
|
16547
|
+
return {
|
|
16548
|
+
menuKeys: menuKeys,
|
|
16549
|
+
docsId: docsId
|
|
16550
|
+
};
|
|
16551
|
+
};
|
|
16515
16552
|
var UN_LISTTEN_DRP;
|
|
16516
16553
|
var routerArray = [];
|
|
16554
|
+
var authMenuPathList = [];
|
|
16555
|
+
var docsId = [];
|
|
16517
16556
|
var lastTwoRouterArray = [1, 2];
|
|
16518
16557
|
var type = 'DraggableTabNode';
|
|
16519
16558
|
var DraggableTabNode = function DraggableTabNode(_ref) {
|
|
@@ -16706,6 +16745,7 @@ var ItemMenu = function ItemMenu(props) {
|
|
|
16706
16745
|
};
|
|
16707
16746
|
var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
|
|
16708
16747
|
function BasicLayout(props) {
|
|
16748
|
+
var _getAuthMenuPathAndDo, _getAuthMenuPathAndDo2;
|
|
16709
16749
|
var _this;
|
|
16710
16750
|
_classCallCheck(this, BasicLayout);
|
|
16711
16751
|
_this = _callSuper(this, BasicLayout, [props]);
|
|
@@ -16722,29 +16762,26 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
16722
16762
|
return queryString;
|
|
16723
16763
|
};
|
|
16724
16764
|
_this.updateTree = function (Tree) {
|
|
16765
|
+
var authMenuKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
16725
16766
|
var treeData = Tree;
|
|
16726
16767
|
var treeList = [];
|
|
16727
|
-
|
|
16728
|
-
var
|
|
16729
|
-
|
|
16730
|
-
|
|
16731
|
-
if (item.children && item.children.length > 0) {
|
|
16732
|
-
getLimitedMenuKeys(item.children);
|
|
16733
|
-
} else {
|
|
16734
|
-
menuKeys.push(item.path.replace(/^\/\w+\//, '/'));
|
|
16735
|
-
}
|
|
16768
|
+
// 是否为权限菜单路径
|
|
16769
|
+
var getLimitedMenuPath = function getLimitedMenuPath(node) {
|
|
16770
|
+
return authMenuKeys.some(function (item) {
|
|
16771
|
+
return (node.path || '').includes(item);
|
|
16736
16772
|
});
|
|
16737
16773
|
};
|
|
16738
|
-
|
|
16774
|
+
// 是否为通用单据菜单路径
|
|
16775
|
+
var getGenerateDocs = function getGenerateDocs(node) {
|
|
16776
|
+
return (node.path || '').includes('all-general-documents');
|
|
16777
|
+
};
|
|
16739
16778
|
// 递归获取树列表
|
|
16740
16779
|
var getTreeList = function getTreeList(data) {
|
|
16741
16780
|
data.forEach(function (node) {
|
|
16742
16781
|
if (node.routes && node.routes.length > 0) {
|
|
16743
16782
|
getTreeList(node.routes);
|
|
16744
16783
|
} else {
|
|
16745
|
-
if (node.path === '/' ||
|
|
16746
|
-
return (node.path || '').includes(item);
|
|
16747
|
-
})) {
|
|
16784
|
+
if (node.path === '/' || getLimitedMenuPath(node) || getGenerateDocs(node)) {
|
|
16748
16785
|
treeList.push({
|
|
16749
16786
|
tab: node.locale,
|
|
16750
16787
|
key: node.path,
|
|
@@ -17097,7 +17134,9 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
17097
17134
|
});
|
|
17098
17135
|
}
|
|
17099
17136
|
};
|
|
17100
|
-
|
|
17137
|
+
authMenuPathList = ((_getAuthMenuPathAndDo = getAuthMenuPathAndDocsId(props.pathToRegexp)) === null || _getAuthMenuPathAndDo === void 0 ? void 0 : _getAuthMenuPathAndDo.menuKeys) || [];
|
|
17138
|
+
docsId = ((_getAuthMenuPathAndDo2 = getAuthMenuPathAndDocsId(props.pathToRegexp)) === null || _getAuthMenuPathAndDo2 === void 0 ? void 0 : _getAuthMenuPathAndDo2.docsId) || [];
|
|
17139
|
+
routerArray = _this.updateTree(props.route.routes, authMenuPathList);
|
|
17101
17140
|
var homeRouter = routerArray.filter(function (itemroute) {
|
|
17102
17141
|
return itemroute.key === '/';
|
|
17103
17142
|
})[0];
|
|
@@ -17198,6 +17237,12 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
17198
17237
|
var newListenRouterState = _toConsumableArray(listenRouterState);
|
|
17199
17238
|
var newListenRouterKey = _toConsumableArray(listenRouterKey);
|
|
17200
17239
|
var replaceRouter = routerArray.filter(function (itemRoute) {
|
|
17240
|
+
var _route$pathname;
|
|
17241
|
+
if ((_route$pathname = route.pathname) === null || _route$pathname === void 0 ? void 0 : _route$pathname.includes('all-general-documents')) {
|
|
17242
|
+
return pathToRegexp(itemRoute.key || '').test(route.pathname) && docsId.some(function (item) {
|
|
17243
|
+
return route.pathname.includes(item);
|
|
17244
|
+
});
|
|
17245
|
+
}
|
|
17201
17246
|
return pathToRegexp(itemRoute.key || '').test(route.pathname);
|
|
17202
17247
|
})[0];
|
|
17203
17248
|
var currentKey = '';
|
package/dist/index.js
CHANGED
|
@@ -16532,8 +16532,47 @@ var NoFoundPage = function NoFoundPage(props) {
|
|
|
16532
16532
|
|
|
16533
16533
|
var _excluded$g = ["route"];
|
|
16534
16534
|
var TabPane = antd.Tabs.TabPane;
|
|
16535
|
+
var getId = function getId(str) {
|
|
16536
|
+
// 找到最后一个 / 的位置
|
|
16537
|
+
var lastSlashIndex = str.lastIndexOf("/");
|
|
16538
|
+
// 如果找到了 /,则返回它后面的部分
|
|
16539
|
+
if (lastSlashIndex !== -1) {
|
|
16540
|
+
return str.substring(lastSlashIndex + 1);
|
|
16541
|
+
} else {
|
|
16542
|
+
// 如果没有找到 /,则返回整个字符串
|
|
16543
|
+
return null;
|
|
16544
|
+
}
|
|
16545
|
+
};
|
|
16546
|
+
// 获取权限菜单path&通用单据id
|
|
16547
|
+
var getAuthMenuPathAndDocsId = function getAuthMenuPathAndDocsId(pathToRegexp) {
|
|
16548
|
+
var limitedMenuData = localStorage.getItem(getLimitMenuDataKey()) ? JSON.parse(localStorage.getItem(getLimitMenuDataKey())) : [];
|
|
16549
|
+
var menuKeys = [];
|
|
16550
|
+
var docsId = [];
|
|
16551
|
+
var getLimitedMenuKeys = function getLimitedMenuKeys(data) {
|
|
16552
|
+
data.forEach(function (item) {
|
|
16553
|
+
if (item.children && item.children.length > 0) {
|
|
16554
|
+
getLimitedMenuKeys(item.children);
|
|
16555
|
+
} else {
|
|
16556
|
+
var originPath = item.path.replace(/^\/\w+\//, '/');
|
|
16557
|
+
menuKeys.push(originPath);
|
|
16558
|
+
if (pathToRegexp('/operation-and-maintenance-center/configuration-management/all-general-documents-specific/:id').test(originPath)) {
|
|
16559
|
+
getId(originPath) && docsId.push(getId(originPath));
|
|
16560
|
+
}
|
|
16561
|
+
}
|
|
16562
|
+
});
|
|
16563
|
+
};
|
|
16564
|
+
try {
|
|
16565
|
+
getLimitedMenuKeys(limitedMenuData);
|
|
16566
|
+
} catch (e) {}
|
|
16567
|
+
return {
|
|
16568
|
+
menuKeys: menuKeys,
|
|
16569
|
+
docsId: docsId
|
|
16570
|
+
};
|
|
16571
|
+
};
|
|
16535
16572
|
var UN_LISTTEN_DRP;
|
|
16536
16573
|
var routerArray = [];
|
|
16574
|
+
var authMenuPathList = [];
|
|
16575
|
+
var docsId = [];
|
|
16537
16576
|
var lastTwoRouterArray = [1, 2];
|
|
16538
16577
|
var type = 'DraggableTabNode';
|
|
16539
16578
|
var DraggableTabNode = function DraggableTabNode(_ref) {
|
|
@@ -16726,6 +16765,7 @@ var ItemMenu = function ItemMenu(props) {
|
|
|
16726
16765
|
};
|
|
16727
16766
|
var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
|
|
16728
16767
|
function BasicLayout(props) {
|
|
16768
|
+
var _getAuthMenuPathAndDo, _getAuthMenuPathAndDo2;
|
|
16729
16769
|
var _this;
|
|
16730
16770
|
_classCallCheck(this, BasicLayout);
|
|
16731
16771
|
_this = _callSuper(this, BasicLayout, [props]);
|
|
@@ -16742,29 +16782,26 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
16742
16782
|
return queryString;
|
|
16743
16783
|
};
|
|
16744
16784
|
_this.updateTree = function (Tree) {
|
|
16785
|
+
var authMenuKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
16745
16786
|
var treeData = Tree;
|
|
16746
16787
|
var treeList = [];
|
|
16747
|
-
|
|
16748
|
-
var
|
|
16749
|
-
|
|
16750
|
-
|
|
16751
|
-
if (item.children && item.children.length > 0) {
|
|
16752
|
-
getLimitedMenuKeys(item.children);
|
|
16753
|
-
} else {
|
|
16754
|
-
menuKeys.push(item.path.replace(/^\/\w+\//, '/'));
|
|
16755
|
-
}
|
|
16788
|
+
// 是否为权限菜单路径
|
|
16789
|
+
var getLimitedMenuPath = function getLimitedMenuPath(node) {
|
|
16790
|
+
return authMenuKeys.some(function (item) {
|
|
16791
|
+
return (node.path || '').includes(item);
|
|
16756
16792
|
});
|
|
16757
16793
|
};
|
|
16758
|
-
|
|
16794
|
+
// 是否为通用单据菜单路径
|
|
16795
|
+
var getGenerateDocs = function getGenerateDocs(node) {
|
|
16796
|
+
return (node.path || '').includes('all-general-documents');
|
|
16797
|
+
};
|
|
16759
16798
|
// 递归获取树列表
|
|
16760
16799
|
var getTreeList = function getTreeList(data) {
|
|
16761
16800
|
data.forEach(function (node) {
|
|
16762
16801
|
if (node.routes && node.routes.length > 0) {
|
|
16763
16802
|
getTreeList(node.routes);
|
|
16764
16803
|
} else {
|
|
16765
|
-
if (node.path === '/' ||
|
|
16766
|
-
return (node.path || '').includes(item);
|
|
16767
|
-
})) {
|
|
16804
|
+
if (node.path === '/' || getLimitedMenuPath(node) || getGenerateDocs(node)) {
|
|
16768
16805
|
treeList.push({
|
|
16769
16806
|
tab: node.locale,
|
|
16770
16807
|
key: node.path,
|
|
@@ -17117,7 +17154,9 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
17117
17154
|
});
|
|
17118
17155
|
}
|
|
17119
17156
|
};
|
|
17120
|
-
|
|
17157
|
+
authMenuPathList = ((_getAuthMenuPathAndDo = getAuthMenuPathAndDocsId(props.pathToRegexp)) === null || _getAuthMenuPathAndDo === void 0 ? void 0 : _getAuthMenuPathAndDo.menuKeys) || [];
|
|
17158
|
+
docsId = ((_getAuthMenuPathAndDo2 = getAuthMenuPathAndDocsId(props.pathToRegexp)) === null || _getAuthMenuPathAndDo2 === void 0 ? void 0 : _getAuthMenuPathAndDo2.docsId) || [];
|
|
17159
|
+
routerArray = _this.updateTree(props.route.routes, authMenuPathList);
|
|
17121
17160
|
var homeRouter = routerArray.filter(function (itemroute) {
|
|
17122
17161
|
return itemroute.key === '/';
|
|
17123
17162
|
})[0];
|
|
@@ -17218,6 +17257,12 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
17218
17257
|
var newListenRouterState = _toConsumableArray(listenRouterState);
|
|
17219
17258
|
var newListenRouterKey = _toConsumableArray(listenRouterKey);
|
|
17220
17259
|
var replaceRouter = routerArray.filter(function (itemRoute) {
|
|
17260
|
+
var _route$pathname;
|
|
17261
|
+
if ((_route$pathname = route.pathname) === null || _route$pathname === void 0 ? void 0 : _route$pathname.includes('all-general-documents')) {
|
|
17262
|
+
return pathToRegexp(itemRoute.key || '').test(route.pathname) && docsId.some(function (item) {
|
|
17263
|
+
return route.pathname.includes(item);
|
|
17264
|
+
});
|
|
17265
|
+
}
|
|
17221
17266
|
return pathToRegexp(itemRoute.key || '').test(route.pathname);
|
|
17222
17267
|
})[0];
|
|
17223
17268
|
var currentKey = '';
|
package/package.json
CHANGED
|
@@ -64,6 +64,43 @@ export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
|
|
|
64
64
|
breadcrumbNameMap: Record<string, MenuDataItem>;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
+
const getId = (str) => {
|
|
68
|
+
// 找到最后一个 / 的位置
|
|
69
|
+
var lastSlashIndex = str.lastIndexOf("/");
|
|
70
|
+
|
|
71
|
+
// 如果找到了 /,则返回它后面的部分
|
|
72
|
+
if (lastSlashIndex !== -1) {
|
|
73
|
+
return str.substring(lastSlashIndex + 1);
|
|
74
|
+
} else {
|
|
75
|
+
// 如果没有找到 /,则返回整个字符串
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 获取权限菜单path&通用单据id
|
|
81
|
+
const getAuthMenuPathAndDocsId = (pathToRegexp) => {
|
|
82
|
+
const limitedMenuData = localStorage.getItem(getLimitMenuDataKey()) ? JSON.parse(localStorage.getItem(getLimitMenuDataKey())) : [];
|
|
83
|
+
const menuKeys = [];
|
|
84
|
+
const docsId = [];
|
|
85
|
+
const getLimitedMenuKeys = (data) => {
|
|
86
|
+
data.forEach((item) => {
|
|
87
|
+
if (item.children && item.children.length > 0) {
|
|
88
|
+
getLimitedMenuKeys(item.children);
|
|
89
|
+
} else {
|
|
90
|
+
const originPath = item.path.replace(/^\/\w+\//, '/');
|
|
91
|
+
menuKeys.push(originPath);
|
|
92
|
+
if (pathToRegexp('/operation-and-maintenance-center/configuration-management/all-general-documents-specific/:id').test(originPath)) {
|
|
93
|
+
getId(originPath) && docsId.push(getId(originPath))
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
getLimitedMenuKeys(limitedMenuData);
|
|
100
|
+
} catch(e) {}
|
|
101
|
+
return {menuKeys, docsId};
|
|
102
|
+
}
|
|
103
|
+
|
|
67
104
|
const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
|
|
68
105
|
menuList.map((item) => {
|
|
69
106
|
return {
|
|
@@ -74,6 +111,8 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
|
|
|
74
111
|
|
|
75
112
|
let UN_LISTTEN_DRP;
|
|
76
113
|
let routerArray = [];
|
|
114
|
+
let authMenuPathList = [];
|
|
115
|
+
let docsId = [];
|
|
77
116
|
let lastTwoRouterArray = [1, 2];
|
|
78
117
|
|
|
79
118
|
let draggerTabKeys = [];
|
|
@@ -289,7 +328,9 @@ class BasicLayout extends React.PureComponent {
|
|
|
289
328
|
}>();
|
|
290
329
|
constructor(props) {
|
|
291
330
|
super(props);
|
|
292
|
-
|
|
331
|
+
authMenuPathList = getAuthMenuPathAndDocsId(props.pathToRegexp)?.menuKeys || [];
|
|
332
|
+
docsId = getAuthMenuPathAndDocsId(props.pathToRegexp)?.docsId || [];
|
|
333
|
+
routerArray = this.updateTree(props.route.routes, authMenuPathList);
|
|
293
334
|
const homeRouter = routerArray.filter(
|
|
294
335
|
(itemroute) => itemroute.key === '/',
|
|
295
336
|
)[0];
|
|
@@ -393,9 +434,12 @@ class BasicLayout extends React.PureComponent {
|
|
|
393
434
|
let newListenRouterState = [...listenRouterState];
|
|
394
435
|
let newListenRouterKey = [...listenRouterKey];
|
|
395
436
|
|
|
396
|
-
let replaceRouter = routerArray.filter((itemRoute) =>
|
|
397
|
-
|
|
398
|
-
|
|
437
|
+
let replaceRouter = routerArray.filter((itemRoute) => {
|
|
438
|
+
if (route.pathname?.includes('all-general-documents')) {
|
|
439
|
+
return pathToRegexp(itemRoute.key || '').test(route.pathname) && docsId.some(item => route.pathname.includes(item));
|
|
440
|
+
}
|
|
441
|
+
return pathToRegexp(itemRoute.key || '').test(route.pathname);
|
|
442
|
+
})[0];
|
|
399
443
|
|
|
400
444
|
let currentKey = '';
|
|
401
445
|
|
|
@@ -541,23 +585,21 @@ class BasicLayout extends React.PureComponent {
|
|
|
541
585
|
return queryString;
|
|
542
586
|
};
|
|
543
587
|
|
|
544
|
-
updateTree = (Tree) => {
|
|
588
|
+
updateTree = (Tree, authMenuKeys = []) => {
|
|
545
589
|
const treeData = Tree;
|
|
546
590
|
const treeList = [];
|
|
547
591
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
};
|
|
560
|
-
getLimitedMenuKeys(limitedMenuData);
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
// 是否为权限菜单路径
|
|
595
|
+
const getLimitedMenuPath = (node) => {
|
|
596
|
+
return authMenuKeys.some(item => (node.path || '').includes(item));
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// 是否为通用单据菜单路径
|
|
600
|
+
const getGenerateDocs = (node) => {
|
|
601
|
+
return (node.path || '').includes('all-general-documents');
|
|
602
|
+
}
|
|
561
603
|
|
|
562
604
|
// 递归获取树列表
|
|
563
605
|
const getTreeList = (data) => {
|
|
@@ -565,7 +607,7 @@ class BasicLayout extends React.PureComponent {
|
|
|
565
607
|
if (node.routes && node.routes.length > 0) {
|
|
566
608
|
getTreeList(node.routes);
|
|
567
609
|
} else {
|
|
568
|
-
if (node.path === '/' ||
|
|
610
|
+
if (node.path === '/' || getLimitedMenuPath(node) || getGenerateDocs(node)) {
|
|
569
611
|
treeList.push({
|
|
570
612
|
tab: node.locale,
|
|
571
613
|
key: node.path,
|