From 1744d6b5cd0e50a80908390bca9ad4f0deba150a Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 24 May 2023 19:35:17 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E7=A7=BB=E9=99=A4=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=9A=84=20tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/layout/util.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts index e149657a0..963115ee9 100644 --- a/app/src/layout/util.ts +++ b/app/src/layout/util.ts @@ -406,6 +406,29 @@ export const JSONToLayout = (app: App, isStart: boolean) => { app.plugins.forEach(item => { afterLoadPlugin(item); }); + // 移除没有插件的 tab + document.querySelectorAll('li[data-type="tab-header"]').forEach((item: HTMLElement) => { + const initData = item.getAttribute("data-initdata") + if (initData) { + const initDataObj = JSON.parse(initData); + if (initDataObj.instance === "Custom") { + let hasPlugin = false; + app.plugins.find(plugin => { + if (Object.keys(plugin.models).includes(initDataObj.customModelType)) { + hasPlugin = true + return true + } + }); + if (!hasPlugin) { + const tabId = item.getAttribute("data-id") + const tab = getInstanceById(tabId) as Tab + if (tab) { + tab.parent.removeTab(tabId, false, false, false); + } + } + } + } + }); const idZoomIn = getIdZoomInByPath(); if (idZoomIn.id) { openFileById({