From 40377a90d7e7627e3fbdee9054f1cfa17f7d069f Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期四, 11 四月 2024 22:09:53 +0800
Subject: [PATCH] 组件维护页面
---
src/utils/request.js | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/utils/request.js b/src/utils/request.js
index 8834691..3253bbf 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,5 +1,5 @@
import axios from 'axios';
-import { ElNotification, ElMessageBox } from 'element-plus';
+import { ElNotification, ElMessageBox, ElMessage } from 'element-plus';
import sysConfig from "@/config";
import tool from '@/utils/tool';
import router from '@/router';
@@ -12,12 +12,13 @@
axios.interceptors.request.use(
(config) => {
let token = tool.cookie.get("TOKEN");
+ config.headers['Authorization'] = 'Basic c2FiZXI6c2FiZXJfc2VjcmV0'
if(token){
config.headers[sysConfig.TOKEN_NAME] = sysConfig.TOKEN_PREFIX + token
}
if(!sysConfig.REQUEST_CACHE && config.method == 'get'){
config.params = config.params || {};
- config.params['_'] = new Date().getTime();
+ // config.params['_'] = new Date().getTime();
}
Object.assign(config.headers, sysConfig.HEADERS)
return config;
@@ -129,7 +130,14 @@
}).then((response) => {
resolve(response.data);
}).catch((error) => {
- reject(error);
+ if(error.status == 400) {
+ ElMessage({
+ message: error.data.msg,
+ type: 'warning',
+ })
+ }else {
+ reject(error);
+ }
})
})
},
@@ -140,10 +148,11 @@
*/
postJ: function(url, data={}, config={}) {
return new Promise((resolve, reject) => {
+ console.log(qsStringify(data))
axios({
method: 'post',
url: url,
- headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8','Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0'},
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'},
data: qsStringify(data),
...config
}).then((response) => {
@@ -203,7 +212,7 @@
axios({
method: 'delete',
url: url,
- data: data,
+ params: data,
...config
}).then((response) => {
resolve(response.data);
--
Gitblit v1.9.3