实现个人中心下拉菜单;更新部分 eslint 规则
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
'use client'
|
||||
import {PanelLeftCloseIcon, PanelLeftOpenIcon} from 'lucide-react'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import Profile from './profile'
|
||||
import {useLayoutStore} from '@/components/providers/StoreProvider'
|
||||
import {merge} from '@/lib/utils'
|
||||
import UserCenter from '@/components/composites/user-center'
|
||||
|
||||
export type HeaderProps = {}
|
||||
|
||||
export default function Header(props: HeaderProps) {
|
||||
|
||||
const navbar = useLayoutStore(store => store.navbar)
|
||||
const toggleNavbar = useLayoutStore(store => store.toggleNavbar)
|
||||
|
||||
@@ -18,7 +17,7 @@ export default function Header(props: HeaderProps) {
|
||||
`flex items-stretch`,
|
||||
)}>
|
||||
{/* left */}
|
||||
<div className={`flex-auto flex items-center gap-2`}>
|
||||
<div className="flex-auto flex items-center gap-2">
|
||||
<Button
|
||||
theme="ghost"
|
||||
className="w-9 h-9"
|
||||
@@ -34,8 +33,8 @@ export default function Header(props: HeaderProps) {
|
||||
</div>
|
||||
|
||||
{/* right */}
|
||||
<div className={`flex-none flex items-center justify-end pr-4`}>
|
||||
<Profile/>
|
||||
<div className="flex-none flex items-center justify-end pr-4">
|
||||
<UserCenter/>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
'use client'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {logout} from '@/actions/auth'
|
||||
import {useProfileStore} from '@/components/providers/StoreProvider'
|
||||
import {useRouter} from 'next/navigation'
|
||||
|
||||
export type ProfileProps = {}
|
||||
|
||||
export default function Profile(props: ProfileProps) {
|
||||
const router = useRouter()
|
||||
const refreshProfile = useProfileStore(store => store.refreshProfile)
|
||||
const doLogout = async () => {
|
||||
const resp = await logout()
|
||||
if (resp.success) {
|
||||
refreshProfile().then()
|
||||
router.replace('/')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex gap-2 items-center">
|
||||
<Button theme={`fail`} onClick={doLogout}>
|
||||
退出登录
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user