优化代码

This commit is contained in:
2026-01-19 13:21:38 +08:00
parent e3b7c63e5a
commit cc603cb158
5 changed files with 43 additions and 6 deletions

View File

@@ -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: '已退出登录',