You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.1 KiB
JavaScript
112 lines
3.1 KiB
JavaScript
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
import { useUserStore } from '@/stores/user'
|
|
|
|
const routes = [
|
|
{
|
|
path: '/',
|
|
redirect: '/dashboard'
|
|
},
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
component: () => import('@/views/login/index.vue'),
|
|
meta: { title: '登录' }
|
|
},
|
|
{
|
|
path: '/',
|
|
component: () => import('@/layouts/MainLayout.vue'),
|
|
children: [
|
|
{
|
|
path: 'dashboard',
|
|
name: 'Dashboard',
|
|
component: () => import('@/views/dashboard/index.vue'),
|
|
meta: { title: '首页', icon: 'HomeFilled' }
|
|
},
|
|
{
|
|
path: 'behavior',
|
|
name: 'Behavior',
|
|
component: () => import('@/views/behavior/index.vue'),
|
|
meta: { title: '课堂行为分析', icon: 'TrendCharts' }
|
|
},
|
|
{
|
|
path: 'history',
|
|
name: 'History',
|
|
component: () => import('@/views/history/index.vue'),
|
|
meta: { title: '历史记录查询', icon: 'Search' }
|
|
},
|
|
{
|
|
path: 'bigscreen',
|
|
name: 'BigScreen',
|
|
component: () => import('@/views/bigscreen/index.vue'),
|
|
meta: { title: '数据展示大屏', icon: 'DataAnalysis' }
|
|
},
|
|
{
|
|
path: 'settings/rules',
|
|
name: 'Rules',
|
|
component: () => import('@/views/settings/rules.vue'),
|
|
meta: { title: '考勤规则设置', icon: 'Setting' }
|
|
},
|
|
{
|
|
path: 'settings/permissions',
|
|
name: 'Permissions',
|
|
component: () => import('@/views/settings/permissions.vue'),
|
|
meta: { title: '权限管理', icon: 'Lock' }
|
|
},
|
|
{
|
|
path: 'info/student',
|
|
name: 'InfoStudent',
|
|
component: () => import('@/views/info/student.vue'),
|
|
meta: { title: '学生信息', icon: 'User' }
|
|
},
|
|
{
|
|
path: 'info/building',
|
|
name: 'InfoBuilding',
|
|
component: () => import('@/views/info/building.vue'),
|
|
meta: { title: '教室信息', icon: 'OfficeBuilding' }
|
|
},
|
|
{
|
|
path: 'info/class',
|
|
name: 'InfoClass',
|
|
component: () => import('@/views/info/class.vue'),
|
|
meta: { title: '班级信息', icon: 'School' }
|
|
},
|
|
{
|
|
path: 'info/teacher',
|
|
name: 'InfoTeacher',
|
|
component: () => import('@/views/info/teacher.vue'),
|
|
meta: { title: '教师信息', icon: 'UserFilled' }
|
|
},
|
|
{
|
|
path: 'info/course',
|
|
name: 'InfoCourse',
|
|
component: () => import('@/views/info/course.vue'),
|
|
meta: { title: '课程信息', icon: 'Reading' }
|
|
},
|
|
{
|
|
path: 'bigscreen/room/:id',
|
|
name: 'BigScreenRoomDetail',
|
|
component: () => import('@/views/bigscreen/roomDetail.vue'),
|
|
meta: { title: '教室监控详情' }
|
|
}
|
|
]
|
|
}
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHashHistory(),
|
|
routes
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
document.title = to.meta.title ? `${to.meta.title} - 教室智能人脸考勤系统` : '教室智能人脸考勤系统'
|
|
|
|
const store = useUserStore()
|
|
if (!store.token && to.path !== '/login') {
|
|
next('/login')
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|