升级依赖版本并修复构建问题
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -59,12 +59,12 @@ export default function DateRangePicker({
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (date: Date | undefined) => {
|
||||
return date && isValid(date) ? format(date, dateFormat) : ''
|
||||
}
|
||||
|
||||
// 格式化显示的日期范围
|
||||
const displayValue = React.useMemo(() => {
|
||||
const formatDate = (date: Date | undefined) => {
|
||||
return date && isValid(date) ? format(date, dateFormat) : ''
|
||||
}
|
||||
|
||||
if (!value?.from) return placeholder
|
||||
|
||||
if (!value.to) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use client'
|
||||
import {createContext, ReactNode, useContext, useEffect, useRef} from 'react'
|
||||
import {createContext, ReactNode, useContext, useEffect, useMemo, useRef, useState} from 'react'
|
||||
import {StoreApi} from 'zustand/vanilla'
|
||||
import {useStore} from 'zustand/react'
|
||||
import {createProfileStore, ProfileStore} from '@/lib/stores/profile'
|
||||
@@ -41,34 +41,22 @@ export type ProfileProviderProps = {
|
||||
}
|
||||
|
||||
export default function StoresProvider(props: ProfileProviderProps) {
|
||||
// 用户信息
|
||||
const profile = useRef<StoreApi<ProfileStore>>(null)
|
||||
if (!profile.current) {
|
||||
console.log('📦 create profile store')
|
||||
profile.current = createProfileStore()
|
||||
}
|
||||
const profileStore = useRef(useStore(profile.current))
|
||||
console.log('init stores')
|
||||
|
||||
const [profile] = useState(createProfileStore())
|
||||
const [layout] = useState(createLayoutStore())
|
||||
const [client] = useState(createClientStore())
|
||||
|
||||
const refreshProfile = useStore(profile, store => store.refreshProfile)
|
||||
useEffect(() => {
|
||||
profileStore.current.refreshProfile()
|
||||
}, [])
|
||||
|
||||
const layout = useRef<StoreApi<LayoutStore>>(null)
|
||||
if (!layout.current) {
|
||||
console.log('📦 create layout store')
|
||||
layout.current = createLayoutStore()
|
||||
}
|
||||
|
||||
const client = useRef<StoreApi<ClientStore>>(null)
|
||||
if (!client.current) {
|
||||
console.log('📦 create client store')
|
||||
client.current = createClientStore()
|
||||
}
|
||||
refreshProfile()
|
||||
}, [refreshProfile])
|
||||
|
||||
return (
|
||||
<StoreContext.Provider value={{
|
||||
profile: profile.current,
|
||||
layout: layout.current,
|
||||
client: client.current,
|
||||
profile,
|
||||
layout,
|
||||
client,
|
||||
}}>
|
||||
{props.children}
|
||||
</StoreContext.Provider>
|
||||
|
||||
@@ -173,7 +173,7 @@ function ChartTooltipContent({
|
||||
return (
|
||||
<div
|
||||
className={merge(
|
||||
'border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',
|
||||
'border-border/50 bg-background grid min-w-32 items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
@@ -202,14 +202,11 @@ function ChartTooltipContent({
|
||||
!hideIndicator && (
|
||||
<div
|
||||
className={merge(
|
||||
'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
|
||||
{
|
||||
'h-2.5 w-2.5': indicator === 'dot',
|
||||
'w-1': indicator === 'line',
|
||||
'w-0 border-[1.5px] border-dashed bg-transparent':
|
||||
indicator === 'dashed',
|
||||
'my-0.5': nestLabel && indicator === 'dashed',
|
||||
},
|
||||
'shrink-0 rounded-xs border-(--color-border) bg-(--color-bg)',
|
||||
indicator === 'dot' && 'h-2.5 w-2.5',
|
||||
indicator === 'line' && 'w-1',
|
||||
indicator === 'dashed' && 'w-0 border-[1.5px] border-dashed bg-transparent',
|
||||
indicator === 'dashed' && nestLabel && 'my-0.5',
|
||||
)}
|
||||
style={
|
||||
{
|
||||
@@ -290,7 +287,7 @@ function ChartLegendContent({
|
||||
<itemConfig.icon/>
|
||||
) : (
|
||||
<div
|
||||
className="h-2 w-2 shrink-0 rounded-[2px]"
|
||||
className="h-2 w-2 shrink-0 rounded-xs"
|
||||
style={{
|
||||
backgroundColor: item.color,
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user