升级依赖版本并修复构建问题
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user