From d71944c876a1091b23247418ae05c9c3bb9685c1 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 12 Sep 2025 10:48:11 +0800 Subject: [PATCH] bugfix --- bricks/wterm.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/bricks/wterm.js b/bricks/wterm.js index 51fc34a..8c1a9ed 100644 --- a/bricks/wterm.js +++ b/bricks/wterm.js @@ -14,6 +14,23 @@ bricks.Wterm = class extends bricks.JsWidget { this.socket = null; this.ping_timeout = opts.ping_timeout || 19; schedule_once(this.open.bind(this), 1); + this.bind('domon', this.send_term_size.bind(this)); + this.bind('domoff', this.destroy.bind(this)); + } + destroy(){ + if (this.socket){ + this.socket.close(); + this.socket.onopen = null; + this.socket.onmessage = null; + this.socket.onerror = null; + this.socket.onclose = null; + this.socket = null; + } + if (this.term){ + this.fitAddon.dispose(); + this.term.dispose(); + this.term = null; + } } charsize_sizing(){ var cs = bricks.app.charsize; @@ -44,10 +61,6 @@ bricks.Wterm = class extends bricks.JsWidget { this.heartbeat_task = schedule_once(this.heartbeat.bind(this), this.ping_timeout); } - async close(){ - this.term.close(); - this.socket.close(); - } async open(){ var term_options = bricks.extend({width: "100%", height: "100%"}, this.term_options); var term = new Terminal(term_options);