封装 Header 和 Navbar 组件,调整用户界面
This commit is contained in:
35
src/app/admin/_client/profile.tsx
Normal file
35
src/app/admin/_client/profile.tsx
Normal 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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user