开启 ppr 优化渲染性能
This commit is contained in:
48
src/components/free-trial.tsx
Normal file
48
src/components/free-trial.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
'use client'
|
||||
import {useProfileStore} from '@/components/stores/profile'
|
||||
import {useRouter} from 'next/navigation'
|
||||
import {Suspense, use} from 'react'
|
||||
|
||||
export default function FreeTrial(props: {
|
||||
className: string
|
||||
}) {
|
||||
return (
|
||||
<Suspense fallback={<Pending className={props.className}/>} >
|
||||
<Resolved className={props.className}/>
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
function Resolved(props: {
|
||||
className: string
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const profile = use(useProfileStore(store => store.profile))
|
||||
|
||||
return (
|
||||
<button
|
||||
className={props.className}
|
||||
onClick={async () => {
|
||||
router.push(profile ? '/admin/purchase' : '/product')
|
||||
}}
|
||||
>
|
||||
免费试用
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
function Pending(props: {
|
||||
className: string
|
||||
}) {
|
||||
const router = useRouter()
|
||||
return (
|
||||
<button
|
||||
className={props.className}
|
||||
onClick={async () => {
|
||||
router.push('/product')
|
||||
}}
|
||||
>
|
||||
免费试用
|
||||
</button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user