封装 Header 和 Navbar 组件,调整用户界面

This commit is contained in:
2025-04-25 16:24:04 +08:00
parent 8b742bdc34
commit 5c88cd7f32
14 changed files with 244 additions and 94 deletions

View File

@@ -0,0 +1,35 @@
'use client'
import {Button} from '@/components/ui/button'
import {logout} from '@/actions/auth/auth'
import {useProfileStore} from '@/components/providers/StoreProvider'
import {useRouter} from 'next/navigation'
import {toast} from 'sonner'
export type ProfileProps = {}
export default function Profile(props: ProfileProps) {
const refreshProfile = useProfileStore(store => store.refreshProfile)
const router = useRouter()
const doLogout = async () => {
try {
const resp = await logout()
if (resp.success) {
await refreshProfile()
router.push('/')
}
}
catch (e) {
toast.error('退出登录失败', {
description: (e as Error).message,
})
}
}
return (
<div className="flex gap-2 items-center">
<Button theme={`error`} onClick={doLogout}>
退
</Button>
</div>
)
}