This commit is contained in:
yumoqing 2025-09-12 12:16:02 +08:00
parent a08aa83884
commit 440ad15e0c
2 changed files with 6 additions and 3 deletions

View File

@ -25,13 +25,13 @@ bricks.dom_on_off_observer=new MutationObserver((mutations)=>{
function handleRemoved(node) { function handleRemoved(node) {
if (node.nodeType !== 1) return; // 只处理元素节点 if (node.nodeType !== 1) return; // 只处理元素节点
if (node.bricks_widget) { if (node.bricks_widget) {
console.log('**** widget removed', node); console.log('**** widget removed', node.bricks_widget);
node.bricks_widget.dispatch('domoff'); node.bricks_widget.dispatch('domoff');
} }
// 遍历后代 // 遍历后代
for (let child of node.querySelectorAll('*')) { for (let child of node.querySelectorAll('*')) {
if (child.bricks_widget) { if (child.bricks_widget) {
console.log('**** widget removed (descendant)', child); console.log('**** widget removed (descendant)', child.bricks_widget);
child.bricks_widget.dispatch('domoff'); child.bricks_widget.dispatch('domoff');
} }
} }

View File

@ -18,10 +18,11 @@ bricks.Wterm = class extends bricks.JsWidget {
this.bind('domoff', this.destroy.bind(this)); this.bind('domoff', this.destroy.bind(this));
} }
destroy(){ destroy(){
console.debug('------domoff event, destory this widget');
this.unbind('element_resize', this.term_resize.bind(this)) this.unbind('element_resize', this.term_resize.bind(this))
this.heartbeat_task.cancel(); this.heartbeat_task.cancel();
this.heartbeat_task = null; this.heartbeat_task = null;
console.debug('------domoff event, destory this widget'); console.debug('---1--domoff event, destory this widget');
if (this.socket){ if (this.socket){
console.log('socket alive, destroy it'); console.log('socket alive, destroy it');
this.socket.send(JSON.stringify({ type: "close"})); this.socket.send(JSON.stringify({ type: "close"}));
@ -32,11 +33,13 @@ bricks.Wterm = class extends bricks.JsWidget {
this.socket.onclose = null; this.socket.onclose = null;
this.socket = null; this.socket = null;
} }
console.debug('---2--domoff event, destory this widget');
if (this.term){ if (this.term){
this.fitAddon.dispose(); this.fitAddon.dispose();
this.term.dispose(); this.term.dispose();
this.term = null; this.term = null;
} }
console.debug('---3--domoff event, destory this widget');
} }
charsize_sizing(){ charsize_sizing(){
var cs = bricks.app.charsize; var cs = bricks.app.charsize;