From 30e430deb4d727aaae8e8c40fbc14df133e43939 Mon Sep 17 00:00:00 2001 From: wangyunfei <1224056307@qq.com> Date: Fri, 12 Sep 2025 19:30:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E4=BC=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatConversation/ChatConversation.js | 5 +- src/pages/topnavbar/TopNavBar copy.js | 524 ------------------ src/pages/topnavbar/TopNavBar.js | 5 +- 3 files changed, 5 insertions(+), 529 deletions(-) delete mode 100644 src/pages/topnavbar/TopNavBar copy.js diff --git a/src/pages/chatConversation/ChatConversation.js b/src/pages/chatConversation/ChatConversation.js index cf0da02..0703c63 100644 --- a/src/pages/chatConversation/ChatConversation.js +++ b/src/pages/chatConversation/ChatConversation.js @@ -354,8 +354,9 @@ function ChatConversation() { {/* 模型切换 */} - + {/* 上传文件 */} diff --git a/src/pages/topnavbar/TopNavBar copy.js b/src/pages/topnavbar/TopNavBar copy.js deleted file mode 100644 index 344213d..0000000 --- a/src/pages/topnavbar/TopNavBar copy.js +++ /dev/null @@ -1,524 +0,0 @@ -import React, { useState, useEffect ,useRef} from 'react' -import { history, Outlet, useModel, useDispatch, useLocation } from '@umijs/max' -import styles from './TopNavBar.less' -import { - Menu, Row, Col, - Avatar, Dropdown, Button, - Layout, theme, Divider, Tooltip, Popover -} from 'antd' -import { getPageQuery } from '@/utils/utils' -import Logo from '@/assets/logo.png' -import UserAvatar from '@/assets/boy.png' -import { - dataAnalysisStore, - conversationStore, - writingStore, - mobileStore, - assistantStore -} from '@/utils/pageConversationStore' -import { renderPageContent } from './form/RenderPageContentForm' -import { - SettingOutlined, - LogoutOutlined, - PlusOutlined, - MessageOutlined, - DeleteOutlined, - HistoryOutlined, - DownOutlined, - RobotOutlined, - BarChartOutlined, - CommentOutlined, - EditOutlined as WritingIcon, - MobileOutlined, - RightCircleOutlined, - LeftCircleOutlined, - AppstoreAddOutlined, - AppstoreOutlined, - - ApiOutlined, - DeploymentUnitOutlined, - BranchesOutlined, - DatabaseOutlined, - FileTextOutlined, -} from '@ant-design/icons'; - -const { Content, Sider } = Layout; - -function getItem(label, key, icon, children) { - return { - key, - icon, - children, - label, - }; -} - - -const menuItem = [ - { - label: 'AI助手', - key: 'aiqa', - icon: '🤖', - children: [ - { label: '智能对话', key: '/topnavbar00/aiqa/conversation', icon: }, - { label: '智能写作', key: '/topnavbar00/aiqa/writing', icon: }, - { label: '智能助理', key: '/topnavbar00/aiqa/assistant', icon: }, - { label: '数据分析', key: '/topnavbar00/aiqa/dataanalysis', icon: }, - { label: '问答移动端', key: '/topnavbar00/aiqa/mobile', icon: }, - ] - }, - { - label: '系统管理', - key: 'system', - icon: '⚙️', - children: [ - { label: '插件安装', key: '/topnavbar00/system/plugininstall', icon: }, - { label: '插件管理', key: '/topnavbar00/system/pluginmanage', icon: }, - { label: '助理配置', key: '/topnavbar00/system/assistantconfig', icon: }, - { label: '模型接入', key: '/topnavbar00/system/model', icon: }, - { label: '应用嵌入', key: '/topnavbar00/system/embed', icon: }, - { label: '工作流配置', key: '/topnavbar00/system/workflow', icon: }, - { label: '知识库管理', key: '/topnavbar00/system/knowledge', icon: }, - { label: '提示词模板管理', key: '/topnavbar00/system/prompts', icon: }, - ] - } -] - -const TopNavBar = (props) => { - const dispatch = useDispatch() - const { initialState: { menu }, setInitialState } = useModel('@@initialState') - - // 测试时候放开启用本地菜单 - window.dynamicRoute = menuItem - const dynamicRoute = window.dynamicRoute - const location = useLocation() - - const pathName = location.pathname - const [activeKey, setActiveKey] = useState(pathName ?? '/topnavbar00/aiqa/conversation') - - const [openKeys, setOpenKeys] = useState([]) - const firstLoadRef = useRef(true) - const [menuItems, setMenuItems] = useState([]) - - - const [expandedPage, setExpandedPage] = useState('conversation') - const conversationExpanded = expandedPage === 'conversation' - const writingExpanded = expandedPage === 'writing' - const dataAnalysisExpanded = expandedPage === 'dataanalysis' - const assistantExpanded = expandedPage === 'assistant' - const mobileExpanded = expandedPage === 'mobile' - - const toggleExpand = (page) => { - setExpandedPage(prev => prev === page ? null : page) - } - - // 每个页面的对话状态 - const [dataAnalysisConversations, setDataAnalysisConversations] = useState(dataAnalysisStore.getConversations()) - const [conversationConversations, setConversationConversations] = useState(conversationStore.getConversations()) - const [writingConversations, setWritingConversations] = useState(writingStore.getConversations()) - const [assistantConversations, setAssistantConversations] = useState(assistantStore.getConversations()) - const [mobileConversations, setMobileConversations] = useState(mobileStore.getConversations()) - - const [collapsed, setCollapsed] = useState(false); - const toggleCollapsed = () => setCollapsed(c => !c); - - useEffect(() => { - if (!dynamicRoute || dynamicRoute?.length === 0) return - let newList = [] - - if (dynamicRoute?.length) { - dynamicRoute?.map(item => { - newList.push({ - key: item?.key, - label: item?.label, - icon: item?.icon, - children: item?.children?.map(child => ({ - key: child?.key, - label: child?.label, - icon: child?.icon, - })) - }) - }) - - // 设置当前激活的菜单项 - const currentActiveKey = newList?.find(item => - item.children?.some(child => pathName.indexOf(child.key) !== -1) - )?.children?.find(child => pathName.indexOf(child.key) !== -1)?.key ?? '' - setActiveKey(currentActiveKey) - - // 设置默认展开的菜单 - const currentOpenKey = newList?.find(item => - item.children?.some(child => pathName.indexOf(child.key) !== -1) - )?.key ?? '' - - if (!firstLoadRef.current) { - if (currentOpenKey) { - setOpenKeys([currentOpenKey]) - } - - } else { - firstLoadRef.current = false - } - } - - setMenuItems(newList) - }, [dynamicRoute, pathName]) - - // 订阅每个页面的对话状态变化 - useEffect(() => { - const unsubscribeDataAnalysis = dataAnalysisStore.subscribe(({ conversations }) => { - setDataAnalysisConversations(conversations) - }) - - const unsubscribeConversation = conversationStore.subscribe(({ conversations }) => { - setConversationConversations(conversations) - }) - - const unsubscribeWriting = writingStore.subscribe(({ conversations }) => { - setWritingConversations(conversations) - }) - - const unsubscribeAssistant = assistantStore.subscribe(({ conversations }) => { - setAssistantConversations(conversations) - }) - - const unsubscribeMobile = mobileStore.subscribe(({ conversations }) => { - setMobileConversations(conversations) - }) - - return () => { - unsubscribeDataAnalysis() - unsubscribeConversation() - unsubscribeWriting() - unsubscribeAssistant() - unsubscribeMobile() - } - }, []) - - const setRouteActive = value => { - const curKey = value.key - setActiveKey(curKey) - history.replace(curKey) - } - - // 处理一级菜单展开/收缩 - const handleMenuGroupClick = (menuKey) => { - if (openKeys.includes(menuKey)) { - // 如果已展开,则收缩 - setOpenKeys(openKeys.filter(key => key !== menuKey)) - } else { - // 如果已收缩,则展开 - setOpenKeys([...openKeys, menuKey]) - } - } - - - - - const loginOut = async () => { - // await outLogin() - const { redirect } = getPageQuery() - if (window.location.pathname !== '/login/login' && !redirect) { - history.replace({ - pathname: '/login', - }) - - setInitialState({ currentUser: null, menu: null, menuMap: null }) - window.dynamicRoute = null - localStorage.clear() - } - } - - const handleMenuClick = (e) => { - switch (e.key) { - case 'logout': - loginOut() - break - default: - break - } - } - - const dropDownMenuItems = [ - { - label: <>退出登录, - key: 'logout' - } - ] - - const dropDownMenu = () => ( - - ) - - const { - token: { colorBgContainer, borderRadiusLG }, - } = theme.useToken(); - - const userNameContent = ( -
-
用户小智
- 帮助中心 -
- - 用户协议 - {/* {userInfo?.user_name_cn ? userInfo.user_name_cn : (userInfo?.user_name || '')} */} -
- ) - - return ( -
- {/* 头部功能 */} -
- - {/* 左侧logo */} - - logo - AI Q&A - {/* 折叠按钮 */} - - {collapsed ? : } - - - - {/* - - 你好,欢迎使用 AI 助手 - - */} - {/* 右侧退出 */} - - - - - {/* 用户名 */} - {/* {userInfo?.user_name_cn ? userInfo.user_name_cn : (userInfo?.user_name || '')} */} - - - - - -
- - {/* 内容 */} -
- - -
- {menuItems.map(item => ( -
-
handleMenuGroupClick(item.key)} - > - {/* 一级菜单 */} - {item.icon}{item.label} - {/* 一级菜单的下拉按钮 */} - {!collapsed && ( - - )} -
- {item.children && openKeys.includes(item.key) && ( -
- {item.children.map(child => { - // 智能对话页面 - if (child.key === '/topnavbar00/aiqa/conversation') { - return ( -
-
{ - toggleExpand('conversation') - setRouteActive(child) - - }} - > - - - {child.icon}{child.label} - {/* */} -
- {conversationExpanded && - renderPageContent('conversation', - conversationConversations, conversationExpanded, - )} -
- ) - } - // 智能写作页面 - if (child.key === '/topnavbar00/aiqa/writing') { - return ( -
-
{ - toggleExpand('writing') - setRouteActive(child) - }} - > - - - {child.icon}{child.label} - {/* */} -
- {writingExpanded && renderPageContent('writing', - writingConversations, writingExpanded,)} -
- ) - } - // 智能助理页面 - if (child.key === '/topnavbar00/aiqa/assistant') { - return ( -
-
{ - toggleExpand('assistant') - setRouteActive(child) - }} - > - - - {child.icon}{child.label} - {/* */} -
- {assistantExpanded && renderPageContent('assistant', - assistantConversations, assistantExpanded,)} -
- ) - } - // 数据分析页面 - if (child.key === '/topnavbar00/aiqa/dataanalysis') { - return ( -
-
{ - toggleExpand('dataanalysis') - setRouteActive(child) - }} - > - - - {child.icon}{child.label} - {/* */} -
- {dataAnalysisExpanded && renderPageContent('dataanalysis', dataAnalysisConversations, - dataAnalysisExpanded,)} -
- ) - } - // 问答移动端页面 - if (child.key === '/topnavbar00/aiqa/mobile') { - return ( -
-
{ - toggleExpand('mobile') - setRouteActive(child) - setCollapsed(true) // 直接收起 - }} - > - - - {child.icon}{child.label} - {/* */} -
- {mobileExpanded && renderPageContent('mobile', mobileConversations, - mobileExpanded,)} -
- ) - } - // 系统管理内部页面 - return ( -
setRouteActive(child)} - > - {child.icon}{child.label} -
- ) - })} -
- )} -
- ))} -
-
- - - - {/* 主题内容区域 */} - - - -
-
-
- ) -} - -export default TopNavBar diff --git a/src/pages/topnavbar/TopNavBar.js b/src/pages/topnavbar/TopNavBar.js index bdfbf1e..83d202a 100644 --- a/src/pages/topnavbar/TopNavBar.js +++ b/src/pages/topnavbar/TopNavBar.js @@ -228,9 +228,8 @@ const TopNavBar = (props) => { {/* 修改:当路由为智能对话页时,渲染历史会话组件(renderPageContent),其它路由不变 */}
- {/* {renderPageContent('conversation', conversationConversations, conversationExpanded)} */} - -
+ {renderPageContent('conversation', conversationConversations, conversationExpanded)} + {/* 底部版权信息 */}