|
|
|
@ -43,7 +43,7 @@ const NavBar: React.FC<NavBarProps> = ({ selected, menuData, onTabChange, onTabC
|
|
|
|
const key = selected.key;
|
|
|
|
const key = selected.key;
|
|
|
|
const title = selected.title;
|
|
|
|
const title = selected.title;
|
|
|
|
// 检查tab是否已存在
|
|
|
|
// 检查tab是否已存在
|
|
|
|
const existingTab = tabs.find(tab => tab.key === key && tab.title === title);
|
|
|
|
const existingTab = tabs.find(tab => tab.key === (key) && tab.title === title);
|
|
|
|
|
|
|
|
|
|
|
|
if (!existingTab) {
|
|
|
|
if (!existingTab) {
|
|
|
|
// 创建新tab
|
|
|
|
// 创建新tab
|
|
|
|
@ -85,10 +85,10 @@ const NavBar: React.FC<NavBarProps> = ({ selected, menuData, onTabChange, onTabC
|
|
|
|
const handleTabChange = (key: string) => {
|
|
|
|
const handleTabChange = (key: string) => {
|
|
|
|
setActiveTab(key);
|
|
|
|
setActiveTab(key);
|
|
|
|
// 查找对应的tab并通知父组件
|
|
|
|
// 查找对应的tab并通知父组件
|
|
|
|
const tab = tabs.find(t => t.key === key);
|
|
|
|
// const tab = tabs.find(t => t.key === key);
|
|
|
|
if (tab) {
|
|
|
|
// if (tab) {
|
|
|
|
onTabChange?.(tab.key);
|
|
|
|
// onTabChange?.(tab.key);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|