This commit is contained in:
parent
e2ef445462
commit
c516067710
|
|
@ -17,7 +17,7 @@ export type PackageInfo = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConfig() {
|
export function getConfig() {
|
||||||
return get<ApiResponse<UserConfig>>('/api/user/config', undefined, { tokenType: 'permanent' })
|
return get<ApiResponse<UserConfig>>('/api/user/config', undefined, { tokenType: 'none' })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getService(tokenType: 'permanent' | 'temporary') {
|
export function getService(tokenType: 'permanent' | 'temporary') {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ type RequestParams = Record<string, RequestValue>
|
||||||
|
|
||||||
type RequestOptions = Omit<RequestInit, 'body' | 'method'> & {
|
type RequestOptions = Omit<RequestInit, 'body' | 'method'> & {
|
||||||
body?: BodyInit | Record<string, unknown> | null
|
body?: BodyInit | Record<string, unknown> | null
|
||||||
tokenType?: 'permanent' | 'temporary'
|
tokenType?: 'none' | 'permanent' | 'temporary'
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiResponseLike = {
|
type ApiResponseLike = {
|
||||||
|
|
@ -168,6 +168,11 @@ function setCommonHeaders(headers: Headers, tokenType: RequestOptions['tokenType
|
||||||
headers.set('x-channel', toHeaderValue(sysInfo.channel))
|
headers.set('x-channel', toHeaderValue(sysInfo.channel))
|
||||||
headers.set('x-click-id', toHeaderValue(params.get('bd_vid') ?? sysInfo.bd_vid ?? ''))
|
headers.set('x-click-id', toHeaderValue(params.get('bd_vid') ?? sysInfo.bd_vid ?? ''))
|
||||||
headers.set('x-app-id', toHeaderValue(__APP_ID__))
|
headers.set('x-app-id', toHeaderValue(__APP_ID__))
|
||||||
|
if (tokenType === 'none') {
|
||||||
|
headers.delete('x-token')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const tokenStorageKey = tokenType === 'temporary' ? TEMP_TOKEN_STORAGE_KEY : TOKEN_STORAGE_KEY
|
const tokenStorageKey = tokenType === 'temporary' ? TEMP_TOKEN_STORAGE_KEY : TOKEN_STORAGE_KEY
|
||||||
const token = window.sessionStorage.getItem(tokenStorageKey)
|
const token = window.sessionStorage.getItem(tokenStorageKey)
|
||||||
if (token) {
|
if (token) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue