|
@@ -9,16 +9,16 @@ import {
|
|
|
} from '@/enums/httpEnum'
|
|
} from '@/enums/httpEnum'
|
|
|
import type { RequestGlobalConfigType, RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
|
import type { RequestGlobalConfigType, RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
|
|
|
|
|
|
|
-export const get = (url: string, params?: object) => {
|
|
|
|
|
- return axiosInstance({
|
|
|
|
|
|
|
+export const get = <T = any>(url: string, params?: object) => {
|
|
|
|
|
+ return axiosInstance<T>({
|
|
|
url: url,
|
|
url: url,
|
|
|
method: RequestHttpEnum.GET,
|
|
method: RequestHttpEnum.GET,
|
|
|
params: params,
|
|
params: params,
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export const post = (url: string, data?: object, headersType?: string) => {
|
|
|
|
|
- return axiosInstance({
|
|
|
|
|
|
|
+export const post = <T = any>(url: string, data?: object, headersType?: string) => {
|
|
|
|
|
+ return axiosInstance<T>({
|
|
|
url: url,
|
|
url: url,
|
|
|
method: RequestHttpEnum.POST,
|
|
method: RequestHttpEnum.POST,
|
|
|
data: data,
|
|
data: data,
|
|
@@ -28,8 +28,8 @@ export const post = (url: string, data?: object, headersType?: string) => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export const patch = (url: string, data?: object, headersType?: string) => {
|
|
|
|
|
- return axiosInstance({
|
|
|
|
|
|
|
+export const patch = <T = any>(url: string, data?: object, headersType?: string) => {
|
|
|
|
|
+ return axiosInstance<T>({
|
|
|
url: url,
|
|
url: url,
|
|
|
method: RequestHttpEnum.PATCH,
|
|
method: RequestHttpEnum.PATCH,
|
|
|
data: data,
|
|
data: data,
|
|
@@ -39,8 +39,8 @@ export const patch = (url: string, data?: object, headersType?: string) => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export const put = (url: string, data?: object, headersType?: ContentTypeEnum) => {
|
|
|
|
|
- return axiosInstance({
|
|
|
|
|
|
|
+export const put = <T = any>(url: string, data?: object, headersType?: ContentTypeEnum) => {
|
|
|
|
|
+ return axiosInstance<T>({
|
|
|
url: url,
|
|
url: url,
|
|
|
method: RequestHttpEnum.PUT,
|
|
method: RequestHttpEnum.PUT,
|
|
|
data: data,
|
|
data: data,
|
|
@@ -50,8 +50,8 @@ export const put = (url: string, data?: object, headersType?: ContentTypeEnum) =
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export const del = (url: string, params?: object) => {
|
|
|
|
|
- return axiosInstance({
|
|
|
|
|
|
|
+export const del = <T = any>(url: string, params?: object) => {
|
|
|
|
|
+ return axiosInstance<T>({
|
|
|
url: url,
|
|
url: url,
|
|
|
method: RequestHttpEnum.DELETE,
|
|
method: RequestHttpEnum.DELETE,
|
|
|
params
|
|
params
|
|
@@ -82,11 +82,11 @@ export const http = (type?: RequestHttpEnum) => {
|
|
|
}
|
|
}
|
|
|
const prefix = 'javascript:'
|
|
const prefix = 'javascript:'
|
|
|
// 对输入字符进行转义处理
|
|
// 对输入字符进行转义处理
|
|
|
-export const translateStr = (target: string | object) => {
|
|
|
|
|
|
|
+export const translateStr = (target: string | Record<any, any>) => {
|
|
|
if (typeof target === 'string') {
|
|
if (typeof target === 'string') {
|
|
|
if (target.startsWith(prefix)) {
|
|
if (target.startsWith(prefix)) {
|
|
|
const funcStr = target.split(prefix)[1]
|
|
const funcStr = target.split(prefix)[1]
|
|
|
- let result;
|
|
|
|
|
|
|
+ let result
|
|
|
try {
|
|
try {
|
|
|
result = new Function(`${funcStr}`)()
|
|
result = new Function(`${funcStr}`)()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -100,8 +100,8 @@ export const translateStr = (target: string | object) => {
|
|
|
}
|
|
}
|
|
|
for (const key in target) {
|
|
for (const key in target) {
|
|
|
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
|
- const subTarget = (target as any)[key];
|
|
|
|
|
- (target as any)[key] = translateStr(subTarget)
|
|
|
|
|
|
|
+ const subTarget = target[key]
|
|
|
|
|
+ target[key] = translateStr(subTarget)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return target
|
|
return target
|