index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. /**
  2. * @author chuzhixin 1204505056@qq.com (不想保留author可删除)
  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: "/test",
  55. component: Layout,
  56. redirect: "noRedirect",
  57. children: [
  58. {
  59. path: "test",
  60. name: "Test",
  61. component: () => import("@/views/test/index"),
  62. meta: {
  63. title: "test",
  64. icon: "marker",
  65. permissions: ["admin"],
  66. },
  67. },
  68. ],
  69. }, */
  70. {
  71. path: "/vab",
  72. component: Layout,
  73. redirect: "noRedirect",
  74. name: "Vab",
  75. alwaysShow: true,
  76. meta: { title: "组件", icon: "box-open" },
  77. children: [
  78. {
  79. path: "permissions",
  80. name: "Permission",
  81. component: () => import("@/views/vab/permissions/index"),
  82. meta: {
  83. title: "角色权限",
  84. permissions: ["admin", "editor"],
  85. },
  86. },
  87. {
  88. path:
  89. "https://github.com/chuzhixin/vue-admin-beautiful?utm_source=gold_browser_extension",
  90. name: "ExternalLink",
  91. meta: {
  92. title: "外链",
  93. target: "_blank",
  94. permissions: ["admin", "editor"],
  95. badge: "New",
  96. },
  97. },
  98. {
  99. path: "icon",
  100. component: EmptyLayout,
  101. redirect: "noRedirect",
  102. name: "Icon",
  103. meta: {
  104. title: "图标",
  105. permissions: ["admin"],
  106. },
  107. children: [
  108. {
  109. path: "awesomeIcon",
  110. name: "AwesomeIcon",
  111. component: () => import("@/views/vab/icon/index"),
  112. meta: { title: "常规图标" },
  113. },
  114. {
  115. path: "remixIcon",
  116. name: "RemixIcon",
  117. component: () => import("@/views/vab/icon/remixIcon"),
  118. meta: { title: "小清新图标" },
  119. },
  120. {
  121. path: "colorfulIcon",
  122. name: "ColorfulIcon",
  123. component: () => import("@/views/vab/icon/colorfulIcon"),
  124. meta: { title: "多彩图标" },
  125. },
  126. ],
  127. },
  128. {
  129. path: "table",
  130. component: () => import("@/views/vab/table/index"),
  131. name: "Table",
  132. meta: {
  133. title: "表格",
  134. permissions: ["admin"],
  135. },
  136. },
  137. {
  138. path: "map",
  139. component: () => import("@/views/vab/map/index"),
  140. name: "Map",
  141. meta: {
  142. title: "地图",
  143. permissions: ["admin"],
  144. },
  145. },
  146. {
  147. path: "webSocket",
  148. name: "WebSocket",
  149. component: () => import("@/views/vab/webSocket/index"),
  150. meta: { title: "webSocket", permissions: ["admin"] },
  151. },
  152. {
  153. path: "form",
  154. name: "Form",
  155. component: () => import("@/views/vab/form/index"),
  156. meta: { title: "表单", permissions: ["admin"] },
  157. },
  158. {
  159. path: "element",
  160. name: "Element",
  161. component: () => import("@/views/vab/element/index"),
  162. meta: { title: "常用组件", permissions: ["admin"] },
  163. },
  164. {
  165. path: "tree",
  166. name: "Tree",
  167. component: () => import("@/views/vab/tree/index"),
  168. meta: { title: "树", permissions: ["admin"] },
  169. },
  170. {
  171. path: "card",
  172. name: "Card",
  173. component: () => import("@/views/vab/card/index"),
  174. meta: { title: "卡片", permissions: ["admin"] },
  175. },
  176. {
  177. path: "verify",
  178. name: "Verify",
  179. component: () => import("@/views/vab/verify/index"),
  180. meta: { title: "验证码", permissions: ["admin"] },
  181. },
  182. {
  183. path: "menu1",
  184. component: () => import("@/views/vab/nested/menu1/index"),
  185. name: "Menu1",
  186. alwaysShow: true,
  187. meta: {
  188. title: "嵌套路由 1",
  189. permissions: ["admin"],
  190. },
  191. children: [
  192. {
  193. path: "menu1-1",
  194. name: "Menu1-1",
  195. alwaysShow: true,
  196. meta: { title: "嵌套路由 1-1" },
  197. component: () => import("@/views/vab/nested/menu1/menu1-1/index"),
  198. children: [
  199. {
  200. path: "menu1-1-1",
  201. name: "Menu1-1-1",
  202. meta: { title: "嵌套路由 1-1-1" },
  203. component: () =>
  204. import("@/views/vab/nested/menu1/menu1-1/menu1-1-1/index"),
  205. },
  206. ],
  207. },
  208. ],
  209. },
  210. {
  211. path: "magnifier",
  212. name: "Magnifier",
  213. component: () => import("@/views/vab/magnifier/index"),
  214. meta: { title: "放大镜", permissions: ["admin"] },
  215. },
  216. {
  217. path: "echarts",
  218. name: "Echarts",
  219. component: () => import("@/views/vab/echarts/index"),
  220. meta: { title: "图表", permissions: ["admin"] },
  221. },
  222. {
  223. path: "loading",
  224. name: "Loading",
  225. component: () => import("@/views/vab/loading/index"),
  226. meta: { title: "loading", permissions: ["admin"] },
  227. },
  228. {
  229. path: "player",
  230. name: "Player",
  231. component: () => import("@/views/vab/player/index"),
  232. meta: { title: "视频播放器", permissions: ["admin"] },
  233. },
  234. {
  235. path: "markdownEditor",
  236. name: "MarkdownEditor",
  237. component: () => import("@/views/vab/markdownEditor/index"),
  238. meta: { title: "markdown编辑器", permissions: ["admin"] },
  239. },
  240. {
  241. path: "editor",
  242. name: "Editor",
  243. component: () => import("@/views/vab/editor/index"),
  244. meta: {
  245. title: "富文本编辑器",
  246. permissions: ["admin"],
  247. badge: "New",
  248. },
  249. },
  250. {
  251. path: "backToTop",
  252. name: "BackToTop",
  253. component: () => import("@/views/vab/backToTop/index"),
  254. meta: { title: "返回顶部", permissions: ["admin"] },
  255. },
  256. {
  257. path: "lodash",
  258. name: "Lodash",
  259. component: () => import("@/views/vab/lodash/index"),
  260. meta: { title: "lodash", permissions: ["admin"] },
  261. },
  262. {
  263. path: "imgComparison",
  264. name: "ImgComparison",
  265. component: () => import("@/views/vab/imgComparison/index"),
  266. meta: { title: "图像拖拽比对", permissions: ["admin"] },
  267. },
  268. {
  269. path: "smallComponents",
  270. name: "SmallComponents",
  271. component: () => import("@/views/vab/smallComponents/index"),
  272. meta: { title: "小组件", permissions: ["admin"] },
  273. },
  274. {
  275. path: "upload",
  276. name: "Upload",
  277. component: () => import("@/views/vab/upload/index"),
  278. meta: { title: "上传", permissions: ["admin"] },
  279. },
  280. {
  281. path: "log",
  282. name: "Log",
  283. component: () => import("@/views/vab/errorLog/index"),
  284. meta: { title: "错误日志模拟", permissions: ["admin"] },
  285. },
  286. {
  287. path: "more",
  288. name: "More",
  289. component: () => import("@/views/vab/more/index"),
  290. meta: { title: "关于", permissions: ["admin"] },
  291. },
  292. ],
  293. },
  294. {
  295. path: "/personnelManagement",
  296. component: Layout,
  297. redirect: "noRedirect",
  298. name: "PersonnelManagement",
  299. meta: { title: "配置", icon: "users-cog", permissions: ["admin"] },
  300. children: [
  301. {
  302. path: "userManagement",
  303. name: "UserManagement",
  304. component: () =>
  305. import("@/views/personnelManagement/userManagement/index"),
  306. meta: { title: "用户管理" },
  307. },
  308. {
  309. path: "roleManagement",
  310. name: "RoleManagement",
  311. component: () =>
  312. import("@/views/personnelManagement/roleManagement/index"),
  313. meta: { title: "角色管理" },
  314. },
  315. {
  316. path: "menuManagement",
  317. name: "MenuManagement",
  318. component: () =>
  319. import("@/views/personnelManagement/menuManagement/index"),
  320. meta: { title: "菜单管理", badge: "New" },
  321. },
  322. ],
  323. },
  324. {
  325. path: "/mall",
  326. component: Layout,
  327. redirect: "noRedirect",
  328. name: "Mall",
  329. meta: {
  330. title: "商城",
  331. icon: "shopping-cart",
  332. permissions: ["admin"],
  333. },
  334. children: [
  335. {
  336. path: "pay",
  337. name: "Pay",
  338. component: () => import("@/views/mall/pay/index"),
  339. meta: {
  340. title: "支付",
  341. noKeepAlive: true,
  342. },
  343. children: null,
  344. },
  345. {
  346. path: "goodsList",
  347. name: "GoodsList",
  348. component: () => import("@/views/mall/goodsList/index"),
  349. meta: {
  350. title: "商品列表",
  351. },
  352. },
  353. ],
  354. },
  355. {
  356. path: "/error",
  357. component: EmptyLayout,
  358. redirect: "noRedirect",
  359. name: "Error",
  360. meta: { title: "错误页", icon: "bug" },
  361. children: [
  362. {
  363. path: "401",
  364. name: "Error401",
  365. component: () => import("@/views/401"),
  366. meta: { title: "401" },
  367. },
  368. {
  369. path: "404",
  370. name: "Error404",
  371. component: () => import("@/views/404"),
  372. meta: { title: "404" },
  373. },
  374. ],
  375. },
  376. {
  377. path: "*",
  378. redirect: "/404",
  379. hidden: true,
  380. },
  381. ];
  382. const router = new VueRouter({
  383. base: publicPath,
  384. mode: routerMode,
  385. scrollBehavior: () => ({
  386. y: 0,
  387. }),
  388. routes: constantRoutes,
  389. });
  390. //注释的地方是允许路由重复点击,如果你觉得框架路由跳转规范太过严格可选择放开
  391. /* const originalPush = VueRouter.prototype.push;
  392. VueRouter.prototype.push = function push(location, onResolve, onReject) {
  393. if (onResolve || onReject)
  394. return originalPush.call(this, location, onResolve, onReject);
  395. return originalPush.call(this, location).catch((err) => err);
  396. }; */
  397. export function resetRouter() {
  398. router.matcher = new VueRouter({
  399. base: publicPath,
  400. mode: routerMode,
  401. scrollBehavior: () => ({
  402. y: 0,
  403. }),
  404. routes: constantRoutes,
  405. }).matcher;
  406. }
  407. export default router;