diff --git a/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/components/ContinueModel.ts b/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/components/ContinueModel.ts index d729aac584fe7d3be9fccc779319e1cc8ae2c409..0c30199dba13d5c219917b297f6adb9c3a4c8e2a 100644 --- a/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/components/ContinueModel.ts +++ b/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/components/ContinueModel.ts @@ -46,12 +46,12 @@ export class ContinueModel { private initFromStorage(): void { try { - const savedTabIndex = AppStorage.get('mainTabIndex'); + const savedTabIndex: number = AppStorage.get('mainTabIndex'); if (savedTabIndex !== undefined) { this.data.mainTabIndex = Number(savedTabIndex); } - const darkMode = AppStorage.get('darkMode'); + const darkMode: boolean = AppStorage.get('darkMode'); if (darkMode !== undefined) { this.data.userPreferences.darkMode = Boolean(darkMode); } diff --git a/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/entryability/EntryAbility.ets index 664be58f825dd7e98d62ef379a34aef5a09e0165..b8a3bf6166b07ea8c4c074057f514948ea49c481 100644 --- a/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/entryability/EntryAbility.ets +++ b/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/entryability/EntryAbility.ets @@ -16,12 +16,18 @@ import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; const DOMAIN = 0x0000; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (error) { + let err = error as BusinessError; + hilog.warn(DOMAIN, 'testTag', `setColorMode failed. code=${err.code}, message=${err.message}`); + } hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -33,7 +39,7 @@ export default class EntryAbility extends UIAbility { // Main window is created, set main page for this ability hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/Index', (err) => { + windowStage.loadContent('pages/MainPage', (err) => { if (err.code) { hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); return; diff --git a/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/pages/MainPage.ets b/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/pages/MainPage.ets index 8efd92374b4a23154e5085628a719f8da4c2c54b..a44ae9c335e9bf187480e7d3eeecf0b37298e14b 100644 --- a/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/pages/MainPage.ets +++ b/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/ets/pages/MainPage.ets @@ -16,22 +16,46 @@ import { AudioPlayerService } from '../components/AudioPlayerService'; import { AudioPlayerStatus } from '../components/AudioPlayerStatus'; import { ContinueModel } from '../components/ContinueModel'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; @Entry @Component -struct Index { - @State message: string = 'Hello World'; +struct MainPage { @State currentIndex: number = 0; build() { - RelativeContainer() { + Column() { // [Start tabs] // products\phone\src\main\ets\pages\MainPage.ets Tabs({ index: this.currentIndex }) { - // ... + // [StartExclude tabs] + TabContent() { + Button('tabBar1') + .width('100%') + .onClick(() => { + this.getUIContext() + .getRouter() + .pushUrl({ + url: 'pages/page1' + }) + .then(() => { + hilog.info(0x000, 'testTag', `pushUrl succeed.`) + }) + .catch((err: BusinessError) => { + hilog.warn(0x000, 'testTag', `pushUrl failed. code=${err.code}, message=${err.message}`); + }) + }) + } + .tabBar('tabBar1') + + TabContent() { + Text('tabBar2 content') + } + .tabBar('tabBar2') + // [EndExclude tabs] } .layoutWeight(1) - .barHeight(0) .scrollable(false) .onChange((index) => { this.currentIndex = index; @@ -46,5 +70,6 @@ struct Index { } .height('100%') .width('100%') + .padding({ left: 12, right: 12 }) } } \ No newline at end of file diff --git a/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/resources/base/profile/main_pages.json b/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/resources/base/profile/main_pages.json index f4241ef2f72e78047b4c449d92bd1a92accc39fb..ae136709812e0f9257ac2d57c24bea8717db34f9 100644 --- a/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/resources/base/profile/main_pages.json +++ b/PerformanceAnalysis/BptaDelayAnalysis/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,7 @@ { "src": [ - "pages/MainPage" + "pages/MainPage", + "pages/page1", + "pages/page2" ] }