fix(ops): 降低 SQL/请求日志噪声并改善 500 恢复
SQL 回显与 DEBUG 解耦;API 请求日志按字节截断并失败降级;可恢复初始化错误不永久锁死,500 页可重试;修复生产任务 in_ 多余 subquery;补充本地登录态清理页。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d7611a1bd6
commit
f50c55f7b6
8 files changed
+112
-12
No files matched your search
@@ -50,11 +50,12 @@
|
||||
import ExceptionIllustration from './ExceptionIllustration.vue'
|
||||
import { useCommon } from '@/hooks/core/useCommon'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { resetRouteInitState } from '@/router/guards/beforeEach'
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
withDefaults(
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
code: string
|
||||
title: string
|
||||
@@ -72,7 +73,15 @@
|
||||
|
||||
const { homePath } = useCommon()
|
||||
|
||||
/** 500 页允许在后端恢复后重新拉菜单/用户信息 */
|
||||
const clearInitLockIfServerError = () => {
|
||||
if (props.variant === 'server-error') {
|
||||
resetRouteInitState()
|
||||
}
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
clearInitLockIfServerError()
|
||||
if (window.history.length > 1) {
|
||||
router.back()
|
||||
return
|
||||
@@ -81,6 +90,7 @@
|
||||
}
|
||||
|
||||
const backHome = () => {
|
||||
clearInitLockIfServerError()
|
||||
const targetHomePath = homePath.value || '/'
|
||||
|
||||
if (!userStore.isLogin) {
|
||||
|
||||
@@ -368,8 +368,6 @@ async function handleDynamicRoutes(
|
||||
return
|
||||
}
|
||||
|
||||
// 标记初始化失败,防止死循环
|
||||
routeInitFailed = true
|
||||
routeInitInProgress = false
|
||||
|
||||
// 输出详细错误信息,便于排查
|
||||
@@ -377,7 +375,14 @@ async function handleDynamicRoutes(
|
||||
console.error(`[RouteGuard] 错误码: ${error.code}, 消息: ${error.message}`)
|
||||
}
|
||||
|
||||
// 跳转到 500 页面,使用 replace 避免产生历史记录
|
||||
// 后端短暂不可达/超时:展示 500,但不永久锁定,便于服务恢复后点「返回首页」重试
|
||||
if (isRecoverableInitError(error)) {
|
||||
next({ name: 'Exception500', replace: true })
|
||||
return
|
||||
}
|
||||
|
||||
// 其它初始化失败:标记失败,防止死循环(刷新页面或重新登录可重置)
|
||||
routeInitFailed = true
|
||||
next({ name: 'Exception500', replace: true })
|
||||
}
|
||||
}
|
||||
@@ -448,3 +453,15 @@ function handleRootPathRedirect(to: RouteLocationNormalized, next: NavigationGua
|
||||
function isUnauthorizedError(error: unknown): boolean {
|
||||
return isHttpError(error) && error.code === ApiStatus.unauthorized
|
||||
}
|
||||
|
||||
/** 后端暂不可达类错误:允许用户在服务恢复后重试初始化 */
|
||||
function isRecoverableInitError(error: unknown): boolean {
|
||||
if (!isHttpError(error)) return false
|
||||
return (
|
||||
error.code === ApiStatus.networkError ||
|
||||
error.code === ApiStatus.requestTimeout ||
|
||||
error.code === ApiStatus.badGateway ||
|
||||
error.code === ApiStatus.serviceUnavailable ||
|
||||
error.code === ApiStatus.gatewayTimeout
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user