mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 封装数据处理
This commit is contained in:
+16
-15
@@ -1,34 +1,35 @@
|
||||
import axiosInstance from './axios'
|
||||
import { RequestEnum, ContentTypeEnum } from '@/enums/httpEnum'
|
||||
|
||||
// 缓存处理
|
||||
const filterUrl = (url: string) => {
|
||||
return url.indexOf('?') !== -1 ? `${url}&time=${new Date().getTime()}` : `${url}?time=${new Date().getTime()}`
|
||||
}
|
||||
|
||||
export const get = (params: object, url: string) => {
|
||||
export const get = (url: string, params: object) => {
|
||||
return axiosInstance({
|
||||
url: filterUrl(url),
|
||||
url: url,
|
||||
method: RequestEnum.GET,
|
||||
params
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
export const post = (params: object, url: string, headersType: string) => {
|
||||
export const post = (url: string, params: object, headersType: string) => {
|
||||
return axiosInstance({
|
||||
url: url,
|
||||
method: RequestEnum.POST,
|
||||
data: params,
|
||||
headers: {
|
||||
'Content-Type': headersType || ContentTypeEnum.JSON
|
||||
}
|
||||
'Content-Type': headersType || ContentTypeEnum.JSON,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const del = (params: object, url: string) => {
|
||||
export const del = (url: string, params: object) => {
|
||||
return axiosInstance({
|
||||
url: filterUrl(url),
|
||||
url: url,
|
||||
method: RequestEnum.DELETE,
|
||||
params
|
||||
params,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
get,
|
||||
post,
|
||||
del,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user