diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts
index b10e116e4..902645479 100644
--- a/app/src/layout/dock/index.ts
+++ b/app/src/layout/dock/index.ts
@@ -609,25 +609,36 @@ export class Dock {
return max;
}
- public genButton(data: IDockTab[], index: number, append = false) {
+ public genButton(data: IDockTab[], index: number, tabIndex?: number) {
let html = "";
data.forEach(item => {
+ if (typeof tabIndex === "undefined" && !TYPES.includes(item.type)) {
+ return;
+ }
html += `
`;
this.data[item.type] = true;
});
if (index === 0) {
- if (append) {
- this.element.firstElementChild.lastElementChild.insertAdjacentHTML("beforebegin", html);
+ if (typeof tabIndex === "number") {
+ if (this.element.firstElementChild.children[tabIndex]) {
+ this.element.firstElementChild.children[tabIndex].insertAdjacentHTML("beforebegin", html);
+ } else {
+ this.element.firstElementChild.lastElementChild.insertAdjacentHTML("beforebegin", html);
+ }
} else {
this.element.firstElementChild.innerHTML = `${html}
`;
}
} else {
- if (append) {
- this.element.lastElementChild.insertAdjacentHTML("beforeend", html);
+ if (typeof tabIndex === "number") {
+ if (this.element.lastElementChild.children[tabIndex]) {
+ this.element.lastElementChild.children[tabIndex].insertAdjacentHTML("beforebegin", html);
+ } else {
+ this.element.lastElementChild.insertAdjacentHTML("beforeend", html);
+ }
} else {
this.element.lastElementChild.innerHTML = html;
}
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index d2388c3b7..1e6b23ea1 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -170,6 +170,9 @@ export class Plugin {
}) {
/// #if !MOBILE
const type2 = this.name + options.type;
+ if (typeof options.config.index === "undefined") {
+ options.config.index = 1000;
+ }
this.docks[type2] = {
config: options.config,
model: (arg: { tab: Tab }) => {
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 69e408c06..de7afc384 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -313,6 +313,7 @@ declare interface IPluginDockTab {
icon: string,
hotkey?: string,
title: string,
+ index?: number
}
declare interface IOpenFileOptions {