XiaoDaiGua-Ray 911c403434
feat: refine admin workflows for v6.0.3
Improve theme consistency, keyboard navigation, and reusable frontend components.
Harden fullstack initialization and expose scoped lint and Vitest commands.
2026-12-01 11:04:13 +08:00

1.7 KiB

Requests and interceptors

Put business endpoints in src/api and use request exported by @/axios. Success interceptors return the response body, so request<T>() resolves to T; failures still reject. Use an Axios instance that retains the full response when headers or HTTP status are needed.

Default request configuration is in src/app-config/request-config.ts. Put reusable request/response logic in axios-interceptor/request/plugins and axios-interceptor/response/plugins, registering each in its provider.ts. Success queues use AxiosRequestInterceptor or AxiosResponseInterceptor; failure queues use FetchErrorFunction. Check prerequisite logic when reordering queues.

Request cancellation

The default canceller identifies duplicates by URL, method, serialized params, and body, then injects a signal into the current request. In the default layout, AppRequestCancelerProvider cancels the pending requests it manages before route updates.

import { request } from '@/axios'

const loadOrders = (signal: AbortSignal) =>
  request<{ id: string }[]>({
    url: '/api/orders',
    method: 'get',
    signal,
    cancelConfig: { cancel: false },
  })

The canceller compares encoded URLSearchParams and ordered FormData entries, including file identity. Raw files, blobs, array buffers, typed-array or DataView bodies, and readable streams are identified by instance. Reuse the same instance to replace an earlier pending upload. Passing a signal or setting cancelConfig.cancel to false opts out of default cancellation. The person list demonstrates forwarding TablePro's signal. useRequest wraps the same instance and must run within an active Vue effect scope.