index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /**
  2. * @copyright chuzhixin 1204505056@qq.com
  3. * @description router全局配置,如有必要可分文件抽离,其中asyncRoutes只有在intelligence模式下才会用到,vip文档中已提供路由的基础图标与小清新图标的配置方案,请仔细阅读
  4. */
  5. import Vue from "vue";
  6. import VueRouter from "vue-router";
  7. import Layout from "@/layouts";
  8. import EmptyLayout from "@/layouts/EmptyLayout";
  9. import { publicPath, routerMode } from "@/config/settings";
  10. Vue.use(VueRouter);
  11. export const constantRoutes = [
  12. {
  13. path: "/login",
  14. component: () => import("@/views/login/index"),
  15. hidden: true,
  16. },
  17. {
  18. path: "/register",
  19. component: () => import("@/views/register/index"),
  20. hidden: true,
  21. },
  22. {
  23. path: "/401",
  24. name: "401",
  25. component: () => import("@/views/401"),
  26. hidden: true,
  27. },
  28. {
  29. path: "/404",
  30. name: "404",
  31. component: () => import("@/views/404"),
  32. hidden: true,
  33. },
  34. ];
  35. export const asyncRoutes = [
  36. {
  37. path: "/",
  38. component: Layout,
  39. redirect: "index",
  40. children: [
  41. {
  42. path: "index",
  43. name: "Index",
  44. component: () => import("@/views/index/index"),
  45. meta: {
  46. title: "首页",
  47. icon: "home",
  48. affix: true,
  49. },
  50. },
  51. ],
  52. },
  53. {
  54. path: "/personalCenter",
  55. component: Layout,
  56. hidden: true,
  57. redirect: "personalCenter",
  58. children: [
  59. {
  60. path: "personalCenter",
  61. name: "PersonalCenter",
  62. component: () => import("@/views/personalCenter/index"),
  63. meta: {
  64. title: "个人中心",
  65. },
  66. },
  67. ],
  68. },
  69. /* {
  70. path: "/test",
  71. component: Layout,
  72. redirect: "noRedirect",
  73. children: [
  74. {
  75. path: "test",
  76. name: "Test",
  77. component: () => import("@/views/test/index"),
  78. meta: {
  79. title: "test",
  80. icon: "marker",
  81. permissions: ["admin"],
  82. },
  83. },
  84. ],
  85. }, */
  86. {
  87. path: "/personnelManagement",
  88. component: Layout,
  89. redirect: "noRedirect",
  90. name: "PersonnelManagement",
  91. meta: { title: "配置", icon: "users-cog", permissions: ["admin"] },
  92. children: [
  93. {
  94. path: "userManagement",
  95. name: "UserManagement",
  96. component: () =>
  97. import("@/views/personnelManagement/userManagement/index"),
  98. meta: { title: "用户管理" },
  99. },
  100. {
  101. path: "roleManagement",
  102. name: "RoleManagement",
  103. component: () =>
  104. import("@/views/personnelManagement/roleManagement/index"),
  105. meta: { title: "角色管理" },
  106. },
  107. {
  108. path: "menuManagement",
  109. name: "MenuManagement",
  110. component: () =>
  111. import("@/views/personnelManagement/menuManagement/index"),
  112. meta: { title: "菜单管理", badge: "New" },
  113. },
  114. ],
  115. },
  116. {
  117. path: "/vab",
  118. component: Layout,
  119. redirect: "noRedirect",
  120. name: "Vab",
  121. alwaysShow: true,
  122. meta: { title: "组件", icon: "box-open" },
  123. children: [
  124. {
  125. path:
  126. "https://github.com/chuzhixin/vue-admin-beautiful?utm_source=gold_browser_extension",
  127. name: "ExternalLink",
  128. meta: {
  129. title: "外链",
  130. target: "_blank",
  131. permissions: ["admin", "editor"],
  132. badge: "New",
  133. },
  134. },
  135. {
  136. path: "permissions",
  137. name: "Permission",
  138. component: () => import("@/views/vab/permissions/index"),
  139. meta: {
  140. title: "权限控制",
  141. permissions: ["admin", "editor"],
  142. },
  143. },
  144. {
  145. path: "icon",
  146. component: EmptyLayout,
  147. redirect: "noRedirect",
  148. name: "Icon",
  149. meta: {
  150. title: "图标",
  151. permissions: ["admin"],
  152. },
  153. children: [
  154. {
  155. path: "awesomeIcon",
  156. name: "AwesomeIcon",
  157. component: () => import("@/views/vab/icon/index"),
  158. meta: { title: "常规图标" },
  159. },
  160. {
  161. path: "remixIcon",
  162. name: "RemixIcon",
  163. component: () => import("@/views/vab/icon/remixIcon"),
  164. meta: { title: "小清新图标" },
  165. },
  166. {
  167. path: "colorfulIcon",
  168. name: "ColorfulIcon",
  169. component: () => import("@/views/vab/icon/colorfulIcon"),
  170. meta: { title: "多彩图标" },
  171. },
  172. ],
  173. },
  174. {
  175. path: "table",
  176. component: EmptyLayout,
  177. redirect: "noRedirect",
  178. name: "Table",
  179. meta: {
  180. title: "表格",
  181. permissions: ["admin"],
  182. },
  183. children: [
  184. {
  185. path: "comprehensiveTable",
  186. name: "ComprehensiveTable",
  187. component: () => import("@/views/vab/table/index"),
  188. meta: { title: "综合表格" },
  189. },
  190. {
  191. path: "inlineEditTable",
  192. name: "InlineEditTable",
  193. component: () => import("@/views/vab/table/inlineEditTable"),
  194. meta: { title: "行内编辑" },
  195. },
  196. ],
  197. },
  198. {
  199. path: "map",
  200. component: () => import("@/views/vab/map/index"),
  201. name: "Map",
  202. meta: {
  203. title: "地图",
  204. permissions: ["admin"],
  205. },
  206. },
  207. {
  208. path: "webSocket",
  209. name: "WebSocket",
  210. component: () => import("@/views/vab/webSocket/index"),
  211. meta: { title: "webSocket", permissions: ["admin"] },
  212. },
  213. {
  214. path: "form",
  215. name: "Form",
  216. component: () => import("@/views/vab/form/index"),
  217. meta: { title: "表单", permissions: ["admin"] },
  218. },
  219. {
  220. path: "element",
  221. name: "Element",
  222. component: () => import("@/views/vab/element/index"),
  223. meta: { title: "常用组件", permissions: ["admin"] },
  224. },
  225. {
  226. path: "tree",
  227. name: "Tree",
  228. component: () => import("@/views/vab/tree/index"),
  229. meta: { title: "树", permissions: ["admin"] },
  230. },
  231. {
  232. path: "card",
  233. name: "Card",
  234. component: () => import("@/views/vab/card/index"),
  235. meta: { title: "卡片", permissions: ["admin"] },
  236. },
  237. {
  238. path: "betterScroll",
  239. name: "BetterScroll",
  240. component: () => import("@/views/vab/betterScroll/index"),
  241. meta: {
  242. title: "滚动侦测",
  243. permissions: ["admin"],
  244. },
  245. },
  246. {
  247. path: "verify",
  248. name: "Verify",
  249. component: () => import("@/views/vab/verify/index"),
  250. meta: { title: "验证码", permissions: ["admin"] },
  251. },
  252. {
  253. path: "menu1",
  254. component: () => import("@/views/vab/nested/menu1/index"),
  255. name: "Menu1",
  256. alwaysShow: true,
  257. meta: {
  258. title: "嵌套路由 1",
  259. permissions: ["admin"],
  260. },
  261. children: [
  262. {
  263. path: "menu1-1",
  264. name: "Menu1-1",
  265. alwaysShow: true,
  266. meta: { title: "嵌套路由 1-1" },
  267. component: () => import("@/views/vab/nested/menu1/menu1-1/index"),
  268. children: [
  269. {
  270. path: "menu1-1-1",
  271. name: "Menu1-1-1",
  272. meta: { title: "嵌套路由 1-1-1" },
  273. component: () =>
  274. import("@/views/vab/nested/menu1/menu1-1/menu1-1-1/index"),
  275. },
  276. ],
  277. },
  278. ],
  279. },
  280. {
  281. path: "magnifier",
  282. name: "Magnifier",
  283. component: () => import("@/views/vab/magnifier/index"),
  284. meta: { title: "放大镜", permissions: ["admin"] },
  285. },
  286. {
  287. path: "echarts",
  288. name: "Echarts",
  289. component: () => import("@/views/vab/echarts/index"),
  290. meta: { title: "图表", permissions: ["admin"] },
  291. },
  292. {
  293. path: "loading",
  294. name: "Loading",
  295. component: () => import("@/views/vab/loading/index"),
  296. meta: { title: "loading", permissions: ["admin"] },
  297. },
  298. {
  299. path: "player",
  300. name: "Player",
  301. component: () => import("@/views/vab/player/index"),
  302. meta: { title: "视频播放器", permissions: ["admin"] },
  303. },
  304. {
  305. path: "markdownEditor",
  306. name: "MarkdownEditor",
  307. component: () => import("@/views/vab/markdownEditor/index"),
  308. meta: { title: "markdown编辑器", permissions: ["admin"] },
  309. },
  310. {
  311. path: "editor",
  312. name: "Editor",
  313. component: () => import("@/views/vab/editor/index"),
  314. meta: {
  315. title: "富文本编辑器",
  316. permissions: ["admin"],
  317. badge: "New",
  318. },
  319. },
  320. {
  321. path: "qrCode",
  322. name: "QrCode",
  323. component: () => import("@/views/vab/qrCode/index"),
  324. meta: { title: "二维码", permissions: ["admin"] },
  325. },
  326. {
  327. path: "backToTop",
  328. name: "BackToTop",
  329. component: () => import("@/views/vab/backToTop/index"),
  330. meta: { title: "返回顶部", permissions: ["admin"] },
  331. },
  332. {
  333. path: "lodash",
  334. name: "Lodash",
  335. component: () => import("@/views/vab/lodash/index"),
  336. meta: { title: "lodash", permissions: ["admin"] },
  337. },
  338. {
  339. path: "imgComparison",
  340. name: "ImgComparison",
  341. component: () => import("@/views/vab/imgComparison/index"),
  342. meta: { title: "图像拖拽比对", permissions: ["admin"] },
  343. },
  344. {
  345. path: "codeGenerator",
  346. name: "CodeGenerator",
  347. component: () => import("@/views/vab/codeGenerator/index"),
  348. meta: { title: "代码生成机", permissions: ["admin"] },
  349. },
  350. {
  351. path: "markdown",
  352. name: "Markdown",
  353. component: () => import("@/views/vab/markdown/index"),
  354. meta: { title: "markdown阅读器", permissions: ["admin"] },
  355. },
  356. {
  357. path: "smallComponents",
  358. name: "SmallComponents",
  359. component: () => import("@/views/vab/smallComponents/index"),
  360. meta: { title: "小组件", permissions: ["admin"] },
  361. },
  362. {
  363. path: "upload",
  364. name: "Upload",
  365. component: () => import("@/views/vab/upload/index"),
  366. meta: { title: "上传", permissions: ["admin"] },
  367. },
  368. {
  369. path: "sticky",
  370. name: "Sticky",
  371. component: () => import("@/views/vab/sticky/index"),
  372. meta: { title: "sticky吸附", permissions: ["admin"] },
  373. },
  374. {
  375. path: "log",
  376. name: "Log",
  377. component: () => import("@/views/vab/errorLog/index"),
  378. meta: { title: "错误日志模拟", permissions: ["admin"] },
  379. },
  380. {
  381. path: "more",
  382. name: "More",
  383. component: () => import("@/views/vab/more/index"),
  384. meta: { title: "更多组件", permissions: ["admin"] },
  385. },
  386. {
  387. path: "blacklist",
  388. name: "Blacklist",
  389. component: () => import("@/views/vab/blacklist/index"),
  390. meta: { title: "黑名单", permissions: ["admin"] },
  391. },
  392. ],
  393. },
  394. {
  395. path: "/mall",
  396. component: Layout,
  397. redirect: "noRedirect",
  398. name: "Mall",
  399. meta: {
  400. title: "商城",
  401. icon: "shopping-cart",
  402. permissions: ["admin"],
  403. },
  404. children: [
  405. {
  406. path: "pay",
  407. name: "Pay",
  408. component: () => import("@/views/mall/pay/index"),
  409. meta: {
  410. title: "支付",
  411. noKeepAlive: true,
  412. },
  413. children: null,
  414. },
  415. {
  416. path: "goodsList",
  417. name: "GoodsList",
  418. component: () => import("@/views/mall/goodsList/index"),
  419. meta: {
  420. title: "商品列表",
  421. },
  422. },
  423. {
  424. path: "goodsDetail",
  425. name: "GoodsDetail",
  426. component: () => import("@/views/mall/goodsDetail/index"),
  427. meta: {
  428. title: "商品详情",
  429. },
  430. },
  431. ],
  432. },
  433. {
  434. path: "/error",
  435. component: EmptyLayout,
  436. redirect: "noRedirect",
  437. name: "Error",
  438. meta: { title: "错误页", icon: "bug" },
  439. children: [
  440. {
  441. path: "401",
  442. name: "Error401",
  443. component: () => import("@/views/401"),
  444. meta: { title: "401" },
  445. },
  446. {
  447. path: "404",
  448. name: "Error404",
  449. component: () => import("@/views/404"),
  450. meta: { title: "404" },
  451. },
  452. ],
  453. },
  454. {
  455. path: "*",
  456. redirect: "/404",
  457. hidden: true,
  458. },
  459. ];
  460. const router = new VueRouter({
  461. base: publicPath,
  462. mode: routerMode,
  463. scrollBehavior: () => ({
  464. y: 0,
  465. }),
  466. routes: constantRoutes,
  467. });
  468. //注释的地方是允许路由重复点击,如果你觉得框架路由跳转规范太过严格可选择放开
  469. /* const originalPush = VueRouter.prototype.push;
  470. VueRouter.prototype.push = function push(location, onResolve, onReject) {
  471. if (onResolve || onReject)
  472. return originalPush.call(this, location, onResolve, onReject);
  473. return originalPush.call(this, location).catch((err) => err);
  474. }; */
  475. export function resetRouter() {
  476. router.matcher = new VueRouter({
  477. base: publicPath,
  478. mode: routerMode,
  479. scrollBehavior: () => ({
  480. y: 0,
  481. }),
  482. routes: constantRoutes,
  483. }).matcher;
  484. }
  485. export default router;