routerConfig.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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/dynamic',
  226. name: '创意列表',
  227. access: 'dynamic',
  228. routes: [
  229. {
  230. path: '/gameDataStatistics/dynamic/tencentMonitor',
  231. name: '腾讯创意监控',
  232. access: 'tencentMonitor',
  233. component: './gameDataStatistics/dynamic/tencentMonitor',
  234. }
  235. ]
  236. },
  237. {
  238. path: '/gameDataStatistics/gameData',
  239. name: '游戏数据',
  240. access: 'gameData',
  241. routes: [
  242. {
  243. path: '/gameDataStatistics/gameData/total',
  244. name: '游戏总数据',
  245. access: 'total',
  246. component: './gameDataStatistics/gameData/total',
  247. },
  248. {
  249. path: '/gameDataStatistics/gameData/everyday',
  250. name: '游戏每日数据',
  251. access: 'everyday',
  252. component: './gameDataStatistics/gameData/everyday',
  253. },
  254. {
  255. path: '/gameDataStatistics/gameData/h5Recharge',
  256. name: 'H5游戏充值表',
  257. access: 'h5Recharge',
  258. component: './gameDataStatistics/gameData/h5Recharge',
  259. },
  260. {
  261. path: '/gameDataStatistics/gameData/flowingWater',
  262. name: '每日流水贡献',
  263. access: 'flowingWater',
  264. component: './gameDataStatistics/gameData/flowingWater',
  265. },
  266. {
  267. path: '/gameDataStatistics/gameData/ltv',
  268. name: 'LTV',
  269. access: 'ltv',
  270. component: './gameDataStatistics/gameData/ltv',
  271. },
  272. {
  273. path: '/gameDataStatistics/gameData/again',
  274. name: '游戏首日复充',
  275. access: 'again',
  276. component: './gameDataStatistics/gameData/again',
  277. },
  278. {
  279. path: '/gameDataStatistics/gameData/active',
  280. name: '游戏留存数据',
  281. access: 'active',
  282. component: './gameDataStatistics/gameData/active',
  283. },
  284. {
  285. path: '/gameDataStatistics/gameData/activeM',
  286. name: '每月留存数据',
  287. access: 'activeM',
  288. component: './gameDataStatistics/gameData/activeM',
  289. },
  290. ]
  291. },
  292. {
  293. path: '/gameDataStatistics/pitcher',
  294. name: '投手数据',
  295. access: 'pitcher',
  296. routes: [
  297. {
  298. path: '/gameDataStatistics/pitcher/total',
  299. name: '投手总数据',
  300. access: 'total',
  301. component: './gameDataStatistics/pitcher/total',
  302. },
  303. {
  304. path: '/gameDataStatistics/pitcher/everyDay',
  305. name: '投手每日数据',
  306. access: 'everyDay',
  307. component: './gameDataStatistics/pitcher/everyDay',
  308. },
  309. {
  310. path: '/gameDataStatistics/pitcher/totalGame',
  311. name: '投手游戏总数据',
  312. access: 'totalGame',
  313. component: './gameDataStatistics/pitcher/totalGame',
  314. },
  315. {
  316. path: '/gameDataStatistics/pitcher/everyDayGame',
  317. name: '投手游戏每日数据',
  318. access: 'everyDayGame',
  319. component: './gameDataStatistics/pitcher/everyDayGame',
  320. },
  321. ]
  322. },
  323. {
  324. path: '/gameDataStatistics/medium',
  325. name: '媒体数据',
  326. access: 'medium',
  327. routes: [
  328. {
  329. path: '/gameDataStatistics/medium/promotionEvery',
  330. name: '推广媒体每日数据',
  331. access: 'promotionEvery',
  332. component: './gameDataStatistics/medium/promotionEvery',
  333. },
  334. {
  335. path: '/gameDataStatistics/medium/promotionTotal',
  336. name: '推广媒体总数据',
  337. access: 'promotionTotal',
  338. component: './gameDataStatistics/medium/promotionTotal',
  339. },
  340. {
  341. path: '/gameDataStatistics/medium/pitcherEvery',
  342. name: '投手媒体每日数据',
  343. access: 'pitcherEvery',
  344. component: './gameDataStatistics/medium/pitcherEvery',
  345. },
  346. {
  347. path: '/gameDataStatistics/medium/pitcherTotal',
  348. name: '投手媒体总数据',
  349. access: 'pitcherTotal',
  350. component: './gameDataStatistics/medium/pitcherTotal',
  351. },
  352. {
  353. path: '/gameDataStatistics/medium/gameEvery',
  354. name: '游戏媒体每日数据',
  355. access: 'gameEvery',
  356. component: './gameDataStatistics/medium/gameEvery',
  357. },
  358. {
  359. path: '/gameDataStatistics/medium/gameTotal',
  360. name: '游戏媒体总数据',
  361. access: 'gameTotal',
  362. component: './gameDataStatistics/medium/gameTotal',
  363. },
  364. {
  365. path: '/gameDataStatistics/medium/mediumActive',
  366. name: '游戏媒体留存数据',
  367. access: 'mediumActive',
  368. component: './gameDataStatistics/medium/mediumActive',
  369. },
  370. ]
  371. },
  372. {
  373. path: '/gameDataStatistics/player',
  374. name: '玩家数据',
  375. access: 'player',
  376. routes: [
  377. {
  378. path: '/gameDataStatistics/player/list',
  379. name: '玩家列表',
  380. access: 'list',
  381. component: './gameDataStatistics/player/list',
  382. },
  383. {
  384. path: '/gameDataStatistics/player/role',
  385. name: '玩家角色',
  386. access: 'role',
  387. component: './gameDataStatistics/player/role',
  388. },
  389. {
  390. path: '/gameDataStatistics/player/loginLog',
  391. name: '玩家登录日志',
  392. access: 'loginLog',
  393. component: './gameDataStatistics/player/loginLog',
  394. },
  395. {
  396. path: '/gameDataStatistics/player/banGamePlayerManage',
  397. name: '封禁玩家管理',
  398. access: 'banGamePlayerManage',
  399. component: './gameDataStatistics/player/banGamePlayerManage',
  400. },
  401. {
  402. path: '/gameDataStatistics/player/banIpManage',
  403. name: '封禁IP管理',
  404. access: 'banIpManage',
  405. component: './gameDataStatistics/player/banIpManage',
  406. }
  407. ]
  408. },
  409. {
  410. path: '/gameDataStatistics/gameServer',
  411. name: '游戏区服',
  412. access: 'gameServer',
  413. routes: [
  414. {
  415. path: '/gameDataStatistics/gameServer/serverData',
  416. name: '区服数据',
  417. access: 'serverData',
  418. component: './gameDataStatistics/gameServer/serverData',
  419. },
  420. {
  421. path: '/gameDataStatistics/gameServer/serverEveryData',
  422. name: '区服每日数据',
  423. access: 'serverEveryData',
  424. component: './gameDataStatistics/gameServer/serverEveryData',
  425. },
  426. {
  427. path: '/gameDataStatistics/gameServer/serverGsData',
  428. name: 'GS区服',
  429. access: 'serverGsData',
  430. component: './gameDataStatistics/gameServer/serverGsData',
  431. }
  432. ]
  433. },
  434. {
  435. path: '/gameDataStatistics/stream',
  436. name: '流水监控',
  437. access: 'stream',
  438. routes: [
  439. {
  440. path: '/gameDataStatistics/stream/recharge',
  441. name: '充值历史',
  442. access: 'recharge',
  443. component: './gameDataStatistics/stream/recharge',
  444. }
  445. ]
  446. },
  447. {
  448. path: '/gameDataStatistics/order',
  449. name: '订单',
  450. access: 'order',
  451. component: './gameDataStatistics/order',
  452. },
  453. ]
  454. }
  455. const gsData = {
  456. path: '/gsData',
  457. routes: [
  458. {
  459. path: '/gsData/bidREveryday',
  460. name: '大R每日充值比',
  461. access: 'bidREveryday',
  462. component: './gsData/bidREveryday',
  463. },
  464. {
  465. path: '/gsData/rolePayRetained',
  466. name: 'GS角色付费留存',
  467. access: 'rolePayRetained',
  468. component: './gsData/rolePayRetained',
  469. },
  470. {
  471. path: '/gsData/serverPayRetained',
  472. name: 'GS区服付费留存',
  473. access: 'serverPayRetained',
  474. component: './gsData/serverPayRetained',
  475. },
  476. {
  477. path: '/gsData/roleRemoveMonitor',
  478. name: '角色流失监控',
  479. access: 'roleRemoveMonitor',
  480. component: './gsData/roleRemoveMonitor',
  481. },
  482. {
  483. path: '/gsData/roleManage',
  484. name: '游戏角色管理',
  485. access: 'roleManage',
  486. component: './gsData/roleManage',
  487. },
  488. {
  489. path: '/gsData/serverManage',
  490. name: '游戏区服管理',
  491. access: 'serverManage',
  492. component: './gsData/serverManage',
  493. },
  494. {
  495. path: '/gsData/xjRoleGrade',
  496. name: '角色等级表(仙剑)',
  497. access: 'xjRoleGrade',
  498. component: './gsData/xjRoleGrade',
  499. }
  500. ]
  501. }
  502. export {
  503. headrRouter,
  504. getMyMenu,
  505. gameDataStatistics,
  506. gsData
  507. }