升级依赖版本并修复构建问题

This commit is contained in:
2025-11-20 12:10:16 +08:00
parent fa6a4e5121
commit c02ffc9983
26 changed files with 669 additions and 649 deletions

View File

@@ -1,70 +1,21 @@
'use client'
import {ChangePasswordDialog} from '@/components/composites/dialogs/change-password-dialog'
import {RealnameAuthDialog} from '@/components/composites/dialogs/realname-auth-dialog'
import {useState, useEffect} from 'react'
import {User} from '@/lib/models'
export function PasswordSetupWrapper({profile}: {profile: User}) {
const [showPasswordDialog, setShowPasswordDialog] = useState(false)
const [showRealnameDialog, setShowRealnameDialog] = useState(false)
useEffect(() => {
// 每次profile变化时都检查是否需要显示弹窗
if (!profile.has_password) {
setShowPasswordDialog(true)
}
else if (!profile.id_token) {
setShowRealnameDialog(true)
}
}, [profile.has_password, profile.id_token])
const handleDismiss = (type: 'password' | 'realname') => {
// 可选使用sessionStorage只在当前会话期间记住关闭状态
if (typeof window !== 'undefined') {
sessionStorage.setItem(`dismissed${type === 'password' ? 'PasswordSetup' : 'RealnameAuth'}`, 'true')
}
}
return (
<>
{showPasswordDialog && (
<ChangePasswordDialog
triggerClassName="hidden"
open={showPasswordDialog}
onOpenChange={(open) => {
setShowPasswordDialog(open)
if (!open) {
handleDismiss('password')
if (!profile.id_token) {
setShowRealnameDialog(true)
}
}
}}
onSuccess={() => {
setShowPasswordDialog(false)
if (!profile.id_token) {
setShowRealnameDialog(true)
}
}}
/>
)}
<RealnameAuthDialog
hasAuthenticated={!!profile.id_token}
triggerClassName="hidden"
defaultOpen={!profile.id_token}
/>
{showRealnameDialog && (
<RealnameAuthDialog
hasAuthenticated={!!profile.id_token}
triggerClassName="hidden"
open={showRealnameDialog}
onOpenChange={(open) => {
setShowRealnameDialog(open)
if (!open) {
handleDismiss('realname')
}
}}
onSuccess={() => {
setShowRealnameDialog(false)
}}
/>
)}
<ChangePasswordDialog
triggerClassName="hidden"
defaultOpen={profile.has_password}
/>
</>
)
}

View File

@@ -1,5 +1,5 @@
'use client'
import {useEffect, useState} from 'react'
import {useCallback, useEffect, useState} from 'react'
import {PageRecord} from '@/lib/api'
import {Bill} from '@/lib/models'
import {useStatus} from '@/lib/states'
@@ -38,7 +38,22 @@ export default function BillsPage(props: BillsPageProps) {
list: [],
})
const refresh = async (page: number, size: number) => {
const form = useForm<FilterSchema>({
resolver: zodResolver(filterSchema),
defaultValues: {
type: 'all',
trade_id: '',
create_after: undefined,
create_before: undefined,
},
})
const onSubmit = async (value: FilterSchema) => {
console.log(value)
await refresh(1, data.size)
}
const refresh = useCallback(async (page: number, size: number) => {
setStatus('load')
try {
const typeValue = form.getValues('type')
@@ -62,26 +77,11 @@ export default function BillsPage(props: BillsPageProps) {
catch (e) {
setStatus('fail')
}
}
}, [form, setStatus])
useEffect(() => {
refresh(1, 10).then()
}, [])
const form = useForm<FilterSchema>({
resolver: zodResolver(filterSchema),
defaultValues: {
type: 'all',
trade_id: '',
create_after: undefined,
create_before: undefined,
},
})
const onSubmit = async (value: FilterSchema) => {
console.log(value)
await refresh(1, data.size)
}
}, [refresh])
return (
<Page>

View File

@@ -4,7 +4,8 @@ import Navbar from './_client/navbar'
import Layout from './_client/layout'
import {getProfile} from '@/actions/auth'
import {redirect} from 'next/navigation'
import {PasswordSetupWrapper} from './_client/passwordSetupWrapper'
import {ChangePasswordDialog} from '@/components/composites/dialogs/change-password-dialog'
import {RealnameAuthDialog} from '@/components/composites/dialogs/realname-auth-dialog'
export type AdminLayoutProps = {
children: ReactNode
@@ -25,10 +26,15 @@ export default async function AdminLayout(props: AdminLayoutProps) {
content={(
<>
{props.children}
{/* 需要时显示密码设置和实名认证 */}
{(!profile?.has_password && !profile?.id_token) && (
<PasswordSetupWrapper profile={profile}/>
)}
<RealnameAuthDialog
hasAuthenticated={!!profile.id_token}
triggerClassName="hidden"
defaultOpen={!profile.id_token}
/>
<ChangePasswordDialog
triggerClassName="hidden"
defaultOpen={profile.has_password}
/>
</>
)}
/>

View File

@@ -2,15 +2,15 @@ import Purchase, {TabType} from '@/components/composites/purchase'
import Page from '@/components/page'
export type PurchasePageProps = {
searchParams?: {
searchParams?: Promise<{
type?: TabType
}
}>
}
export default async function PurchasePage(props: PurchasePageProps) {
return (
<Page className="flex-col">
<Purchase defaultType={props.searchParams?.type ?? 'short'}/>
<Purchase defaultTab={(await props.searchParams)?.type ?? 'short'}/>
</Page>
)
}

View File

@@ -0,0 +1,8 @@
export default function TestPage() {
return (
<div>
<h1>Test Page</h1>
<p>This is a test page.</p>
</div>
)
}