This commit is contained in:
parent
e99c6a1600
commit
841f21e8f3
3 changed files with 23 additions and 4 deletions
|
@ -416,6 +416,7 @@ export class Wnd {
|
|||
|
||||
public switchTab(target: HTMLElement, pushBack = false, update = true, resize = true, isSaveLayout = true) {
|
||||
let currentTab: Tab;
|
||||
let isInitActive = false
|
||||
this.children.forEach((item) => {
|
||||
if (target === item.headElement) {
|
||||
if (item.headElement && item.headElement.classList.contains("fn__none")) {
|
||||
|
@ -423,7 +424,12 @@ export class Wnd {
|
|||
} else {
|
||||
if (item.headElement) {
|
||||
item.headElement.classList.add("item--focus");
|
||||
item.headElement.setAttribute("data-activetime", (new Date()).getTime().toString());
|
||||
if (item.headElement.getAttribute("data-init-active") === "true") {
|
||||
item.headElement.removeAttribute("data-init-active");
|
||||
isInitActive = true;
|
||||
} else {
|
||||
item.headElement.setAttribute("data-activetime", (new Date()).getTime().toString());
|
||||
}
|
||||
}
|
||||
item.panelElement.classList.remove("fn__none");
|
||||
}
|
||||
|
@ -436,7 +442,10 @@ export class Wnd {
|
|||
}
|
||||
}
|
||||
});
|
||||
setPanelFocus(this.headersElement.parentElement.parentElement);
|
||||
// 在 JSONToLayout 中进行 focus
|
||||
if (!isInitActive) {
|
||||
setPanelFocus(this.headersElement.parentElement.parentElement);
|
||||
}
|
||||
if (currentTab && currentTab.headElement) {
|
||||
const initData = currentTab.headElement.getAttribute("data-initdata");
|
||||
if (initData) {
|
||||
|
|
|
@ -54,6 +54,7 @@ export const setPanelFocus = (element: Element) => {
|
|||
if (element.getAttribute("data-type") === "wnd") {
|
||||
element.classList.add("layout__wnd--active");
|
||||
element.querySelector(".layout-tab-bar .item--focus")?.setAttribute("data-activetime", (new Date()).getTime().toString());
|
||||
saveLayout();
|
||||
} else {
|
||||
element.classList.add("layout__tab--active");
|
||||
Array.from(element.classList).find(item => {
|
||||
|
@ -492,11 +493,21 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
|
|||
zoomIn: idZoomIn.isZoomIn
|
||||
});
|
||||
} else {
|
||||
let latestTabHeaderElement:HTMLElement
|
||||
document.querySelectorAll('li[data-type="tab-header"][data-init-active="true"]').forEach((item: HTMLElement) => {
|
||||
item.removeAttribute("data-init-active");
|
||||
if (!latestTabHeaderElement) {
|
||||
latestTabHeaderElement = item
|
||||
} else {
|
||||
if (item.dataset.activetime > latestTabHeaderElement.dataset.activetime) {
|
||||
latestTabHeaderElement = item
|
||||
}
|
||||
}
|
||||
const tab = getInstanceById(item.getAttribute("data-id")) as Tab;
|
||||
tab.parent.switchTab(item, false, false, true, false);
|
||||
});
|
||||
if (latestTabHeaderElement) {
|
||||
setPanelFocus(latestTabHeaderElement.parentElement.parentElement.parentElement);
|
||||
}
|
||||
}
|
||||
// 需放在 tab.parent.switchTab 后,否则当前 tab 永远为最后一个
|
||||
app.plugins.forEach(item => {
|
||||
|
|
|
@ -65,7 +65,6 @@ const afterLayout = (app: App) => {
|
|||
afterLoadPlugin(item);
|
||||
});
|
||||
document.querySelectorAll('li[data-type="tab-header"][data-init-active="true"]').forEach((item: HTMLElement) => {
|
||||
item.removeAttribute("data-init-active");
|
||||
const tab = getInstanceById(item.getAttribute("data-id")) as Tab;
|
||||
tab.parent.switchTab(item, false, false);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue