2026-03-12 09:29:23 +00:00
|
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
2026-03-19 05:53:56 +00:00
|
|
|
import Index from '../pages/Index.vue'
|
2026-03-12 09:29:23 +00:00
|
|
|
import Archives from '../pages/Archives.vue'
|
|
|
|
|
import Inspections from '../pages/Inspections.vue'
|
|
|
|
|
import Projects from '../pages/Projects.vue'
|
|
|
|
|
import Analytics from '../pages/Analytics.vue'
|
|
|
|
|
import QrLogin from '../pages/QrLogin.vue'
|
|
|
|
|
import AdminLayout from '../pages/admin/AdminLayout.vue'
|
2026-03-19 05:49:40 +00:00
|
|
|
import AdminHome from '../pages/admin/Home.vue'
|
2026-03-12 09:29:23 +00:00
|
|
|
import { getToken } from '../lib/auth'
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
|
history: createWebHistory(),
|
|
|
|
|
routes: [
|
|
|
|
|
{
|
|
|
|
|
path: '/',
|
2026-03-19 05:49:40 +00:00
|
|
|
name: 'index',
|
|
|
|
|
component: Index,
|
2026-03-12 09:29:23 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/archives',
|
|
|
|
|
name: 'archives',
|
|
|
|
|
component: Archives,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/inspections',
|
|
|
|
|
name: 'inspections',
|
|
|
|
|
component: Inspections,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/projects',
|
|
|
|
|
name: 'projects',
|
|
|
|
|
component: Projects,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/analytics',
|
|
|
|
|
name: 'analytics',
|
|
|
|
|
component: Analytics,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/login',
|
|
|
|
|
name: 'login',
|
|
|
|
|
component: QrLogin,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/admin',
|
|
|
|
|
component: AdminLayout,
|
|
|
|
|
children: [
|
2026-03-19 05:49:40 +00:00
|
|
|
{ path: '', redirect: '/admin/home' },
|
|
|
|
|
{ path: 'home', component: AdminHome },
|
2026-03-12 09:29:23 +00:00
|
|
|
{ path: 'archives', name: 'admin-archives', component: Archives },
|
|
|
|
|
{ path: 'inspections', name: 'admin-inspections', component: Inspections },
|
2026-03-19 09:35:05 +00:00
|
|
|
{ path: 'system/user', name: 'admin-system-usr', component: () => import('../pages/system/user.vue') },
|
|
|
|
|
{ path: 'system/role', name: 'admin-system-role', component: () => import('../pages/system/role.vue') },
|
|
|
|
|
{ path: 'system/option', name: 'admin-system-option', component: () => import('../pages/system/option.vue') },
|
|
|
|
|
{ path: 'org/list', name: 'admin-org-list', component: () => import('../pages/org/list.vue') },
|
|
|
|
|
{ path: 'org/person', name: 'admin-org-person', component: () => import('../pages/org/person.vue') },
|
|
|
|
|
{ path: 'device/summary', name: 'admin-device-summary', component: () => import('../pages/device/summary.vue') },
|
|
|
|
|
{ path: 'device/list', name: 'admin-device-list', component: () => import('../pages/device/list.vue') },
|
|
|
|
|
{ path: 'project/list', name: 'admin-project-list', component: () => import('../pages/project/list.vue') },
|
|
|
|
|
{ path: 'project/detail', name: 'admin-project-detail', component: () => import('../pages/project/detail.vue') },
|
2026-03-23 07:57:48 +00:00
|
|
|
{path:'task/list',name:'admin-task-list',component:()=> import('../pages/task/list.vue')},
|
|
|
|
|
{path:'data/list',name:'admin-record-list',component:()=> import('../pages/record/list.vue')},
|
|
|
|
|
{path:'point/list',name:'admin-point-list',component:()=> import('../pages/point/list.vue')}
|
2026-03-12 09:29:23 +00:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
router.beforeEach((to) => {
|
|
|
|
|
if (to.path.startsWith('/admin') && !getToken()) {
|
|
|
|
|
return { path: '/login' }
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default router
|