🧑‍💻 新增env.dev,用于区分环境类型, dev环境忽略路由守卫

This commit is contained in:
MoeSnowyFox
2025-08-14 00:12:42 +08:00
parent 512667b850
commit 2391e5b806
3 changed files with 12 additions and 0 deletions

1
frontend/.env Normal file
View File

@@ -0,0 +1 @@
VITE_APP_ENV='prod'

View File

@@ -0,0 +1 @@
VITE_APP_ENV='dev'

View File

@@ -3,6 +3,7 @@ import type { RouteRecordRaw } from 'vue-router'
import { isAppInitialized } from '@/utils/config'
const routes: RouteRecordRaw[] = [
{
path: '/',
@@ -96,6 +97,14 @@ router.beforeEach(async (to, from, next) => {
// 如果访问的不是初始化页面,且没有初始化标记,则重定向到初始化页面
if (to.path !== '/initialization') {
// 在开发环境下跳过初始化检查
const isDev = import.meta.env.VITE_APP_ENV === 'dev'
if (isDev) {
console.log('开发环境,跳过初始化检查')
next()
return
}
const initialized = await isAppInitialized()
console.log('检查初始化状态:', initialized)
@@ -109,4 +118,5 @@ router.beforeEach(async (to, from, next) => {
next()
})
export default router