|
@@ -16,6 +16,29 @@ export default class EntryAbility extends UIAbility {
|
|
|
onWindowStageCreate(windowStage: window.WindowStage): void {
|
|
|
// Main window is created, set main page for this ability
|
|
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
|
|
+ // 1.获取应用主窗口。
|
|
|
+ let windowClass: window.Window
|
|
|
+ windowStage.getMainWindow((err, data) => {
|
|
|
+
|
|
|
+ if (err.code) {
|
|
|
+ console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ windowClass = data;
|
|
|
+ console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
|
|
|
+ // 2.实现沉浸式效果:设置导航栏、状态栏不显示。
|
|
|
+ let names: [] = [];
|
|
|
+ windowClass.setWindowSystemBarEnable(names, (err) => {
|
|
|
+ if (err.code) {
|
|
|
+ console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.info('Succeeded in setting the system bar to be visible.');
|
|
|
+ });
|
|
|
+
|
|
|
+ windowClass.setWindowLayoutFullScreen(true)
|
|
|
+ })
|
|
|
|
|
|
windowStage.loadContent('pages/Index', (err) => {
|
|
|
if (err.code) {
|