From 2a2ee844c6e11adf08120b6bab5b025b87f83178 Mon Sep 17 00:00:00 2001 From: zhouyuejun <505127606@qq.com> Date: Thu, 10 Jan 2019 12:53:16 +0800 Subject: [PATCH] =?UTF-8?q?worker=E5=85=B1=E7=94=A8=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=96=B9=E5=BC=8F=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/main/main.component.ts | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/app/pages/main/main.component.ts b/src/app/pages/main/main.component.ts index 84e8df2..e6d39af 100644 --- a/src/app/pages/main/main.component.ts +++ b/src/app/pages/main/main.component.ts @@ -470,6 +470,7 @@ export class MainComponent implements OnInit { /** * 创建线程并执行 */ + public promise:Worker = new Worker('/adminweb/assets/web-worker-handle.js'); creatWorkers() { let dynamicData = { raw_data: this.raw_data, @@ -480,20 +481,19 @@ export class MainComponent implements OnInit { flightStatus: this.flightStatus, flightTypes: this.flightTypes } - // const promise = new Worker('/assets/web-worker-handle.js'); - // promise.postMessage(dynamicData); - // promise.onmessage = function (e) { - // console.log('====='); - // this.combined_data = e.data; - // this.selectChange('dynamic'); - // // promise.terminate(); - // }.bind(this); - const promise = this.webWorkerService.run(webWorkerHandle, dynamicData); - promise.then(function (response) { - this.combined_data = response; + this.promise.postMessage(dynamicData); + this.promise.onmessage = function (e) { + console.log('====='); + this.combined_data = e.data; this.selectChange('dynamic'); - this.webWorkerService.terminate(promise); - }.bind(this)); + // this.promise.terminate(); + }.bind(this); + // const promise = this.webWorkerService.run(webWorkerHandle, dynamicData); + // promise.then(function (response) { + // this.combined_data = response; + // this.selectChange('dynamic'); + // this.webWorkerService.terminate(promise); + // }.bind(this)); } /** @@ -646,7 +646,7 @@ export class MainComponent implements OnInit { continue; } } else { - if (item['preFlight'][key] === filterItems[key]) { + if (item['preFlight'][key] == filterItems[key]) { is_satis = true; continue; } else { @@ -690,7 +690,7 @@ export class MainComponent implements OnInit { continue; } } else { - if (item['reaFlight'][key] === filterItems[key]) { + if (item['reaFlight'][key] == filterItems[key]) { is_satis = true; continue; } else { @@ -735,7 +735,7 @@ export class MainComponent implements OnInit { continue; } } else { - if (item['preFlight'][key] === filterItems[key]) { + if (item['preFlight'][key] == filterItems[key]) { pre_satis = true; continue; } else { @@ -776,7 +776,7 @@ export class MainComponent implements OnInit { continue; } } else { - if (item['reaFlight'][key] === filterItems[key]) { + if (item['reaFlight'][key] == filterItems[key]) { rea_satis = true; continue; } else {