123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- /**头部路由一级菜单点击逻辑 */
- function headrRouter(initialState: any, history: any) {
- let ok = true
- let u = navigator?.userAgent
- let isPhone = !!u.match(/AppleWebKit.*Mobile.*/) || u?.indexOf('iPad') > -1
- //登录时指向/辅助处理看当前用户的一级菜单有哪些,找到第一个符合的跳转
- initialState?.menu?.data.forEach((item: { roles: string[], path: string, routes: { path: string, routes: any[] }[] }) => {
- if (ok) {
- ok = false
- 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
- if (history?.location?.pathname === '/') {
- history.push(path)
- }
- }
- })
- if (history?.location?.pathname === '/operatePage') { //当切换一级菜单的辅助跳转
- history?.goBack()
- initialState?.menu?.data.forEach((item: { roles: string[], path: string, routes: { path: string, routes: any[] }[] }) => {
- if (item?.routes?.some((i: { path: string }) => i.path?.includes('/operatePage'))) {
- 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
- // history.push(path)
- isPhone ? history.push(path) : window.open(location.origin+'/#'+path)
- // window.open(location.origin+'/#'+path)
- }
- })
- // localStorage.setItem('bg', 'light')
- }
- if (history?.location?.pathname === '/dataStatistics') { //当切换一级菜单的辅助跳转
- history?.goBack()
- initialState?.menu?.data.forEach((item: { roles: string[], path: string, routes: { path: string, routes: any[] }[] }) => {
- if (item?.routes?.some((i: { path: string }) => i.path?.includes('/dataStatistics'))) {
- 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
- // history.push(path)
- // window.open(location.origin+'/#'+path)
- isPhone ? history.push(path) : window.open(location.origin+'/#'+path)
- }
- })
- // localStorage.setItem('bg', 'dark')
- }
- if (history?.location?.pathname === '/launchSystem') { //当切换一级菜单的辅助跳转
- history?.goBack()
- initialState?.menu?.data.forEach((item: { roles: string[], path: string, routes: { path: string, routes: any[] }[] }) => {
- if (item?.routes?.some((i: { path: string }) => i.path?.includes('/launchSystem'))) {
- 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
- // history.push(path)
- // window.open(location.origin+'/#'+path)
- isPhone ? history.push(path) : window.open(location.origin+'/#'+path)
- }
- })
- // localStorage.setItem('bg', 'dark')
- }
- if (history?.location?.pathname === '/enterpriseWeChat') { //当切换一级菜单的辅助跳转
- history?.goBack()
- initialState?.menu?.data.forEach((item: { roles: string[], path: string, routes: { path: string, routes: any[] }[] }) => {
- if (item?.routes?.some((i: { path: string }) => i.path?.includes('/enterpriseWeChat'))) {
- 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
- // history.push(path)
- // window.open(location.origin+'/#'+path)
- isPhone ? history.push(path) : window.open(location.origin+'/#'+path)
- }
- })
- // localStorage.setItem('bg', 'dark')
- }
- }
- //返回按钮路由
- function btnFun(items: any) {
- return items?.childrenBtn?.map((btn: any,) => {
- return { name: btn.meta.title, key: btn?.menuId }
- })
- }
- //返回子路由
- function routeFun(items: any) {
- return items.children.map((route: any) => {//循环重组
- if (route?.children?.length > 0) {
- let arr = routeFun(route)
- return { path: route.path, name: route.meta.title, component: route.component, routes: arr, icon: route.meta.icon, key: route?.menuId }
- }
- if (route?.childrenBtn?.length > 0) {
- let arr = btnFun(route)
- return { path: route.path, name: route.meta.title, component: route.component, routes: arr, icon: route.meta.icon, key: route?.menuId }
- }
- return { path: route.path, name: route.meta.title, component: route.component, icon: items.meta.icon, key: route?.menuId }
- })
- }
- /**获取线上菜单并重组路由格式和权限*/
- function getMyMenu(code: any, data: any,) {
- let newData: any = []
- // let roles = userInfo?.roles.map((role: any) => role.roleKey)//权限从个人信息中取,以防路由列表中有错误
- if (code === 200) {
- let new_data: any[] = []
- // 循环判断不为空的主菜单加入
- Object.keys(data).reverse().map((key) => {
- if (Array.isArray(data[key]) && data[key]?.length > 0) {
- new_data.push(data[key][0])
- }
- })
- // 处理顺序
- new_data = new_data.sort((a, b) => {
- let v1 = a.orderNum
- let v2 = b.orderNum
- return v1 - v2
- })
- new_data.forEach((items: any) => {
- if (items?.children?.length === 0) {//假如路由的子路由只有一个代表当前组件没有子路由,将children中的component组件路径给外层component
- 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
- }
- if (items?.children?.length >= 0) {//假如路由的子路由个数大于1代表有子路由
- let arr: any[] = routeFun(items)
- newData.push({ path: items.path, name: items.meta.title, icon: items.meta.icon, routes: arr, key: items.menuId })//最后添加进routes , roles: roles
- }
- })
- }
- return newData
- }
- /**本地运营路由配置 */
- let operatePage = {
- path: '/operatePage',
- access: 'operatePage',
- name: '运营',
- routes: [
- {
- path: '/operatePage/account/wxcode',
- layout: false,
- routes: [
- {
- name: 'wxcode',
- path: '/operatePage/account/wxcode',
- component: './operatePage/account/wxcode',
- },
- ],
- },
- {
- path: '/operatePage/operate',
- name: '运营中心',
- access: 'operate',
- icon: 'DesktopOutlined',
- component: './operatePage/operate',
- },
- {
- path: '/operatePage/interact',
- name: '智能互动',
- access: 'interact',
- icon: 'MessageOutlined',
- routes: [
- {
- name: '智能推送',
- path: '/operatePage/interact/push',
- access: 'push',
- component: './operatePage/interact/push',
- },
- {
- name: '关注回复',
- path: '/operatePage/interact/reply',
- access: 'reply',
- component: './operatePage/interact/reply',
- },
- {
- name: '关键字回复',
- path: '/operatePage/interact/keyword',
- access: 'keyword',
- component: './operatePage/interact/keyword',
- },
- {
- name: '自定义菜单',
- path: '/operatePage/interact/custommenu',
- access: 'custommenu',
- component: './operatePage/interact/custommenu',
- }
- ]
- },
- {
- path: '/operatePage/news',
- name: '群发推送',
- access: 'news',
- icon: 'SendOutlined',
- routes: [
- {
- name: '客服消息',
- path: '/operatePage/news/aservice',
- access: 'aservice',
- component: './operatePage/news/aservice',
- },
- {
- name: '模板消息',
- path: '/operatePage/news/atemplate',
- access: 'atemplate',
- component: './operatePage/news/atemplate',
- },
- {
- name: '高级群发',
- path: '/operatePage/news/advanced',
- access: 'advanced',
- component: './operatePage/news/advanced',
- }
- ]
- },
- {
- path: '/operatePage/fans',
- name: '粉丝管理',
- access: 'fans',
- icon: 'TeamOutlined',
- routes: [
- {
- name: '粉丝消息',
- path: '/operatePage/fans/message',
- access: 'message',
- component: './operatePage/fans/message',
- },
- {
- name: '粉丝列表',
- path: '/operatePage/fans/list',
- access: 'list',
- component: './operatePage/fans/list',
- },
- {
- name: '粉丝标签',
- path: '/operatePage/fans/tag',
- access: 'tag',
- component: './operatePage/fans/tag',
- }
- ]
- },
- {
- path: '/operatePage/material',
- name: '素材管理',
- access: 'material',
- icon: 'DatabaseOutlined',
- routes: [
- {
- name: '本地素材',
- path: '/operatePage/material/cloud',
- access: 'cloud',
- component: './operatePage/material/cloud',
- },
- {
- name: '微信素材',
- path: '/operatePage/material/weChat',
- access: 'weChat',
- component: './operatePage/material/weChat',
- }
- ],
- },
- {
- path: '/operatePage/account',
- name: '公众号管理',
- access: 'account',
- icon: 'QrcodeOutlined',
- component: './operatePage/account',
- },
- {
- path: '/operatePage/weMenu',
- name: '公众号菜单管理',
- access: 'weMenu',
- icon: 'MobileOutlined',
- component: './operatePage/weMenu',
- },
- {
- path: '/operatePage/books',
- name: '小说平台管理',
- access: 'books',
- icon: 'ReadOutlined',
- routes: [
- {
- name: '小说平台管理',
- path: '/operatePage/books/bookcity',
- access: 'bookcity',
- component: './operatePage/books/bookcity',
- },
- {
- name: '小说分类管理',
- path: '/operatePage/books/bookify',
- access: 'bookify',
- component: './operatePage/books/bookify',
- },
- {
- name: '书籍管理',
- path: '/operatePage/books/book',
- access: 'book',
- component: './operatePage/books/book',
- },
- ],
- },
- {
- path: '/operatePage/automation',
- name: '自动化管理',
- access: 'automation',
- icon: 'ReadOutlined',
- routes: [
- {
- name: '自动化创建',
- path: '/operatePage/automation/create',
- access: 'automationCreate',
- component: './operatePage/automation/create',
- },
- {
- name: '书城链接',
- path: '/operatePage/automation/links',
- access: 'automationLinks',
- component: './operatePage/automation/links',
- },
- ],
- },
- {
- path: '/operatePage/advertisements',
- name: '广告',
- access: 'advertisements',
- icon: 'DesktopOutlined',
- routes: [
- {
- name: '广告变现说明',
- path: '/operatePage/advertisements/course',
- access: 'course',
- component: './operatePage/advertisements/course'
- },
- {
- name: '广告数据统计',
- path: '/operatePage/advertisements/dataCensus',
- access: 'course',
- component: './operatePage/advertisements/dataCensus'
- },
- ],
- },
- {
- path: '/operatePage/examine',
- name: '消息审查',
- access: 'examine',
- icon: 'DesktopOutlined',
- routes: [
- {
- name: '高级群发',
- path: '/operatePage/examine/examineAdvanced',
- access: 'examineAdvanced',
- component: './operatePage/examine/examineAdvanced'
- },
- {
- name: '客服消息',
- path: '/operatePage/examine/examineAservice',
- access: 'examineAservice',
- component: './operatePage/examine/examineAservice'
- },
- {
- name: '模板消息',
- path: '/operatePage/examine/examineAtemplate',
- access: 'examineAtemplate',
- component: './operatePage/examine/examineAtemplate'
- },
- {
- name: '立即/延迟消息',
- path: '/operatePage/examine/examineInteract',
- access: 'examineInteract',
- component: './operatePage/examine/examineInteract'
- },
- ],
- },
- {
- path: '/operatePage/accountyyb',
- name: '账号管理',
- access: 'accountyyb',
- icon: 'ReadOutlined',
- component: './operatePage/accountyyb',
- },
- {
- path: '/operatePage/kyyBoxManage',
- name: '快应用包管理',
- access: 'kyyBoxManage',
- icon: 'ReadOutlined',
- component: './operatePage/kyyBoxManage',
- },
- {
- path: '/operatePage/apitest',
- name: 'api测试',
- access: 'apitest',
- icon: 'ReadOutlined',
- component: './operatePage/apitest',
- },
- ]
- }
- /**本地数据中心路由配置 */
- const dataStatistics = {
- path: '/dataStatistics',
- routes: [
- {
- path: '/dataStatistics/weChat',
- name: '公众号数据',
- access: 'weChat',
- routes: [
- {
- path: '/dataStatistics/weChat/weChatList',
- name: '公众号总数据',
- access: 'weChatList',
- component: './dataStatistics/weChat/weChatList',
- },
- {
- path: '/dataStatistics/weChat/advertising',
- name: '广告投放数据',
- access: 'advertising',
- component: './dataStatistics/weChat/advertising',
- },
- {
- path: '/dataStatistics/weChat/ChannelAnalysis',
- name: '公众号用户充值查询',
- access: 'ChannelAnalysis',
- component: './dataStatistics/weChat/ChannelAnalysis',
- },
- {
- path: '/dataStatistics/weChat/todayRanking',
- name: '今日消耗排行',
- access: 'todayRanking',
- component: './dataStatistics/weChat/todayRanking',
- },
- {
- path: '/dataStatistics/weChat/sevenDay',
- name: '公众号7日复充趋势',
- access: 'sevenDay',
- component: './dataStatistics/weChat/sevenDay',
- },
- {
- path: '/dataStatistics/weChat/payFans',
- name: '公众号付费粉丝激活数据',
- access: 'payFans',
- component: './dataStatistics/weChat/payFans',
- },
- {
- path: '/dataStatistics/weChat/payTrend',
- name: '公众号付费趋势表',
- access: 'payTrend',
- component: './dataStatistics/weChat/payTrend',
- },
- {
- path: '/dataStatistics/weChat/payTrendCom',
- name: '公众号付费趋势(含赔付金)',
- access: 'payTrend',
- component: './dataStatistics/weChat/payTrendCom',
- },
- {
- path: '/dataStatistics/weChat/osoRoi',
- name: '公众号回收查询',
- access: 'osoRoi',
- component: './dataStatistics/weChat/osoRoi',
- },
- ]
- },
- {
- path: '/dataStatistics/pitcher',
- name: '投手数据',
- access: 'pitcher',
- routes: [
- {
- path: '/dataStatistics/pitcher/pitcherPay',
- name: '投手付费趋势表',
- access: 'pitcherPay',
- component: './dataStatistics/pitcher/pitcherPay',
- },
- {
- path: '/dataStatistics/pitcher/dataCenter',
- name: '投手概况',
- access: 'dataCenter',
- component: './dataStatistics/pitcher/dataCenter',
- },
- {
- path: '/dataStatistics/pitcher/overview',
- name: '投手总数据',
- access: 'overview',
- component: './dataStatistics/pitcher/overview',
- },
- {
- path: '/dataStatistics/pitcher/pitcherChannel',
- name: '投手投放号',
- access: 'pitcherChannel',
- component: './dataStatistics/pitcher/pitcherChannel',
- },
- {
- path: '/dataStatistics/pitcher/recoveryQuery',
- name: '投手回收查询',
- access: 'recoveryQuery',
- component: './dataStatistics/pitcher/recoveryQuery',
- },
- ]
- },
- {
- path: '/dataStatistics/book',
- name: '小说数据',
- access: 'novel',
- routes: [
- {
- path: '/dataStatistics/book/payTrend',
- name: '小说付费趋势',
- access: 'payTrend',
- component: './dataStatistics/book/payTrend',
- },
- {
- path: '/dataStatistics/book/summarizing',
- name: '小说总数据',
- access: 'summarizing',
- component: './dataStatistics/book/summarizing',
- },
- ]
- },
- {
- path: '/dataStatistics/imageRank',
- name: '素材数据',
- access: 'imageRank',
- routes: [
- {
- path: '/dataStatistics/imageRank/imageLibrary',
- name: '素材库',
- access: 'imageLibrary',
- component: './dataStatistics/imageRank/imageLibrary',
- },
- {
- path: '/dataStatistics/imageRank/adCost',
- name: '素材消耗排行榜',
- access: 'adCost',
- component: './dataStatistics/imageRank/adCost',
- },
- ]
- },
- {
- path: '/dataStatistics/rechargeMonitor',
- name: '充值监控',
- access: 'rechargeMonitor',
- routes: [
- {
- path: '/dataStatistics/rechargeMonitor/rechargeHis',
- name: '充值历史',
- access: 'rechargeHis',
- component: './dataStatistics/rechargeMonitor/rechargeHis',
- },
- {
- path: '/dataStatistics/rechargeMonitor/rechargeHisYear',
- name: '充值历史(年)',
- access: 'rechargeHisYear',
- component: './dataStatistics/rechargeMonitor/rechargeHisYear',
- },
- ]
- },
- {
- path: '/dataStatistics/allSurvey',
- name: '整体概况',
- access: 'allSurvey',
- component: './dataStatistics/allSurvey',
- },
- ]
- }
- /** 投放系统 */
- const launchSystem = {
- path: '/launchSystem',
- routes: [
- {
- path: '/launchSystem/adMonitor',
- name: '广告监控',
- access: 'adMonitor',
- routes: [
- {
- path: '/launchSystem/adMonitor/adMonitorList',
- name: '广告监控',
- access: 'adMonitorList',
- component: './launchSystem/adMonitor/adMonitorList',
- },
- {
- path: '/launchSystem/adMonitor/monitorDataSource',
- name: '监控数据源',
- access: 'monitorDataSource',
- component: './launchSystem/adMonitor/monitorDataSource',
- },
- ]
- },
- {
- path: '/launchSystem/launchManage',
- name: '广告投放',
- access: 'launchManage',
- routes: [
- {
- path: '/launchSystem/launchManage/adAuthorize',
- name: '授权',
- access: 'adAuthorize',
- component: './launchSystem/launchManage/adAuthorize',
- },
- {
- path: '/launchSystem/launchManage/weChat',
- name: '微信',
- access: 'weChat',
- component: './launchSystem/launchManage/weChat',
- },
- {
- path: '/launchSystem/launchManage/taskList',
- name: '任务列表',
- access: 'taskList',
- component: './launchSystem/launchManage/taskList',
- },
- ]
- },
- {
- path: '/launchSystem/launchManageNew',
- name: '广告投放(new)',
- access: 'launchManageNew',
- routes: [
- {
- path: '/launchSystem/launchManageNew/weChatNew',
- name: '微信',
- access: 'weChatNew',
- component: './launchSystem/launchManageNew/weChatNew',
- },
- {
- path: '/launchSystem/launchManageNew/taskList',
- name: '任务列表',
- access: 'taskList',
- component: './launchSystem/launchManageNew/taskList',
- }
- ]
- },
- {
- path: '/launchSystem/launchManageAdq',
- name: '广告投放(ADQ)',
- access: 'launchManageAdq',
- routes: [
- {
- path: '/launchSystem/launchManageAdq/weChatAdq',
- name: '微信',
- access: 'weChatAdq',
- component: './launchSystem/launchManageAdq/weChatAdq',
- }
- ]
- },
- {
- path: '/launchSystem/materialManage',
- name: '云素材管理中心',
- access: 'materialManage',
- routes: [
- {
- path: '/launchSystem/materialManage/adOriginality',
- name: '广告创意',
- access: 'adOriginality',
- component: './launchSystem/materialManage/adOriginality',
- },
- {
- path: '/launchSystem/materialManage/adMaterial',
- name: '广告图片/视频',
- access: 'adMaterial',
- component: './launchSystem/materialManage/adMaterial',
- },
- {
- path: '/launchSystem/materialManage/adTitle',
- name: '广告标题/文案',
- access: 'adTitle',
- component: './launchSystem/materialManage/adTitle',
- },
- // {
- // path: '/launchSystem/materialManage/tagManage',
- // name: '标签管理',
- // access: 'tagManage',
- // component: './launchSystem/materialManage/tagManage',
- // },
- ]
- },
- {
- path: '/launchSystem/materialManageBd',
- name: '本地素材管理中心',
- access: 'materialManage',
- routes: [
- {
- path: '/launchSystem/materialManageBd/adOriginality',
- name: '广告创意',
- access: 'adOriginality',
- component: './launchSystem/materialManageBd/adOriginality',
- },
- {
- path: '/launchSystem/materialManageBd/adMaterial',
- name: '广告图片/视频',
- access: 'adMaterial',
- component: './launchSystem/materialManageBd/adMaterial',
- },
- {
- path: '/launchSystem/materialManageBd/adTitle',
- name: '广告标题/文案',
- access: 'adTitle',
- component: './launchSystem/materialManageBd/adTitle',
- },
- {
- path: '/launchSystem/materialManageBd/tagManage',
- name: '标签管理',
- access: 'tagManage',
- component: './launchSystem/materialManageBd/tagManage',
- },
- ]
- },
- {
- path: '/launchSystem/headline/staticHtml',
- name: '头条落地页',
- access: 'staticHtml',
- component: './launchSystem/headline/staticHtml',
- },
- {
- path: '/launchSystem/material',
- name: '素材管理',
- access: 'material',
- icon: 'DatabaseOutlined',
- routes: [
- {
- name: '本地素材',
- path: '/launchSystem/material/cloud',
- access: 'cloud',
- component: './launchSystem/material/cloud',
- },
- ],
- },
- ]
- }
- /** 企业微信 */
- const enterpriseWeChat = {
- path: '/enterpriseWeChat',
- routes: [
- {
- path: '/enterpriseWeChat/userManage',
- name: '账号管理',
- access: 'enterpriseWeChatUserManage',
- component: './enterpriseWeChat/userManage'
- },
- {
- path: '/enterpriseWeChat/complaint',
- name: '投诉信息',
- access: 'enterpriseWeChatComplaint',
- component: './enterpriseWeChat/complaint'
- },
- ]
- }
- export {
- headrRouter,
- getMyMenu,
- operatePage,
- dataStatistics,
- launchSystem,
- enterpriseWeChat
- }
|