重构认证逻辑,优化登录和用户信息获取流程,新增全局缓存支持
This commit is contained in:
@@ -13,7 +13,7 @@ import {Identify} from '@/actions/auth/identify'
|
||||
import {toast} from 'sonner'
|
||||
import {useContext, useEffect, useRef, useState} from 'react'
|
||||
import * as qrcode from 'qrcode'
|
||||
import {AuthContext} from '@/components/providers/AuthProvider'
|
||||
import {StoreContext, useProfileStore} from '@/components/providers/StoreProvider'
|
||||
|
||||
export type IdentifyPageProps = {}
|
||||
|
||||
@@ -90,8 +90,8 @@ export default function IdentifyPage(props: IdentifyPageProps) {
|
||||
// 用户数据
|
||||
// ======================
|
||||
|
||||
const ctx = useContext(AuthContext)
|
||||
console.log('render identify page')
|
||||
const profile = useProfileStore(store => store.profile)
|
||||
const refreshProfile = useProfileStore(store => store.refreshProfile)
|
||||
|
||||
// ======================
|
||||
// render
|
||||
@@ -116,7 +116,7 @@ export default function IdentifyPage(props: IdentifyPageProps) {
|
||||
<h3 className={`text-center text-lg font-bold`}>个人认证</h3>
|
||||
<p className={`text-sm text-gray-600`}>平台授权支付宝安全认证,不会泄露您的认证信息</p>
|
||||
</div>
|
||||
{ctx.profile?.id_token ? (
|
||||
{profile?.id_token ? (
|
||||
<div className={`flex flex-col gap-4`}>
|
||||
<p className={`text-sm text-gray-600`}>已完成实名认证</p>
|
||||
</div>
|
||||
@@ -162,7 +162,7 @@ export default function IdentifyPage(props: IdentifyPageProps) {
|
||||
<canvas ref={canvas} width={256} height={256}/>
|
||||
<p className={`text-sm text-gray-600`}>请扫码完成认证</p>
|
||||
<Button onClick={async () => {
|
||||
await ctx.refreshProfile()
|
||||
await refreshProfile()
|
||||
setOpenDialog(false)
|
||||
}}>
|
||||
已完成认证
|
||||
|
||||
Reference in New Issue
Block a user