feat: app功能基本实现

This commit is contained in:
gin
2026-05-26 11:54:24 +08:00
parent 2757a4fb49
commit 2a702fa6a9
218 changed files with 6766 additions and 5961 deletions
+37
View File
@@ -0,0 +1,37 @@
import Taro from '@tarojs/taro'
import type { TokenDTO, UserInfoDTO } from '@/api/types'
const tokenKey = 'simple-todo-app-token'
const userKey = 'simple-todo-app-user'
export function getToken() {
return Taro.getStorageSync<string>(tokenKey) || ''
}
export function getCurrentUser() {
return Taro.getStorageSync<UserInfoDTO>(userKey) || {}
}
export function isLoggedIn() {
return Boolean(getToken())
}
export function setLoginSession(data: TokenDTO) {
Taro.setStorageSync(tokenKey, data.token)
Taro.setStorageSync(userKey, data.currentUser.userInfo)
}
export function setCurrentUser(user: UserInfoDTO) {
Taro.setStorageSync(userKey, user)
}
export function clearLoginSession() {
Taro.removeStorageSync(tokenKey)
Taro.removeStorageSync(userKey)
}
export function redirectToLogin() {
clearLoginSession()
Taro.reLaunch({ url: '/pages/login/index' })
}