| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990 |
- import * as VueRouter from 'vue-router'
- import { useUserStore } from '@/store'
- import { isElectron } from '../utils/electron'
- import { canAccessRoute, QK_ASSISTANT_ACCESS_CODES } from '@/utils/permission'
- const DEFAULT_LAYOUT = () => import('@/layout/default-layout.vue')
- const HTML_VIEW = () => import('@/layout/html-view.vue')
- // import { Message } from '@arco-design/web-vue'
- const routes = [
- {
- path: "/",
- name: "main",
- component: () => import('../pages/Main/Main.vue'),
- meta: {
- hideInMenu: true,
- onlyWeb: true,
- public: true
- }
- },
- {
- path: "/faceReco",
- name: "faceReco",
- component: () => import('../pages/face/index.vue'),
- meta: {
- hideInMenu: true,
- onlyWeb: true,
- public: true,
- viewport: 'width=device-width, initial-scale=1'
- }
- },
- {
- path: "/login",
- name: "login",
- component: () => import('../pages/login/login.vue'),
- meta: {
- title: '用户登录',
- hideInMenu: true,
- public: true
- }
- },
- {
- path: "/proxy",
- name: "proxy",
- component: DEFAULT_LAYOUT,
- meta: {
- title: '乐跑登录',
- icon: 'icon-command',
- onlyElectron: true
- },
- children: [
- {
- path: 'openProxy',
- name: 'proxy.openProxy',
- component: () => import('../pages/openProxy/index.vue'),
- meta: {
- title: '启动登录器'
- }
- }
- ]
- },
- {
- path: "/htmlView",
- name: "htmlView",
- component: HTML_VIEW,
- meta: {
- title: '第三方页面',
- hideInMenu: true
- },
- children: [
- {
- path: 'view',
- name: 'htmlView.view',
- component: () => import('../pages/htmlView/index.vue'),
- meta: {
- title: '第三方页面',
- public: true
- }
- }
- ]
- },
- {
- path: "/ai",
- name: 'ai',
- redirect: '/ai/assistant',
- component: DEFAULT_LAYOUT,
- meta: {
- title: 'AI助手',
- icon: 'icon-robot'
- },
- children: [
- {
- path: 'assistant',
- name: 'ai.assistant',
- component: () => import('../pages/ai/assistant/index.vue'),
- meta: {
- title: '小妍助理'
- }
- }
- ]
- },
- {
- path: "/store",
- name: 'store',
- redirect: '/store/goodsList',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '云商城',
- icon: 'icon-gift'
- },
- children: [
- {
- path: 'goodsList',
- name: 'store.goodsList',
- component: () => import('../pages/store/goodsList/index.vue'),
- meta: {
- title: '商品列表'
- }
- },
- {
- path: 'goodsDetail/:id',
- name: 'store.goodsDetail',
- component: () => import('../pages/store/goodsDetail/index.vue'),
- meta: {
- title: '商品详情',
- hideInMenu: true,
- parent: 'store.goodsList'
- }
- },
- {
- path: 'orderDetail/:id',
- name: 'store.orderDetail',
- component: () => import('../pages/store/orders/orderDetail/index.vue'),
- meta: {
- title: '订单详情',
- hideInMenu: true,
- parent: 'store.myOrder'
- }
- },
- {
- path: 'myOrder',
- name: 'store.myOrder',
- component: () => import('../pages/store/orders/orderList/index.vue'),
- meta: {
- title: '我的订单'
- }
- },
- {
- path: 'sendCountRecords',
- name: 'store.sendCountRecords',
- component: () => import('../pages/store/sendCountRecords/index.vue'),
- meta: {
- title: '赠送记录',
- hideInMenu: true,
- parent: 'store.goodsList'
- },
- }
- ]
- },
- {
- path: "/lepao",
- name: 'lepao',
- redirect: '/lepao/accountList',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '校园乐跑',
- icon: 'icon-sun'
- },
- children: [
- {
- path: 'accountList',
- name: 'lepao.accountList',
- component: () => import('../pages/lepao/accountList/index.vue'),
- meta: {
- title: '乐跑账号',
- permissionCode: 'page.lepao.accountList'
- }
- },
- {
- path: 'lepaoRecords',
- name: 'lepao.lepaoRecords',
- component: () => import('../pages/lepao/lepaoRecords/index.vue'),
- meta: {
- title: '乐跑记录'
- }
- },
- {
- path: 'countLedger',
- name: 'lepao.countLedger',
- component: () => import('../pages/lepao/countLedger/index.vue'),
- meta: {
- title: '次数明细'
- }
- },
- {
- path: 'recordDetail/:id',
- name: 'lepao.recordDetail',
- component: () => import('../pages/lepao/lepaoRecords/recordDetail.vue'),
- meta: {
- title: '乐跑记录详情',
- hideInMenu: true,
- parent: 'lepao.lepaoRecords'
- }
- }
- ]
- },
- {
- path: '/qk',
- name: 'qk',
- redirect: '/qk/taskList',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '抢课助手',
- icon: 'icon-calendar-clock',
- permissionCodes: QK_ASSISTANT_ACCESS_CODES
- },
- children: [
- {
- path: 'taskList',
- name: 'qk.taskList',
- component: () => import('../pages/qk/taskList.vue'),
- meta: {
- title: '抢课任务',
- permissionCodes: QK_ASSISTANT_ACCESS_CODES
- }
- }
- ]
- },
- {
- path: "/qxs",
- name: "qxs",
- component: DEFAULT_LAYOUT,
- meta: {
- title: '趣选书',
- icon: 'icon-book'
- },
- children: [
- {
- path: 'getBookList',
- name: 'qxs.getBookList',
- component: () => import('../pages/qxs/getBookList.vue'),
- meta: {
- title: '书单查询',
- public: true
- }
- }
- ]
- },
- {
- path: "/power",
- name: "power",
- component: DEFAULT_LAYOUT,
- meta: {
- title: '宿舍电费',
- icon: 'icon-thunderbolt'
- },
- children: [
- {
- path: 'accountList',
- name: 'power.accountList',
- component: () => import('../pages/power/accountList.vue'),
- meta: {
- title: '定制电费提醒'
- }
- }
- ]
- },
- // {
- // path: '/jwAccount',
- // name: 'jwAccount',
- // redirect: '/jwAccount/accountList',
- // component: DEFAULT_LAYOUT,
- // meta: {
- // title: '统一身份认证',
- // icon: 'icon-idcard'
- // },
- // children: [
- // {
- // path: 'accountList',
- // name: 'jwAccount.accountList',
- // component: () => import('../pages/jwAccount/accountList.vue'),
- // meta: {
- // title: '账号管理'
- // }
- // }
- // ]
- // },
- // {
- // path: '/ic',
- // name: 'ic',
- // redirect: '/ic/freeSeats',
- // component: DEFAULT_LAYOUT,
- // meta: {
- // title: '图书馆占座',
- // icon: 'icon-bookmark'
- // },
- // children: [
- // {
- // path: 'freeSeats',
- // name: 'ic.freeSeats',
- // component: () => import('../pages/ic/freeSeats.vue'),
- // meta: {
- // title: '座位查询'
- // }
- // },
- // {
- // path: 'myOrder',
- // name: 'ic.myOrder',
- // component: () => import('../pages/ic/myOrder.vue'),
- // meta: {
- // title: '我的预约'
- // }
- // },
- // {
- // path: 'star',
- // name: 'ic.star',
- // component: () => import('../pages/ic/star.vue'),
- // meta: {
- // title: '座位志愿'
- // }
- // },
- // {
- // path: 'rule',
- // name: 'ic.rule',
- // component: () => import('../pages/ic/rule.vue'),
- // meta: {
- // title: '占座规则'
- // }
- // }
- // ]
- // },
- {
- path: "/service",
- name: 'service',
- redirect: '/service/orderList',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '售后服务',
- icon: 'icon-customer-service'
- },
- children: [
- {
- path: 'createOrder',
- name: 'service.createOrder',
- component: () => import('../pages/service/createOrder.vue'),
- meta: {
- title: '提交工单',
- permissionCode: 'page.service.createOrder'
- }
- },
- {
- path: 'orderList',
- name: 'service.orderList',
- component: () => import('../pages/service/orderList.vue'),
- meta: {
- title: '我的工单'
- }
- },
- {
- path: 'orderDetail/:id',
- name: 'service.orderDetail',
- component: () => import('../pages/service/orderDetail.vue'),
- meta: {
- title: '工单详情',
- hideInMenu: true,
- parent: 'service.orderList'
- }
- }
- ]
- },
- {
- path: "/aiManage",
- name: 'aiManage',
- redirect: '/aiManage/workOrder/orderList',
- component: DEFAULT_LAYOUT,
- meta: {
- title: 'AI管理',
- icon: 'icon-robot',
- permission: ['admin', 'service'],
- permissionCodes: [
- 'page.admin.service.orderList',
- 'page.admin.aiChat'
- ]
- },
- children: [
- {
- path: 'workOrder/orderList',
- name: 'aiManage.workOrder.orderList',
- component: () => import('../pages/admin/workOrder/orderList.vue'),
- meta: {
- title: '工单处理',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.service.orderList'
- }
- },
- {
- path: 'workOrder/orderDetail/:id',
- name: 'aiManage.workOrder.orderDetail',
- component: () => import('../pages/admin/workOrder/orderDetail.vue'),
- meta: {
- title: '工单详情',
- hideInMenu: true,
- parent: 'aiManage.workOrder.orderList',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.service.orderList'
- }
- },
- {
- path: 'aiChat',
- name: 'aiManage.aiChat.list',
- component: () => import('../pages/admin/aiChat/list.vue'),
- meta: {
- title: 'AI聊天管理',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.aiChat'
- }
- },
- {
- path: 'aiChat/detail/:id',
- name: 'aiManage.aiChat.detail',
- component: () => import('../pages/admin/aiChat/detail.vue'),
- meta: {
- title: 'AI聊天详情',
- hideInMenu: true,
- parent: 'aiManage.aiChat.list',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.aiChat'
- }
- },
- {
- path: 'weixinBinding',
- name: 'aiManage.weixinBinding.list',
- component: () => import('../pages/admin/aiChat/weixinBindingList.vue'),
- meta: {
- title: '微信绑定管理',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.aiChat'
- }
- },
- {
- path: 'quota',
- name: 'aiManage.quota',
- component: () => import('../pages/admin/systemConfig/index.vue'),
- meta: {
- title: 'AI限额配置',
- permission: ['admin'],
- permissionCode: 'page.admin.aiChat'
- }
- }
- ]
- },
- {
- path: "/admin",
- name: 'admin',
- redirect: '/admin/systemConfig',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '网站管理',
- icon: 'icon-computer',
- permission: ['admin', 'service', 'product'],
- permissionCodes: [
- 'page.admin.userList',
- 'page.admin.lepaoAccount',
- 'page.admin.service.orderList',
- 'page.admin.aiChat',
- 'page.admin.goods.sendCountRequestList'
- ]
- },
- children: [
- {
- path: 'systemConfig',
- name: 'admin.systemConfig',
- component: () => import('../pages/admin/systemConfig/index.vue'),
- meta: {
- title: '基础配置',
- permission: ['admin']
- }
- },
- {
- path: 'userList',
- name: 'admin.userList',
- component: () => import('../pages/admin/user/userList.vue'),
- meta: {
- title: '用户管理',
- permission: ['admin', 'userList'],
- permissionCode: 'page.admin.userList'
- }
- },
- {
- path: 'lepaoAccount',
- name: 'admin.lepaoAccount',
- component: () => import('../pages/admin/lepaoAccount/accountList.vue'),
- meta: {
- title: '乐跑账号管理',
- permission: ['admin', 'lepaoAccount'],
- permissionCode: 'page.admin.lepaoAccount'
- }
- },
- {
- path: 'lepaoRecords',
- name: 'admin.lepaoRecords',
- component: () => import('../pages/admin/lepaoRecords/lepaoRecords.vue'),
- meta: {
- title: '乐跑记录',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'lepaoBindAudit',
- name: 'admin.lepaoBindAudit',
- component: () => import('../pages/admin/lepaoBindAudit/index.vue'),
- meta: {
- title: '绑定记录',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'lepaoCountLedger',
- name: 'admin.lepaoCountLedger',
- component: () => import('../pages/admin/lepaoCountLedger/index.vue'),
- meta: {
- title: '乐跑次数明细',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'lepaoRecords/:id',
- name: 'admin.lepaoRecords.detail',
- component: () => import('../pages/admin/lepaoRecords/recordDetail.vue'),
- meta: {
- title: '乐跑记录详情',
- hideInMenu: true,
- parent: 'admin.lepaoRecords',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'popup',
- redirect: '/noticeManage/popup',
- meta: {
- hideInMenu: true,
- permission: ['admin', 'service']
- }
- },
- {
- path: 'mqQueue',
- name: 'admin.mq.queue',
- component: () => import('../pages/admin/mqQueue/index.vue'),
- meta: {
- title: '任务队列',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'goods/sendCountRequestList',
- name: 'admin.goods.sendCountRequestList',
- component: () => import('../pages/admin/goods/sendCountRequestList.vue'),
- meta: {
- title: '赠送审核',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.goods.sendCountRequestList'
- }
- },
- {
- path: 'reqLog',
- name: 'admin.log.reqLog',
- component: () => import('../pages/admin/reqLog/index.vue'),
- meta: {
- title: '请求日志',
- permission: ['admin']
- }
- },
- {
- path: 'powerTask',
- name: 'admin.powerTask',
- component: () => import('../pages/admin/powerTask/index.vue'),
- meta: {
- title: '电费任务',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'qxsAccount',
- name: 'admin.qxsAccount',
- component: () => import('../pages/admin/qxsAccount/index.vue'),
- meta: {
- title: '趣选书管理',
- permission: ['admin', 'service']
- }
- }
- ]
- },
- {
- path: '/qkManage',
- name: 'qkManage',
- redirect: '/qkManage/task',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '抢课管理',
- icon: 'icon-schedule',
- permissionCodes: [
- 'page.admin.qk.client',
- 'page.admin.qk.batch',
- 'page.admin.qk.task',
- 'page.admin.qk.report'
- ]
- },
- children: [
- {
- path: 'batch',
- name: 'qkManage.batch',
- component: () => import('../pages/admin/qkBatch/index.vue'),
- meta: {
- title: '批次管理',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.qk.batch'
- }
- },
- {
- path: 'client',
- name: 'qkManage.client',
- component: () => import('../pages/admin/qkClient/index.vue'),
- meta: {
- title: '抢课客户端',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.qk.client'
- }
- },
- {
- path: 'task',
- name: 'qkManage.task',
- component: () => import('../pages/admin/qkTask/index.vue'),
- meta: {
- title: '抢课任务',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.qk.task'
- }
- },
- {
- path: 'report',
- name: 'qkManage.report',
- component: () => import('../pages/admin/qkReport/index.vue'),
- meta: {
- title: '回报记录',
- permission: ['admin', 'service'],
- permissionCode: 'page.admin.qk.report'
- }
- }
- ]
- },
- {
- path: '/lepao/qkAssistant',
- redirect: '/qk/taskList',
- meta: { hideInMenu: true }
- },
- {
- path: '/admin/qkAssistant',
- redirect: '/qk/taskList',
- meta: { hideInMenu: true }
- },
- {
- path: '/qkManage/assistant',
- redirect: '/qk/taskList',
- meta: { hideInMenu: true }
- },
- {
- path: '/admin/qkClient',
- redirect: '/qkManage/client',
- meta: { hideInMenu: true }
- },
- {
- path: '/admin/qkTask',
- redirect: '/qkManage/task',
- meta: { hideInMenu: true }
- },
- {
- path: '/noticeManage',
- name: 'noticeManage',
- redirect: '/noticeManage/notice',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '公告管理',
- icon: 'icon-notification',
- permission: ['admin', 'service', 'article']
- },
- children: [
- {
- path: 'notice',
- name: 'noticeManage.notice',
- component: () => import('../pages/admin/notice/index.vue'),
- meta: {
- title: '横幅公告',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'popup',
- name: 'noticeManage.popup',
- component: () => import('../pages/admin/popup/index.vue'),
- meta: {
- title: '弹窗公告',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'article',
- name: 'noticeManage.article',
- component: () => import('../pages/admin/article/index.vue'),
- meta: {
- title: '文章管理',
- permission: ['admin', 'article']
- }
- },
- {
- path: 'articleCategory',
- name: 'noticeManage.articleCategory',
- component: () => import('../pages/admin/articleCategory/index.vue'),
- meta: {
- title: '文档分类',
- permission: ['admin', 'article']
- }
- },
- {
- path: 'download',
- name: 'noticeManage.download',
- component: () => import('../pages/admin/download/index.vue'),
- meta: {
- title: '下载项管理',
- permission: ['admin', 'service']
- }
- },
- {
- path: 'downloadVersion',
- name: 'noticeManage.downloadVersion',
- component: () => import('../pages/admin/downloadVersion/index.vue'),
- meta: {
- title: '下载版本管理',
- permission: ['admin', 'service']
- }
- }
- ]
- },
- {
- path: '/goodsManage',
- name: 'goodsManage',
- redirect: '/goodsManage/goods/goodsList',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '商品管理',
- icon: 'icon-apps',
- permission: ['admin', 'product']
- },
- children: [
- {
- path: 'goods/addGoods',
- name: 'admin.goods.addGoods',
- component: () => import('../pages/admin/goods/addGoods.vue'),
- meta: {
- title: '添加商品',
- permission: ['admin', 'product']
- }
- },
- {
- path: 'goods/addGoods/:id',
- name: 'admin.goods.editGoods',
- component: () => import('../pages/admin/goods/addGoods.vue'),
- meta: {
- title: '编辑商品',
- hideInMenu: true,
- parent: 'admin.goods.goodsList',
- permission: ['admin', 'product']
- }
- },
- {
- path: 'goods/goodsList',
- name: 'admin.goods.goodsList',
- component: () => import('../pages/admin/goods/goodsList.vue'),
- meta: {
- title: '商品管理',
- permission: ['admin', 'product']
- }
- },
- {
- path: 'goods/couponList',
- name: 'admin.goods.couponList',
- component: () => import('../pages/admin/goods/couponList.vue'),
- meta: {
- title: '优惠码管理',
- permission: ['admin', 'product']
- }
- },
- {
- path: 'goods/couponEdit',
- name: 'admin.goods.couponAdd',
- component: () => import('../pages/admin/goods/couponEdit.vue'),
- meta: {
- title: '新建优惠码',
- hideInMenu: true,
- parent: 'admin.goods.couponList',
- permission: ['admin', 'product']
- }
- },
- {
- path: 'goods/couponEdit/:id',
- name: 'admin.goods.couponEdit',
- component: () => import('../pages/admin/goods/couponEdit.vue'),
- meta: {
- title: '编辑优惠码',
- hideInMenu: true,
- parent: 'admin.goods.couponList',
- permission: ['admin', 'product']
- }
- },
- {
- path: 'goods/orderList',
- name: 'admin.goods.orderList',
- component: () => import('../pages/admin/goods/orderList.vue'),
- meta: {
- title: '订单管理',
- permission: ['admin', 'product']
- }
- },
- {
- path: 'goods/orderDetail/:orderId',
- name: 'admin.goods.orderDetail',
- component: () => import('../pages/admin/goods/orderDetail.vue'),
- meta: {
- title: '订单详情',
- hideInMenu: true,
- parent: 'admin.goods.orderList',
- permission: ['admin', 'product']
- }
- }
- ]
- },
- {
- path: "/path",
- name: "path",
- redirect: '/path/list',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '路径数据',
- icon: 'icon-location',
- permission: ['admin', 'path']
- },
- children: [
- {
- path: 'list',
- name: 'path.list',
- component: () => import('../pages/path/pathList.vue'),
- meta: {
- title: '路径列表'
- }
- },
- {
- path: 'detail/:id',
- name: 'path.detail',
- component: () => import('../pages/path/pathDetail.vue'),
- meta: {
- title: '路径详情',
- hideInMenu: true,
- parent: 'path.list'
- }
- }
- ]
- },
- {
- path: "/user",
- name: "user",
- redirect: '/user/setting',
- component: DEFAULT_LAYOUT,
- meta: {
- title: '个人中心',
- icon: 'icon-user'
- },
- children: [
- {
- path: 'setting',
- name: 'user.setings',
- component: () => import('../pages/user/setting/index.vue'),
- meta: {
- title: '用户设置'
- },
- }
- ]
- },
- {
- path: "/doc",
- name: "docLayout",
- component: DEFAULT_LAYOUT,
- redirect: "/doc/list",
- meta: {
- title: '文档中心',
- icon: 'icon-file',
- public: true,
- flatMenu: true
- },
- children: [
- {
- path: "list",
- name: "doc",
- alias: "/doc",
- component: () => import('../pages/doc/index.vue'),
- meta: {
- title: '文档中心',
- public: true
- }
- },
- {
- path: ":slug",
- name: "doc.detail",
- component: () => import('../pages/doc/detail.vue'),
- meta: {
- title: '文档详情',
- public: true,
- hideInMenu: true,
- parent: 'doc'
- }
- }
- ]
- },
- {
- path: "/download",
- name: "downloadLayout",
- component: DEFAULT_LAYOUT,
- redirect: "/download/index",
- meta: {
- title: '下载中心',
- icon: 'icon-download',
- public: true,
- onlyWeb: true,
- flatMenu: true
- },
- children: [
- {
- path: "index",
- name: "download",
- alias: "/download",
- component: () => import('../pages/download/index.vue'),
- meta: {
- title: '下载中心',
- public: true,
- onlyWeb: true
- }
- }
- ]
- }
- ]
- const router = VueRouter.createRouter({
- history: VueRouter.createWebHashHistory(),
- routes: routes
- })
- const isPublicRoute = (to) => to.matched.some(r => r.meta?.public)
- router.beforeEach(async (to, from, next) => {
- if (!isPublicRoute(to)) {
- const userStore = useUserStore()
- let user = await userStore.getInfo()
- if (!user || !user.uuid || !user.session) {
- // Message.error('请先登录')
- return router.push(`/login?from=${to.path}`)
- }
- if ((!user.permissionCodes || user.permissionCodes.length === 0) && userStore.refreshPermissions)
- await userStore.refreshPermissions()
- user = userStore.$state
- if (!canAccessRoute(to, user)) return next('/')
- }
- if (to.meta.viewport) {
- const meta = document.querySelector('meta[name="viewport"]')
- meta.setAttribute('content', to.meta.viewport)
- }
- if (to.meta && (to.meta.onlyWeb || to.meta.onlyElectron)) {
- const electronEnv = isElectron()
- if (to.meta.onlyWeb && electronEnv) return next('/proxy/openProxy')
- if (to.meta.onlyElectron && !electronEnv) return next('/lepao/accountList')
- }
- if (!to.meta.title) document.title = 'RunForge - 智能校园乐跑平台'
- else document.title = to.meta.title + ' - RunForge'
- next()
- })
- export { routes, router }
|