路由设置

This commit is contained in:
龚皓 2024-09-30 15:45:00 +08:00
parent c76d2e498c
commit d423ea00c0
1 changed files with 37 additions and 18 deletions

View File

@ -1,58 +1,77 @@
// 第一步引入createRouter import { createRouter, createWebHashHistory } from 'vue-router'
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import Layout from '@/components/Layout.vue'; import Layout from '@/components/Layout.vue';
import AlertChart from '@/components/AlertChart.vue'; import AlertChart from '@/components/AlertChart.vue';
import Statistics from '@/components/Statistics.vue'; import Statistics from '@/components/Statistics.vue';
import AlertManagement from '@/html/AlertManagement.vue'; import AlertManagement from '@/html/AlertManagement.vue';
import Test from '@/html/Test.vue'; import Test from '@/html/Test.vue';
// import Login from '@/html/LoginView.vue'; import Login from '@/html/LoginView.vue';
import UserList from '@/html/UserList.vue';
import Home from '@/html/Home.vue';
import DataStatistics from '@/html/DataStatistics.vue';
const routes = [ const routes = [
{ {
path: '/', path: '/',
name: 'Layout', name: 'Layout',
component: Layout, component: Layout,
meta: { requiresAuth: true },
children: [ children: [
{ {
path: '', path: '',
name: 'Home',
component: Home,
meta: { requiresAuth: true }
},
{
path: '/alertManagement',
name: 'AlertManagement', name: 'AlertManagement',
component: AlertManagement, component: AlertManagement,
meta: { requiresAuth: true }
}, },
{ {
path: '/test', path: '/test',
name: 'Test', name: 'Test',
component: Test, component: Test,
meta: { requiresAuth: true }
}, },
{ {
path: '/alertChart', path: '/alertChart',
name: 'AlertChart', name: 'AlertChart',
component: AlertChart, component: AlertChart,
meta: { requiresAuth: true }
}, },
{ {
path: '/statistics', path: '/statistics',
name: 'Statistics', name: 'Statistics',
component: Statistics, component: Statistics,
meta: { requiresAuth: true }
},
{
path:'/userList',
name: 'UserList',
component: UserList,
meta: { requiresAuth: true }
},
{
path:'/dataStatistics',
name: 'DataStatistics',
component: DataStatistics,
meta: { requiresAuth: true }
} }
] ]
},
{
path: '/login',
name: 'Login',
component: Login,
meta: { requiresAuth: false }
} }
// , ];
// {
// path: '/login',
// name: 'Login',
// component: Login,
// meta: { requiresAuth: false }
// },
]
const router = createRouter({ const router = createRouter({
history: createWebHashHistory(), history: createWebHashHistory(),
routes routes
}) });
export default router;
export default router;