feat(frontend): unify authenticated requests with 401 session handling
- add utils/session.ts: on 401 clear auth state and redirect to SSO or /login with return path; singleton promise prevents duplicate redirects; typed AuthenticationRequiredError for callers - add api/authRequest.ts: shared generic authRequest with token injection, response parsing and 401 hook - migrate businessLine/containerService/delivery/machine/subsystemAuth/taskLog api modules to the shared helper, removing six duplicated implementations; keep getToken only for EventSource query-param auth - Catalog: silence session-expiry error in instance-name precheck; prefer mysql delivery target by exact template name (matches backend DELIVERY_MYSQL_TEMPLATE_NAME default)
This commit is contained in:
@@ -522,6 +522,7 @@ import { deliveryApi, type DeliveryMountPath, type DeliveryTarget, type Deployme
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useBusinessLineStore } from '@/stores/businessLine'
|
||||
import { useBusinessLineMockProfile } from '@/utils/businessLineMock'
|
||||
import { isAuthenticationRequiredError } from '@/utils/session'
|
||||
|
||||
type FlowView = 'config' | 'execution' | 'result'
|
||||
type StepState = 'pending' | 'running' | 'done' | 'failed'
|
||||
@@ -1295,6 +1296,7 @@ async function precheck() {
|
||||
}
|
||||
} catch (error) {
|
||||
precheckPassed.value = false
|
||||
if (isAuthenticationRequiredError(error)) return
|
||||
ElMessage.error(error instanceof Error ? `实例名称可用性检查失败:${error.message}` : '实例名称可用性检查失败')
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user