|
|
|
@ -1,8 +1,7 @@ |
|
|
|
|
import { ChatContext } from '@/app/chat-context'; |
|
|
|
|
import UserBar from '@/new-components/layout/UserBar'; |
|
|
|
|
import { DarkSvg, SunnySvg } from '@/components/icons'; |
|
|
|
|
import { STORAGE_LANG_KEY, STORAGE_THEME_KEY, STORAGE_USERINFO_KEY } from '@/utils/constants/index'; |
|
|
|
|
import Icon, { GlobalOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'; |
|
|
|
|
import { STORAGE_LANG_KEY, STORAGE_THEME_KEY, STORAGE_USERINFO_KEY, USER_MENU } from '@/utils/constants/index'; |
|
|
|
|
import { GlobalOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'; |
|
|
|
|
import { Popover, Tooltip } from 'antd'; |
|
|
|
|
import { ItemType } from 'antd/es/menu/hooks/useItems'; |
|
|
|
|
import cls from 'classnames'; |
|
|
|
@ -13,7 +12,6 @@ import Link from 'next/link'; |
|
|
|
|
import { useRouter } from 'next/router'; |
|
|
|
|
import { ReactNode, useCallback, useContext, useEffect, useMemo, useState } from 'react'; |
|
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
|
import { USER_MENU } from '@/utils/constants/index'; |
|
|
|
|
|
|
|
|
|
type SettingItem = { |
|
|
|
|
key: string; |
|
|
|
@ -43,8 +41,9 @@ type RouteItem = { |
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
function smallMenuItemStyle(active?: boolean) { |
|
|
|
|
return `flex items-center justify-center mx-auto rounded w-14 h-14 text-xl hover:bg-[#F1F5F9] dark:hover:bg-theme-dark transition-colors cursor-pointer ${active ? 'bg-[#F1F5F9] dark:bg-theme-dark' : '' |
|
|
|
|
}`;
|
|
|
|
|
return `flex items-center justify-center mx-auto rounded w-14 h-14 text-xl hover:bg-[#F1F5F9] dark:hover:bg-theme-dark transition-colors cursor-pointer ${ |
|
|
|
|
active ? 'bg-[#F1F5F9] dark:bg-theme-dark' : '' |
|
|
|
|
}`;
|
|
|
|
|
} |
|
|
|
|
function SideBar() { |
|
|
|
|
// const { chatId, scene, isMenuExpand, refreshDialogList, setIsMenuExpand, setAgent, mode, setMode, adminList } =
|
|
|
|
@ -258,34 +257,35 @@ function SideBar() { |
|
|
|
|
|
|
|
|
|
const functions = useMemo(() => { |
|
|
|
|
const items: RouteItem[] = (userMenus || []) |
|
|
|
|
.filter((menu) => menu.visible === 1) // 过滤可见项
|
|
|
|
|
.map((menu) => { |
|
|
|
|
const isActive = pathname === menu.path || (menu.path !== '/' && pathname.startsWith(`/${menu.component_name}`)); |
|
|
|
|
let iconSrc = '/menus/default.svg'; // 默认图标
|
|
|
|
|
if (isActive) { |
|
|
|
|
iconSrc = `/menus/${menu.component_name}_active.svg`; // 动态 active 状态图标
|
|
|
|
|
} else { |
|
|
|
|
iconSrc = `/menus/${menu.component_name}.svg`; |
|
|
|
|
} |
|
|
|
|
.filter(menu => menu.visible === 1) // 过滤可见项
|
|
|
|
|
.map(menu => { |
|
|
|
|
const isActive = |
|
|
|
|
pathname === menu.path || (menu.path !== '/' && pathname.startsWith(`/${menu.component_name}`)); |
|
|
|
|
let iconSrc = '/menus/default.svg'; // 默认图标
|
|
|
|
|
if (isActive) { |
|
|
|
|
iconSrc = `/menus/${menu.component_name}_active.svg`; // 动态 active 状态图标
|
|
|
|
|
} else { |
|
|
|
|
iconSrc = `/menus/${menu.component_name}.svg`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
key: menu.component_name, |
|
|
|
|
name: t(menu.component_name), |
|
|
|
|
path: menu.path, |
|
|
|
|
isActive, |
|
|
|
|
icon: ( |
|
|
|
|
<Image |
|
|
|
|
key={`image_${menu.component_name}`} |
|
|
|
|
src={iconSrc} |
|
|
|
|
alt={`${menu.name}_image`} |
|
|
|
|
width={20} |
|
|
|
|
height={20} |
|
|
|
|
/> |
|
|
|
|
), |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
return { |
|
|
|
|
key: menu.component_name, |
|
|
|
|
name: t(menu.component_name), |
|
|
|
|
path: menu.path, |
|
|
|
|
isActive, |
|
|
|
|
icon: ( |
|
|
|
|
<Image |
|
|
|
|
key={`image_${menu.component_name}`} |
|
|
|
|
src={iconSrc} |
|
|
|
|
alt={`${menu.name}_image`} |
|
|
|
|
width={20} |
|
|
|
|
height={20} |
|
|
|
|
/> |
|
|
|
|
), |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return items; |
|
|
|
|
return items; |
|
|
|
|
// const items: RouteItem[] = [
|
|
|
|
|
// {
|
|
|
|
|
// key: 'chat',
|
|
|
|
@ -348,9 +348,9 @@ function SideBar() { |
|
|
|
|
// path: '/system/organization',
|
|
|
|
|
// },
|
|
|
|
|
// ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return items;
|
|
|
|
|
}, [t, pathname, hasAdmin,userMenus]); |
|
|
|
|
}, [t, pathname, hasAdmin, userMenus]); |
|
|
|
|
|
|
|
|
|
// TODO: unused function
|
|
|
|
|
// const dropDownRoutes: ItemType[] = useMemo(() => {
|
|
|
|
@ -454,9 +454,9 @@ function SideBar() { |
|
|
|
|
return ( |
|
|
|
|
<div |
|
|
|
|
className='flex flex-col justify-between pt-4 h-screen bg-bar dark:bg-[#232734] animate-fade animate-duration-300' |
|
|
|
|
// onMouseEnter={() => {
|
|
|
|
|
// setIsMenuExpand(true);
|
|
|
|
|
// }}
|
|
|
|
|
// onMouseEnter={() => {
|
|
|
|
|
// setIsMenuExpand(true);
|
|
|
|
|
// }}
|
|
|
|
|
> |
|
|
|
|
<div> |
|
|
|
|
<Link href='/' className='flex justify-center items-center pb-4'> |
|
|
|
@ -489,9 +489,9 @@ function SideBar() { |
|
|
|
|
return ( |
|
|
|
|
<div |
|
|
|
|
className='flex flex-col justify-between h-screen px-4 pt-4 bg-bar bg-[#F9FBFF] dark:bg-[#232734] animate-fade animate-duration-300' |
|
|
|
|
// onMouseLeave={() => {
|
|
|
|
|
// setIsMenuExpand(false);
|
|
|
|
|
// }}
|
|
|
|
|
// onMouseLeave={() => {
|
|
|
|
|
// setIsMenuExpand(false);
|
|
|
|
|
// }}
|
|
|
|
|
> |
|
|
|
|
<div> |
|
|
|
|
{/* LOGO */} |
|
|
|
|