menu.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. // TODO:remove
  2. // import { isUrl } from '../utils/utils';
  3. // const menuData = [
  4. // {
  5. // name: 'dashboard',
  6. // icon: 'dashboard',
  7. // path: 'dashboard',
  8. // children: [
  9. // {
  10. // name: '分析页',
  11. // path: 'analysis',
  12. // },
  13. // {
  14. // name: '监控页',
  15. // path: 'monitor',
  16. // },
  17. // {
  18. // name: '工作台',
  19. // path: 'workplace',
  20. // // hideInBreadcrumb: true,
  21. // // hideInMenu: true,
  22. // },
  23. // ],
  24. // },
  25. // {
  26. // name: '表单页',
  27. // icon: 'form',
  28. // path: 'form',
  29. // children: [
  30. // {
  31. // name: '基础表单',
  32. // path: 'basic-form',
  33. // },
  34. // {
  35. // name: '分步表单',
  36. // path: 'step-form',
  37. // },
  38. // {
  39. // name: '高级表单',
  40. // authority: 'admin',
  41. // path: 'advanced-form',
  42. // },
  43. // ],
  44. // },
  45. // {
  46. // name: '列表页',
  47. // icon: 'table',
  48. // path: 'list',
  49. // children: [
  50. // {
  51. // name: '查询表格',
  52. // path: 'table-list',
  53. // },
  54. // {
  55. // name: '标准列表',
  56. // path: 'basic-list',
  57. // },
  58. // {
  59. // name: '卡片列表',
  60. // path: 'card-list',
  61. // },
  62. // {
  63. // name: '搜索列表',
  64. // path: 'search',
  65. // children: [
  66. // {
  67. // name: '搜索列表(文章)',
  68. // path: 'articles',
  69. // },
  70. // {
  71. // name: '搜索列表(项目)',
  72. // path: 'projects',
  73. // },
  74. // {
  75. // name: '搜索列表(应用)',
  76. // path: 'applications',
  77. // },
  78. // ],
  79. // },
  80. // ],
  81. // },
  82. // {
  83. // name: '详情页',
  84. // icon: 'profile',
  85. // path: 'profile',
  86. // children: [
  87. // {
  88. // name: '基础详情页',
  89. // path: 'basic',
  90. // },
  91. // {
  92. // name: '高级详情页',
  93. // path: 'advanced',
  94. // authority: 'admin',
  95. // },
  96. // ],
  97. // },
  98. // {
  99. // name: '结果页',
  100. // icon: 'check-circle-o',
  101. // path: 'result',
  102. // children: [
  103. // {
  104. // name: '成功',
  105. // path: 'success',
  106. // },
  107. // {
  108. // name: '失败',
  109. // path: 'fail',
  110. // },
  111. // ],
  112. // },
  113. // {
  114. // name: '异常页',
  115. // icon: 'warning',
  116. // path: 'exception',
  117. // children: [
  118. // {
  119. // name: '403',
  120. // path: '403',
  121. // },
  122. // {
  123. // name: '404',
  124. // path: '404',
  125. // },
  126. // {
  127. // name: '500',
  128. // path: '500',
  129. // },
  130. // {
  131. // name: '触发异常',
  132. // path: 'trigger',
  133. // hideInMenu: true,
  134. // },
  135. // ],
  136. // },
  137. // {
  138. // name: '账户',
  139. // icon: 'user',
  140. // path: 'user',
  141. // authority: 'guest',
  142. // children: [
  143. // {
  144. // name: '登录',
  145. // path: 'login',
  146. // },
  147. // {
  148. // name: '注册',
  149. // path: 'register',
  150. // },
  151. // {
  152. // name: '注册结果',
  153. // path: 'register-result',
  154. // },
  155. // ],
  156. // },
  157. // {
  158. // name: '个人页',
  159. // icon: 'user',
  160. // path: 'account',
  161. // children: [
  162. // {
  163. // name: '个人中心',
  164. // path: 'center',
  165. // },
  166. // {
  167. // name: '个人设置',
  168. // path: 'settings',
  169. // },
  170. // ],
  171. // },
  172. // ];
  173. // function formatter(data, parentPath = '/', parentAuthority) {
  174. // return data.map(item => {
  175. // let { path } = item;
  176. // if (!isUrl(path)) {
  177. // path = parentPath + item.path;
  178. // }
  179. // const result = {
  180. // ...item,
  181. // path,
  182. // authority: item.authority || parentAuthority,
  183. // };
  184. // if (item.children) {
  185. // result.children = formatter(item.children, `${parentPath}${item.path}/`, item.authority);
  186. // }
  187. // return result;
  188. // });
  189. // }
  190. // export const getMenuData = () => formatter(menuData);
  191. import { isUrl } from '../utils/utils';
  192. // TODO: authority
  193. const menuData = [
  194. {
  195. name: 'dashboard',
  196. icon: 'dashboard',
  197. path: 'Dashboard',
  198. children: [
  199. {
  200. name: '分析页',
  201. path: 'Analysis',
  202. },
  203. {
  204. name: '监控页',
  205. path: 'Monitor',
  206. },
  207. {
  208. name: '工作台',
  209. path: 'Workplace',
  210. // hideInBreadcrumb: true,
  211. // hideInMenu: true,
  212. },
  213. ],
  214. },
  215. {
  216. name: '表单页',
  217. icon: 'form',
  218. path: 'Forms',
  219. children: [
  220. {
  221. name: '基础表单',
  222. path: 'BasicForm',
  223. },
  224. {
  225. name: '分步表单',
  226. path: 'StepForm',
  227. },
  228. {
  229. name: '高级表单',
  230. // authority: 'admin',
  231. path: 'AdvancedForm',
  232. },
  233. ],
  234. },
  235. {
  236. name: '列表页',
  237. icon: 'table',
  238. path: 'List',
  239. children: [
  240. {
  241. name: '查询表格',
  242. path: 'TableList',
  243. },
  244. {
  245. name: '标准列表',
  246. path: 'basicList',
  247. },
  248. {
  249. name: '卡片列表',
  250. path: 'CardList',
  251. },
  252. {
  253. name: '搜索列表',
  254. path: 'Search',
  255. children: [
  256. {
  257. name: '搜索列表(文章)',
  258. path: 'Articles',
  259. },
  260. {
  261. name: '搜索列表(项目)',
  262. path: 'Projects',
  263. },
  264. {
  265. name: '搜索列表(应用)',
  266. path: 'Applications',
  267. },
  268. ],
  269. },
  270. ],
  271. },
  272. {
  273. name: '详情页',
  274. icon: 'profile',
  275. path: 'Profile',
  276. children: [
  277. {
  278. name: '基础详情页',
  279. path: 'BasicProfile',
  280. },
  281. {
  282. name: '高级详情页',
  283. path: 'AdvancedProfile',
  284. // authority: 'admin',
  285. },
  286. ],
  287. },
  288. {
  289. name: '结果页',
  290. icon: 'check-circle-o',
  291. path: 'Result',
  292. children: [
  293. {
  294. name: '成功',
  295. path: 'Success',
  296. },
  297. {
  298. name: '失败',
  299. path: 'Fail',
  300. },
  301. ],
  302. },
  303. {
  304. name: '异常页',
  305. icon: 'warning',
  306. path: 'Exception',
  307. children: [
  308. {
  309. name: '403',
  310. path: '403',
  311. },
  312. {
  313. name: '404',
  314. path: '404',
  315. },
  316. {
  317. name: '500',
  318. path: '500',
  319. },
  320. {
  321. name: '触发异常',
  322. path: 'triggerException',
  323. hideInMenu: true,
  324. },
  325. ],
  326. },
  327. {
  328. name: '账户',
  329. icon: 'user',
  330. path: 'User',
  331. authority: 'guest',
  332. children: [
  333. {
  334. name: '登录',
  335. path: 'Login',
  336. },
  337. {
  338. name: '注册',
  339. path: 'Register',
  340. },
  341. {
  342. name: '注册结果',
  343. path: 'RegisterResult',
  344. },
  345. ],
  346. },
  347. {
  348. name: '个人页',
  349. icon: 'user',
  350. path: 'Account',
  351. children: [
  352. {
  353. name: '个人中心',
  354. path: 'Center',
  355. },
  356. {
  357. name: '个人设置',
  358. path: 'Settings',
  359. },
  360. ],
  361. },
  362. ];
  363. function formatter(data, parentPath = '/', parentAuthority) {
  364. return data.map(item => {
  365. let { path } = item;
  366. if (!isUrl(path)) {
  367. path = parentPath + item.path;
  368. }
  369. const result = {
  370. ...item,
  371. path,
  372. authority: item.authority || parentAuthority,
  373. };
  374. if (item.children) {
  375. result.children = formatter(item.children, `${parentPath}${item.path}/`, item.authority);
  376. }
  377. return result;
  378. });
  379. }
  380. export const getMenuData = () => formatter(menuData);