程序启动时打开的第一个tab改为不允许关闭

This commit is contained in:
Allen 2025-05-18 22:47:34 +08:00
parent dc6386f671
commit dcdacf0694

View File

@ -116,9 +116,10 @@ function renderMenu(menuList: MenuItem[]): void {
*
* @param tabGroup
* @param menuItem
* @param allowCloseTab
* @returns
*/
async function addTabAsync(tabGroup: TabGroup, menuItem: MenuItem): Promise<Tab | null> {
async function addTabAsync(tabGroup: TabGroup, menuItem: MenuItem, allowCloseTab: boolean = true): Promise<Tab | null> {
const url: string = menuItem.Url.startsWith("http") ? menuItem.Url : `http://${menuItem.Url}`;
const result: { ok: boolean; status: number; message?: string } = await window.electronAPI.checkUrlAvailable(url);
if (result.ok && result.status >= 200 && result.status < 400) {
@ -140,7 +141,7 @@ async function addTabAsync(tabGroup: TabGroup, menuItem: MenuItem): Promise<Tab
const tab: Tab = tabGroup.addTab({
active: true,
closable: true,
closable: allowCloseTab,
title: menuItem.ShowName,
src: url,
iconURL: menuItem.IconConfig._1x.Default,
@ -401,7 +402,7 @@ async function initialize(): Promise<void> {
// Create initial tab
const firstMenuItem: MenuItem = menuList[0];
await addTabAsync(tabGroup, firstMenuItem);
await addTabAsync(tabGroup, firstMenuItem, false);
// Bind help icon click event
const helpMenuItem: MenuItem = menuList[menuList.length - 2];