/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import worker, { MessageEvents } from '@ohos.worker'; import zlib from '@ohos.zlib'; import request from '@ohos.request'; import type common from '@ohos.app.ability.common'; import ConvertXML from '@ohos.convertxml'; import xml from '@ohos.xml'; import hilog from '@ohos.hilog'; import { getDoubleCeneterTable, getSingleCenterTable } from '../common/service/indexService'; import { initTableParam } from '../pages/interfaces'; let workerPort = worker.workerPort; workerPort.onmessage = (e: MessageEvents): void => { let param:initTableParam = e.data; console.log('baoyihu,onmessage',JSON.stringify(param)) if(param.mode=='1'){ //单中心 getSingleCenterTable(param).then((ret) => { console.log('teststetfinsh1') if (ret) { workerPort.postMessage({ isComplete: true }); }else{ workerPort.postMessage({ isComplete: false }); } }) }else if(param.mode=='3'){ //双中心 getDoubleCeneterTable(param).then((ret)=>{ if (ret) { workerPort.postMessage({ isComplete: true }); }else{ workerPort.postMessage({ isComplete: false }); } }) } // worker线程向主线程发送信息 //let context: common.UIAbilityContext = e.data.context; // workerPort.postMessage({ isComplete: true, jsonStr: result }); };