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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| import { PrivacyDialog } from '../views/components/PrivacyDialog' import { router, window } from '@kit.ArkUI' import { preferences } from '@kit.ArkData' import { common } from '@kit.AbilityKit'
@Entry @Component struct launchPage { context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext @State isStore: boolean = true
aboutToAppear(): void { window.getLastWindow(getContext()).then(win => { win.setWindowLayoutFullScreen(true) }) const store = preferences.getPreferencesSync(this.context, { 'name': 'infoStore' }) this.isStore = store.getSync('isStore', true) as boolean console.info(`userAction: ${this.isStore}`) }
async saveInfo() { const store = preferences.getPreferencesSync(this.context, { 'name': 'infoStore' }) store.putSync('isStore', false) store.flush() }
onPageShow(): void { if (this.isStore) { this.controller.open() } else { router.pushUrl({ url: 'pages/AdvertisementPage' }) }
}
controller: CustomDialogController = new CustomDialogController({ builder: PrivacyDialog({ cancel: () => { this.context?.terminateSelf()
}, confirm: () => { this.saveInfo() router.pushUrl({ url: 'pages/AdvertisementPage' }) },
}), alignment: DialogAlignment.Bottom, }
)
build() { Stack() { Image($r('app.media.back')) Column({ space: 10 }) { Image($r('app.media.study_app')) .width(80) .aspectRatio(1) Text('健康学习') .fontSize(20) .fontWeight(FontWeight.Bold) Text('学习总有新玩法') .fontWeight(FontWeight.Bold) }.width('100%') .height('100%') .padding({ top: 100 }) } .height('100%') .width('100%') } }
|