|
|
@@ -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)
|
|
|
}
|
|
|
}
|