fix:客服上传图片及接受问题修复

This commit is contained in:
李伊帆
2026-10-20 14:35:39 +08:00
parent 4b93b50e50
commit 83a1e961ea
24 changed files with 937 additions and 652 deletions

View File

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