feat(avatar): optimize embedded H5 management flow

This commit is contained in:
stefanfeng
2026-08-27 09:28:05 +08:00
parent 6e3fe5a616
commit ef58c5f2d2
10 changed files with 307 additions and 63 deletions
+13 -4
View File
@@ -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()
}