module-menu 0.1.27 → 0.1.29

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,6 +1,6 @@
1
1
  {
2
2
  "name": "module-menu",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "城市大数据平台公共头部及尾部",
5
5
  "main": "src/pages/index.jsx",
6
6
  "scripts": {
@@ -1,219 +1,254 @@
1
1
  import { useState, useEffect, useRef, useMemo } from 'react';
2
2
  import { Popconfirm, message, Popover } from 'antd';
3
- import { menuList as menuListInit, menuIconSrc, sysNameMap } from './constData'
4
- import HeaderDropdown from '../ModuleUser/HeaderDropdown'
5
- import './index.less'
3
+ import { menuList as menuListInit, menuIconSrc, sysNameMap } from './constData';
4
+ import HeaderDropdown from '../ModuleUser/HeaderDropdown';
5
+ import './index.less';
6
6
 
7
7
  const ModuleMenu = ({ sysName }) => {
8
- const [sessionMenu, setsessionMenu] = useState([]);
9
- const [showMenuList, setshowMenuList] = useState(false);
10
- const [menuList, setMenuList] = useState([]);
8
+ const [sessionMenu, setsessionMenu] = useState([]);
9
+ const [showMenuList, setshowMenuList] = useState(false);
10
+ const [menuList, setMenuList] = useState([]);
11
11
 
12
- useEffect(() => {
13
- let newSessionMenu = getSessionMenu();
14
- setsessionMenu(newSessionMenu);
15
- let newMenuList = getNewMenuList();
16
- // let newMenuList = menuListInit;
17
- setMenuList(newMenuList);
18
- }, []);
12
+ useEffect(() => {
13
+ let newSessionMenu = getSessionMenu();
14
+ setsessionMenu(newSessionMenu);
15
+ let newMenuList = getNewMenuList();
16
+ // let newMenuList = menuListInit;
17
+ setMenuList(newMenuList);
18
+ }, []);
19
19
 
20
- const getSessionMenu = () => {
21
- const menuObj = JSON.parse(sessionStorage.getItem('bigdata-menu'));
22
- if (menuObj) {
23
- return menuObj.content || []
24
- }
25
- return []
20
+ const getSessionMenu = () => {
21
+ const menuObj = JSON.parse(sessionStorage.getItem('bigdata-menu'));
22
+ if (menuObj) {
23
+ return menuObj.content || [];
26
24
  }
25
+ return [];
26
+ };
27
27
 
28
- // 获取系统logo及title
29
- const getLogoAndTitle = () => {
30
- let sysInfo = sysNameMap.find(item => item.sysName === sysName);
31
- let logoAndTitle = { logoSrc: "", title: "" };
32
- if (sysInfo) {
33
- logoAndTitle.logoSrc = sysInfo.logoSrc;
34
- logoAndTitle.title = sysInfo.title;
35
- };
36
- return logoAndTitle;
28
+ // 获取系统logo及title
29
+ const getLogoAndTitle = () => {
30
+ let sysInfo = sysNameMap.find((item) => item.sysName === sysName);
31
+ let logoAndTitle = { logoSrc: '', title: '' };
32
+ if (sysInfo) {
33
+ logoAndTitle.logoSrc = sysInfo.logoSrc;
34
+ logoAndTitle.title = sysInfo.title;
37
35
  }
36
+ return logoAndTitle;
37
+ };
38
38
 
39
- /**
40
- * 判断第三方服务是否有对应服务的菜单权限
41
- * @param {*} authMenus
42
- * @param {*} rootMenuPath
43
- */
44
- const judgeThirdPartyServiceIsHaveMenus = (authMenus, rootMenuPath) => {
45
- let dsMenus = [];
46
- if (
47
- typeof authMenus !== "undefined" &&
48
- authMenus !== null &&
49
- authMenus.length > 0
50
- ) {
51
- const rootMenus = authMenus.filter((item) => {
52
- const { parentId, type, path } = item;
53
- if (parentId === -1 && type === "3" && path === rootMenuPath) {
54
- return true;
55
- }
56
- return false;
57
- });
58
- if (
59
- rootMenus &&
60
- Object.keys(rootMenus).length > 0 &&
61
- rootMenus[0].children
62
- ) {
63
- dsMenus = rootMenus[0].children;
64
- }
65
- }
66
- if (!dsMenus || dsMenus.length === 0) {
67
- return false;
68
- }
69
- return true;
70
- };
71
- // 跳转各个模块
72
- const toModulePage = (nameStr) => {
73
- if (!sessionMenu || sessionMenu.length === 0) {
74
- message.destroy()
75
- message.warning("没有获取到菜单列表,请联系管理员添加权限");
76
- return;
39
+ /**
40
+ * 判断第三方服务是否有对应服务的菜单权限
41
+ * @param {*} authMenus
42
+ * @param {*} rootMenuPath
43
+ */
44
+ const judgeThirdPartyServiceIsHaveMenus = (authMenus, rootMenuPath) => {
45
+ let dsMenus = [];
46
+ if (
47
+ typeof authMenus !== 'undefined' &&
48
+ authMenus !== null &&
49
+ authMenus.length > 0
50
+ ) {
51
+ const rootMenus = authMenus.filter((item) => {
52
+ const { parentId, type, path } = item;
53
+ console.log('object', path, rootMenuPath);
54
+ if (parentId === -1 && type === '3' && path === rootMenuPath) {
55
+ return true;
77
56
  }
78
- console.log('nameStr', nameStr)
79
- let thirdPartyServiceJumpPath = ""; // 第三方服务跳转路径
80
- let thirdPartyServiceRootMenuPath = ""; // 第三方服务根菜单路径
81
- switch (nameStr) {
82
- case "数据集成":
83
- thirdPartyServiceJumpPath = "/datacollect/";
84
- thirdPartyServiceRootMenuPath = "/datacollection";
85
- break;
86
- case "数据治理":
87
- thirdPartyServiceJumpPath = "/datamanage/";
88
- thirdPartyServiceRootMenuPath = "/dataManager";
89
- break;
90
- case "元数据管理":
91
- thirdPartyServiceJumpPath = "/metadata/";
92
- thirdPartyServiceRootMenuPath = "/metadata";
93
- break;
94
- case "数据质量":
95
- thirdPartyServiceJumpPath = "/quality/";
96
- thirdPartyServiceRootMenuPath = "/quality/";
97
- break;
98
- case "离线开发":
99
- thirdPartyServiceJumpPath = "/datadev/";
100
- thirdPartyServiceRootMenuPath = "/datadev/";
101
- break;
102
- case "实时开发":
103
- thirdPartyServiceJumpPath = "/dataanalytic/";
104
- thirdPartyServiceRootMenuPath = "/dataanalytic";
105
- break;
106
- case "数据服务":
107
- thirdPartyServiceJumpPath = "/dataservice/";
108
- thirdPartyServiceRootMenuPath = "/dataservice";
109
- break;
110
- case "数据资产":
111
- thirdPartyServiceJumpPath = "/dataasset/";
112
- thirdPartyServiceRootMenuPath = "/dataasset";
113
- break;
114
- case "数据共享":
115
- thirdPartyServiceJumpPath = "/datasharing/";
116
- thirdPartyServiceRootMenuPath = "/datasharing";
117
- break;
118
- case "运维中心":
119
- thirdPartyServiceJumpPath = "/operate/";
120
- thirdPartyServiceRootMenuPath = "/operate";
121
- break;
122
- case "消息中心":
123
- thirdPartyServiceJumpPath = "/alert/";
124
- thirdPartyServiceRootMenuPath = "/alert/";
125
- break;
126
- default:
127
- break;
128
- }
129
- // 判断第三方服务是否有对应服务的菜单权限
130
- if (
131
- !judgeThirdPartyServiceIsHaveMenus(
132
- sessionMenu,
133
- thirdPartyServiceRootMenuPath
134
- )
57
+ return false;
58
+ });
59
+ if (
60
+ rootMenus &&
61
+ Object.keys(rootMenus).length > 0 &&
62
+ rootMenus[0].children
63
+ ) {
64
+ dsMenus = rootMenus[0].children;
65
+ }
66
+ }
67
+ if (!dsMenus || dsMenus.length === 0) {
68
+ return false;
69
+ }
70
+ return true;
71
+ };
72
+ // 跳转各个模块
73
+ const toModulePage = (nameStr) => {
74
+ if (!sessionMenu || sessionMenu.length === 0) {
75
+ message.destroy();
76
+ message.warning('没有获取到菜单列表,请联系管理员添加权限');
77
+ return;
78
+ }
79
+ console.log('nameStr', nameStr);
80
+ let thirdPartyServiceJumpPath = ''; // 第三方服务跳转路径
81
+ let thirdPartyServiceRootMenuPath = ''; // 第三方服务根菜单路径
82
+ switch (nameStr) {
83
+ case '数据集成':
84
+ thirdPartyServiceJumpPath = '/datacollect/';
85
+ thirdPartyServiceRootMenuPath = '/datacollection';
86
+ break;
87
+ case '数据治理':
88
+ thirdPartyServiceJumpPath = '/datamanage/';
89
+ thirdPartyServiceRootMenuPath = '/dataManager';
90
+ break;
91
+ case '元数据管理':
92
+ thirdPartyServiceJumpPath = '/metadata/';
93
+ thirdPartyServiceRootMenuPath = '/metadata';
94
+ break;
95
+ case '数据质量':
96
+ thirdPartyServiceJumpPath = '/quality/';
97
+ thirdPartyServiceRootMenuPath = '/quality/';
98
+ break;
99
+ case '离线开发':
100
+ thirdPartyServiceJumpPath = '/datadev/';
101
+ thirdPartyServiceRootMenuPath = '/datadev/';
102
+ break;
103
+ case '实时开发':
104
+ thirdPartyServiceJumpPath = '/dataanalytic/';
105
+ thirdPartyServiceRootMenuPath = '/dataanalytic';
106
+ break;
107
+ case '数据服务':
108
+ thirdPartyServiceJumpPath = '/dataservice/';
109
+ thirdPartyServiceRootMenuPath = '/dataservice';
110
+ break;
111
+ case '数据资产':
112
+ thirdPartyServiceJumpPath = '/dataasset/';
113
+ thirdPartyServiceRootMenuPath = '/dataasset';
114
+ break;
115
+ case '数据共享':
116
+ thirdPartyServiceJumpPath = '/datasharing/';
117
+ thirdPartyServiceRootMenuPath = '/datasharing';
118
+ break;
119
+ case '运维中心':
120
+ thirdPartyServiceJumpPath = '/operate/';
121
+ thirdPartyServiceRootMenuPath = '/operate';
122
+ break;
123
+ case '消息中心':
124
+ thirdPartyServiceJumpPath = '/alert/';
125
+ thirdPartyServiceRootMenuPath = '/alert';
126
+ break;
127
+ default:
128
+ break;
129
+ }
130
+ // 判断第三方服务是否有对应服务的菜单权限
131
+ if (
132
+ !judgeThirdPartyServiceIsHaveMenus(
133
+ sessionMenu,
134
+ thirdPartyServiceRootMenuPath,
135
+ )
136
+ ) {
137
+ message.destroy();
138
+ message.warning('您没有权限,请联系管理员添加权限。');
139
+ return;
140
+ }
141
+ window.location.href = thirdPartyServiceJumpPath;
142
+ };
143
+ // 跳转首页
144
+ const toHomePage = (index) => {
145
+ if (index === 0) {
146
+ window.location.href = '/#/index';
147
+ }
148
+ };
149
+ const getNewMenuList = () => {
150
+ const sessionMenu = getSessionMenu();
151
+ let newMenuList = [...menuListInit];
152
+ if (sessionMenu) {
153
+ const pathList = sessionMenu.map((item) => item.path);
154
+ // 过滤掉没有权限的子菜单(PS:如果模块下面子菜单都没有,则不显示该模块)
155
+ for (let index = newMenuList.length - 1; index >= 0; index--) {
156
+ const menuItem = newMenuList[index];
157
+ for (
158
+ let index_ch = menuItem.children.length - 1;
159
+ index_ch >= 0;
160
+ index_ch--
135
161
  ) {
136
- message.destroy()
137
- message.warning("您没有权限,请联系管理员添加权限。");
138
- return
162
+ const child = menuItem.children[index_ch];
163
+ if (!pathList.includes(child.path)) {
164
+ newMenuList[index].children.splice(index_ch, 1);
165
+ }
139
166
  }
140
- window.location.href = thirdPartyServiceJumpPath
141
- };
142
- // 跳转首页
143
- const toHomePage = (index) => {
144
- if (index === 0) {
145
- window.location.href = '/#/index'
167
+ if (menuItem.children.length === 0 && menuItem.name !== '首页') {
168
+ newMenuList.splice(index, 1);
146
169
  }
147
- };
148
- const getNewMenuList = () => {
149
- const sessionMenu = getSessionMenu()
150
- let newMenuList = [...menuListInit];
151
- if (sessionMenu) {
152
- const pathList = sessionMenu.map(item => item.path)
153
- // 过滤掉没有权限的子菜单(PS:如果模块下面子菜单都没有,则不显示该模块)
154
- for (let index = newMenuList.length - 1; index >= 0; index--) {
155
- const menuItem = newMenuList[index]
156
- for (let index_ch = menuItem.children.length - 1; index_ch >= 0; index_ch--) {
157
- const child = menuItem.children[index_ch]
158
- if (!pathList.includes(child.path)) {
159
- newMenuList[index].children.splice(index_ch, 1)
160
- }
161
- }
162
- if (menuItem.children.length === 0 && menuItem.name !== '首页') {
163
- newMenuList.splice(index, 1)
164
- }
165
- }
166
- }
167
- return newMenuList;
168
-
170
+ }
169
171
  }
170
- const menu = menuList.map((item, index) => {
171
- return (
172
- <div key={item.name} className="cardLine" style={{ height: item.children.length > 3 ? '90px' : '' }}>
173
- <div className='leftMenu' style={{
174
- height: item.children.length > 3 ? '96px' : '70px',
175
- lineHeight: item.children.length > 3 ? '45px' : '70px',
176
- }}>
177
- <img src={item.url} className="middle" />
178
- <span className="middle textPad" onClick={() => { toHomePage(index) }}>{item.name}</span>
179
- </div>
180
- <div className='rightMenu'
181
- style={{
182
- height: item.children.length > 3 ? '96px' : '70px',
183
- lineHeight: item.children.length > 3 ? '45px' : '70px',
184
- borderBottom: index === menuList.length - 1 ? '0px' : '1px solid #E9E9E9',
185
- }}>
186
- {
187
- item.children.map((child, idx) => {
188
- return (
189
- <span key={child.childName}>
190
- <img src={child.url} className="middle iconPad" />
191
- <span className='childMenu textPad middle' onClick={() => { toModulePage(child.childName) }}>{child.childName}</span>
192
- </span>
193
- )
194
- })
195
- }
196
- </div>
197
- </div>
198
- )
199
- });
200
-
172
+ return newMenuList;
173
+ };
174
+ const menu = menuList.map((item, index) => {
201
175
  return (
202
- <div>
203
- <div className='menuPopupAndTitle'>
204
- <div className='menuIcon' onClick={() => setshowMenuList(!showMenuList)}>
205
- <img className="menuIcon_img" src={menuIconSrc} />
206
- </div>
207
- <div className="menu_title_content">
208
- <img className="menu_title_content_img" src={getLogoAndTitle().logoSrc} alt="logo" />
209
- <span className="menu_title">{getLogoAndTitle().title}</span>
210
- </div>
211
- </div>
212
- <div className='menu_list_content' style={{ display: showMenuList ? 'block' : 'none' }}>
213
- {menu}
214
- </div>
215
- </div >
176
+ <div
177
+ key={item.name}
178
+ className="cardLine"
179
+ style={{ height: item.children.length > 3 ? '90px' : '' }}
180
+ >
181
+ <div
182
+ className="leftMenu"
183
+ style={{
184
+ height: item.children.length > 3 ? '96px' : '70px',
185
+ lineHeight: item.children.length > 3 ? '45px' : '70px',
186
+ }}
187
+ >
188
+ <img src={item.url} className="middle" />
189
+ <span
190
+ className="middle textPad"
191
+ onClick={() => {
192
+ toHomePage(index);
193
+ }}
194
+ >
195
+ {item.name}
196
+ </span>
197
+ </div>
198
+ <div
199
+ className="rightMenu"
200
+ style={{
201
+ height: item.children.length > 3 ? '96px' : '70px',
202
+ lineHeight: item.children.length > 3 ? '45px' : '70px',
203
+ borderBottom:
204
+ index === menuList.length - 1 ? '0px' : '1px solid #E9E9E9',
205
+ }}
206
+ >
207
+ {item.children.map((child, idx) => {
208
+ return (
209
+ <span key={child.childName}>
210
+ <img src={child.url} className="middle iconPad" />
211
+ <span
212
+ className="childMenu textPad middle"
213
+ onClick={() => {
214
+ toModulePage(child.childName);
215
+ }}
216
+ >
217
+ {child.childName}
218
+ </span>
219
+ </span>
220
+ );
221
+ })}
222
+ </div>
223
+ </div>
216
224
  );
225
+ });
217
226
 
218
- }
227
+ return (
228
+ <div>
229
+ <div className="menuPopupAndTitle">
230
+ <div
231
+ className="menuIcon"
232
+ onClick={() => setshowMenuList(!showMenuList)}
233
+ >
234
+ <img className="menuIcon_img" src={menuIconSrc} />
235
+ </div>
236
+ <div className="menu_title_content">
237
+ <img
238
+ className="menu_title_content_img"
239
+ src={getLogoAndTitle().logoSrc}
240
+ alt="logo"
241
+ />
242
+ <span className="menu_title">{getLogoAndTitle().title}</span>
243
+ </div>
244
+ </div>
245
+ <div
246
+ className="menu_list_content"
247
+ style={{ display: showMenuList ? 'block' : 'none' }}
248
+ >
249
+ {menu}
250
+ </div>
251
+ </div>
252
+ );
253
+ };
219
254
  export default ModuleMenu;
@@ -62,14 +62,6 @@ const ModuleUser = () => {
62
62
  />
63
63
  <span>个人中心</span>
64
64
  </Menu.Item>
65
- <Menu.Item key="messageCenter" onClick={() => handleClickmenu('/alert/')}>
66
- <img
67
- src={MessageCenterSrc}
68
- alt=""
69
- style={{ marginRight: '10px', marginTop: '-3px' }}
70
- />
71
- <span>消息中心</span>
72
- </Menu.Item>
73
65
  {isHaveSystemManagementPermission && (
74
66
  <Menu.Item key="systemManage" onClick={() => handleClickmenu('/')}>
75
67
  <img
@@ -1,5 +1,5 @@
1
- import ModuleMenu from './ModuleMenu'
2
- import ModuleUser from './ModuleUser'
3
- import Footer from './Footer'
4
- export {ModuleMenu,ModuleUser,Footer}
5
- // export default ModuleUser
1
+ import ModuleMenu from './ModuleMenu';
2
+ import ModuleUser from './ModuleUser';
3
+ import Footer from './Footer';
4
+ export { ModuleMenu, ModuleUser, Footer };
5
+ // export default ModuleMenu;