| | |
| | | { path: "", redirect: "/dashboard" }, |
| | | { path: "dashboard", component: () => import("../views/DashboardView.vue"), meta: { permission: "dashboard:page" } }, |
| | | { path: "appointments", component: () => import("../views/AppointmentListView.vue"), meta: { permission: "appointments:page" } }, |
| | | { path: "approvals", component: () => import("../views/ApprovalTodoView.vue"), meta: { permission: "approvals:page" } }, |
| | | { path: "approvals", component: () => import("../views/ApprovalTodoView.vue"), meta: { title: "运维日志", permission: "approvals:page" } }, |
| | | { path: "config", redirect: "/system/booking-settings" }, |
| | | { |
| | | path: "system/approval-settings", |
| | |
| | | component: () => import("../views/ContentSettingsView.vue"), |
| | | meta: { title: "内容设置", permission: "config:content-settings:page" }, |
| | | }, |
| | | { path: "exports", component: () => import("../views/ExportView.vue"), meta: { permission: "exports:page" } }, |
| | | { path: "exports", component: () => import("../views/ExportView.vue"), meta: { title: "操作日志", permission: "exports:page" } }, |
| | | { path: "staff/depts", component: () => import("../views/DeptManageView.vue"), meta: { permission: "sys:depts:page" } }, |
| | | { path: "staff/employees", component: () => import("../views/StaffEmployeesView.vue"), meta: { permission: "sys:staff:page" } }, |
| | | { |
| | |
| | | router.beforeEach((to, _from, next) => { |
| | | const auth = useAuthStore(); |
| | | if (to.path === "/login" && auth.token) { |
| | | next(resolveFirstAllowedPath()); |
| | | const redirectPath = resolveFirstAllowedPath(); |
| | | if (redirectPath === "/login") { |
| | | auth.clear(); |
| | | next(); |
| | | return; |
| | | } |
| | | next(redirectPath); |
| | | return; |
| | | } |
| | | if (to.meta.requiresAuth && !auth.token) { |
| | |
| | | } |
| | | const requiredPermission = typeof to.meta.permission === "string" ? to.meta.permission : ""; |
| | | if (requiredPermission && !auth.hasPermission(requiredPermission)) { |
| | | next(resolveFirstAllowedPath()); |
| | | const redirectPath = resolveFirstAllowedPath(); |
| | | if (redirectPath === to.path) { |
| | | next(); |
| | | return; |
| | | } |
| | | if (redirectPath === "/login") { |
| | | auth.clear(); |
| | | } |
| | | next(redirectPath); |
| | | return; |
| | | } |
| | | if (to.path === "/") { |
| | | next(resolveFirstAllowedPath()); |
| | | const redirectPath = resolveFirstAllowedPath(); |
| | | if (redirectPath === "/") { |
| | | next(); |
| | | return; |
| | | } |
| | | if (redirectPath === "/login" && auth.token) { |
| | | auth.clear(); |
| | | } |
| | | next(redirectPath); |
| | | return; |
| | | } |
| | | next(); |