mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 19:06:51 +08:00
refact common layout (#490)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Fragment, useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useContext } from 'use-context-selector'
|
||||
import classNames from 'classnames'
|
||||
import Link from 'next/link'
|
||||
@@ -13,24 +14,33 @@ import WorkplaceSelector from './workplace-selector'
|
||||
import type { LangGeniusVersionResponse, UserProfileResponse } from '@/models/common'
|
||||
import I18n from '@/context/i18n'
|
||||
import Avatar from '@/app/components/base/avatar'
|
||||
import { logout } from '@/service/common'
|
||||
|
||||
type IAppSelectorProps = {
|
||||
userProfile: UserProfileResponse
|
||||
onLogout: () => void
|
||||
langeniusVersionInfo: LangGeniusVersionResponse
|
||||
}
|
||||
|
||||
export default function AppSelector({ userProfile, onLogout, langeniusVersionInfo }: IAppSelectorProps) {
|
||||
export default function AppSelector({ userProfile, langeniusVersionInfo }: IAppSelectorProps) {
|
||||
const itemClassName = `
|
||||
flex items-center w-full h-10 px-3 text-gray-700 text-[14px]
|
||||
rounded-lg font-normal hover:bg-gray-100 cursor-pointer
|
||||
`
|
||||
const router = useRouter()
|
||||
const [settingVisible, setSettingVisible] = useState(false)
|
||||
const [aboutVisible, setAboutVisible] = useState(false)
|
||||
|
||||
const { locale } = useContext(I18n)
|
||||
const { t } = useTranslation()
|
||||
|
||||
const handleLogout = async () => {
|
||||
await logout({
|
||||
url: '/logout',
|
||||
params: {},
|
||||
})
|
||||
router.push('/signin')
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="">
|
||||
<Menu as="div" className="relative inline-block text-left">
|
||||
@@ -107,7 +117,7 @@ export default function AppSelector({ userProfile, onLogout, langeniusVersionInf
|
||||
</Menu.Item>
|
||||
</div>
|
||||
<Menu.Item>
|
||||
<div className='p-1' onClick={() => onLogout()}>
|
||||
<div className='p-1' onClick={() => handleLogout()}>
|
||||
<div
|
||||
className='flex items-center justify-between h-12 px-3 rounded-lg cursor-pointer group hover:bg-gray-100'
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user