// WindowModel.ets
setMainWindowImmersive() {
if (this.windowStage === undefined) {
Logger.error('windowStage is undefined.');
return;
}
// 获取主窗口window实例
this.windowStage.getMainWindow((err, windowClass: window.Window) => {
if (err.code) {
Logger.error(`Failed to obtain the main window. Code:${err.code}, message:${err.message}`);
return;
}
// 设置主窗口全屏显示
windowClass.setWindowLayoutFullScreen(true, (err) => {
if (err.code) {
Logger.error(`Failed to set full-screen mode. Code:${err.code}, message:${err.message}`);
return;
}
});
// 设置状态栏与导航栏不显示
windowClass.setWindowSystemBarEnable([], (err) => {
if (err.code) {
Logger.error(`Failed to set the system bar to be invisible. Code:${err.code}, message:${err.message}`);
return;
}
});
});
}