更新:登录功能
This commit is contained in:
19
utils/auth.ts
Normal file
19
utils/auth.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// 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')
|
||||
}
|
||||
Reference in New Issue
Block a user