From 98ad5d16f4e5c2a54369defd4245febe48b48377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8?= Date: Fri, 17 Apr 2026 16:58:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8F=96=E6=B6=88get=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=E7=9A=84message=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index a69c189..4db0a07 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -78,6 +78,7 @@ service.interceptors.request.use(requestInterceptor, requestErrorInterceptor) const responseInterceptor = (response: AxiosResponse>) => { //关闭loading(无论成功失败都要关) hideLoading() + const config = response.config if (response.headers['new_token'] !== undefined) { setStorage('token', response.headers['new_token'] as string) } @@ -86,13 +87,14 @@ const responseInterceptor = (response: AxiosResponse console.log('响应数据data', data); // 判断业务状态码 if (data.code == 200 || data.code == 0) { - // 仅当业务成功时,才弹成功提示 - ElNotification({ - message: data.msg || '操作成功!', - type: 'success', - duration: 2000, - customClass: 'global-notification' - }) + if (config.showMessage !== false) { + ElNotification({ + message: data.msg || '操作成功!', + type: 'success', + duration: 2000, + customClass: 'global-notification' + }) + } return data.data } else { if (data.code === 1) { @@ -155,12 +157,14 @@ const responseErrorInterceptor = (error: AxiosError) => { errMsg = error.message || '服务器错误' } - ElNotification({ - message: errMsg, - type: 'error', - duration: 2000, - customClass: 'global-notification' - }) + if (error.config?.showMessage !== false) { + ElNotification({ + message: errMsg, + type: 'error', + duration: 2000, + customClass: 'global-notification' + }) + } return Promise.reject(error) } @@ -169,12 +173,12 @@ service.interceptors.response.use(responseInterceptor, responseErrorInterceptor) // 5. 封装通用请求方法 export const request = { get(url: string, params?: unknown, config?: InternalAxiosRequestConfig): Promise { - return service.get>(url, { params, ...config }).then((res) => { + return service.get>(url, { params, ...config,showMessage:false }).then((res) => { return res as T; }); }, post(url: string, data?: unknown, config?: InternalAxiosRequestConfig): Promise { - return service.post>(url, data, config).then((res) => { + return service.post>(url, data, {config,showMessage: true,}).then((res) => { return res as T; }); }, From 19a76015bd4fc978c7d563a31a1eb9c86f961b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8?= Date: Wed, 22 Apr 2026 14:02:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 ++-- src/components/layout/Sidebar.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env.development b/.env.development index dbc8548..0b4293a 100644 --- a/.env.development +++ b/.env.development @@ -1,8 +1,8 @@ # 开发环境标识(Vite 内置变量,无需修改) NODE_ENV = development -# 开发环境接口基础地址(对应你配置的 192.168.10.10:8085/api) -VITE_API_BASE_URL = http://192.168.10.10:8085/api +# 开发环境接口基础地址(192.168.11.183:8085/api) +VITE_API_BASE_URL = http://192.168.11.183:8085/api # 请求超时时间(毫秒) VITE_REQUEST_TIMEOUT = 10000 diff --git a/src/components/layout/Sidebar.vue b/src/components/layout/Sidebar.vue index 73cddc0..f3cc575 100644 --- a/src/components/layout/Sidebar.vue +++ b/src/components/layout/Sidebar.vue @@ -9,7 +9,7 @@ -