Files
zn-ai/src/permission.ts
duanshuwen 6615d11dd6 chore: restructure project and add i18n support
- Reorganize project structure with new electron and shared directories
- Add comprehensive i18n support with Chinese, English, and Japanese locales
- Update build configurations and TypeScript paths for new structure
- Add various UI components including chat interface and task management
- Include Windows release binaries and localization files
- Update dependencies and fix import paths throughout the codebase
2026-04-06 14:39:06 +08:00

30 lines
741 B
TypeScript

import router from './router'
import { isPathMatch } from '@utils/validate'
import { Session } from '@src/utils/storage'
// 白名单
const whiteList = ['/login', '/register']
const isWhiteList = (path: string) => whiteList.some(pattern => isPathMatch(pattern, path))
router.beforeEach((to: any, _from: any, next: any) => {
if(Session.getToken()) {
// has token
if (to.path === '/login') {
next({path: '/home'})
} else if (isWhiteList(to.path)) {
next()
} else {
next()
}
} else {
// no token
if (isWhiteList(to.path)) {
// 在免登录白名单,直接进入
next()
} else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
}
}
})