点击logo打开负一屏时,如果此前已有打开的标签页,则直接激活标签页(切换到所在标签页并显示),避免打开多个负一屏。

This commit is contained in:
Allen 2025-05-17 21:36:13 +08:00
parent 542a167066
commit 58d3ea3577

View File

@ -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);
}
});
}