diff --git a/src/router/index.ts b/src/router/index.ts index 4c8cd5f..63715c6 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,186 +1,195 @@ import { createRouter, createWebHashHistory } from 'vue-router' const router = createRouter({ - history: createWebHashHistory(import.meta.env.BASE_URL), - routes: [ - { - path: '/', - name: 'home', - // 自动引导到 /editor - component: () => import('@/views/HomeView.vue'), - children: [ + history: createWebHashHistory(import.meta.env.BASE_URL), + routes: [ { - path: '/dashboard', - name: 'dashboard', - meta: { - title: '仪表盘' - }, - component: () => import('@/views/dashboard/index.vue') + path: '/', + name: 'home', + // 自动引导到 /editor + component: () => import('@/views/HomeView.vue'), + children: [ + { + path: '/dashboard', + name: 'dashboard', + meta: { + title: '仪表盘' + }, + component: () => import('@/views/dashboard/index.vue') + }, + { + path: '/modelingSimulation', + name: 'modelingSimulation', + redirect: '/editor' + }, + { + path: '/taskManagement', + name: 'taskManagement', + children: [ + { + path: '/taskQuery', + name: 'taskQuery', + meta: { + title: '任务查询' + }, + component: () => import('@/views/taskManagement/taskQuery.vue') + }, + { + path: '/automatedPresentation', + name: 'automatedPresentation', + meta: { + title: '自动演示管理' + }, + component: () => import('@/views/taskManagement/automatedPresentation.vue') + } + ] + }, + { + path: '/log', + name: 'log', + children: [ + { + path: '/upstream', + name: 'upstream', + meta: { + title: '上游接口日志' + }, + component: () => import('@/views/log/upstream.vue') + }, + { + path: '/device', + name: 'device', + meta: { + title: '设备报文日志' + }, + component: () => import('@/views/log/device.vue') + } + ] + }, + { + path: '/device', + name: 'device', + children: [ + { + path: '/points', + name: 'points', + meta: { + title: '点位管理' + }, + component: () => import('@/views/device/points.vue') + }, + { + path: '/locations', + name: 'locations', + meta: { + title: '货位管理' + }, + component: () => import('@/views/device/locations.vue') + }, + { + path: '/vehicles', + name: 'vehicles', + meta: { + title: '车辆管理' + }, + component: () => import('@/views/device/vehicles.vue') + }, + { + path: '/chargers', + name: 'chargers', + meta: { + title: '充电位管理' + }, + component: () => import('@/views/device/chargers.vue') + } + ] + }, + { + path: '/inventory', + name: 'inventory', + children: [ + { + path: '/query', + name: 'query', + meta: { + title: '库存查询' + }, + component: () => import('@/views/inventory/query.vue') + }, + { + path: '/account', + name: 'account', + meta: { + title: '帐页查询' + }, + component: () => import('@/views/inventory/account.vue') + } + ] + }, + { + path: '/user', + name: 'user', + children: [ + { + path: '/users', + name: 'users', + meta: { + title: '用户管理' + }, + component: () => import('@/views/user/users.vue') + }, + { + path: '/roles', + name: 'roles', + meta: { + title: '角色管理' + }, + component: () => import('@/views/user/roles.vue') + } + ] + } + ] }, { - path: '/modelingSimulation', - name: 'modelingSimulation', - redirect: '/editor' + path: '/tp', + name: 'tp', + component: () => import('@/components/ThreePerfView.vue') }, { - path: '/taskManagement', - name: 'taskManagement', - children: [ - { - path: '/taskQuery', - name: 'taskQuery', - meta: { - title: '任务查询' - }, - component: () => import('@/views/taskManagement/taskQuery.vue') - }, - { - path: '/automatedPresentation', - name: 'automatedPresentation', - meta: { - title: '自动演示管理' - }, - component: () => import('@/views/taskManagement/automatedPresentation.vue') - } - ] + path: '/editor', + name: 'editor', + // component: HomeView, + component: () => import('../editor/ModelMain.vue') }, { - path: '/log', - name: 'log', - children: [ - { - path: '/upstream', - name: 'upstream', - meta: { - title: '上游接口日志' - }, - component: () => import('@/views/log/upstream.vue') - }, - { - path: '/device', - name: 'device', - meta: { - title: '设备报文日志' - }, - component: () => import('@/views/log/device.vue') - } - ] - }, - { - path: '/device', - name: 'device', - children: [ - { - path: '/points', - name: 'points', - meta: { - title: '点位管理' - }, - component: () => import('@/views/device/points.vue') - }, - { - path: '/locations', - name: 'locations', - meta: { - title: '货位管理' - }, - component: () => import('@/views/device/locations.vue') - }, - { - path: '/vehicles', - name: 'vehicles', - meta: { - title: '车辆管理' - }, - component: () => import('@/views/device/vehicles.vue') - }, - { - path: '/chargers', - name: 'chargers', - meta: { - title: '充电位管理' - }, - component: () => import('@/views/device/chargers.vue') - } - ] + path: '/about', + name: 'about', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/AboutView.vue') }, + { - path: '/inventory', - name: 'inventory', - children: [ - { - path: '/query', - name: 'query', - meta: { - title: '库存查询' - }, - component: () => import('@/views/inventory/query.vue') - }, - { - path: '/account', - name: 'account', - meta: { - title: '帐页查询' - }, - component: () => import('@/views/inventory/account.vue') - } - ] + path: '/DataForm01', + name: 'DataForm01', + component: () => import('@/pages/DataForm01.vue') }, { - path: '/user', - name: 'user', - children: [ - { - path: '/users', - name: 'users', - meta: { - title: '用户管理' - }, - component: () => import('@/views/user/users.vue') - }, - { - path: '/roles', - name: 'roles', - meta: { - title: '角色管理' - }, - component: () => import('@/views/user/roles.vue') - } - ] + path: '/JsDemo', + name: 'JsDemo', + component: () => import('@/pages/JsDemo.vue') } - ] - }, - { - path: '/tp', - name: 'tp', - component: () => import('@/components/ThreePerfView.vue') - }, - { - path: '/editor', - name: 'editor', - // component: HomeView, - component: () => import('../editor/ModelMain.vue') - }, - { - path: '/about', - name: 'about', - // route level code-splitting - // this generates a separate chunk (About.[hash].js) for this route - // which is lazy-loaded when the route is visited. - component: () => import('../views/AboutView.vue') - }, + ] +}) - { - path: '/DataForm01', - name: 'DataForm01', - component: () => import('@/pages/DataForm01.vue') - }, - { - path: '/JsDemo', - name: 'JsDemo', - component: () => import('@/pages/JsDemo.vue') +router.beforeEach((to, from) => { + if (to.name !== "login" && !window.globalConfig.user) { + return { name: "login" }; } - ] + // if (to.name === "login" && window.globalConfig.user) { + // return { name: "home" }; + // } }) export default router