routerConfig.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. /**头部路由一级菜单点击逻辑 */
  2. function headrRouter(initialState: any, history: any) {
  3. let ok = true
  4. let u = navigator?.userAgent
  5. let isPhone = !!u.match(/AppleWebKit.*Mobile.*/) || u?.indexOf('iPad') > -1
  6. //登录时指向/辅助处理看当前用户的一级菜单有哪些,找到第一个符合的跳转
  7. initialState?.menu?.data.forEach((item: { roles: string[], path: string, routes: { path: string, routes: any[] }[] }) => {
  8. if (ok) {
  9. ok = false
  10. let path = item?.routes?.length > 0 ? item?.routes[0]?.routes?.length > 0 ? item?.routes[0]?.routes[0]?.path ? item?.routes[0]?.routes[0]?.path : item?.routes[0].path : item?.routes[0].path : item?.routes[0].path
  11. if (history?.location?.pathname === '/') {
  12. history.push(path)
  13. }
  14. }
  15. })
  16. if (history?.location?.pathname === '/gameDataStatistics') { //当切换一级菜单的辅助跳转
  17. history?.goBack()
  18. initialState?.menu?.data.forEach((item: { roles: string[], path: string, routes: { path: string, routes: any[] }[] }) => {
  19. if (item?.routes?.some((i: { path: string }) => i.path?.includes('/gameDataStatistics'))) {
  20. let path = item?.routes?.length > 0 ? (item?.routes[0]?.routes?.length > 0 && item?.routes[0]?.routes[0]?.path) ? item?.routes[0]?.routes[0]?.path : item?.routes[0].path : item?.routes[0].path
  21. isPhone ? history.push(path) : window.open(location.origin + '/#' + path)
  22. }
  23. })
  24. }
  25. if (history?.location?.pathname === '/gsData') { //当切换一级菜单的辅助跳转
  26. history?.goBack()
  27. initialState?.menu?.data.forEach((item: { roles: string[], path: string, routes: { path: string, routes: any[] }[] }) => {
  28. if (item?.routes?.some((i: { path: string }) => i.path?.includes('/gsData'))) {
  29. let path = item?.routes?.length > 0 ? (item?.routes[0]?.routes?.length > 0 && item?.routes[0]?.routes[0]?.path) ? item?.routes[0]?.routes[0]?.path : item?.routes[0].path : item?.routes[0].path
  30. isPhone ? history.push(path) : window.open(location.origin + '/#' + path)
  31. }
  32. })
  33. }
  34. }
  35. //返回按钮路由
  36. function btnFun(items: any) {
  37. return items?.childrenBtn?.map((btn: any,) => {
  38. return { name: btn.meta.title, key: btn?.menuId }
  39. })
  40. }
  41. //返回子路由
  42. function routeFun(items: any) {
  43. return items.children.map((route: any) => {//循环重组
  44. if (route?.children?.length > 0) {
  45. let arr = routeFun(route)
  46. return { path: route.path, name: route.meta.title, component: route.component, routes: arr, icon: route.meta.icon, key: route?.menuId }
  47. }
  48. if (route?.childrenBtn?.length > 0) {
  49. let arr = btnFun(route)
  50. return { path: route.path, name: route.meta.title, component: route.component, routes: arr, icon: route.meta.icon, key: route?.menuId }
  51. }
  52. return { path: route.path, name: route.meta.title, component: route.component, icon: route.meta.icon, key: route?.menuId }
  53. })
  54. }
  55. /**获取线上菜单并重组路由格式和权限*/
  56. function getMyMenu(code: any, data: any,) {
  57. let newData: any = []
  58. // let roles = userInfo?.roles.map((role: any) => role.roleKey)//权限从个人信息中取,以防路由列表中有错误
  59. if (code === 200) {
  60. let new_data: any[] = []
  61. // 循环判断不为空的主菜单加入
  62. Object.keys(data).reverse().map((key) => {
  63. if (Array.isArray(data[key]) && data[key]?.length > 0) {
  64. new_data.push(data[key][0])
  65. }
  66. })
  67. // 处理顺序
  68. new_data = new_data.sort((a, b) => {
  69. let v1 = a.orderNum
  70. let v2 = b.orderNum
  71. return v1 - v2
  72. })
  73. new_data.forEach((items: any) => {
  74. if (items?.children?.length === 0) {//假如路由的子路由只有一个代表当前组件没有子路由,将children中的component组件路径给外层component
  75. newData.push({ path: items.children[0].path, name: items.meta.title, icon: items.meta.icon, component: items.children[0].component, key: items.menuId }) // roles: roles
  76. }
  77. if (items?.children?.length >= 0) {//假如路由的子路由个数大于1代表有子路由
  78. let arr: any[] = routeFun(items)
  79. newData.push({ path: items.path, name: items.meta.title, icon: items.meta.icon, routes: arr, key: items.menuId })//最后添加进routes , roles: roles
  80. }
  81. })
  82. }
  83. return newData
  84. }
  85. const gameDataStatistics = {
  86. path: '/gameDataStatistics',
  87. routes: [
  88. {
  89. path: '/gameDataStatistics/allSurvey',
  90. name: '整体概况',
  91. access: 'allSurvey',
  92. component: './gameDataStatistics/allSurvey',
  93. },
  94. {
  95. path: '/gameDataStatistics/rankingList',
  96. name: '排行榜',
  97. access: 'rankingList',
  98. routes: [
  99. {
  100. path: '/gameDataStatistics/rankingList/gamer',
  101. name: '玩家充值排行榜',
  102. access: 'gamer',
  103. component: './gameDataStatistics/rankingList/gamer',
  104. },
  105. {
  106. path: '/gameDataStatistics/rankingList/game',
  107. name: '游戏充值排行榜',
  108. access: 'game',
  109. component: './gameDataStatistics/rankingList/game',
  110. },
  111. {
  112. path: '/gameDataStatistics/rankingList/channel',
  113. name: '推广渠道充值排行榜',
  114. access: 'channel',
  115. component: './gameDataStatistics/rankingList/channel',
  116. },
  117. {
  118. path: '/gameDataStatistics/rankingList/account',
  119. name: '推广账号消耗排行榜',
  120. access: 'account',
  121. component: './gameDataStatistics/rankingList/account',
  122. }
  123. ]
  124. },
  125. {
  126. path: '/gameDataStatistics/roleOperate',
  127. name: '角色运营管理',
  128. access: 'roleOperate',
  129. routes: [
  130. {
  131. path: '/gameDataStatistics/roleOperate/roleRechargeRanking',
  132. name: '角色充值排行榜',
  133. access: 'roleRechargeRanking',
  134. component: './gameDataStatistics/roleOperate/roleRechargeRanking',
  135. },
  136. {
  137. path: '/gameDataStatistics/roleOperate/roleFightingRanking',
  138. name: '角色战力排行榜',
  139. access: 'roleFightingRanking',
  140. component: './gameDataStatistics/roleOperate/roleFightingRanking',
  141. },
  142. {
  143. path: '/gameDataStatistics/roleOperate/gameServer',
  144. name: '游戏区服',
  145. access: 'gameServer',
  146. component: './gameDataStatistics/roleOperate/gameServer',
  147. },
  148. {
  149. path: '/gameDataStatistics/roleOperate/pack',
  150. name: '礼包',
  151. access: 'pack',
  152. component: './gameDataStatistics/roleOperate/pack',
  153. },
  154. {
  155. path: '/gameDataStatistics/roleOperate/createRoleConfig',
  156. name: '有效创角配置',
  157. access: 'createRoleConfig',
  158. component: './gameDataStatistics/roleOperate/createRoleConfig',
  159. },
  160. {
  161. path: '/gameDataStatistics/roleOperate/vip',
  162. name: '游戏VIP档位',
  163. access: 'vip',
  164. component: './gameDataStatistics/roleOperate/vip',
  165. },
  166. {
  167. path: '/gameDataStatistics/roleOperate/strategy',
  168. name: '游戏策略配置',
  169. access: 'strategy',
  170. component: './gameDataStatistics/roleOperate/strategy',
  171. },
  172. {
  173. path: '/gameDataStatistics/roleOperate/codeSender',
  174. name: '游戏发码器',
  175. access: 'codeSender',
  176. component: './gameDataStatistics/roleOperate/codeSender',
  177. }
  178. ]
  179. },
  180. {
  181. path: '/gameDataStatistics/extensionData',
  182. name: '推广数据',
  183. access: 'extensionData',
  184. routes: [
  185. {
  186. path: '/gameDataStatistics/extensionData/total',
  187. name: '推广总数据',
  188. access: 'total',
  189. component: './gameDataStatistics/extensionData/total',
  190. },
  191. {
  192. path: '/gameDataStatistics/extensionData/everyday',
  193. name: '推广每日数据',
  194. access: 'everyday',
  195. component: './gameDataStatistics/extensionData/everyday',
  196. },
  197. ]
  198. },
  199. {
  200. path: '/gameDataStatistics/adlist',
  201. name: '广告列表',
  202. access: 'adlist',
  203. routes: [
  204. {
  205. path: '/gameDataStatistics/adlist/monitor',
  206. name: '头条广告监控',
  207. access: 'monitor',
  208. component: './gameDataStatistics/adlist/monitor',
  209. },
  210. {
  211. path: '/gameDataStatistics/adlist/tencentMonitor',
  212. name: '腾讯广告监控',
  213. access: 'tencentMonitor',
  214. component: './gameDataStatistics/adlist/tencentMonitor',
  215. },
  216. {
  217. path: '/gameDataStatistics/adlist/strategy',
  218. name: '游戏广告策略',
  219. access: 'strategy',
  220. component: './gameDataStatistics/adlist/strategy',
  221. }
  222. ]
  223. },
  224. {
  225. path: '/gameDataStatistics/gameData',
  226. name: '游戏数据',
  227. access: 'gameData',
  228. routes: [
  229. {
  230. path: '/gameDataStatistics/gameData/total',
  231. name: '游戏总数据',
  232. access: 'total',
  233. component: './gameDataStatistics/gameData/total',
  234. },
  235. {
  236. path: '/gameDataStatistics/gameData/everyday',
  237. name: '游戏每日数据',
  238. access: 'everyday',
  239. component: './gameDataStatistics/gameData/everyday',
  240. },
  241. {
  242. path: '/gameDataStatistics/gameData/h5Recharge',
  243. name: 'H5游戏充值表',
  244. access: 'h5Recharge',
  245. component: './gameDataStatistics/gameData/h5Recharge',
  246. },
  247. {
  248. path: '/gameDataStatistics/gameData/flowingWater',
  249. name: '每日流水贡献',
  250. access: 'flowingWater',
  251. component: './gameDataStatistics/gameData/flowingWater',
  252. },
  253. {
  254. path: '/gameDataStatistics/gameData/ltv',
  255. name: 'LTV',
  256. access: 'ltv',
  257. component: './gameDataStatistics/gameData/ltv',
  258. },
  259. {
  260. path: '/gameDataStatistics/gameData/again',
  261. name: '游戏首日复充',
  262. access: 'again',
  263. component: './gameDataStatistics/gameData/again',
  264. },
  265. {
  266. path: '/gameDataStatistics/gameData/active',
  267. name: '游戏留存数据',
  268. access: 'active',
  269. component: './gameDataStatistics/gameData/active',
  270. },
  271. ]
  272. },
  273. {
  274. path: '/gameDataStatistics/pitcher',
  275. name: '投手数据',
  276. access: 'pitcher',
  277. routes: [
  278. {
  279. path: '/gameDataStatistics/pitcher/total',
  280. name: '投手总数据',
  281. access: 'total',
  282. component: './gameDataStatistics/pitcher/total',
  283. },
  284. {
  285. path: '/gameDataStatistics/pitcher/everyDay',
  286. name: '投手每日数据',
  287. access: 'everyDay',
  288. component: './gameDataStatistics/pitcher/everyDay',
  289. },
  290. {
  291. path: '/gameDataStatistics/pitcher/totalGame',
  292. name: '投手游戏总数据',
  293. access: 'totalGame',
  294. component: './gameDataStatistics/pitcher/totalGame',
  295. },
  296. {
  297. path: '/gameDataStatistics/pitcher/everyDayGame',
  298. name: '投手游戏每日数据',
  299. access: 'everyDayGame',
  300. component: './gameDataStatistics/pitcher/everyDayGame',
  301. },
  302. ]
  303. },
  304. {
  305. path: '/gameDataStatistics/medium',
  306. name: '媒体数据',
  307. access: 'medium',
  308. routes: [
  309. {
  310. path: '/gameDataStatistics/medium/promotionEvery',
  311. name: '推广媒体每日数据',
  312. access: 'promotionEvery',
  313. component: './gameDataStatistics/medium/promotionEvery',
  314. },
  315. {
  316. path: '/gameDataStatistics/medium/promotionTotal',
  317. name: '推广媒体总数据',
  318. access: 'promotionTotal',
  319. component: './gameDataStatistics/medium/promotionTotal',
  320. },
  321. {
  322. path: '/gameDataStatistics/medium/pitcherEvery',
  323. name: '投手媒体每日数据',
  324. access: 'pitcherEvery',
  325. component: './gameDataStatistics/medium/pitcherEvery',
  326. },
  327. {
  328. path: '/gameDataStatistics/medium/pitcherTotal',
  329. name: '投手媒体总数据',
  330. access: 'pitcherTotal',
  331. component: './gameDataStatistics/medium/pitcherTotal',
  332. },
  333. {
  334. path: '/gameDataStatistics/medium/gameEvery',
  335. name: '游戏媒体每日数据',
  336. access: 'gameEvery',
  337. component: './gameDataStatistics/medium/gameEvery',
  338. },
  339. {
  340. path: '/gameDataStatistics/medium/gameTotal',
  341. name: '游戏媒体总数据',
  342. access: 'gameTotal',
  343. component: './gameDataStatistics/medium/gameTotal',
  344. },
  345. {
  346. path: '/gameDataStatistics/medium/mediumActive',
  347. name: '游戏媒体留存数据',
  348. access: 'mediumActive',
  349. component: './gameDataStatistics/medium/mediumActive',
  350. },
  351. ]
  352. },
  353. {
  354. path: '/gameDataStatistics/player',
  355. name: '玩家数据',
  356. access: 'player',
  357. routes: [
  358. {
  359. path: '/gameDataStatistics/player/list',
  360. name: '玩家列表',
  361. access: 'list',
  362. component: './gameDataStatistics/player/list',
  363. },
  364. {
  365. path: '/gameDataStatistics/player/role',
  366. name: '玩家角色',
  367. access: 'role',
  368. component: './gameDataStatistics/player/role',
  369. },
  370. {
  371. path: '/gameDataStatistics/player/loginLog',
  372. name: '玩家登录日志',
  373. access: 'loginLog',
  374. component: './gameDataStatistics/player/loginLog',
  375. },
  376. {
  377. path: '/gameDataStatistics/player/banGamePlayerManage',
  378. name: '封禁玩家管理',
  379. access: 'banGamePlayerManage',
  380. component: './gameDataStatistics/player/banGamePlayerManage',
  381. },
  382. {
  383. path: '/gameDataStatistics/player/banIpManage',
  384. name: '封禁IP管理',
  385. access: 'banIpManage',
  386. component: './gameDataStatistics/player/banIpManage',
  387. }
  388. ]
  389. },
  390. {
  391. path: '/gameDataStatistics/gameServer',
  392. name: '游戏区服',
  393. access: 'gameServer',
  394. routes: [
  395. {
  396. path: '/gameDataStatistics/gameServer/serverData',
  397. name: '区服数据',
  398. access: 'serverData',
  399. component: './gameDataStatistics/gameServer/serverData',
  400. },
  401. {
  402. path: '/gameDataStatistics/gameServer/serverEveryData',
  403. name: '区服每日数据',
  404. access: 'serverEveryData',
  405. component: './gameDataStatistics/gameServer/serverEveryData',
  406. },
  407. {
  408. path: '/gameDataStatistics/gameServer/serverGsData',
  409. name: 'GS区服',
  410. access: 'serverGsData',
  411. component: './gameDataStatistics/gameServer/serverGsData',
  412. }
  413. ]
  414. },
  415. {
  416. path: '/gameDataStatistics/stream',
  417. name: '流水监控',
  418. access: 'stream',
  419. routes: [
  420. {
  421. path: '/gameDataStatistics/stream/recharge',
  422. name: '充值历史',
  423. access: 'recharge',
  424. component: './gameDataStatistics/stream/recharge',
  425. }
  426. ]
  427. },
  428. {
  429. path: '/gameDataStatistics/order',
  430. name: '订单',
  431. access: 'order',
  432. component: './gameDataStatistics/order',
  433. },
  434. ]
  435. }
  436. const gsData = {
  437. path: '/gsData',
  438. routes: [
  439. {
  440. path: '/gsData/bidREveryday',
  441. name: '大R每日充值比',
  442. access: 'bidREveryday',
  443. component: './gsData/bidREveryday',
  444. },
  445. {
  446. path: '/gsData/rolePayRetained',
  447. name: 'GS角色付费留存',
  448. access: 'rolePayRetained',
  449. component: './gsData/rolePayRetained',
  450. },
  451. {
  452. path: '/gsData/serverPayRetained',
  453. name: 'GS区服付费留存',
  454. access: 'serverPayRetained',
  455. component: './gsData/serverPayRetained',
  456. },
  457. {
  458. path: '/gsData/roleRemoveMonitor',
  459. name: '角色流失监控',
  460. access: 'roleRemoveMonitor',
  461. component: './gsData/roleRemoveMonitor',
  462. },
  463. {
  464. path: '/gsData/roleManage',
  465. name: '游戏角色管理',
  466. access: 'roleManage',
  467. component: './gsData/roleManage',
  468. },
  469. {
  470. path: '/gsData/serverManage',
  471. name: '游戏区服管理',
  472. access: 'serverManage',
  473. component: './gsData/serverManage',
  474. }
  475. ]
  476. }
  477. export {
  478. headrRouter,
  479. getMyMenu,
  480. gameDataStatistics,
  481. gsData
  482. }