【私域操盘手】账号密码登录

This commit is contained in:
eison
2025-03-16 17:43:30 +08:00
parent f4e36f1921
commit 1d7a87f29f
30 changed files with 1474 additions and 97 deletions

View File

@@ -7,7 +7,7 @@ export default {
{
path: '/auth/login',
meta: {
title: '账号登录',
title: '账号登录',
needLogin: false,
},
component: () => import('@/views/auth/login'),

View File

@@ -6,6 +6,8 @@ import SystemRouter from './system'
import ProductRouter from '@/router/product';
import TaskRouter from '@/router/task';
import DeviceRouter from '@/router/device';
import { isLogin } from '@/utils/auth'
import store from '@/store'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
@@ -46,7 +48,33 @@ const routes = [
},
]
export default new Router({
const router = new Router({
routes,
mode: 'hash',
})
// 全局前置守卫
router.beforeEach((to, from, next) => {
// 设置页面标题
document.title = to.meta.title ? to.meta.title : '医视管理系统'
// 检查路由是否需要登录
if (to.meta.needLogin) {
// 检查登录状态
if (isLogin()) {
next()
} else {
// 未登录,重定向到登录页
next({ path: '/auth/login' })
}
} else {
// 如果是访问登录页且已登录,则跳转到首页
if (to.path === '/auth/login' && isLogin()) {
next({ path: '/' })
} else {
next()
}
}
})
export default router