开启 ppr 优化渲染性能
This commit is contained in:
@@ -9,9 +9,9 @@ import zod from 'zod'
|
||||
import {zodResolver} from '@hookform/resolvers/zod'
|
||||
import {Identify} from '@/actions/user'
|
||||
import {toast} from 'sonner'
|
||||
import {useEffect, useRef, useState} from 'react'
|
||||
import {ReactNode, Suspense, use, useEffect, useRef, useState} from 'react'
|
||||
import * as qrcode from 'qrcode'
|
||||
import {useProfileStore} from '@/components/stores-provider'
|
||||
import {useProfileStore} from '@/components/stores/profile'
|
||||
import {merge} from '@/lib/utils'
|
||||
import banner from './_assets/banner.webp'
|
||||
import personal from './_assets/personal.webp'
|
||||
@@ -123,63 +123,60 @@ export default function IdentifyPage(props: IdentifyPageProps) {
|
||||
平台不会收集您的个人信息,您的信息仅用于账户安全认证
|
||||
</p>
|
||||
</div>
|
||||
{profile?.id_token ? (
|
||||
<p className="flex gap-2 items-center">
|
||||
<CheckCircleIcon className="text-done"/>
|
||||
<span>已完成实名认证</span>
|
||||
</p>
|
||||
) : (
|
||||
<Dialog open={openDialog} onOpenChange={setOpenDialog}>
|
||||
<DialogTrigger asChild>
|
||||
<Button className="w-full">去认证</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogTitle>
|
||||
{step === 'form' ? `实名认证` : `扫码完成认证`}
|
||||
</DialogTitle>
|
||||
{step === 'form' && (
|
||||
<Form form={form} handler={handler} className="flex flex-col gap-4">
|
||||
<FormField<Schema> name="name" label="姓名">
|
||||
{({id, field}) => (
|
||||
<input
|
||||
{...field}
|
||||
id={id}
|
||||
placeholder="请输入姓名"
|
||||
className="border rounded p-2 w-full"
|
||||
autoComplete="name"
|
||||
/>
|
||||
)}
|
||||
</FormField>
|
||||
<FormField<Schema> name="iden_no" label="身份证号">
|
||||
{({id, field}) => (
|
||||
<input
|
||||
{...field}
|
||||
id={id}
|
||||
placeholder="请输入身份证号"
|
||||
className="border rounded p-2 w-full"
|
||||
/>
|
||||
)}
|
||||
</FormField>
|
||||
<DialogFooter>
|
||||
<Button type="submit" className="w-full mt-4">提交</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
)}
|
||||
{step === 'scan' && (
|
||||
<div className="flex flex-col gap-4 items-center">
|
||||
<canvas ref={canvas} width={256} height={256}/>
|
||||
<p className="text-sm text-gray-600">请扫码完成认证</p>
|
||||
<Button onClick={async () => {
|
||||
await refreshProfile()
|
||||
setOpenDialog(false)
|
||||
}}>
|
||||
已完成认证
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)}
|
||||
<Suspense>
|
||||
<IfNotIdentofy>
|
||||
<Dialog open={openDialog} onOpenChange={setOpenDialog}>
|
||||
<DialogTrigger asChild>
|
||||
<Button className="w-full">去认证</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogTitle>
|
||||
{step === 'form' ? `实名认证` : `扫码完成认证`}
|
||||
</DialogTitle>
|
||||
{step === 'form' && (
|
||||
<Form form={form} handler={handler} className="flex flex-col gap-4">
|
||||
<FormField<Schema> name="name" label="姓名">
|
||||
{({id, field}) => (
|
||||
<input
|
||||
{...field}
|
||||
id={id}
|
||||
placeholder="请输入姓名"
|
||||
className="border rounded p-2 w-full"
|
||||
autoComplete="name"
|
||||
/>
|
||||
)}
|
||||
</FormField>
|
||||
<FormField<Schema> name="iden_no" label="身份证号">
|
||||
{({id, field}) => (
|
||||
<input
|
||||
{...field}
|
||||
id={id}
|
||||
placeholder="请输入身份证号"
|
||||
className="border rounded p-2 w-full"
|
||||
/>
|
||||
)}
|
||||
</FormField>
|
||||
<DialogFooter>
|
||||
<Button type="submit" className="w-full mt-4">提交</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
)}
|
||||
{step === 'scan' && (
|
||||
<div className="flex flex-col gap-4 items-center">
|
||||
<canvas ref={canvas} width={256} height={256}/>
|
||||
<p className="text-sm text-gray-600">请扫码完成认证</p>
|
||||
<Button onClick={async () => {
|
||||
await refreshProfile()
|
||||
setOpenDialog(false)
|
||||
}}>
|
||||
已完成认证
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</IfNotIdentofy>
|
||||
</Suspense>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@@ -235,3 +232,15 @@ export default function IdentifyPage(props: IdentifyPageProps) {
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
function IfNotIdentofy(props: {children: ReactNode}) {
|
||||
const profile = use(useProfileStore(store => store.profile))
|
||||
return !profile?.id_token
|
||||
? props.children
|
||||
: (
|
||||
<p className="flex gap-2 items-center">
|
||||
<CheckCircleIcon className="text-done"/>
|
||||
<span>已完成实名认证</span>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user