请求配置更改

This commit is contained in:
李志鹏
2026-04-24 13:31:45 +08:00
parent 136c24ce30
commit 071930f257
2 changed files with 34 additions and 9 deletions

View File

@@ -478,14 +478,15 @@ export const Https = {
},
axiosGet(url, config) {
axiosGet(url, config, pathParams) {
return new Promise((resolve, reject) => {
if (isLoginTime && url != '/api/portfolio/page') {
resolve('')
return
}
axios
.get(url, config)
.get(setPathParams(url, pathParams), config)
.then(response => {
resolve(response)
})
@@ -495,14 +496,14 @@ export const Https = {
})
},
axiosPut(url, data) {
axiosPut(url, data, pathParams) {
return new Promise((resolve, reject) => {
if (isLoginTime && url != '/api/portfolio/page') {
resolve('')
return
}
axios
.put(url, data)
.put(setPathParams(url, pathParams), data)
.then(response => {
resolve(response)
})
@@ -512,14 +513,14 @@ export const Https = {
})
},
axiosPost(url, data, config) {
axiosPost(url, data, config, pathParams) {
return new Promise((resolve, reject) => {
if (isLoginTime && url != '/api/portfolio/page') {
resolve('')
return
}
axios
.post(url, data, config)
.post(setPathParams(url, pathParams), data, config)
.then(response => {
resolve(response)
})
@@ -529,14 +530,14 @@ export const Https = {
})
},
axiosDelete(url, newData) {
axiosDelete(url, newData, pathParams) {
return new Promise((resolve, reject) => {
if (isLoginTime && url != '/api/portfolio/page') {
resolve('')
return
}
axios
.delete(url, { data: newData })
.delete(setPathParams(url, pathParams), { data: newData })
.then(response => {
resolve(response)
})
@@ -546,3 +547,12 @@ export const Https = {
})
}
}
function setPathParams(url, pathParams = {}) {
const obj = typeof pathParams === 'object' ? pathParams : { id: pathParams }
const keys = Object.keys(obj)
keys.forEach(key => {
url = url.replace(new RegExp(`\\{${key}\\}`, 'g'), obj[key]);
})
return url
}