feat: 完成客户端联调与通用列表组件

This commit is contained in:
2026-08-01 12:17:33 +08:00
parent be7675954a
commit beb86d53e7
31 changed files with 1326 additions and 378 deletions
+1
View File
@@ -79,6 +79,7 @@ export interface FirstLegOrderCargoPayload {
dangerousGoods?: boolean
cargoRemark?: string
skuNo?: string
upcNo?: string
cargoNameEn?: string
totalQuantity?: number
netWeightKg?: number
+14 -1
View File
@@ -14,7 +14,7 @@ interface RetryableRequest extends InternalAxiosRequestConfig {
}
function unwrap<T>(envelope: ApiEnvelope<T>) {
if (envelope.code !== '0') {
if (envelope.code !== '200') {
throw new ApiError(envelope.message || '请求失败', envelope.code, undefined, asFieldErrors(envelope.data), envelope.traceId)
}
return envelope.data
@@ -40,6 +40,18 @@ function mapError(error: unknown) {
}
let refreshPromise: Promise<TokenPair> | null = null
let redirectingToLogin = false
function redirectToLoginAfterSessionExpiry() {
if (redirectingToLogin || typeof window === 'undefined') return
const { pathname, search, hash } = window.location
if (pathname === '/login' || pathname === '/register') return
redirectingToLogin = true
const redirect = `${pathname}${search}${hash}`
window.location.replace(`/login?redirect=${encodeURIComponent(redirect)}`)
}
async function refreshSession() {
const refreshToken = getRefreshToken()
@@ -85,6 +97,7 @@ transport.interceptors.response.use(
if (mappedError.status === 401 || mappedError.code === 'A0401') {
clearSessionTokens()
window.dispatchEvent(new CustomEvent('cc-client-session-expired'))
redirectToLoginAfterSessionExpiry()
}
throw mappedError
}