mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
chore: 新增put请求类型
This commit is contained in:
parent
15fc418fc4
commit
c095e15d6c
@ -28,8 +28,6 @@ axiosInstance.interceptors.response.use(
|
||||
return Promise.resolve(res.data)
|
||||
},
|
||||
(err: AxiosResponse) => {
|
||||
const { code } = err.data as { code: number }
|
||||
if (ErrorPageNameMap.get(code)) redirectErrorPage(code)
|
||||
window['$message'].error('接口异常,请检查!')
|
||||
Promise.reject(err)
|
||||
}
|
||||
|
@ -19,6 +19,17 @@ export const post = (url: string, params: object, headersType?: string) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const put = (url: string, data?: object, headersType?: string) => {
|
||||
return axiosInstance({
|
||||
url: url,
|
||||
method: RequestHttpEnum.PUT,
|
||||
data: data,
|
||||
headers: {
|
||||
'Content-Type': headersType || ContentTypeEnum.JSON
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const del = (url: string, params: object) => {
|
||||
return axiosInstance({
|
||||
url: url,
|
||||
@ -29,11 +40,20 @@ export const del = (url: string, params: object) => {
|
||||
|
||||
// 获取请求函数,默认get
|
||||
export const http = (type?: RequestHttpEnum) => {
|
||||
return type === RequestHttpEnum.GET
|
||||
? get
|
||||
: type === RequestHttpEnum.POST
|
||||
? post
|
||||
: type === RequestHttpEnum.DELETE
|
||||
? del
|
||||
: get
|
||||
switch (type) {
|
||||
case RequestHttpEnum.GET:
|
||||
return get
|
||||
|
||||
case RequestHttpEnum.POST:
|
||||
return post
|
||||
|
||||
case RequestHttpEnum.PUT:
|
||||
return put
|
||||
|
||||
case RequestHttpEnum.DELETE:
|
||||
return del
|
||||
|
||||
default:
|
||||
return get
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user