28 lines
661 B
JavaScript
28 lines
661 B
JavaScript
/** 对齐 tyc-webview-v2 登录成功后的本地存储字段 */
|
|
export function saveAuthSession(payload) {
|
|
uni.setStorageSync('token', payload.accessToken)
|
|
uni.setStorageSync('refreshAfter', String(payload.refreshAfter))
|
|
uni.setStorageSync('accessExpire', String(payload.accessExpire))
|
|
}
|
|
|
|
export function hasToken() {
|
|
try {
|
|
const t = uni.getStorageSync('token')
|
|
return typeof t === 'string' && t.length > 0
|
|
}
|
|
catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
export function clearAuthSession() {
|
|
try {
|
|
uni.removeStorageSync('token')
|
|
uni.removeStorageSync('refreshAfter')
|
|
uni.removeStorageSync('accessExpire')
|
|
}
|
|
catch {
|
|
// ignore
|
|
}
|
|
}
|