routerConfig.ts 17 KB

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