去除所有的控制台日志日志

This commit is contained in:
xiaowang
2026-03-04 10:48:29 +08:00
parent 769a736836
commit 074d49c378
19 changed files with 6 additions and 147 deletions
+5 -16
View File
@@ -47,7 +47,6 @@ const showError = (msg: string) => {
const handleTokenExpired = (isAdmin = false) => {
// 登录过期,只提示一次
if (Date.now() - lastErrorTime > ERROR_DEBOUNCE_TIME || lastErrorMessage !== '登录已过期,请重新登录') {
console.log('Token 过期,清理本地存储并跳转到登录页')
if (isAdmin) {
// 清理后台管理的token
@@ -58,12 +57,10 @@ const handleTokenExpired = (isAdmin = false) => {
sessionStorage.removeItem('adminAccessToken')
showError('登录已过期,请重新登录')
try {
router.push('/admin/login').catch(err => {
console.error('跳转到后台登录页失败:', err)
router.push('/admin/login').catch(() => {
window.location.href = '/admin/login'
})
} catch (err) {
console.error('跳转到后台登录页异常:', err)
} catch {
window.location.href = '/admin/login'
}
} else {
@@ -74,12 +71,10 @@ const handleTokenExpired = (isAdmin = false) => {
sessionStorage.removeItem('accessToken')
showError('登录已过期,请重新登录')
try {
router.push('/').catch(err => {
console.error('跳转到登录页失败:', err)
window.location.href = '/'
router.push('/').catch(() => {
window.location.href = '/'
})
} catch (err) {
console.error('跳转到登录页异常:', err)
} catch {
window.location.href = '/'
}
}
@@ -118,8 +113,6 @@ api.interceptors.response.use(
const errorMsg = res.message || '请求失败'
if (!errorMsg.includes('权限') && !errorMsg.includes('permission')) {
showError(errorMsg)
} else {
console.error('权限不足:', errorMsg)
}
return Promise.reject(new Error(errorMsg))
}
@@ -205,11 +198,7 @@ api.interceptors.response.use(
} else if (error.response?.status !== 403) { // 403权限不足不提示
const errorMsg = (error.response?.data as any)?.message || error.message || '请求失败'
showError(errorMsg)
} else {
console.error('权限不足:', error)
}
console.error('API Error:', error)
return Promise.reject(error)
}
)