初始化窗口按需加载

Signed-off-by: 钱玉英 <qianyuying@huawei.com>
This commit is contained in:
钱玉英 2024-06-05 17:30:17 +08:00
parent 4c38ab9cf8
commit f961846cd5
2 changed files with 7 additions and 3 deletions

View File

@ -15,7 +15,7 @@
import { secToTime } from '../common/utils/TimeUtils';
import { TaskStatus } from '../common/profiler/base/ProfilerConstant';
import { ProfilerTask } from '../common/profiler/ProfilerTask';
import { initFloatWindow, destoryAllFloatWindow } from '../common/ui/floatwindow/utils/FloatWindowUtils';
import { destoryAllFloatWindow } from '../common/ui/floatwindow/utils/FloatWindowUtils';
import WorkerHandler from '../common/profiler/WorkerHandler';
import worker from '@ohos.worker';
let mainWorker = globalThis.MainWorker
@ -47,7 +47,6 @@ struct FloatBall {
globalThis.CreateTitleWindow()
console.log('cm-floatBall-CreateTitleWindow2')
globalThis.task_status = TaskStatus.task_init
initFloatWindow()
console.log('cm-floatBall-CreateTitleWindow3')
}

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { TIndexInfo } from '../common/entity/DatabaseEntity';
import { showFloatWindow, hideFloatWindow } from '../common/ui/floatwindow/utils/FloatWindowUtils';
import { initFloatWindow, showFloatWindow, hideFloatWindow } from '../common/ui/floatwindow/utils/FloatWindowUtils';
import { getCpuCoreInfo} from '../common/utils/SystemUtils';
import FloatWindowConstant from '../common/ui/floatwindow/FloatWindowConstant';
import CommonEvent from '@ohos.commonEvent';
@ -50,6 +50,7 @@ struct TitleWindowPage {
offsetX: number = -1
offsetY: number = -1
cpuCoreArr: Array<Number>
@State isInitFloatWindow: boolean = false
aboutToAppear() {
this.cpuCoreArr = getCpuCoreInfo().map(Number).sort()
@ -107,6 +108,10 @@ struct TitleWindowPage {
}
floatWindowEvent(floatName: string, flag: number) {
if (!this.isInitFloatWindow) {
initFloatWindow()
this.isInitFloatWindow = true
}
if (this.data[flag]) {
hideFloatWindow(floatName)
this.data[flag] = false