ソースを参照

:art: https://github.com/siyuan-note/siyuan/issues/11974

Vanessa 10 ヶ月 前
コミット
9c0af1a252
2 ファイル変更11 行追加2 行削除
  1. 9 1
      app/src/layout/dock/Files.ts
  2. 2 1
      app/src/types/index.d.ts

+ 9 - 1
app/src/layout/dock/Files.ts

@@ -45,6 +45,9 @@ export class Files extends Model {
                             break;
                         case "mount":
                             this.onMount(data);
+                            options.app.plugins.forEach((item) => {
+                                item.eventBus.emit("opened-notebook", data);
+                            });
                             break;
                         case "createnotebook":
                             setNoteBook((notebooks) => {
@@ -65,6 +68,11 @@ export class Files extends Model {
                             });
                             break;
                         case "unmount":
+                            this.onRemove(data);
+                            options.app.plugins.forEach((item) => {
+                                item.eventBus.emit("closed-notebook", data);
+                            });
+                            break;
                         case "removeDoc":
                             this.onRemove(data);
                             break;
@@ -763,7 +771,7 @@ export class Files extends Model {
                     removeElement.remove();
                     const counterElement = this.closeElement.querySelector(".counter");
                     counterElement.textContent = (parseInt(counterElement.textContent) - 1).toString();
-                    if (counterElement.textContent === "0")  {
+                    if (counterElement.textContent === "0") {
                         counterElement.classList.add("fn__none");
                     }
                 }

+ 2 - 1
app/src/types/index.d.ts

@@ -60,7 +60,8 @@ type TEventBus = "ws-main" | "sync-start" | "sync-end" | "sync-fail" |
     "open-noneditableblock" |
     "open-menu-blockref" | "open-menu-fileannotationref" | "open-menu-tag" | "open-menu-link" | "open-menu-image" |
     "open-menu-av" | "open-menu-content" | "open-menu-breadcrumbmore" | "open-menu-doctree" | "open-menu-inbox" |
-    "open-siyuan-url-plugin" | "open-siyuan-url-block" |
+    "open-siyuan-url-plugin" | "open-siyuan-url-block" | "opened-notebook" |
+    "closed-notebook" |
     "paste" |
     "input-search" |
     "loaded-protyle" | "loaded-protyle-dynamic" | "loaded-protyle-static" |