点击logo打开负一屏时,如果此前已有打开的标签页,则直接激活标签页(切换到所在标签页并显示),避免打开多个负一屏。
This commit is contained in:
parent
542a167066
commit
58d3ea3577
10
src/index.ts
10
src/index.ts
@ -213,8 +213,14 @@ function bindLogoClickEvent(tabGroup: TabGroup, menuItem: MenuItem): void {
|
|||||||
logo.addEventListener('click', async () => {
|
logo.addEventListener('click', async () => {
|
||||||
console.log('logo clicked');
|
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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user