优化代码
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import config from '@/config/index.js'
|
||||
import tool from '@/utils/tool'
|
||||
|
||||
// 全局存储当前路由
|
||||
let currentRoute = ''
|
||||
@@ -17,7 +18,7 @@ export function setCurrentRoute(route) {
|
||||
*/
|
||||
export function isLogin() {
|
||||
try {
|
||||
const token = uni.getStorageSync('token')
|
||||
const token = tool.data.get('token')
|
||||
return !!token
|
||||
} catch (e) {
|
||||
console.error('检查登录状态失败:', e)
|
||||
@@ -134,8 +135,12 @@ export function checkLogin() {
|
||||
*/
|
||||
export function logout() {
|
||||
try {
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('userInfo')
|
||||
tool.data.remove('token')
|
||||
tool.data.remove('userInfo')
|
||||
tool.data.remove('familyInfo')
|
||||
tool.data.remove('familyId')
|
||||
tool.data.remove('isOwner')
|
||||
tool.data.remove('beforLoginUrl')
|
||||
|
||||
uni.showToast({
|
||||
title: '已退出登录',
|
||||
|
||||
Reference in New Issue
Block a user