代码拉取完成,页面将自动刷新
import { WinsleiLogManager } from '@winslei/winsleilog'
import { MenuInfo } from '../../Common/model/MenuInfo'
import Window from '@ohos.window'
import { AppStorageNameConstant } from '../../Common/constants/AppStorageNameConstant'
const TAG = 'WindowHome'
@Entry
@Component
struct WindowHome {
scroller: Scroller = new Scroller()
@State focusIndex: number = -1
@State menus: MenuInfo[] = []
private window: Window.Window | undefined = AppStorage.Get(AppStorageNameConstant.MAIN_WINDOW_NAME)
aboutToDisappear() {
Window.getLastWindow(getContext(this)).then((win) => {
win.setWindowLayoutFullScreen(false).then(() => {
win.setWindowSystemBarEnable(['status', 'navigation', 'navigationIndicator']).then(()=> {
})
})
})
}
aboutToAppear() {
Window.getLastWindow(getContext(this)).then((win) => {
win.setWindowLayoutFullScreen(true).then(() => {
// win.setWindowSystemBarEnable(['navigation', 'navigationIndicator']).then(()=> {
//
// })
win.setSpecificSystemBarEnabled('navigationIndicator', true).then(()=> {
})
})
})
let menuInfo1 = new MenuInfo()
menuInfo1.title = '屏幕常亮'
let menuInfo2 = new MenuInfo()
menuInfo2.title = 'Window'
let menuInfo3 = new MenuInfo()
menuInfo3.title = 'Window'
let menuInfo4 = new MenuInfo()
menuInfo4.title = 'Window'
let menuInfo5 = new MenuInfo()
menuInfo5.title = 'Window'
let menuInfo6 = new MenuInfo()
menuInfo6.title = 'Window'
let menuInfo7 = new MenuInfo()
menuInfo7.title = 'Window'
let menuInfo8 = new MenuInfo()
menuInfo8.title = 'Window'
let menuInfo9 = new MenuInfo()
menuInfo9.title = 'Window'
this.menus.push(menuInfo1, menuInfo2, menuInfo3, menuInfo4, menuInfo5, menuInfo6, menuInfo7, menuInfo8, menuInfo9)
}
build() {
Grid() {
ForEach(this.menus, (menuInfo: MenuInfo, index: number) => {
GridItem() {
Text(menuInfo.title)
.fontSize(30)
.fontColor(Color.White)
.backgroundColor('#1affffff')
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
.border({
style: BorderStyle.Solid,
width: this.focusIndex == index ? 4 : 0,
color: Color.White
})
.focusable(true)
.defaultFocus(index == 0)
.onFocus(() => {
WinsleiLogManager.hilogIWithTag(TAG, JSON.stringify(menuInfo))
this.focusIndex = index
})
.onClick((event?: ClickEvent) => {
switch(menuInfo.title) {
case '屏幕常亮':
if (this.window as Window.Window) {
(this.window as Window.Window).setWindowKeepScreenOn(true).then(()=>{
WinsleiLogManager.hilogIWithTag(TAG, `setWindowKeepScreenOn success`)
})
}
break
}
AppStorage.setOrCreate('showGlobalCustomDialog', true)
})
}
})
}
.columnsTemplate('1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr')
.columnsGap(10)
.rowsGap(10)
.width('100%')
.backgroundColor('#304353')
.height('100%')
.padding(20)
.focusable(true)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。