fix error

Signed-off-by: liwuli <liwuli@huawei.com>
This commit is contained in:
liwuli
2023-03-28 10:48:30 +08:00
parent 5af166cbb2
commit 1635d0a249
6 changed files with 112 additions and 109 deletions
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@@ -13,13 +13,13 @@
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
import logger from '../common/logger'
import AbilityStage from '@ohos.app.ability.AbilityStage';
import logger from '../common/logger';
const TAG = 'MyAbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
logger.info(TAG, 'onCreate is called')
}
onCreate(): void {
logger.info(TAG, 'onCreate is called');
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@@ -13,40 +13,43 @@
* limitations under the License.
*/
import UIAbility from '@ohos.app.ability.UIAbility'
import logger from '../common/logger'
import UIAbility from '@ohos.app.ability.UIAbility';
import logger from '../common/logger';
import type Want from '@ohos.app.ability.Want';
import type AbilityConstant from '@ohos.app.ability.AbilityConstant';
import type window from '@ohos.window';
const TAG = 'AutoManagerAbility';
export default class AutoManagerAbility extends UIAbility {
onCreate(want, launchParam) {
logger.info(TAG, 'onCreate')
globalThis.autoManagerAbilityWant = want;
globalThis.autoManagerAbilityContext = this.context;
}
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
logger.info(TAG, 'onCreate');
globalThis.autoManagerAbilityWant = want;
globalThis.autoManagerAbilityContext = this.context;
}
onDestroy() {
logger.info(TAG, 'onDestroy')
}
onDestroy(): void {
logger.info(TAG, 'onDestroy');
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
logger.info(TAG, 'onWindowStageCreate')
windowStage.setUIContent(this.context, "pages/autoManager/managerStart", null)
}
onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
logger.info(TAG, 'onWindowStageCreate');
windowStage.loadContent('pages/autoManager/managerStart', null);
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
logger.info(TAG, 'onWindowStageDestroy')
}
onWindowStageDestroy(): void {
// Main window is destroyed, release UI related resources
logger.info(TAG, 'onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
logger.info(TAG, 'onForeground')
}
onForeground(): void {
// Ability has brought to foreground
logger.info(TAG, 'onForeground');
}
onBackground() {
// Ability has back to background
logger.info(TAG, 'onBackground')
}
onBackground(): void {
// Ability has back to background
logger.info(TAG, 'onBackground');
}
};
+28 -28
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@@ -13,40 +13,40 @@
* limitations under the License.
*/
import UIAbility from '@ohos.app.ability.UIAbility'
import logger from '../common/logger'
import UIAbility from '@ohos.app.ability.UIAbility';
import Logger from '../common/logger';
const TAG = 'MainAbility';
export default class MainAbility extends UIAbility {
onCreate(want, launchParam) {
logger.info(TAG, 'onCreate')
globalThis.adminProvisioningWant = want;
globalThis.adminProvisioningContext = this.context;
}
onCreate(want, launchParam): void {
Logger.info(TAG, 'onCreate');
globalThis.adminProvisioningWant = want;
globalThis.adminProvisioningContext = this.context;
}
onDestroy() {
logger.info(TAG, 'onDestroy')
}
onDestroy(): void {
Logger.info(TAG, 'onDestroy');
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
logger.info(TAG, 'onWindowStageCreate')
windowStage.setUIContent(this.context, "pages/applicationInfo", null)
}
onWindowStageCreate(windowStage): void {
// Main window is created, set main page for this ability
Logger.info(TAG, 'onWindowStageCreate');
windowStage.setUIContent(this.context, 'pages/applicationInfo', null);
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
logger.info(TAG, 'onWindowStageDestroy')
}
onWindowStageDestroy(): void {
// Main window is destroyed, release UI related resources
Logger.info(TAG, 'onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
logger.info(TAG, 'onForeground')
}
onForeground(): void {
// Ability has brought to foreground
Logger.info(TAG, 'onForeground');
}
onBackground() {
// Ability has back to background
logger.info(TAG, 'onBackground')
}
onBackground(): void {
// Ability has back to background
Logger.info(TAG, 'onBackground');
}
};
+21 -22
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@@ -16,31 +16,30 @@
import hilog from '@ohos.hilog';
class Logger {
private domain: number
private prefix: string
private format: string = '%{public}s, %{public}s'
private domain: number;
private prefix: string;
private format: string = '%{public}s, %{public}s';
constructor(prefix: string) {
this.prefix = prefix
// "EM" ascii
this.domain = 0x6977
}
constructor(prefix: string) {
this.prefix = prefix;
this.domain = 0x6977;
}
debug(...args: any[]) {
hilog.debug(this.domain, this.prefix, this.format, args)
}
debug(...args: unknown[]):void {
hilog.debug(this.domain, this.prefix, this.format, args);
}
info(...args: any[]) {
hilog.info(this.domain, this.prefix, this.format, args)
}
info(...args: unknown[]):void {
hilog.info(this.domain, this.prefix, this.format, args);
}
warn(...args: any[]) {
hilog.warn(this.domain, this.prefix, this.format, args)
}
warn(...args: unknown[]):void {
hilog.warn(this.domain, this.prefix, this.format, args);
}
error(...args: any[]) {
hilog.error(this.domain, this.prefix, this.format, args)
}
error(...args: unknown[]):void {
hilog.error(this.domain, this.prefix, this.format, args);
}
}
export default new Logger('[adminprovisioning]')
export default new Logger('[adminprovisioning]');
+25 -24
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@@ -13,34 +13,35 @@
* limitations under the License.
*/
const LARGE_SCREEN_GRID_SUM: number = 12;
const SMALL_SCREEN_GRID_SUM: number = 8;
const VP2PX_SUM_IN_LARGE_SCREEN: number = 2;
class Utils {
isValid(item: any): boolean {
if (item === null || item === undefined) {
return false;
}
return true;
isValid(item: unknown): boolean {
return item !== null && item !== undefined;
}
checkObjPropertyValid(obj: unknown, tree: string): boolean {
if (!this.isValid(obj) || !this.isValid(tree)) {
return false;
}
checkObjPropertyValid(obj: any, tree: string) {
if (!this.isValid(obj) || !this.isValid(tree)) {
return false;
}
let arr = tree.split('.');
let tempObj = obj;
for (let i = 0; i < arr.length; i++) {
if(!this.isValid(tempObj[arr[i]])) {
return false;
} else {
tempObj = tempObj[arr[i]];
}
}
return true;
let arr = tree.split('.');
let tempObj = obj;
for (let i = 0; i < arr.length; i++) {
if (!this.isValid(tempObj[arr[i]])) {
return false;
} else {
tempObj = tempObj[arr[i]];
}
}
return true;
}
isLargeDevice(): number {
return vp2px(1) === 2 ? 12 : 8;
}
isLargeDevice(): number {
return vp2px(1) === VP2PX_SUM_IN_LARGE_SCREEN ? LARGE_SCREEN_GRID_SUM : SMALL_SCREEN_GRID_SUM;
}
}
export default new Utils();
+1 -1
View File
@@ -22,4 +22,4 @@
# For customization when using a Version Control System, please read the header note.
sdk.dir=XXX
nodejs.dir=XXX
npm.dir=XXX
npm.dir=XXX