程序启动时打开的第一个tab改为不允许关闭
This commit is contained in:
parent
dc6386f671
commit
dcdacf0694
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user