用户端(四面9分批次): 三条全局错误出口、URL 白名单收口、令牌键单点、uid 短路进门禁

- 此前全树 0 处全局错误处理器:装 app.config.errorHandler + window error + unhandledrejection,
  每条都留可诊断记录、界面只出中文、处理器自身异常不重抛也不白屏(9 例判据)。
- safeHttpUrl 未覆盖的 3 处(两个品牌 Tab 与 useVersionUpdate 直装服务端 file_url)收口;
  令牌键 aiimage_auth_token 由 4 处各自定义 + 2 处内联收成唯一定义点。
- 「localStorage 有 uid 就免校验」改走 auth-gate 单点,剩余例外台账化且同口径必须能抓到
  评审点名的原写法(6 例);卸载配对 3 处补齐 + 全树判据(7 例)。
- task-status-text 把 CANCELLED 显示成"执行中"改对,CANCELED/CANCELLED 两拼写都映射(4 例)。
- 主审计补的四处修复:新判据里两处拿数组和 0 比(怎么写都红);静默 catch 的"用户可见出口"
  符号表认不出本仓 userNotice 与注入式 notify,把真报了用户的 catch 判成静默;
  新错误出口带来的 2 个 try/catch 按棘轮合同写理由进基线(296→298,silent 一格没涨)。
- 验收:node --test 820 例 0 红、npx vue-tsc --noEmit rc=0。
This commit is contained in:
2026-10-09 23:09:37 +08:00
parent 8776a9bf1e
commit 3987b8d7fe
27 changed files with 1701 additions and 49 deletions
+2 -1
View File
@@ -6,6 +6,7 @@ import axios, {
type InternalAxiosRequestConfig,
} from 'axios'
import { authReasonOf, handleKicked, handleSessionExpired, isKickedPayload, isUnauthorizedPayload } from '../auth/kick-handler.ts'
import { AUTH_TOKEN_KEY } from '../auth/session-keys.ts'
import { userNotice } from '../utils/user-notice.ts'
const REQUEST_FALLBACK = '请求未能完成,请稍后重试'
@@ -103,7 +104,7 @@ function createHttpClient(): AxiosInstance {
// 携带本地登录令牌:桌面端同源 cookie 仍可用;dev(5173) 无 cookie 时靠 Bearer 过 Java 鉴权
try {
if (config.url && config.url.indexOf('/newApi') === 0 && typeof window !== 'undefined') {
const token = window.localStorage.getItem('aiimage_auth_token') || ''
const token = window.localStorage.getItem(AUTH_TOKEN_KEY) || ''
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
@@ -1,4 +1,5 @@
import { requestGetJson } from '../../http.ts'
import { AUTH_TOKEN_KEY } from '../../../auth/session-keys.ts'
export interface PermissionMenuItem {
id: number | string
@@ -72,7 +73,7 @@ export function readCachedAppColumnPermissions(uid: number): PermissionMenuItem[
}
function getAuthToken() {
return typeof window === 'undefined' ? '' : window.localStorage.getItem('aiimage_auth_token') || ''
return typeof window === 'undefined' ? '' : window.localStorage.getItem(AUTH_TOKEN_KEY) || ''
}
function normalizeColumnKeys(items: PermissionMenuItem[] | undefined) {