feat(avatar): optimize embedded H5 management flow
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
type SmsLoginResult,
|
||||
type UserProfile
|
||||
} from '@/api'
|
||||
import { clearHuihuiEmbeddedMode, markHuihuiEmbeddedMode } from '@/utils/embed-mode'
|
||||
|
||||
const TOKEN_KEY = 'hh_app_token'
|
||||
const USER_KEY = 'hh_app_user'
|
||||
@@ -70,16 +71,23 @@ export const useUserStore = defineStore('smsuser', () => {
|
||||
|
||||
// 短信登录
|
||||
const login = async (phone: string, code: string) => {
|
||||
return acceptLogin(await loginBySms(phone, code))
|
||||
const result = await loginBySms(phone, code)
|
||||
clearHuihuiEmbeddedMode()
|
||||
return acceptLogin(result)
|
||||
}
|
||||
|
||||
// 账号密码登录
|
||||
const loginByPwd = async (account: string, password: string) => {
|
||||
return acceptLogin(await loginByPassword(account, password))
|
||||
const result = await loginByPassword(account, password)
|
||||
clearHuihuiEmbeddedMode()
|
||||
return acceptLogin(result)
|
||||
}
|
||||
|
||||
const loginByToken = async (huihuiToken: string) =>
|
||||
acceptLogin(await loginByHuihuiToken(huihuiToken))
|
||||
const loginByToken = async (huihuiToken: string) => {
|
||||
const result = await loginByHuihuiToken(huihuiToken)
|
||||
markHuihuiEmbeddedMode()
|
||||
return acceptLogin(result)
|
||||
}
|
||||
|
||||
// 退出
|
||||
const logout = async () => {
|
||||
@@ -88,6 +96,7 @@ export const useUserStore = defineStore('smsuser', () => {
|
||||
} catch {
|
||||
/* 忽略网络错误,本地清除即可 */
|
||||
}
|
||||
clearHuihuiEmbeddedMode()
|
||||
clearSession()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user