fix(ampy): 添加 dispose 方法 null 检查防止重复调用报错
This commit is contained in:
@@ -1,24 +1,24 @@
|
|||||||
goog.loadJs('web', () => {
|
goog.loadJs('web', () => {
|
||||||
|
|
||||||
goog.require('path');
|
goog.require('path');
|
||||||
goog.require('Mustache');
|
goog.require('Mustache');
|
||||||
goog.require('Mixly.Env');
|
goog.require('Mixly.Env');
|
||||||
goog.require('Mixly.Events');
|
goog.require('Mixly.Events');
|
||||||
goog.require('Mixly.Msg');
|
goog.require('Mixly.Msg');
|
||||||
goog.require('Mixly.Ampy');
|
goog.require('Mixly.Ampy');
|
||||||
goog.require('Mixly.Web');
|
goog.require('Mixly.Web');
|
||||||
goog.provide('Mixly.Web.Ampy');
|
goog.provide('Mixly.Web.Ampy');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Env,
|
Env,
|
||||||
Events,
|
Events,
|
||||||
Msg,
|
Msg,
|
||||||
Ampy,
|
Ampy,
|
||||||
Web
|
Web
|
||||||
} = Mixly;
|
} = Mixly;
|
||||||
|
|
||||||
|
|
||||||
class AmpyExt extends Ampy {
|
class AmpyExt extends Ampy {
|
||||||
static {
|
static {
|
||||||
this.LS = goog.readFileSync(path.join(Env.templatePath, 'python/ls.py'));
|
this.LS = goog.readFileSync(path.join(Env.templatePath, 'python/ls.py'));
|
||||||
this.LS_RECURSIVE = goog.readFileSync(path.join(Env.templatePath, 'python/ls-recursive.py'));
|
this.LS_RECURSIVE = goog.readFileSync(path.join(Env.templatePath, 'python/ls-recursive.py'));
|
||||||
@@ -417,13 +417,17 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async dispose() {
|
async dispose() {
|
||||||
this.#active_ = false;
|
this.#active_ = false;
|
||||||
|
if (this.#device_) {
|
||||||
await this.#device_.dispose();
|
await this.#device_.dispose();
|
||||||
this.#device_ = null;
|
this.#device_ = null;
|
||||||
|
}
|
||||||
|
if (this.#events_) {
|
||||||
this.#events_.reset();
|
this.#events_.reset();
|
||||||
this.#events_ = null;
|
this.#events_ = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Web.Ampy = AmpyExt;
|
Web.Ampy = AmpyExt;
|
||||||
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user