fix(login): noMobile 响应缺 openId 时从本地缓存兜底,避免授权链路断开
This commit is contained in:
parent
96c2255c10
commit
34a3887b2d
|
|
@ -13,6 +13,8 @@ import {
|
|||
import { useToast } from '@/hooks/useToast'
|
||||
import { ROUTES } from '@/constants/routes'
|
||||
import { reLaunch } from '@/utils/navigation'
|
||||
import { storage } from '@/utils/storage'
|
||||
import { WX_OPENID_STORAGE_KEY } from '@/constants/auth'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
export default function Login() {
|
||||
|
|
@ -34,7 +36,10 @@ export default function Login() {
|
|||
const state = getLoginSubState(result)
|
||||
if (state !== 'complete') {
|
||||
console.log('[login-page] 注册未完成,推进到', state)
|
||||
if (result.openId) setOpenId(result.openId)
|
||||
// noMobile 响应可能不回传 openId(首次 needUserInfo 已缓存本地),从 storage 兜底
|
||||
const openIdNext = result.openId ?? storage.get<string>(WX_OPENID_STORAGE_KEY) ?? openId
|
||||
if (!openIdNext) throw new Error('响应缺少 openId,无法继续授权')
|
||||
setOpenId(openIdNext)
|
||||
setSubState(state)
|
||||
setLoading(false)
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue