#鸿蒙通关秘籍#如果我想要删除一个模块,DevEco Studio会帮我处理相关的依赖关系吗?

HarmonyOS
2024-11-27 13:50:16
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
系统小天才

是的,如果你想要删除一个模块,DevEco Studio会提示你处理相关的依赖关系,避免错误。

// 删除 EntryAbility.ets 会抛出 EntryAbility.ets存在个无法安全删除的用途.
import { AbilityConstant, UIAbility,Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window} from '@kit.ArkUI';
import { BusinessError} from '@kit.BasicServicesKit';

export default class EntryAbility extends UIAbility{
    onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
        hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
    }

    onDestroy(): void {
        hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
    }

    onWindowStageCreate(windowStage: window.WindowStage): void {
        // Main window is created, set main page for this ability
        hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');

        windowStage.loadContent('pages/Index', (err) => {
            if (err.code) {
                hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
                return;
            }
            hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
        });
        let windowClass: window.Window | undefined = undefined;
        windowStage.getMainWindow((err: BusinessError, data) => {
            windowClass = data;
            const errCode`: number = err.code;
            if (errCode) {
                console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
                return;
            }
            windowClass = data;
            try {
                let promise = windowClass.setSpecificSystemBarEnabled('navigationIndicator', false);
                promise.then(() => {
                    console.info('Succeeded in setting the system bar to be invisible.');
                }).catch((err: BusinessError) => {
                    console.error(`Failed to set the system bar to be invisible. Cause code: ${err.code}, message: ${err.message}`);
                });
            } catch (exception) {
                console.error(`Failed to set the system bar to be invisible. Cause code: ${exception.code}, message: ${exception.message}`);
            }
        });
    }

    onWindowStageDestroy(): void {
        // Main window is destroyed, release UI related resources
        hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
    }

    onForeground(): void {
        // Ability has brought to foreground
        hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
    }

    onBackground(): void {
        // Ability has back to background
        hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
    }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
已于2024-11-27 15:45:00修改
分享
微博
QQ
微信
回复
2024-11-27 15:05:28
相关问题