Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Vanessaf3a1ce12f855
diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts
index cc004ff062..4e2254f551 100644
--- a/app/src/layout/Wnd.ts
+++ b/app/src/layout/Wnd.ts
@@ -692,6 +692,11 @@ export class Wnd {
clearCounter();
this.children.find((item, index) => {
if (item.id === id) {
+ if (item.model instanceof Custom) {
+ if (item.model.beforeDestroy) {
+ item.model.beforeDestroy();
+ }
+ }
if (item.model instanceof Editor && hasSaveScroll) {
saveScroll(item.model.editor.protyle);
}
diff --git a/app/src/layout/dock/Custom.ts b/app/src/layout/dock/Custom.ts
index 34a7e056a1..f2e89feab7 100644
--- a/app/src/layout/dock/Custom.ts
+++ b/app/src/layout/dock/Custom.ts
@@ -9,6 +9,7 @@ export class Custom extends Model {
public type: string;
public init: () => void;
public destroy: () => void;
+ public beforeDestroy: () => void;
public resize: () => void;
public update: () => void;
@@ -18,6 +19,7 @@ export class Custom extends Model {
tab: Tab,
data: any,
destroy?: () => void,
+ beforeDestroy?: () => void,
resize?: () => void,
update?: () => void,
init: () => void
@@ -33,6 +35,7 @@ export class Custom extends Model {
this.type = options.type;
this.init = options.init;
this.destroy = options.destroy;
+ this.beforeDestroy = options.beforeDestroy;
this.resize = options.resize;
this.update = options.update;
this.init();
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index cbf2fe2f09..dad5a52b15 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -174,6 +174,7 @@ export class Plugin {
public addTab(options: {
type: string,
destroy?: () => void,
+ beforeDestroy?: () => void,
resize?: () => void,
update?: () => void,
init: () => void
@@ -187,6 +188,7 @@ export class Plugin {
type: type2,
data: arg.data,
init: options.init,
+ beforeDestroy: options.beforeDestroy,
destroy: options.destroy,
resize: options.resize,
update: options.update,