From 0d3b0bd28d05c0c5309e89326674370e05051507 Mon Sep 17 00:00:00 2001 From: siujamo Date: Mon, 5 Jan 2026 10:10:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=20axios=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/auth/index.ts | 2 +- src/api/department/index.ts | 2 +- src/api/menu/index.ts | 2 +- src/api/position/index.ts | 2 +- src/api/role/index.ts | 2 +- src/api/user/index.ts | 2 +- src/{service => client}/web-client/index.ts | 2 ++ 7 files changed, 8 insertions(+), 6 deletions(-) rename src/{service => client}/web-client/index.ts (95%) diff --git a/src/api/auth/index.ts b/src/api/auth/index.ts index d750f62..9dbd38e 100644 --- a/src/api/auth/index.ts +++ b/src/api/auth/index.ts @@ -1,4 +1,4 @@ -import webClient from "@/service/web-client" +import webClient from "@/client/web-client" import { HttpStatus } from "@/constant" import type { CaptchaResponse, UserAuthResponse } from "@/types/web/response" import type { UsernamePasswordLoginRequest } from "@/types/web/request" diff --git a/src/api/department/index.ts b/src/api/department/index.ts index e7bd189..3d31c2a 100644 --- a/src/api/department/index.ts +++ b/src/api/department/index.ts @@ -1,4 +1,4 @@ -import webClient from "@/service/web-client" +import webClient from "@/client/web-client" import type { TreeNode } from "@/types/tree" import type { Department } from "@/types/entity" diff --git a/src/api/menu/index.ts b/src/api/menu/index.ts index 4defb0e..358034e 100644 --- a/src/api/menu/index.ts +++ b/src/api/menu/index.ts @@ -1,4 +1,4 @@ -import webClient from "@/service/web-client" +import webClient from "@/client/web-client" import type { TreeNode } from "@/types/tree" import type { MenuItem } from "@/types/entity" diff --git a/src/api/position/index.ts b/src/api/position/index.ts index 0c8a79b..0c56c3b 100644 --- a/src/api/position/index.ts +++ b/src/api/position/index.ts @@ -1,4 +1,4 @@ -import webClient from "@/service/web-client" +import webClient from "@/client/web-client" import type { QueryPositionRequest } from "@/types/web/request" import type { PageResponse } from "@/types/web/response" import type { Position } from "@/types/entity" diff --git a/src/api/role/index.ts b/src/api/role/index.ts index 67d58a8..820565c 100644 --- a/src/api/role/index.ts +++ b/src/api/role/index.ts @@ -1,5 +1,5 @@ import type { QueryRoleRequest } from "@/types/web/request" -import webClient from "@/service/web-client" +import webClient from "@/client/web-client" import type { PageResponse, RoleResponse } from "@/types/web/response" import type { RoleFormValues } from "@/components/role-display-form" diff --git a/src/api/user/index.ts b/src/api/user/index.ts index 34adf46..d40c343 100644 --- a/src/api/user/index.ts +++ b/src/api/user/index.ts @@ -1,4 +1,4 @@ -import webClient from "@/service/web-client" +import webClient from "@/client/web-client" import { getCountryCallingCode } from "libphonenumber-js" import { getDefaultCountryCode } from "@/utils/phone-number-utils" import type { AddUserRequest, EditUserRequest, QueryUserRequest } from "@/types/web/request" diff --git a/src/service/web-client/index.ts b/src/client/web-client/index.ts similarity index 95% rename from src/service/web-client/index.ts rename to src/client/web-client/index.ts index b4f80b6..1946987 100644 --- a/src/service/web-client/index.ts +++ b/src/client/web-client/index.ts @@ -8,6 +8,8 @@ import type { GeneralErrorResponse } from "@/types/web/response" const webClient = axios.create({ baseURL: import.meta.env.VITE_API_BASE_URL, timeout: dayjs.duration({ seconds: 10 }).asMilliseconds(), + withCredentials: true, + withXSRFToken: true }) webClient.interceptors.request.use(