tntd 1.4.10 → 1.4.11

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.
Files changed (42) hide show
  1. package/components/Layout/AppList.js +1 -1
  2. package/components/Layout/GlobalNavigation/NavigationPopup.js +8 -8
  3. package/components/Layout/GlobalNavigation/index.js +2 -2
  4. package/components/Layout/OrgAppList.js +14 -15
  5. package/components/Layout/SideMenu.js +2 -2
  6. package/components/Layout/index.js +4 -5
  7. package/components/Layout/paaslayout/CompactSideMenu.js +1 -1
  8. package/components/Layout/paaslayout/index.js +2 -2
  9. package/components/Layout/storage.js +1 -1
  10. package/components/index.js +1 -0
  11. package/components/{Layout → utils}/checkAuth.js +3 -1
  12. package/components/utils/findMenuInfoByPath.js +39 -0
  13. package/components/{Layout/utils.js → utils/index.js} +3 -35
  14. package/dist/stats.json +9760 -9514
  15. package/dist/tntd.js +1 -1
  16. package/es/Layout/AppList.js +1 -1
  17. package/es/Layout/GlobalNavigation/NavigationPopup.js +1 -1
  18. package/es/Layout/GlobalNavigation/index.js +1 -1
  19. package/es/Layout/OrgAppList.js +3 -4
  20. package/es/Layout/SideMenu.js +1 -1
  21. package/es/Layout/index.js +5 -4
  22. package/es/Layout/paaslayout/CompactSideMenu.js +1 -1
  23. package/es/Layout/paaslayout/index.js +1 -1
  24. package/es/Layout/storage.js +1 -1
  25. package/es/index.js +2 -1
  26. package/es/utils/checkAuth.js +30 -0
  27. package/es/utils/findMenuInfoByPath.js +41 -0
  28. package/es/utils/index.js +99 -0
  29. package/lib/Layout/AppList.js +1 -1
  30. package/lib/Layout/GlobalNavigation/NavigationPopup.js +1 -1
  31. package/lib/Layout/GlobalNavigation/index.js +1 -1
  32. package/lib/Layout/OrgAppList.js +5 -6
  33. package/lib/Layout/SideMenu.js +1 -1
  34. package/lib/Layout/index.js +6 -6
  35. package/lib/Layout/paaslayout/CompactSideMenu.js +1 -1
  36. package/lib/Layout/paaslayout/index.js +1 -1
  37. package/lib/Layout/storage.js +1 -1
  38. package/lib/index.js +34 -0
  39. package/lib/utils/checkAuth.js +41 -0
  40. package/lib/utils/findMenuInfoByPath.js +52 -0
  41. package/lib/utils/index.js +159 -0
  42. package/package.json +1 -1
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ isGroupMenu: true,
8
+ getSelectedMenuInfo: true,
9
+ hasLevel3: true,
10
+ isNewTabMenu: true,
11
+ openInNewTab: true,
12
+ traverseTree: true,
13
+ safeParseJSON: true
14
+ };
15
+ exports.safeParseJSON = exports.traverseTree = exports.openInNewTab = exports.isNewTabMenu = exports.hasLevel3 = exports.getSelectedMenuInfo = exports.isGroupMenu = void 0;
16
+
17
+ var _checkAuth = require("./checkAuth");
18
+
19
+ Object.keys(_checkAuth).forEach(function (key) {
20
+ if (key === "default" || key === "__esModule") return;
21
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function get() {
25
+ return _checkAuth[key];
26
+ }
27
+ });
28
+ });
29
+
30
+ var _findMenuInfoByPath = require("./findMenuInfoByPath");
31
+
32
+ Object.keys(_findMenuInfoByPath).forEach(function (key) {
33
+ if (key === "default" || key === "__esModule") return;
34
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
+ Object.defineProperty(exports, key, {
36
+ enumerable: true,
37
+ get: function get() {
38
+ return _findMenuInfoByPath[key];
39
+ }
40
+ });
41
+ });
42
+
43
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
44
+
45
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
46
+
47
+ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
48
+
49
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
50
+
51
+ var isGroupMenu = function isGroupMenu(menu) {
52
+ return (menu == null ? void 0 : menu.children) && !(menu == null ? void 0 : menu.path);
53
+ };
54
+
55
+ exports.isGroupMenu = isGroupMenu;
56
+
57
+ var getSelectedMenuInfo = function getSelectedMenuInfo(selectedKey) {
58
+ var menus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
59
+ var subMenu;
60
+ var menu;
61
+ var parentMenus = [];
62
+
63
+ if (selectedKey) {
64
+ traverseTree(menus, function (node, pnode, pnodes) {
65
+ if (!isGroupMenu(node) && node.code === selectedKey) {
66
+ subMenu = node;
67
+ menu = pnode;
68
+ parentMenus = pnodes;
69
+ return false;
70
+ }
71
+ });
72
+ } else {
73
+ // 默认找到第一个菜单项
74
+ traverseTree(menus, function (node, pnode, pnodes) {
75
+ if (!isGroupMenu(node)) {
76
+ subMenu = node;
77
+ menu = pnode;
78
+ parentMenus = pnodes;
79
+ return false;
80
+ }
81
+ });
82
+ }
83
+
84
+ return {
85
+ subMenu: subMenu,
86
+ menu: menu,
87
+ parentMenus: parentMenus
88
+ };
89
+ };
90
+
91
+ exports.getSelectedMenuInfo = getSelectedMenuInfo;
92
+
93
+ var hasLevel3 = function hasLevel3(menus) {
94
+ return menus == null ? void 0 : menus.some(function (menu) {
95
+ var _menu$children;
96
+
97
+ return menu == null ? void 0 : (_menu$children = menu.children) == null ? void 0 : _menu$children.some(function (item) {
98
+ var _item$children;
99
+
100
+ return item == null ? void 0 : (_item$children = item.children) == null ? void 0 : _item$children.length;
101
+ });
102
+ });
103
+ };
104
+
105
+ exports.hasLevel3 = hasLevel3;
106
+
107
+ var isNewTabMenu = function isNewTabMenu(menu) {
108
+ var _ref = menu || {},
109
+ target = _ref.target,
110
+ path = _ref.path;
111
+
112
+ return target === '_blank' || /^http/i.test(path) && /blankType=newTarget/.test(path);
113
+ };
114
+
115
+ exports.isNewTabMenu = isNewTabMenu;
116
+
117
+ var openInNewTab = function openInNewTab(path) {
118
+ window.open(path, '_blank');
119
+ };
120
+
121
+ exports.openInNewTab = openInNewTab;
122
+
123
+ var traverseTree = function traverseTree(treeData, callback, pnode) {
124
+ var pnodes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
125
+ (treeData || []).every(function (node, index) {
126
+ var result;
127
+
128
+ if (callback) {
129
+ result = callback(node, pnode, (pnodes == null ? void 0 : pnodes.length) ? pnodes : [pnode].filter(function (item) {
130
+ return !!item;
131
+ }), index);
132
+ } // 回调函数返回false则终止遍历
133
+
134
+
135
+ if (result !== false) {
136
+ node && traverseTree(node.children || [], callback, node, [node].concat(_toConsumableArray(pnodes)));
137
+ }
138
+
139
+ return result !== false;
140
+ });
141
+ return treeData;
142
+ };
143
+
144
+ exports.traverseTree = traverseTree;
145
+
146
+ var safeParseJSON = function safeParseJSON(str, defaultObj) {
147
+ var result;
148
+
149
+ try {
150
+ result = JSON.parse(str);
151
+ } catch (err) {
152
+ console.warn('json parse error:', err);
153
+ result = typeof defaultObj === 'undefined' ? str : defaultObj;
154
+ }
155
+
156
+ return result || defaultObj;
157
+ };
158
+
159
+ exports.safeParseJSON = safeParseJSON;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tntd",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "ued tnt design",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",