This commit is contained in:
zhangjianjun 2026-07-20 15:14:47 +08:00
parent e2ef445462
commit c516067710
2 changed files with 7 additions and 2 deletions

View File

@ -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') {

View File

@ -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) {