index.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. import * as VueRouter from 'vue-router'
  2. import { useUserStore } from '@/store'
  3. import { isElectron } from '../utils/electron'
  4. import { canAccessRoute, QK_ASSISTANT_ACCESS_CODES } from '@/utils/permission'
  5. const DEFAULT_LAYOUT = () => import('@/layout/default-layout.vue')
  6. const HTML_VIEW = () => import('@/layout/html-view.vue')
  7. // import { Message } from '@arco-design/web-vue'
  8. const routes = [
  9. {
  10. path: "/",
  11. name: "main",
  12. component: () => import('../pages/Main/Main.vue'),
  13. meta: {
  14. hideInMenu: true,
  15. onlyWeb: true,
  16. public: true
  17. }
  18. },
  19. {
  20. path: "/faceReco",
  21. name: "faceReco",
  22. component: () => import('../pages/face/index.vue'),
  23. meta: {
  24. hideInMenu: true,
  25. onlyWeb: true,
  26. public: true,
  27. viewport: 'width=device-width, initial-scale=1'
  28. }
  29. },
  30. {
  31. path: "/login",
  32. name: "login",
  33. component: () => import('../pages/login/login.vue'),
  34. meta: {
  35. title: '用户登录',
  36. hideInMenu: true,
  37. public: true
  38. }
  39. },
  40. {
  41. path: "/proxy",
  42. name: "proxy",
  43. component: DEFAULT_LAYOUT,
  44. meta: {
  45. title: '乐跑登录',
  46. icon: 'icon-command',
  47. onlyElectron: true
  48. },
  49. children: [
  50. {
  51. path: 'openProxy',
  52. name: 'proxy.openProxy',
  53. component: () => import('../pages/openProxy/index.vue'),
  54. meta: {
  55. title: '启动登录器'
  56. }
  57. }
  58. ]
  59. },
  60. {
  61. path: "/htmlView",
  62. name: "htmlView",
  63. component: HTML_VIEW,
  64. meta: {
  65. title: '第三方页面',
  66. hideInMenu: true
  67. },
  68. children: [
  69. {
  70. path: 'view',
  71. name: 'htmlView.view',
  72. component: () => import('../pages/htmlView/index.vue'),
  73. meta: {
  74. title: '第三方页面',
  75. public: true
  76. }
  77. }
  78. ]
  79. },
  80. {
  81. path: "/ai",
  82. name: 'ai',
  83. redirect: '/ai/assistant',
  84. component: DEFAULT_LAYOUT,
  85. meta: {
  86. title: 'AI助手',
  87. icon: 'icon-robot'
  88. },
  89. children: [
  90. {
  91. path: 'assistant',
  92. name: 'ai.assistant',
  93. component: () => import('../pages/ai/assistant/index.vue'),
  94. meta: {
  95. title: '小妍助理'
  96. }
  97. }
  98. ]
  99. },
  100. {
  101. path: "/store",
  102. name: 'store',
  103. redirect: '/store/goodsList',
  104. component: DEFAULT_LAYOUT,
  105. meta: {
  106. title: '云商城',
  107. icon: 'icon-gift'
  108. },
  109. children: [
  110. {
  111. path: 'goodsList',
  112. name: 'store.goodsList',
  113. component: () => import('../pages/store/goodsList/index.vue'),
  114. meta: {
  115. title: '商品列表'
  116. }
  117. },
  118. {
  119. path: 'goodsDetail/:id',
  120. name: 'store.goodsDetail',
  121. component: () => import('../pages/store/goodsDetail/index.vue'),
  122. meta: {
  123. title: '商品详情',
  124. hideInMenu: true,
  125. parent: 'store.goodsList'
  126. }
  127. },
  128. {
  129. path: 'orderDetail/:id',
  130. name: 'store.orderDetail',
  131. component: () => import('../pages/store/orders/orderDetail/index.vue'),
  132. meta: {
  133. title: '订单详情',
  134. hideInMenu: true,
  135. parent: 'store.myOrder'
  136. }
  137. },
  138. {
  139. path: 'myOrder',
  140. name: 'store.myOrder',
  141. component: () => import('../pages/store/orders/orderList/index.vue'),
  142. meta: {
  143. title: '我的订单'
  144. }
  145. },
  146. {
  147. path: 'sendCountRecords',
  148. name: 'store.sendCountRecords',
  149. component: () => import('../pages/store/sendCountRecords/index.vue'),
  150. meta: {
  151. title: '赠送记录',
  152. hideInMenu: true,
  153. parent: 'store.goodsList'
  154. },
  155. }
  156. ]
  157. },
  158. {
  159. path: "/lepao",
  160. name: 'lepao',
  161. redirect: '/lepao/accountList',
  162. component: DEFAULT_LAYOUT,
  163. meta: {
  164. title: '校园乐跑',
  165. icon: 'icon-sun'
  166. },
  167. children: [
  168. {
  169. path: 'accountList',
  170. name: 'lepao.accountList',
  171. component: () => import('../pages/lepao/accountList/index.vue'),
  172. meta: {
  173. title: '乐跑账号',
  174. permissionCode: 'page.lepao.accountList'
  175. }
  176. },
  177. {
  178. path: 'lepaoRecords',
  179. name: 'lepao.lepaoRecords',
  180. component: () => import('../pages/lepao/lepaoRecords/index.vue'),
  181. meta: {
  182. title: '乐跑记录'
  183. }
  184. },
  185. {
  186. path: 'countLedger',
  187. name: 'lepao.countLedger',
  188. component: () => import('../pages/lepao/countLedger/index.vue'),
  189. meta: {
  190. title: '次数明细'
  191. }
  192. },
  193. {
  194. path: 'recordDetail/:id',
  195. name: 'lepao.recordDetail',
  196. component: () => import('../pages/lepao/lepaoRecords/recordDetail.vue'),
  197. meta: {
  198. title: '乐跑记录详情',
  199. hideInMenu: true,
  200. parent: 'lepao.lepaoRecords'
  201. }
  202. }
  203. ]
  204. },
  205. {
  206. path: '/qk',
  207. name: 'qk',
  208. redirect: '/qk/taskList',
  209. component: DEFAULT_LAYOUT,
  210. meta: {
  211. title: '抢课助手',
  212. icon: 'icon-calendar-clock',
  213. permissionCodes: QK_ASSISTANT_ACCESS_CODES
  214. },
  215. children: [
  216. {
  217. path: 'taskList',
  218. name: 'qk.taskList',
  219. component: () => import('../pages/qk/taskList.vue'),
  220. meta: {
  221. title: '抢课任务',
  222. permissionCodes: QK_ASSISTANT_ACCESS_CODES
  223. }
  224. }
  225. ]
  226. },
  227. {
  228. path: "/qxs",
  229. name: "qxs",
  230. component: DEFAULT_LAYOUT,
  231. meta: {
  232. title: '趣选书',
  233. icon: 'icon-book'
  234. },
  235. children: [
  236. {
  237. path: 'getBookList',
  238. name: 'qxs.getBookList',
  239. component: () => import('../pages/qxs/getBookList.vue'),
  240. meta: {
  241. title: '书单查询',
  242. public: true
  243. }
  244. }
  245. ]
  246. },
  247. {
  248. path: "/power",
  249. name: "power",
  250. component: DEFAULT_LAYOUT,
  251. meta: {
  252. title: '宿舍电费',
  253. icon: 'icon-thunderbolt'
  254. },
  255. children: [
  256. {
  257. path: 'accountList',
  258. name: 'power.accountList',
  259. component: () => import('../pages/power/accountList.vue'),
  260. meta: {
  261. title: '定制电费提醒'
  262. }
  263. }
  264. ]
  265. },
  266. // {
  267. // path: '/jwAccount',
  268. // name: 'jwAccount',
  269. // redirect: '/jwAccount/accountList',
  270. // component: DEFAULT_LAYOUT,
  271. // meta: {
  272. // title: '统一身份认证',
  273. // icon: 'icon-idcard'
  274. // },
  275. // children: [
  276. // {
  277. // path: 'accountList',
  278. // name: 'jwAccount.accountList',
  279. // component: () => import('../pages/jwAccount/accountList.vue'),
  280. // meta: {
  281. // title: '账号管理'
  282. // }
  283. // }
  284. // ]
  285. // },
  286. // {
  287. // path: '/ic',
  288. // name: 'ic',
  289. // redirect: '/ic/freeSeats',
  290. // component: DEFAULT_LAYOUT,
  291. // meta: {
  292. // title: '图书馆占座',
  293. // icon: 'icon-bookmark'
  294. // },
  295. // children: [
  296. // {
  297. // path: 'freeSeats',
  298. // name: 'ic.freeSeats',
  299. // component: () => import('../pages/ic/freeSeats.vue'),
  300. // meta: {
  301. // title: '座位查询'
  302. // }
  303. // },
  304. // {
  305. // path: 'myOrder',
  306. // name: 'ic.myOrder',
  307. // component: () => import('../pages/ic/myOrder.vue'),
  308. // meta: {
  309. // title: '我的预约'
  310. // }
  311. // },
  312. // {
  313. // path: 'star',
  314. // name: 'ic.star',
  315. // component: () => import('../pages/ic/star.vue'),
  316. // meta: {
  317. // title: '座位志愿'
  318. // }
  319. // },
  320. // {
  321. // path: 'rule',
  322. // name: 'ic.rule',
  323. // component: () => import('../pages/ic/rule.vue'),
  324. // meta: {
  325. // title: '占座规则'
  326. // }
  327. // }
  328. // ]
  329. // },
  330. {
  331. path: "/service",
  332. name: 'service',
  333. redirect: '/service/orderList',
  334. component: DEFAULT_LAYOUT,
  335. meta: {
  336. title: '售后服务',
  337. icon: 'icon-customer-service'
  338. },
  339. children: [
  340. {
  341. path: 'createOrder',
  342. name: 'service.createOrder',
  343. component: () => import('../pages/service/createOrder.vue'),
  344. meta: {
  345. title: '提交工单',
  346. permissionCode: 'page.service.createOrder'
  347. }
  348. },
  349. {
  350. path: 'orderList',
  351. name: 'service.orderList',
  352. component: () => import('../pages/service/orderList.vue'),
  353. meta: {
  354. title: '我的工单'
  355. }
  356. },
  357. {
  358. path: 'orderDetail/:id',
  359. name: 'service.orderDetail',
  360. component: () => import('../pages/service/orderDetail.vue'),
  361. meta: {
  362. title: '工单详情',
  363. hideInMenu: true,
  364. parent: 'service.orderList'
  365. }
  366. }
  367. ]
  368. },
  369. {
  370. path: "/aiManage",
  371. name: 'aiManage',
  372. redirect: '/aiManage/workOrder/orderList',
  373. component: DEFAULT_LAYOUT,
  374. meta: {
  375. title: 'AI管理',
  376. icon: 'icon-robot',
  377. permission: ['admin', 'service'],
  378. permissionCodes: [
  379. 'page.admin.service.orderList',
  380. 'page.admin.aiChat'
  381. ]
  382. },
  383. children: [
  384. {
  385. path: 'workOrder/orderList',
  386. name: 'aiManage.workOrder.orderList',
  387. component: () => import('../pages/admin/workOrder/orderList.vue'),
  388. meta: {
  389. title: '工单处理',
  390. permission: ['admin', 'service'],
  391. permissionCode: 'page.admin.service.orderList'
  392. }
  393. },
  394. {
  395. path: 'workOrder/orderDetail/:id',
  396. name: 'aiManage.workOrder.orderDetail',
  397. component: () => import('../pages/admin/workOrder/orderDetail.vue'),
  398. meta: {
  399. title: '工单详情',
  400. hideInMenu: true,
  401. parent: 'aiManage.workOrder.orderList',
  402. permission: ['admin', 'service'],
  403. permissionCode: 'page.admin.service.orderList'
  404. }
  405. },
  406. {
  407. path: 'aiChat',
  408. name: 'aiManage.aiChat.list',
  409. component: () => import('../pages/admin/aiChat/list.vue'),
  410. meta: {
  411. title: 'AI聊天管理',
  412. permission: ['admin', 'service'],
  413. permissionCode: 'page.admin.aiChat'
  414. }
  415. },
  416. {
  417. path: 'aiChat/detail/:id',
  418. name: 'aiManage.aiChat.detail',
  419. component: () => import('../pages/admin/aiChat/detail.vue'),
  420. meta: {
  421. title: 'AI聊天详情',
  422. hideInMenu: true,
  423. parent: 'aiManage.aiChat.list',
  424. permission: ['admin', 'service'],
  425. permissionCode: 'page.admin.aiChat'
  426. }
  427. },
  428. {
  429. path: 'weixinBinding',
  430. name: 'aiManage.weixinBinding.list',
  431. component: () => import('../pages/admin/aiChat/weixinBindingList.vue'),
  432. meta: {
  433. title: '微信绑定管理',
  434. permission: ['admin', 'service'],
  435. permissionCode: 'page.admin.aiChat'
  436. }
  437. },
  438. {
  439. path: 'quota',
  440. name: 'aiManage.quota',
  441. component: () => import('../pages/admin/systemConfig/index.vue'),
  442. meta: {
  443. title: 'AI限额配置',
  444. permission: ['admin'],
  445. permissionCode: 'page.admin.aiChat'
  446. }
  447. }
  448. ]
  449. },
  450. {
  451. path: "/admin",
  452. name: 'admin',
  453. redirect: '/admin/systemConfig',
  454. component: DEFAULT_LAYOUT,
  455. meta: {
  456. title: '网站管理',
  457. icon: 'icon-computer',
  458. permission: ['admin', 'service', 'product'],
  459. permissionCodes: [
  460. 'page.admin.userList',
  461. 'page.admin.lepaoAccount',
  462. 'page.admin.service.orderList',
  463. 'page.admin.aiChat',
  464. 'page.admin.goods.sendCountRequestList'
  465. ]
  466. },
  467. children: [
  468. {
  469. path: 'systemConfig',
  470. name: 'admin.systemConfig',
  471. component: () => import('../pages/admin/systemConfig/index.vue'),
  472. meta: {
  473. title: '基础配置',
  474. permission: ['admin']
  475. }
  476. },
  477. {
  478. path: 'userList',
  479. name: 'admin.userList',
  480. component: () => import('../pages/admin/user/userList.vue'),
  481. meta: {
  482. title: '用户管理',
  483. permission: ['admin', 'userList'],
  484. permissionCode: 'page.admin.userList'
  485. }
  486. },
  487. {
  488. path: 'lepaoAccount',
  489. name: 'admin.lepaoAccount',
  490. component: () => import('../pages/admin/lepaoAccount/accountList.vue'),
  491. meta: {
  492. title: '乐跑账号管理',
  493. permission: ['admin', 'lepaoAccount'],
  494. permissionCode: 'page.admin.lepaoAccount'
  495. }
  496. },
  497. {
  498. path: 'lepaoRecords',
  499. name: 'admin.lepaoRecords',
  500. component: () => import('../pages/admin/lepaoRecords/lepaoRecords.vue'),
  501. meta: {
  502. title: '乐跑记录',
  503. permission: ['admin', 'service']
  504. }
  505. },
  506. {
  507. path: 'lepaoBindAudit',
  508. name: 'admin.lepaoBindAudit',
  509. component: () => import('../pages/admin/lepaoBindAudit/index.vue'),
  510. meta: {
  511. title: '绑定记录',
  512. permission: ['admin', 'service']
  513. }
  514. },
  515. {
  516. path: 'lepaoCountLedger',
  517. name: 'admin.lepaoCountLedger',
  518. component: () => import('../pages/admin/lepaoCountLedger/index.vue'),
  519. meta: {
  520. title: '乐跑次数明细',
  521. permission: ['admin', 'service']
  522. }
  523. },
  524. {
  525. path: 'lepaoRecords/:id',
  526. name: 'admin.lepaoRecords.detail',
  527. component: () => import('../pages/admin/lepaoRecords/recordDetail.vue'),
  528. meta: {
  529. title: '乐跑记录详情',
  530. hideInMenu: true,
  531. parent: 'admin.lepaoRecords',
  532. permission: ['admin', 'service']
  533. }
  534. },
  535. {
  536. path: 'popup',
  537. redirect: '/noticeManage/popup',
  538. meta: {
  539. hideInMenu: true,
  540. permission: ['admin', 'service']
  541. }
  542. },
  543. {
  544. path: 'mqQueue',
  545. name: 'admin.mq.queue',
  546. component: () => import('../pages/admin/mqQueue/index.vue'),
  547. meta: {
  548. title: '任务队列',
  549. permission: ['admin', 'service']
  550. }
  551. },
  552. {
  553. path: 'goods/sendCountRequestList',
  554. name: 'admin.goods.sendCountRequestList',
  555. component: () => import('../pages/admin/goods/sendCountRequestList.vue'),
  556. meta: {
  557. title: '赠送审核',
  558. permission: ['admin', 'service'],
  559. permissionCode: 'page.admin.goods.sendCountRequestList'
  560. }
  561. },
  562. {
  563. path: 'reqLog',
  564. name: 'admin.log.reqLog',
  565. component: () => import('../pages/admin/reqLog/index.vue'),
  566. meta: {
  567. title: '请求日志',
  568. permission: ['admin']
  569. }
  570. },
  571. {
  572. path: 'powerTask',
  573. name: 'admin.powerTask',
  574. component: () => import('../pages/admin/powerTask/index.vue'),
  575. meta: {
  576. title: '电费任务',
  577. permission: ['admin', 'service']
  578. }
  579. },
  580. {
  581. path: 'qxsAccount',
  582. name: 'admin.qxsAccount',
  583. component: () => import('../pages/admin/qxsAccount/index.vue'),
  584. meta: {
  585. title: '趣选书管理',
  586. permission: ['admin', 'service']
  587. }
  588. }
  589. ]
  590. },
  591. {
  592. path: '/qkManage',
  593. name: 'qkManage',
  594. redirect: '/qkManage/task',
  595. component: DEFAULT_LAYOUT,
  596. meta: {
  597. title: '抢课管理',
  598. icon: 'icon-schedule',
  599. permissionCodes: [
  600. 'page.admin.qk.client',
  601. 'page.admin.qk.batch',
  602. 'page.admin.qk.task',
  603. 'page.admin.qk.report'
  604. ]
  605. },
  606. children: [
  607. {
  608. path: 'batch',
  609. name: 'qkManage.batch',
  610. component: () => import('../pages/admin/qkBatch/index.vue'),
  611. meta: {
  612. title: '批次管理',
  613. permission: ['admin', 'service'],
  614. permissionCode: 'page.admin.qk.batch'
  615. }
  616. },
  617. {
  618. path: 'client',
  619. name: 'qkManage.client',
  620. component: () => import('../pages/admin/qkClient/index.vue'),
  621. meta: {
  622. title: '抢课客户端',
  623. permission: ['admin', 'service'],
  624. permissionCode: 'page.admin.qk.client'
  625. }
  626. },
  627. {
  628. path: 'task',
  629. name: 'qkManage.task',
  630. component: () => import('../pages/admin/qkTask/index.vue'),
  631. meta: {
  632. title: '抢课任务',
  633. permission: ['admin', 'service'],
  634. permissionCode: 'page.admin.qk.task'
  635. }
  636. },
  637. {
  638. path: 'report',
  639. name: 'qkManage.report',
  640. component: () => import('../pages/admin/qkReport/index.vue'),
  641. meta: {
  642. title: '回报记录',
  643. permission: ['admin', 'service'],
  644. permissionCode: 'page.admin.qk.report'
  645. }
  646. }
  647. ]
  648. },
  649. {
  650. path: '/lepao/qkAssistant',
  651. redirect: '/qk/taskList',
  652. meta: { hideInMenu: true }
  653. },
  654. {
  655. path: '/admin/qkAssistant',
  656. redirect: '/qk/taskList',
  657. meta: { hideInMenu: true }
  658. },
  659. {
  660. path: '/qkManage/assistant',
  661. redirect: '/qk/taskList',
  662. meta: { hideInMenu: true }
  663. },
  664. {
  665. path: '/admin/qkClient',
  666. redirect: '/qkManage/client',
  667. meta: { hideInMenu: true }
  668. },
  669. {
  670. path: '/admin/qkTask',
  671. redirect: '/qkManage/task',
  672. meta: { hideInMenu: true }
  673. },
  674. {
  675. path: '/noticeManage',
  676. name: 'noticeManage',
  677. redirect: '/noticeManage/notice',
  678. component: DEFAULT_LAYOUT,
  679. meta: {
  680. title: '公告管理',
  681. icon: 'icon-notification',
  682. permission: ['admin', 'service', 'article']
  683. },
  684. children: [
  685. {
  686. path: 'notice',
  687. name: 'noticeManage.notice',
  688. component: () => import('../pages/admin/notice/index.vue'),
  689. meta: {
  690. title: '横幅公告',
  691. permission: ['admin', 'service']
  692. }
  693. },
  694. {
  695. path: 'popup',
  696. name: 'noticeManage.popup',
  697. component: () => import('../pages/admin/popup/index.vue'),
  698. meta: {
  699. title: '弹窗公告',
  700. permission: ['admin', 'service']
  701. }
  702. },
  703. {
  704. path: 'article',
  705. name: 'noticeManage.article',
  706. component: () => import('../pages/admin/article/index.vue'),
  707. meta: {
  708. title: '文章管理',
  709. permission: ['admin', 'article']
  710. }
  711. },
  712. {
  713. path: 'articleCategory',
  714. name: 'noticeManage.articleCategory',
  715. component: () => import('../pages/admin/articleCategory/index.vue'),
  716. meta: {
  717. title: '文档分类',
  718. permission: ['admin', 'article']
  719. }
  720. },
  721. {
  722. path: 'download',
  723. name: 'noticeManage.download',
  724. component: () => import('../pages/admin/download/index.vue'),
  725. meta: {
  726. title: '下载项管理',
  727. permission: ['admin', 'service']
  728. }
  729. },
  730. {
  731. path: 'downloadVersion',
  732. name: 'noticeManage.downloadVersion',
  733. component: () => import('../pages/admin/downloadVersion/index.vue'),
  734. meta: {
  735. title: '下载版本管理',
  736. permission: ['admin', 'service']
  737. }
  738. }
  739. ]
  740. },
  741. {
  742. path: '/goodsManage',
  743. name: 'goodsManage',
  744. redirect: '/goodsManage/goods/goodsList',
  745. component: DEFAULT_LAYOUT,
  746. meta: {
  747. title: '商品管理',
  748. icon: 'icon-apps',
  749. permission: ['admin', 'product']
  750. },
  751. children: [
  752. {
  753. path: 'goods/addGoods',
  754. name: 'admin.goods.addGoods',
  755. component: () => import('../pages/admin/goods/addGoods.vue'),
  756. meta: {
  757. title: '添加商品',
  758. permission: ['admin', 'product']
  759. }
  760. },
  761. {
  762. path: 'goods/addGoods/:id',
  763. name: 'admin.goods.editGoods',
  764. component: () => import('../pages/admin/goods/addGoods.vue'),
  765. meta: {
  766. title: '编辑商品',
  767. hideInMenu: true,
  768. parent: 'admin.goods.goodsList',
  769. permission: ['admin', 'product']
  770. }
  771. },
  772. {
  773. path: 'goods/goodsList',
  774. name: 'admin.goods.goodsList',
  775. component: () => import('../pages/admin/goods/goodsList.vue'),
  776. meta: {
  777. title: '商品管理',
  778. permission: ['admin', 'product']
  779. }
  780. },
  781. {
  782. path: 'goods/couponList',
  783. name: 'admin.goods.couponList',
  784. component: () => import('../pages/admin/goods/couponList.vue'),
  785. meta: {
  786. title: '优惠码管理',
  787. permission: ['admin', 'product']
  788. }
  789. },
  790. {
  791. path: 'goods/couponEdit',
  792. name: 'admin.goods.couponAdd',
  793. component: () => import('../pages/admin/goods/couponEdit.vue'),
  794. meta: {
  795. title: '新建优惠码',
  796. hideInMenu: true,
  797. parent: 'admin.goods.couponList',
  798. permission: ['admin', 'product']
  799. }
  800. },
  801. {
  802. path: 'goods/couponEdit/:id',
  803. name: 'admin.goods.couponEdit',
  804. component: () => import('../pages/admin/goods/couponEdit.vue'),
  805. meta: {
  806. title: '编辑优惠码',
  807. hideInMenu: true,
  808. parent: 'admin.goods.couponList',
  809. permission: ['admin', 'product']
  810. }
  811. },
  812. {
  813. path: 'goods/orderList',
  814. name: 'admin.goods.orderList',
  815. component: () => import('../pages/admin/goods/orderList.vue'),
  816. meta: {
  817. title: '订单管理',
  818. permission: ['admin', 'product']
  819. }
  820. },
  821. {
  822. path: 'goods/orderDetail/:orderId',
  823. name: 'admin.goods.orderDetail',
  824. component: () => import('../pages/admin/goods/orderDetail.vue'),
  825. meta: {
  826. title: '订单详情',
  827. hideInMenu: true,
  828. parent: 'admin.goods.orderList',
  829. permission: ['admin', 'product']
  830. }
  831. }
  832. ]
  833. },
  834. {
  835. path: "/path",
  836. name: "path",
  837. redirect: '/path/list',
  838. component: DEFAULT_LAYOUT,
  839. meta: {
  840. title: '路径数据',
  841. icon: 'icon-location',
  842. permission: ['admin', 'path']
  843. },
  844. children: [
  845. {
  846. path: 'list',
  847. name: 'path.list',
  848. component: () => import('../pages/path/pathList.vue'),
  849. meta: {
  850. title: '路径列表'
  851. }
  852. },
  853. {
  854. path: 'detail/:id',
  855. name: 'path.detail',
  856. component: () => import('../pages/path/pathDetail.vue'),
  857. meta: {
  858. title: '路径详情',
  859. hideInMenu: true,
  860. parent: 'path.list'
  861. }
  862. }
  863. ]
  864. },
  865. {
  866. path: "/user",
  867. name: "user",
  868. redirect: '/user/setting',
  869. component: DEFAULT_LAYOUT,
  870. meta: {
  871. title: '个人中心',
  872. icon: 'icon-user'
  873. },
  874. children: [
  875. {
  876. path: 'setting',
  877. name: 'user.setings',
  878. component: () => import('../pages/user/setting/index.vue'),
  879. meta: {
  880. title: '用户设置'
  881. },
  882. }
  883. ]
  884. },
  885. {
  886. path: "/doc",
  887. name: "docLayout",
  888. component: DEFAULT_LAYOUT,
  889. redirect: "/doc/list",
  890. meta: {
  891. title: '文档中心',
  892. icon: 'icon-file',
  893. public: true,
  894. flatMenu: true
  895. },
  896. children: [
  897. {
  898. path: "list",
  899. name: "doc",
  900. alias: "/doc",
  901. component: () => import('../pages/doc/index.vue'),
  902. meta: {
  903. title: '文档中心',
  904. public: true
  905. }
  906. },
  907. {
  908. path: ":slug",
  909. name: "doc.detail",
  910. component: () => import('../pages/doc/detail.vue'),
  911. meta: {
  912. title: '文档详情',
  913. public: true,
  914. hideInMenu: true,
  915. parent: 'doc'
  916. }
  917. }
  918. ]
  919. },
  920. {
  921. path: "/download",
  922. name: "downloadLayout",
  923. component: DEFAULT_LAYOUT,
  924. redirect: "/download/index",
  925. meta: {
  926. title: '下载中心',
  927. icon: 'icon-download',
  928. public: true,
  929. onlyWeb: true,
  930. flatMenu: true
  931. },
  932. children: [
  933. {
  934. path: "index",
  935. name: "download",
  936. alias: "/download",
  937. component: () => import('../pages/download/index.vue'),
  938. meta: {
  939. title: '下载中心',
  940. public: true,
  941. onlyWeb: true
  942. }
  943. }
  944. ]
  945. }
  946. ]
  947. const router = VueRouter.createRouter({
  948. history: VueRouter.createWebHashHistory(),
  949. routes: routes
  950. })
  951. const isPublicRoute = (to) => to.matched.some(r => r.meta?.public)
  952. router.beforeEach(async (to, from, next) => {
  953. if (!isPublicRoute(to)) {
  954. const userStore = useUserStore()
  955. let user = await userStore.getInfo()
  956. if (!user || !user.uuid || !user.session) {
  957. // Message.error('请先登录')
  958. return router.push(`/login?from=${to.path}`)
  959. }
  960. if ((!user.permissionCodes || user.permissionCodes.length === 0) && userStore.refreshPermissions)
  961. await userStore.refreshPermissions()
  962. user = userStore.$state
  963. if (!canAccessRoute(to, user)) return next('/')
  964. }
  965. if (to.meta.viewport) {
  966. const meta = document.querySelector('meta[name="viewport"]')
  967. meta.setAttribute('content', to.meta.viewport)
  968. }
  969. if (to.meta && (to.meta.onlyWeb || to.meta.onlyElectron)) {
  970. const electronEnv = isElectron()
  971. if (to.meta.onlyWeb && electronEnv) return next('/proxy/openProxy')
  972. if (to.meta.onlyElectron && !electronEnv) return next('/lepao/accountList')
  973. }
  974. if (!to.meta.title) document.title = 'RunForge - 智能校园乐跑平台'
  975. else document.title = to.meta.title + ' - RunForge'
  976. next()
  977. })
  978. export { routes, router }