/* * @Author: Liuyi candymxq888@outlook.com * @Date: 2024-08-06 14:47:41 * @LastEditors: Liuyi candymxq888@outlook.com * @LastEditTime: 2024-09-28 11:11:38 * @FilePath: \water-qinghe-web\src\router\index.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看é…ç½® 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import { createWebHashHistory, createRouter } from 'vue-router' /* Layout */ import Screen from '@/screen' import Flow from '@/screen/flow.vue' import Temp from '@/screen/temp.vue' /** * Note: 路由é…置项 * * hidden: true // 当设置 true 的时候该路由ä¸ä¼šå†ä¾§è¾¹æ 出现 如401,loginç‰é¡µé¢ï¼Œæˆ–者如一些编辑页é¢/edit/1 * alwaysShow: true // å½“ä½ ä¸€ä¸ªè·¯ç”±ä¸‹é¢çš„ children 声明的路由大于1ä¸ªæ—¶ï¼Œè‡ªåŠ¨ä¼šå˜æˆåµŒå¥—的模å¼--å¦‚ç»„ä»¶é¡µé¢ * redirect: noRedirect // 当设置 noRedirect 的时候该路由在é¢åŒ…屑导航ä¸ä¸å¯è¢«ç‚¹å‡» * name:'router-name' // 设定路由的åå—,一定è¦å¡«å†™ä¸ç„¶ä½¿ç”¨<keep-alive>时会出现å„ç§é—®é¢˜ * query: '{"id": 1, "name": "ry"}' // è®¿é—®è·¯ç”±çš„é»˜è®¤ä¼ é€’å‚æ•° * roles: ['admin', 'common'] // 访问路由的角色æƒé™ * permissions: ['a:a:a', 'b:b:b'] // 访问路由的èœå•æƒé™ * meta : { noCache: true // 如果设置为true,则ä¸ä¼šè¢« <keep-alive> 缓å˜(默认 false) title: 'title' // 设置该路由在侧边æ å’Œé¢åŒ…屑ä¸å±•示的åå— icon: 'svg-name' // è®¾ç½®è¯¥è·¯ç”±çš„å›¾æ ‡ï¼Œå¯¹åº”è·¯å¾„src/assets/icons/svg breadcrumb: false // 如果设置为false,则ä¸ä¼šåœ¨breadcrumbé¢åŒ…屑䏿˜¾ç¤º activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边æ 。 } */ // 公共路由 export const constantRoutes = [ { path: '/', hidden: true, redirect: '/screen' }, { path: '/login', component: () => import('@/views/login'), hidden: true }, { path: "/:pathMatch(.*)*", component: () => import('@/views/error/404'), hidden: true }, { path: '/401', component: () => import('@/views/error/401'), hidden: true }, { path: '/screen', component: Screen, hidden: true } ] // æµé‡å¤§å±è·¯ç”± const FlowScreenRouter = [ { path: '/flow', component: Flow, redirect: '/flow/home', children: [ { path: 'home', component: () => import('@/views/screen/flow/home/index.vue') }, { path: 'ecology', component: () => import('@/views/screen/flow/ecology/index.vue') }, { path: 'graphic', component: () => import('@/views/screen/flow/graphic/index.vue') }, { path: 'shebei', component: () => import('@/views/screen/flow/shebei/index.vue') }, { path: 'warning', component: () => import('@/views/screen/flow/warning/index.vue') }, { path: 'report', component: () => import('@/views/screen/flow/report/index.vue') }, ] }, ] // 温度大å±è·¯ç”± const TempScreenRouter = [ { path: '/temp', component: Temp, redirect: '/temp/home', children: [ { path: 'home', component: () => import('@/views/screen/temperature/home/index.vue') }, { path: 'shebei', component: () => import('@/views/screen/temperature/shebei/index.vue') }, { path: 'monitor', component: () => import('@/views/screen/temperature/monitor/index.vue') }, { path: 'graphic', component: () => import('@/views/screen/temperature/graphic/index.vue') }, { path: 'statics', component: () => import('@/views/screen/temperature/statics/index.vue') }, { path: 'report', component: () => import('@/views/screen/temperature/report/index.vue') }, ] } ] // 动æ€è·¯ç”±ï¼ŒåŸºäºŽç”¨æˆ·æƒé™åЍæ€åŽ»åŠ è½½ export const dynamicRoutes = [ ] const router = createRouter({ history: createWebHashHistory(), routes: [...constantRoutes, ...FlowScreenRouter, ...TempScreenRouter], scrollBehavior(to, from, savedPosition) { if (savedPosition) { return savedPosition } else { return { top: 0 } } }, }); export default router;