Bläddra i källkod

Update:系统重构

XieXing 3 månader sedan
förälder
incheckning
e128b53eb6
2 ändrade filer med 16 tillägg och 13 borttagningar
  1. 13 13
      shudao-vue-frontend/src/main.js
  2. 3 0
      shudao-vue-frontend/src/utils/apiConfig.js

+ 13 - 13
shudao-vue-frontend/src/main.js

@@ -133,31 +133,31 @@ async function initApp() {
   
   console.log('🚀 蜀道系统启动成功')
   
-  // 5. 如果认证失败,在应用挂载后跳转到404页面
+  // 5. 如果认证失败,根据环境决定是否跳转到404页面
   if (authError) {
-    console.log('⚠️ 检测到认证错误,准备跳转到404页面')
+    console.log('⚠️ 检测到认证错误:', authError.message)
     
-    // 检查是否在 APP 环境中
-    const isInApp = window.nativeClosePage && typeof window.nativeClosePage === 'function'
+    // 导入环境判断
+    const { isLocal, isTest } = await import('@/utils/apiConfig')
+    
+    // 本地和测试环境不跳转,只打印错误
+    if (isLocal || isTest) {
+      console.log('🔧 本地/测试环境:认证失败但不跳转,请检查认证网关服务是否启动')
+      return
+    }
     
-    // 根据错误类型确定跳转原因
+    // 生产环境跳转到404
+    const isInApp = window.nativeClosePage && typeof window.nativeClosePage === 'function'
     let reason = 'ticket_failed'
     if (authError.message === 'TICKET_NOT_FOUND') {
-      // 如果在 APP 环境中缺少票据,可能是 APP 返回操作导致的
       reason = isInApp ? 'app_token_lost' : 'ticket_not_found'
     } else if (authError.message.includes('网络') || authError.message.includes('Network')) {
       reason = 'network_error'
-    } else if (authError.message.includes('权限') || authError.message.includes('Permission')) {
-      reason = 'no_permission'
     }
     
-    // 使用 router.push 进行跳转(应用已挂载,router 可用)
     setTimeout(() => {
       console.log('🔄 跳转到404页面,原因:', reason)
-      router.push({
-        path: '/404',
-        query: { reason }
-      })
+      router.push({ path: '/404', query: { reason } })
     }, 100)
   }
 }

+ 3 - 0
shudao-vue-frontend/src/utils/apiConfig.js

@@ -30,6 +30,9 @@ export const isProd = hostname === 'aqai.shudaodsj.com'
 /** 当前环境名称 */
 export const ENV = isLocal ? 'local' : isTest ? 'test' : 'prod'
 
+// 环境检测日志
+console.log('🌍 环境检测:', { hostname, isLocal, isTest, isProd, ENV })
+
 /**
  * 根据环境获取配置值
  * @param {Object} config - { local: value, test: value, prod: value }