先进先出

This commit is contained in:
qianhao.xu
2024-04-14 11:17:15 +08:00
parent c0ce07b146
commit 90be1fd3c4
4 changed files with 110 additions and 36 deletions

View File

@@ -18,14 +18,20 @@ import {
let timeout = 10000
const request = config => {
// 浏览器测试用
const storageBaseUrl = 'http://' + getBaseUrl() + '/api';
// const storageBaseUrl = 'http://' + getBaseUrl() + '/api';
// 真机测试以及部署用
//const storageBaseUrl = 'http://' + getBaseUrl();
const storageBaseUrl = 'http://' + getBaseUrl();
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
config.header = config.header || {}
// 假设你使用的是PHP作为你的后端语言
config.header['Access-Control-Allow-Origin']= '*'; // 允许任何源访问
config.header['Access-Control-Allow-Methods']='GET, POST, OPTIONS'; // 允许的HTTP方法
config.header['Access-Control-Allow-Headers']= 'X-Requested-With'; // 允许的HTTP头
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
}
// get请求映射params参数
if (config.params) {
@@ -44,9 +50,10 @@ const request = config => {
dataType: 'json'
}).then(response => {
let [error, res] = response
// console.log('token:','Bearer ' + getToken());
// console.log('token:','Bearer ' + getToAccess-Control-Allow-Originken());
// console.log('request:',storageBaseUrl + config.url,response);
if (error) {
console.log(error)
toast('后端接口连接异常')
reject('后端接口连接异常')
return