diff --git a/src/index.ts b/src/index.ts index 30b1b77..f8d3ac5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -213,8 +213,14 @@ function bindLogoClickEvent(tabGroup: TabGroup, menuItem: MenuItem): void { logo.addEventListener('click', async () => { console.log('logo clicked'); - const tab: Tab = await addTabAsync(tabGroup, menuItem); - tab.setPosition(0); + // 先检查是否已经打开过该标签页,如果打开过,则直接激活该标签页,否则打开新标签页 + const tab: Tab | null = tabGroup.tabs.find(tab => (tab.webview as Electron.WebviewTag).getURL() === menuItem.Url); + if (tab) { + tab.activate(); + } else { + const newTab: Tab = await addTabAsync(tabGroup, menuItem); + newTab.setPosition(0); + } }); }