fix: 修复request请求自定义headers类型错误
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
4
types/global.d.ts
vendored
4
types/global.d.ts
vendored
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user