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

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

@@ -15,6 +15,7 @@ import {updatePassword} from '@/actions/user'
interface ChangePasswordDialogProps {
triggerClassName?: string
open?: boolean
defaultOpen?: boolean
onOpenChange?: (open: boolean) => void
onSuccess?: () => void
}
@@ -22,10 +23,11 @@ interface ChangePasswordDialogProps {
export function ChangePasswordDialog({
triggerClassName,
open,
defaultOpen,
onOpenChange,
onSuccess,
}: ChangePasswordDialogProps) {
const [internalOpen, setInternalOpen] = useState(false)
const [internalOpen, setInternalOpen] = useState(defaultOpen || false)
const router = useRouter()
const actualOpen = open !== undefined ? open : internalOpen

View File

@@ -8,6 +8,7 @@ interface RealnameAuthDialogProps {
hasAuthenticated: boolean
triggerClassName?: string
open?: boolean
defaultOpen?: boolean
onOpenChange?: (open: boolean) => void
onSuccess?: () => void
}
@@ -16,10 +17,11 @@ export function RealnameAuthDialog({
hasAuthenticated,
triggerClassName,
open,
defaultOpen,
onOpenChange,
onSuccess,
}: RealnameAuthDialogProps) {
const [internalOpen, setInternalOpen] = useState(false)
const [internalOpen, setInternalOpen] = useState(defaultOpen || false)
const router = useRouter()
const actualOpen = open !== undefined ? open : internalOpen

View File

@@ -22,6 +22,7 @@ import ExtractDocs from '@/components/docs/extract.mdx'
import Markdown from '@/components/markdown'
import Link from 'next/link'
import {useProfileStore} from '@/components/stores-provider'
const schema = z.object({
resource: z.number({required_error: '请选择套餐'}),
prov: z.string().optional(),
@@ -517,8 +518,10 @@ function ApplyLink() {
const form = useFormContext<Schema>()
const values = form.watch()
const type = useRef<'copy' | 'open'>('open')
// let type: 'open' | 'copy' = 'open'
const type = useRef<'open' | 'copy'>('open')
const handler = form.handleSubmit(
// eslint-disable-next-line react-hooks/refs
async (values: z.infer<typeof schema>) => {
const params = link(values)
@@ -572,6 +575,11 @@ function ApplyLink() {
},
)
const submit = (t: 'open' | 'copy') => {
type.current = t
handler()
}
return (
<div className={merge(
`flex flex-col gap-4`,
@@ -586,23 +594,11 @@ function ApplyLink() {
{/* 操作 */}
<div className="flex gap-4">
<Button
type="button"
onClick={async () => {
type.current = 'copy'
await handler()
}}
>
<Button type="button" onClick={() => submit('copy')}>
<CopyIcon/>
<span></span>
</Button>
<Button
type="button"
onClick={async () => {
type.current = 'open'
await handler()
}}
>
<Button type="button" onClick={() => submit('open')}>
<ExternalLinkIcon/>
<span></span>
</Button>

View File

@@ -1,31 +1,30 @@
'use client'
import {ReactNode, useEffect, useState} from 'react'
import {ReactNode, useState} from 'react'
import {merge} from '@/lib/utils'
import {Tabs, TabsContent, TabsList, TabsTrigger} from '@/components/ui/tabs'
import LongForm from '@/components/composites/purchase/long/form'
import ShortForm from '@/components/composites/purchase/short/form'
import {useProfileStore} from '@/components/stores-provider'
import {useRouter} from 'next/navigation'
import {useSearchParams} from 'next/navigation'
export type TabType = 'short' | 'long' | 'fixed' | 'custom'
type PurchaseProps = {
defaultType: TabType
defaultTab: TabType
}
export default function Purchase(props: PurchaseProps) {
const [currentTab, setCurrentTab] = useState<string>(props.defaultType)
const profile = useProfileStore(store => store.profile)
const router = useRouter()
useEffect(() => {
setCurrentTab(props.defaultType)
// if (!profile) {
// router.push('/login?redirect=/admin/purchase') // 未登录用户重定向到登录页
// }
}, [props.defaultType, profile, router])
const [tab, setTab] = useState(props.defaultTab)
const params = useSearchParams()
const updateTab = async (tab: string) => {
setTab(tab as TabType)
const newParams = new URLSearchParams(params)
newParams.set('type', tab)
window.history.pushState({}, '', `?${newParams.toString()}`)
}
return (
<div className="flex flex-col gap-4">
<Tabs value={currentTab} onValueChange={setCurrentTab} className="gap-4">
<Tabs value={tab} onValueChange={updateTab} className="gap-4">
<TabsList className="w-full p-2 bg-white rounded-lg justify-start md:justify-center overflow-auto">
<Tab value="short"></Tab>
<Tab value="long"></Tab>