From a8160285608ed6c170985b1f3a510355de2b99c4 Mon Sep 17 00:00:00 2001 From: Sean Huang Date: Fri, 1 Jul 2022 12:38:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=96=AD=E7=82=B9=E4=B8=8D=E5=9C=A8=E6=BA=90=E7=A0=81=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=A4=84=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=BE=9D=E8=B5=96vite-plugin-vue-setup-extend=E4=B8=BAvite-plu?= =?UTF-8?q?gin-vue-setup-extend-plus=E5=8D=B3=E5=8F=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ef42ff..3a2e7c9 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,6 @@ "vite": "^2.9.9", "vite-plugin-html": "^3.2.0", "vite-plugin-mock": "^2.9.6", - "vite-plugin-vue-setup-extend": "^0.3.0" + "vite-plugin-vue-setup-extend-plus": "^0.1.0" } } From dff8862c75ce37ed8c69d4462214ce0a2aae6e9b Mon Sep 17 00:00:00 2001 From: Sean Huang Date: Tue, 5 Jul 2022 18:35:05 +0800 Subject: [PATCH 2/2] feat: Add response code 400. fix: Change the parameter naming of the get method to params. --- src/api/post/index.js | 4 ++-- src/api/user/index.js | 4 ++-- src/utils/http/interceptors.js | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/api/post/index.js b/src/api/post/index.js index e06f12b..d40a9a7 100644 --- a/src/api/post/index.js +++ b/src/api/post/index.js @@ -1,10 +1,10 @@ import { defAxios as request } from '@/utils/http' -export function getPosts(data = {}) { +export function getPosts(params = {}) { return request({ url: '/posts', method: 'get', - data, + params, }) } diff --git a/src/api/user/index.js b/src/api/user/index.js index 55c7c5f..b12ed7f 100644 --- a/src/api/user/index.js +++ b/src/api/user/index.js @@ -1,10 +1,10 @@ import { defAxios as request } from '@/utils/http' -export function getUsers(data = {}) { +export function getUsers(params = {}) { return request({ url: '/users', method: 'get', - data, + params, }) } diff --git a/src/utils/http/interceptors.js b/src/utils/http/interceptors.js index 843bd75..6388807 100644 --- a/src/utils/http/interceptors.js +++ b/src/utils/http/interceptors.js @@ -52,6 +52,9 @@ export function repReject(error) { * TODO 此处可以根据后端返回的错误码自定义框架层面的错误处理 */ switch (code) { + case 400: + message = message || '请求参数错误' + break case 401: message = message || '登录已过期' break