fix: 修复request请求自定义headers类型错误
This commit is contained in:
parent
649fb17d00
commit
bf2cd720d0
|
@ -1,4 +1,4 @@
|
||||||
import { AxiosResponse, AxiosRequestHeaders, InternalAxiosRequestConfig } from './types'
|
import { AxiosResponse, InternalAxiosRequestConfig } from './types'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import qs from 'qs'
|
import qs from 'qs'
|
||||||
import { SUCCESS_CODE } from '@/constants'
|
import { SUCCESS_CODE } from '@/constants'
|
||||||
|
@ -7,7 +7,7 @@ import { useUserStoreWithOut } from '@/store/modules/user'
|
||||||
const defaultRequestInterceptors = (config: InternalAxiosRequestConfig) => {
|
const defaultRequestInterceptors = (config: InternalAxiosRequestConfig) => {
|
||||||
if (
|
if (
|
||||||
config.method === 'post' &&
|
config.method === 'post' &&
|
||||||
(config.headers as AxiosRequestHeaders)['Content-Type'] === 'application/x-www-form-urlencoded'
|
config.headers['Content-Type'] === 'application/x-www-form-urlencoded'
|
||||||
) {
|
) {
|
||||||
config.data = qs.stringify(config.data)
|
config.data = qs.stringify(config.data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { CSSProperties } from 'vue'
|
import type { CSSProperties } from 'vue'
|
||||||
import { AxiosRequestHeaders } from 'axios'
|
import { RawAxiosRequestHeaders } from 'axios'
|
||||||
declare global {
|
declare global {
|
||||||
declare interface Fn<T = any> {
|
declare interface Fn<T = any> {
|
||||||
(...arg: T[]): T
|
(...arg: T[]): T
|
||||||
|
@ -40,7 +40,7 @@ declare global {
|
||||||
data?: any
|
data?: any
|
||||||
url?: string
|
url?: string
|
||||||
method?: AxiosMethod
|
method?: AxiosMethod
|
||||||
headers?: AxiosRequestHeaders
|
headers?: RawAxiosRequestHeaders
|
||||||
responseType?: AxiosResponseType
|
responseType?: AxiosResponseType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue