- 将课程管理从活动模块移至专用课程模块 - 使用新的课程管理结构更新 AdminLayout 侧边栏菜单 - 修改路由器配置以反映新的课程管理路由 - 从活动模块中删除已弃用的课程管理视图 -添加物种监测
222 lines
6.6 KiB
JavaScript
222 lines
6.6 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import AdminLayout from '../layout/AdminLayout.vue'
|
|
import { useUserStore } from '../stores/user'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
redirect: to => {
|
|
// 如果已登录,重定向到后台首页,否则重定向到登录页
|
|
const userStore = useUserStore()
|
|
return userStore.isLoggedIn ? '/dashboard' : '/login'
|
|
}
|
|
},
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
component: () => import('../views/login/index.vue')
|
|
},
|
|
{
|
|
path: '/screen',
|
|
name: 'Screen',
|
|
component: () => import('@/views/dashboard/screen/index.vue'),
|
|
meta: {
|
|
title: '数据大屏',
|
|
requiresAuth: true
|
|
}
|
|
},
|
|
{
|
|
path: '/',
|
|
component: AdminLayout,
|
|
redirect: '/dashboard',
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{
|
|
path: 'dashboard',
|
|
name: 'Dashboard',
|
|
component: () => import('../views/dashboard/index.vue')
|
|
},
|
|
{
|
|
path: 'system/users',
|
|
name: 'UserManagement',
|
|
component: () => import('../views/system/users/index.vue')
|
|
},
|
|
{
|
|
path: 'system/roles',
|
|
name: 'RoleManagement',
|
|
component: () => import('../views/system/roles/index.vue')
|
|
},
|
|
{
|
|
path: 'system/permissions',
|
|
name: 'PermissionManagement',
|
|
component: () => import('../views/system/permissions/index.vue')
|
|
},
|
|
{
|
|
path: 'monitor/species',
|
|
name: 'SpeciesMonitor',
|
|
component: () => import('../views/monitor/species/index.vue')
|
|
},
|
|
{
|
|
path: 'monitor/environment',
|
|
name: 'EnvironmentMonitor',
|
|
component: () => import('../views/monitor/environment/index.vue')
|
|
},
|
|
{
|
|
path: 'monitor/observations',
|
|
name: 'ObservationsMonitor',
|
|
component: () => import('../views/monitor/observations/index.vue')
|
|
},
|
|
{
|
|
path: 'patrol/tasks',
|
|
name: 'PatrolTasks',
|
|
component: () => import('../views/patrol/tasks/index.vue')
|
|
},
|
|
{
|
|
path: 'patrol/events',
|
|
name: 'PatrolEvents',
|
|
component: () => import('../views/patrol/events/index.vue')
|
|
},
|
|
{
|
|
path: 'patrol/plans',
|
|
name: 'PatrolPlans',
|
|
component: () => import('../views/patrol/plans/index.vue')
|
|
},
|
|
{
|
|
path: 'patrol/records',
|
|
name: 'PatrolRecords',
|
|
component: () => import('../views/patrol/records/index.vue')
|
|
},
|
|
{
|
|
path: 'patrol/points',
|
|
name: 'PatrolPoints',
|
|
component: () => import('../views/patrol/points/index.vue'),
|
|
},
|
|
{
|
|
path: 'report/daily',
|
|
name: 'DailyReports',
|
|
component: () => import('../views/report/daily/index.vue')
|
|
},
|
|
{
|
|
path: 'report/reportTemplates',
|
|
name: 'ReportTemplates',
|
|
component: () => import('../views/report/reportTemplates/index.vue')
|
|
},
|
|
{
|
|
path: 'report/analysis',
|
|
name: 'AnalysisReports',
|
|
component: () => import('../views/report/analysis/index.vue')
|
|
},
|
|
{
|
|
path: 'report/about',
|
|
name: 'ProjectAbout',
|
|
component: () => import('../views/report/about/index.vue')
|
|
},
|
|
{
|
|
path: 'system/settings',
|
|
name: 'SystemSettings',
|
|
component: () => import('../views/system/settings/index.vue')
|
|
},
|
|
{
|
|
path: 'system/logs',
|
|
name: 'SystemLogs',
|
|
component: () => import('../views/system/logs/index.vue')
|
|
},
|
|
{
|
|
path: 'system/data',
|
|
name: 'DataManagement',
|
|
component: () => import('@/views/system/data/index.vue'),
|
|
meta: { title: '数据管理', icon: 'data' }
|
|
},
|
|
{
|
|
path: 'system/carousel',
|
|
name: 'SystemCarousel',
|
|
component: () => import('../views/system/carousel/index.vue'),
|
|
meta: { title: '轮播图管理', icon: 'picture' }
|
|
},
|
|
{
|
|
path: 'course/index',
|
|
name: 'CourseManagement',
|
|
component: () => import('../views/course/index.vue'),
|
|
meta: { title: '课程管理', icon: 'reading' }
|
|
},
|
|
{
|
|
path: 'course/application',
|
|
name: 'CourseApplication',
|
|
component: () => import('../views/course/Application.vue')
|
|
},
|
|
{
|
|
path: 'activity/study',
|
|
name: 'StudyManagement',
|
|
component: () => import('../views/activity/study/index.vue')
|
|
},
|
|
{
|
|
path: 'activity/knowledge',
|
|
name: 'KnowledgeManagement',
|
|
component: () => import('../views/activity/knowledge/index.vue')
|
|
},
|
|
{
|
|
path: 'AIPatrol/sensor',
|
|
name: 'SensorManagement',
|
|
component: () => import('../views/AIPatrol/sensor/index.vue')
|
|
},
|
|
{
|
|
path: 'AIPatrol/camera',
|
|
name: 'CameraManagement',
|
|
component: () => import('../views/AIPatrol/Camera/index.vue')
|
|
},
|
|
{
|
|
path: 'AIPatrol/drone',
|
|
name: 'DroneManagement',
|
|
component: () => import('../views/AIPatrol/drone/index.vue')
|
|
},
|
|
{
|
|
path: 'feedback/suggestions',
|
|
name: 'FeedbackSuggestions',
|
|
component: () => import('../views/feedback/suggestions/index.vue')
|
|
},
|
|
{
|
|
path: 'feedback/satisfaction',
|
|
name: 'FeedbackSatisfaction',
|
|
component: () => import('../views/feedback/satisfaction/index.vue')
|
|
},
|
|
{
|
|
path: 'data',
|
|
name: 'SystemData',
|
|
component: () => import('@/views/system/data/index.vue'),
|
|
meta: { title: '数据管理', icon: 'data' }
|
|
},
|
|
{
|
|
path: 'projects',
|
|
name: 'Projects',
|
|
component: () => import('@/views/projects/index.vue'),
|
|
meta: { title: '项目简介管理', icon: 'data' }
|
|
}
|
|
]
|
|
}
|
|
]
|
|
})
|
|
|
|
// 路由守卫
|
|
router.beforeEach((to, from, next) => {
|
|
const userStore = useUserStore()
|
|
|
|
// 如果访问登录页且已登录,重定向到首页
|
|
if (to.path === '/login' && userStore.isLoggedIn) {
|
|
next('/')
|
|
return
|
|
}
|
|
|
|
// 如果需要认证但未登录,重定向到登录页
|
|
if (to.matched.some(record => record.meta.requiresAuth) && !userStore.isLoggedIn) {
|
|
next({
|
|
path: '/login',
|
|
query: { redirect: to.fullPath }
|
|
})
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router |