fix:客服上传图片及接受问题修复
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const TOKEN_KEY = 'token'
|
||||
const CS_TOKEN_KEY = 'cs_token'
|
||||
|
||||
/** 从登录响应中提取 access_token(兼容 RuoYi-Vue-Plus) */
|
||||
export function extractAuthToken(payload: unknown): string {
|
||||
@@ -30,6 +31,13 @@ export function getStoredToken(): string {
|
||||
return raw.replace(/^Bearer\s+/i, '').trim()
|
||||
}
|
||||
|
||||
/** 生成 Authorization 请求头值:Bearer <token> */
|
||||
export function formatBearerAuthorization(token: string): string {
|
||||
const normalized = token.replace(/^Bearer\s+/i, '').trim()
|
||||
if (!normalized) return ''
|
||||
return `Bearer ${normalized}`
|
||||
}
|
||||
|
||||
export function saveStoredToken(token: string): string {
|
||||
const normalized = token.replace(/^Bearer\s+/i, '').trim()
|
||||
if (!normalized) {
|
||||
@@ -41,4 +49,21 @@ export function saveStoredToken(token: string): string {
|
||||
|
||||
export function clearStoredToken(): void {
|
||||
uni.removeStorageSync(TOKEN_KEY)
|
||||
clearStoredCsToken()
|
||||
}
|
||||
|
||||
export function getStoredCsToken(): string {
|
||||
const raw = (uni.getStorageSync(CS_TOKEN_KEY) as string) || ''
|
||||
return raw.replace(/^Bearer\s+/i, '').trim()
|
||||
}
|
||||
|
||||
export function saveStoredCsToken(token: string): string {
|
||||
const normalized = token.replace(/^Bearer\s+/i, '').trim()
|
||||
if (!normalized) throw new Error('empty cs token')
|
||||
uni.setStorageSync(CS_TOKEN_KEY, normalized)
|
||||
return normalized
|
||||
}
|
||||
|
||||
export function clearStoredCsToken(): void {
|
||||
uni.removeStorageSync(CS_TOKEN_KEY)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user