20 lines
426 B
TypeScript
20 lines
426 B
TypeScript
// utils/auth.ts
|
|
import { useUserStore } from '@/stores/user'
|
|
|
|
export function getAuthToken(): string {
|
|
try {
|
|
const store = useUserStore()
|
|
return store?.token || uni.getStorageSync('token') || ''
|
|
} catch {
|
|
return uni.getStorageSync('token') || ''
|
|
}
|
|
}
|
|
|
|
export function setAuthToken(token: string) {
|
|
uni.setStorageSync('token', token)
|
|
}
|
|
|
|
export function clearAuthToken() {
|
|
uni.removeStorageSync('token')
|
|
}
|