diff --git a/features/fund/oh-package.json5 b/features/fund/oh-package.json5 index 1bb4c039a3396d1963540399bbe9ca19244feee4..c4700c19ef6e7fd1859503db84c99a49530a5171 100644 --- a/features/fund/oh-package.json5 +++ b/features/fund/oh-package.json5 @@ -9,9 +9,9 @@ "packageType": "InterfaceHar", "dynamicDependencies": {}, "dependencies": { - "@ohos/transaction": "file:../transaction", - "@ohos/fundComparison": "file:../fundComparison", - "@ohos/basic": "file:../../commons/basic", + "transaction": "file:../transaction", + "fundComparison": "file:../fundComparison", + "basic": "file:../../commons/basic", "@ohos/mpchart": "3.0.23-rc.0" } } diff --git a/features/fund/src/main/ets/view/ChartLegendComponent.ets b/features/fund/src/main/ets/view/ChartLegendComponent.ets index 4b79e53969ed6754084647e67b2bc5dd75408a2b..acea6ad26422fc724dc2bda0b37ce518a0cfde74 100644 --- a/features/fund/src/main/ets/view/ChartLegendComponent.ets +++ b/features/fund/src/main/ets/view/ChartLegendComponent.ets @@ -15,9 +15,9 @@ @Component export struct ChartLegendComponent { - private name: ResourceStr = ''; - private color: ResourceStr = ''; - private value: ResourceStr = ''; + name: ResourceStr = ''; + color: ResourceStr = ''; + value: ResourceStr = ''; build() { Column() { diff --git a/features/fund/src/main/ets/view/DetailComponent.ets b/features/fund/src/main/ets/view/DetailComponent.ets index cac46e3618c6c61a18503990ecbe8928b022bd11..efb160ea0d18c3ac716dd8a037fc1b4914ceedeb 100644 --- a/features/fund/src/main/ets/view/DetailComponent.ets +++ b/features/fund/src/main/ets/view/DetailComponent.ets @@ -14,7 +14,7 @@ */ import { LineChart, LineChartModel } from '@ohos/mpchart'; -import { BreakpointUtil, CommonConstants, FundDetail, RouterConstants } from '@ohos/basic'; +import { BreakpointUtil, CommonConstants, FundDetail, RouterConstants } from 'basic'; import ChartViewModel from '../viewmodel/ChartViewModel'; import FundingViewModel from '../viewmodel/FundingViewModel'; import { FundConstants } from '../constants/FundConstants'; diff --git a/features/fund/src/main/ets/view/FundComponent.ets b/features/fund/src/main/ets/view/FundComponent.ets index dd9d273fa30ac2f20f54d7d3648ab29ddc504b7a..3ce7eeff5565831f5f387c034feb65aa88b53288 100644 --- a/features/fund/src/main/ets/view/FundComponent.ets +++ b/features/fund/src/main/ets/view/FundComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BreakpointUtil, BusinessInfo, CommonConstants, FundDetail, RouterConstants } from '@ohos/basic'; +import { BreakpointUtil, BusinessInfo, CommonConstants, FundDetail, RouterConstants } from 'basic'; import { FundConstants } from '../constants/FundConstants'; import FundingViewModel from '../viewmodel/FundingViewModel'; diff --git a/features/fund/src/main/ets/view/FundNavigationComponent.ets b/features/fund/src/main/ets/view/FundNavigationComponent.ets index b159654cc0acffc457cccc515b92a1d913cf0526..c528ad31e06f48c59466e4a22938d8bd4b0652a9 100644 --- a/features/fund/src/main/ets/view/FundNavigationComponent.ets +++ b/features/fund/src/main/ets/view/FundNavigationComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BreakpointUtil, BusinessInfo, CommonConstants, FundDetail } from '@ohos/basic'; +import { BreakpointUtil, BusinessInfo, CommonConstants, FundDetail } from 'basic'; import { FundConstants } from '../constants/FundConstants'; import FundingViewModel from '../viewmodel/FundingViewModel'; diff --git a/features/fund/src/main/ets/view/Funding.ets b/features/fund/src/main/ets/view/Funding.ets index 453f852e57ac79b38f4e5c76ec6f7d3900182e72..7432603092cab3d7549637ac4b8767efdaaad272 100644 --- a/features/fund/src/main/ets/view/Funding.ets +++ b/features/fund/src/main/ets/view/Funding.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { CommonConstants } from '@ohos/basic/'; +import { CommonConstants } from 'basic/'; import { window } from '@kit.ArkUI'; import { FundConstants } from '../constants/FundConstants'; import { FundComponent } from './FundComponent'; diff --git a/features/fund/src/main/ets/view/FundingDetail.ets b/features/fund/src/main/ets/view/FundingDetail.ets index 70731a6e925062edb92b23b16aab50baae227967..779c873f53966b0f15e1266f01446b683afa1b4a 100644 --- a/features/fund/src/main/ets/view/FundingDetail.ets +++ b/features/fund/src/main/ets/view/FundingDetail.ets @@ -13,9 +13,9 @@ * limitations under the License. */ -import { CommonConstants } from '@ohos/basic/'; -import { ComparisonComponent, ComparisonInfo, ComparisonDetailComponent } from '@ohos/fundComparison/'; -import { TransactionComponent } from '@ohos/transaction/'; +import { CommonConstants } from 'basic/'; +import { ComparisonComponent, ComparisonInfo, ComparisonDetailComponent } from 'fundComparison/'; +import { TransactionComponent } from 'transaction'; import { FundConstants } from '../constants/FundConstants'; import { DetailComponent } from './DetailComponent'; import { FundNavigationComponent } from './FundNavigationComponent'; diff --git a/features/fund/src/main/ets/view/TrendsPage.ets b/features/fund/src/main/ets/view/TrendsPage.ets index dff0d8d546080ade2b0450cdc415ef871c042698..b1adcb9c6859be938264bd05558c9847123a4cc2 100644 --- a/features/fund/src/main/ets/view/TrendsPage.ets +++ b/features/fund/src/main/ets/view/TrendsPage.ets @@ -17,10 +17,12 @@ import { Callback } from '@kit.BasicServicesKit'; import { display } from '@kit.ArkUI'; import { window } from '@kit.ArkUI'; import { LineChart, LineChartModel } from '@ohos/mpchart'; -import { BreakpointUtil, CommonConstants, logger } from '@ohos/basic/'; +import { BreakpointUtil, CommonConstants, logger } from 'basic/'; import ChartViewModel from '../viewmodel/ChartViewModel'; import { ChartLegendComponent } from './ChartLegendComponent'; import { FundConstants } from '../constants/FundConstants'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; @Component export struct TrendsPage { @@ -37,12 +39,16 @@ export struct TrendsPage { private callback: Callback = (data: display.FoldDisplayMode) => { if (this.isLandScape && data === display.FoldDisplayMode.FOLD_DISPLAY_MODE_FULL) { window.getLastWindow(this.getUIContext().getHostContext()).then((stage: window.Window) => { - stage.setPreferredOrientation(window.Orientation.PORTRAIT); + stage.setPreferredOrientation(window.Orientation.PORTRAIT).catch((error: BusinessError) => { + hilog.error(0x0000, 'TrendsPage', `Failed to set window orientation. Cause code: ${error.code}, message: ${error.message}`) + }); }); } if (data === display.FoldDisplayMode.FOLD_DISPLAY_MODE_MAIN) { window.getLastWindow(this.getUIContext().getHostContext()).then((stage: window.Window) => { - stage.setPreferredOrientation(window.Orientation.LANDSCAPE) + stage.setPreferredOrientation(window.Orientation.LANDSCAPE).catch((error: BusinessError) => { + hilog.error(0x0000, 'TrendsPage', `Failed to set window orientation. Cause code: ${error.code}, message: ${error.message}`) + }) }); this.isLandScape = true; } @@ -257,11 +263,15 @@ export struct TrendsPage { .hideTitleBar(true) .onAppear(() => { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { - windowStage.setWindowLayoutFullScreen(true); + windowStage.setWindowLayoutFullScreen(true).catch((error: BusinessError) => { + hilog.error(0x0000, 'TrendsPage', `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`) + }); }) if (!this.isLandScape && this.breakPoint === CommonConstants.BREAK_POINT_SM) { window.getLastWindow(this.getUIContext().getHostContext()).then((stage: window.Window) => { - stage.setPreferredOrientation(window.Orientation.LANDSCAPE); + stage.setPreferredOrientation(window.Orientation.LANDSCAPE).catch((error: BusinessError) => { + hilog.error(0x0000, 'TrendsPage', `Failed to set window orientation. Cause code: ${error.code}, message: ${error.message}`); + }); this.isLandScape = true; }); } @@ -273,11 +283,15 @@ export struct TrendsPage { }) .onWillDisappear(() => { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { - windowStage.setWindowLayoutFullScreen(true); + windowStage.setWindowLayoutFullScreen(true).catch((error: BusinessError) => { + hilog.error(0x0000, 'TrendsPage', `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`); + }); }) if (this.isLandScape) { window.getLastWindow(this.getUIContext().getHostContext()).then((stage: window.Window) => { - stage.setPreferredOrientation(window.Orientation.PORTRAIT); + stage.setPreferredOrientation(window.Orientation.PORTRAIT).catch((error: BusinessError) => { + hilog.error(0x0000, 'TrendsPage', `Failed to set window orientation. Cause code: ${error.code}, message: ${error.message}`); + }); }); this.isLandScape = false; } diff --git a/features/fund/src/main/ets/viewmodel/ChartAxisFormatter.ets b/features/fund/src/main/ets/viewmodel/ChartAxisFormatter.ets index e488755edbed65c0029605a09e46ee3fde08bd46..fac4cdf5dc572497ab706a6bc47b3110cb8db482 100644 --- a/features/fund/src/main/ets/viewmodel/ChartAxisFormatter.ets +++ b/features/fund/src/main/ets/viewmodel/ChartAxisFormatter.ets @@ -15,6 +15,7 @@ import { HashMap } from '@kit.ArkTS'; import { AxisBase, IAxisValueFormatter } from '@ohos/mpchart'; +import { hilog } from '@kit.PerformanceAnalysisKit'; export class ChartAxisFormatter implements IAxisValueFormatter { xAxis: HashMap = new HashMap(); @@ -24,10 +25,12 @@ export class ChartAxisFormatter implements IAxisValueFormatter { } public getFormattedValue(value: number, axis: AxisBase): string { - let xAxis = this.xAxis.get(value); - if (xAxis) { - return xAxis; + let xAxis = ''; + try { + xAxis = this.xAxis.get(value); + } catch (error) { + hilog.error(0x0000, 'ChartAxisFormatter', `Failed to obtain the formatted value. Cause code: ${error.code}, message: ${error.message}`) } - return ''; + return xAxis; } } \ No newline at end of file diff --git a/features/fund/src/main/ets/viewmodel/ChartViewModel.ets b/features/fund/src/main/ets/viewmodel/ChartViewModel.ets index 60d22c3957a08c5e42e39735b02d4056d5c57559..0e95d07ff00e7b47631c9a1ed5577e05c286852c 100644 --- a/features/fund/src/main/ets/viewmodel/ChartViewModel.ets +++ b/features/fund/src/main/ets/viewmodel/ChartViewModel.ets @@ -21,6 +21,7 @@ import { EntryOhos, ILineDataSet, JArrayList, LineChartModel, LineData, LineData Description } from '@ohos/mpchart'; import { ChartAxisFormatter } from './ChartAxisFormatter'; +import { hilog } from '@kit.PerformanceAnalysisKit'; class ChartViewModel { xAxis: XAxis | null = null; @@ -134,9 +135,14 @@ class ChartViewModel { this.xAxis.setAvoidFirstLastClipping(true); this.xAxis.setDrawGridLines(false) let xMap: HashMap = new HashMap(); - xMap.set(0, '07-14'); - xMap.set(22, '08-01'); - xMap.set(44, '08-16'); + try { + xMap.set(0, '07-14'); + xMap.set(22, '08-01'); + xMap.set(44, '08-16'); + } catch (error) { + hilog.error(0x0000, 'ChartViewModel', `Failed to set. Cause code: ${error.code}, message: ${error.message}`) + } + this.xAxis.setValueFormatter(new ChartAxisFormatter(xMap)) } @@ -153,7 +159,11 @@ class ChartViewModel { this.leftAxis.setDrawAxisLine(true); let yMap: HashMap = new HashMap(); for (let i = miny; i <= maxy; i++) { - yMap.set(i, i + '.00%'); + try { + yMap.set(i, i + '.00%'); + } catch (error) { + hilog.error(0x0000, 'ChartViewModel', `Failed to set. Cause code: ${error.code}, message: ${error.message}`) + } } this.leftAxis.setValueFormatter(new ChartAxisFormatter(yMap)) } diff --git a/features/fund/src/main/ets/viewmodel/FundingViewModel.ets b/features/fund/src/main/ets/viewmodel/FundingViewModel.ets index a36648e9a939543671322d69ba5e20c326034b31..84f0f77bfed34a320e2a2c64fbcaacd52541173b 100644 --- a/features/fund/src/main/ets/viewmodel/FundingViewModel.ets +++ b/features/fund/src/main/ets/viewmodel/FundingViewModel.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BusinessInfo, FundDetail } from '@ohos/basic'; +import { BusinessInfo, FundDetail } from 'basic'; /** * Get fund data. diff --git a/features/fundComparison/oh-package.json5 b/features/fundComparison/oh-package.json5 index 8a449523209cf65ad106f160a50be194917d972d..78e4693e92a83da34e143d0f62b29848c427886d 100644 --- a/features/fundComparison/oh-package.json5 +++ b/features/fundComparison/oh-package.json5 @@ -9,6 +9,6 @@ "packageType": "InterfaceHar", "dynamicDependencies": {}, "dependencies": { - "@ohos/basic": "file:../../commons/basic" + "basic": "file:../../commons/basic" } } diff --git a/features/fundComparison/src/main/ets/view/ComparisonComponent.ets b/features/fundComparison/src/main/ets/view/ComparisonComponent.ets index 87d7bfdbf19271a9e525e3bdf08a7c085b4e3bdd..48c2412482693bd96bff1e04970b135563963104 100644 --- a/features/fundComparison/src/main/ets/view/ComparisonComponent.ets +++ b/features/fundComparison/src/main/ets/view/ComparisonComponent.ets @@ -14,7 +14,7 @@ */ import { TreeMap } from '@kit.ArkTS'; -import { CommonConstants } from '@ohos/basic'; +import { CommonConstants } from 'basic'; import { ComparisonInfo } from '../viewmodel/ComparisonInfo'; import FundComparisonViewModel from '../viewmodel/FundComparisonViewModel'; import { ComparisonConstants } from '../constants/ComparisonConstants'; diff --git a/features/fundComparison/src/main/ets/view/ComparisonDetailComponent.ets b/features/fundComparison/src/main/ets/view/ComparisonDetailComponent.ets index 222a5c7f4cdac7c83e1a6d06072289859dd82b8f..b15bf91f5303d5d660576e92dea157ab73611b7b 100644 --- a/features/fundComparison/src/main/ets/view/ComparisonDetailComponent.ets +++ b/features/fundComparison/src/main/ets/view/ComparisonDetailComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { CommonConstants, logger, RouterConstants } from '@ohos/basic'; +import { CommonConstants, logger, RouterConstants } from 'basic'; import { ComparisonConstants } from '../constants/ComparisonConstants'; import { ComparisonInfo } from '../viewmodel/ComparisonInfo'; import FundComparisonViewModel from '../viewmodel/FundComparisonViewModel'; diff --git a/features/fundComparison/src/main/ets/view/ComparisonDetailPage.ets b/features/fundComparison/src/main/ets/view/ComparisonDetailPage.ets index 4b06aa934f06c3e638ffbef21b21141002c4bc8f..58277ba51aa6678eda3d8d2d7fe10508504cf7f4 100644 --- a/features/fundComparison/src/main/ets/view/ComparisonDetailPage.ets +++ b/features/fundComparison/src/main/ets/view/ComparisonDetailPage.ets @@ -15,7 +15,7 @@ import { ComparisonDetailComponent } from './ComparisonDetailComponent'; import { ComparisonInfo } from '../viewmodel/ComparisonInfo'; -import { CommonConstants } from '@ohos/basic'; +import { CommonConstants } from 'basic'; @Component export struct ComparisonDetailPage { diff --git a/features/home/oh-package.json5 b/features/home/oh-package.json5 index 31c266be418d28dbc0529c9adc15f15eaa0d4a18..571001ab09236100ddae693c6035fa54b14b907f 100644 --- a/features/home/oh-package.json5 +++ b/features/home/oh-package.json5 @@ -9,6 +9,6 @@ "packageType": "InterfaceHar", "dynamicDependencies": {}, "dependencies": { - "@ohos/basic": "file:../../commons/basic" + "basic": "file:../../commons/basic" } } diff --git a/features/home/src/main/ets/view/AccountComponent.ets b/features/home/src/main/ets/view/AccountComponent.ets index 3f42f68575cb779a7db86b10e74f24b87fe2f112..13ad584dc5feea447f02669c46f142ca6344a66a 100644 --- a/features/home/src/main/ets/view/AccountComponent.ets +++ b/features/home/src/main/ets/view/AccountComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { CommonConstants } from '@ohos/basic/Index'; +import { CommonConstants } from 'basic/Index'; import { DemandDepositComponent } from './DemandDepositComponent'; import { InvestmentComponent } from './InvestmentComponent'; import { LiabilitiesComponent } from './LiabilitiesComponent'; diff --git a/features/home/src/main/ets/view/AccountPage.ets b/features/home/src/main/ets/view/AccountPage.ets index 2e63072eb15f61100c299fca212c0adbbdc6c0a8..4726afc7211a160cbc954abfa864ae783759bd3e 100644 --- a/features/home/src/main/ets/view/AccountPage.ets +++ b/features/home/src/main/ets/view/AccountPage.ets @@ -14,8 +14,13 @@ */ import { window } from '@kit.ArkUI'; -import { CommonConstants } from '@ohos/basic/Index'; +import { CommonConstants } from 'basic/Index'; import { AccountComponent } from './AccountComponent'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const DOMAIN = 0x0000; +const TAG = 'AccountPage'; @Component export struct AccountPage { @@ -23,20 +28,32 @@ export struct AccountPage { onPageShow() { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { - let area = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - let topHeight = this.getUIContext().px2vp(area.topRect.height); - if (topHeight > 0) { - windowStage.setWindowLayoutFullScreen(true); + try { + let area = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + let topHeight = this.getUIContext().px2vp(area.topRect.height); + if (topHeight > 0) { + windowStage.setWindowLayoutFullScreen(true).catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to set the window layout to full-screen mode. Cause code: ${err.code}, message: ${err.message}`) + }); + } + } catch (error) { + hilog.error(DOMAIN, TAG, `Failed to set the window avoid area. Cause code: ${error.code}, message: ${error.message}`) } - }); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to obtain the last window. Cause code: ${error.code}, message: ${error.message}`) + }) } onPageHide() { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { if (this.topHeight > 0) { - windowStage.setWindowLayoutFullScreen(false); + windowStage.setWindowLayoutFullScreen(false).catch((error: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`) + }); } - }); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to obtain the last window. Cause code: ${error.code}, message: ${error.message}`) + }) } build() { diff --git a/features/home/src/main/ets/view/AdvertisementDialog.ets b/features/home/src/main/ets/view/AdvertisementDialog.ets index 9521196b99603ce3c38a8f84e4e76f267c137d9c..8b8baac82840b25da79d1a5c1c428c9cc89b4319 100644 --- a/features/home/src/main/ets/view/AdvertisementDialog.ets +++ b/features/home/src/main/ets/view/AdvertisementDialog.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BreakpointUtil, CommonConstants } from '@ohos/basic'; +import { BreakpointUtil, CommonConstants } from 'basic'; @CustomDialog export struct AdvertisementDialog { diff --git a/features/home/src/main/ets/view/DemandDepositComponent.ets b/features/home/src/main/ets/view/DemandDepositComponent.ets index 150837770b0753c9b0be5b1badd3d7fa4afb465e..66725010e99204ba2a85e89e55bb4ac1f18b0525 100644 --- a/features/home/src/main/ets/view/DemandDepositComponent.ets +++ b/features/home/src/main/ets/view/DemandDepositComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { CommonConstants } from '@ohos/basic/Index'; +import { CommonConstants } from 'basic/Index'; import { HomeConstants } from '../constants/HomeConstants'; @Component diff --git a/features/home/src/main/ets/view/HomeComponent.ets b/features/home/src/main/ets/view/HomeComponent.ets index c0437db2c28fbbf8d37348b99a6b4ab53b17f0ba..6a999693b7248704d064374ed4e51aeb7e8301e3 100644 --- a/features/home/src/main/ets/view/HomeComponent.ets +++ b/features/home/src/main/ets/view/HomeComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BreakpointUtil, BusinessInfo, CommonConstants, RouterConstants } from '@ohos/basic'; +import { BreakpointUtil, BusinessInfo, CommonConstants, RouterConstants } from 'basic'; import { HomeConstants } from '../constants/HomeConstants'; import HomeViewModel from '../viewmodel/HomeViewModel'; diff --git a/features/home/src/main/ets/view/InvestmentComponent.ets b/features/home/src/main/ets/view/InvestmentComponent.ets index 767a0e73c5209c260ff2fe6f28b17cfe2e464c5b..1db3622d6d992e979e0e2e9a625d9fadd62e454f 100644 --- a/features/home/src/main/ets/view/InvestmentComponent.ets +++ b/features/home/src/main/ets/view/InvestmentComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BreakpointUtil, CommonConstants } from '@ohos/basic/Index'; +import { BreakpointUtil, CommonConstants } from 'basic/Index'; @Component export struct InvestmentComponent { diff --git a/features/home/src/main/ets/view/LiabilitiesComponent.ets b/features/home/src/main/ets/view/LiabilitiesComponent.ets index f274054fbda3684cd032d492187480cc706f8a47..4c60c623b67c636e7ef0f5e87e241efa6a6af43b 100644 --- a/features/home/src/main/ets/view/LiabilitiesComponent.ets +++ b/features/home/src/main/ets/view/LiabilitiesComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BreakpointUtil, CommonConstants } from '@ohos/basic/Index'; +import { BreakpointUtil, CommonConstants } from 'basic/Index'; @Component export struct LiabilitiesComponent { diff --git a/features/home/src/main/ets/viewmodel/HomeViewModel.ets b/features/home/src/main/ets/viewmodel/HomeViewModel.ets index a7b049780241b8500193df678d4270e2268068bf..86d6123a16953c1f30433a90a6db6f707cdf8188 100644 --- a/features/home/src/main/ets/viewmodel/HomeViewModel.ets +++ b/features/home/src/main/ets/viewmodel/HomeViewModel.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BusinessInfo, RouterConstants } from '@ohos/basic'; +import { BusinessInfo, RouterConstants } from 'basic'; /** * Get home data. diff --git a/features/transaction/oh-package.json5 b/features/transaction/oh-package.json5 index 5ee1df01e14a3989cb6b81ac615c0c8e68c682e4..1abba65e57679b44a8f639851d49f657c3d54916 100644 --- a/features/transaction/oh-package.json5 +++ b/features/transaction/oh-package.json5 @@ -9,6 +9,6 @@ "packageType": "InterfaceHar", "dynamicDependencies": {}, "dependencies": { - "@ohos/basic": "file:../../commons/basic" + "basic": "file:../../commons/basic" } } diff --git a/features/transaction/src/main/ets/view/TransactionComponent.ets b/features/transaction/src/main/ets/view/TransactionComponent.ets index 9dddd8b88443cda6feba75a638cca180265d5720..2efe0faa3794953118790ae994de6ac368aa1857 100644 --- a/features/transaction/src/main/ets/view/TransactionComponent.ets +++ b/features/transaction/src/main/ets/view/TransactionComponent.ets @@ -14,7 +14,7 @@ */ import { window } from '@kit.ArkUI'; -import { CommonConstants, FundDetail } from '@ohos/basic'; +import { CommonConstants, FundDetail } from 'basic'; import { TransactionConstants } from '../constants/TransactionConstants'; @Component diff --git a/product/phone/oh-package.json5 b/product/phone/oh-package.json5 index 7a777161c5d81f1f467c7ff5f9f2c123e7a151d4..488b369c4202d2ffb38d64204804d09a50a3946e 100644 --- a/product/phone/oh-package.json5 +++ b/product/phone/oh-package.json5 @@ -8,9 +8,9 @@ "version": "1.0.0", "dynamicDependencies": {}, "dependencies": { - "@ohos/basic": "file:../../commons/basic", - "@ohos/home": "file:../../features/home", - "@ohos/fund": "file:../../features/fund", - "@ohos/fundComparison": "file:../../features/fundComparison" + "basic": "file:../../commons/basic", + "home": "file:../../features/home", + "fund": "file:../../features/fund", + "fundComparison": "file:../../features/fundComparison" } } diff --git a/product/phone/src/main/ets/entryability/EntryAbility.ets b/product/phone/src/main/ets/entryability/EntryAbility.ets index a7dbce920e78486514c9cc450e3718ce8f5bb4c1..b3d1604ac2f8d1dad82d7e2767afac4dadd39766 100644 --- a/product/phone/src/main/ets/entryability/EntryAbility.ets +++ b/product/phone/src/main/ets/entryability/EntryAbility.ets @@ -17,7 +17,10 @@ import { UIAbility, Want, AbilityConstant } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { display, window } from '@kit.ArkUI'; -import { CommonConstants } from '@ohos/basic'; +import { CommonConstants } from 'basic'; + +const DOMAIN = 0x0000; +const TAG = 'EntryAbility'; export default class EntryAbility extends UIAbility { private windowObj?: window.Window; @@ -36,11 +39,17 @@ export default class EntryAbility extends UIAbility { windowStage.getMainWindow().then((data: window.Window) => { this.windowObj = data; - this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width); + try { + this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width); + } catch (error) { + hilog.error(DOMAIN, TAG, `Failed to obtain the window properties. Cause code: ${error.code}, message: ${error.message}`) + } this.windowObj.on('windowSizeChange', (windowSize: window.Size) => { this.updateBreakpoint(windowSize.width); }) - }) + }).catch((error: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${error.code}, message: ${error.message}`) + }); windowStage.loadContent('pages/Index', (err: BusinessError, data) => { if (err.code) { @@ -52,16 +61,20 @@ export default class EntryAbility extends UIAbility { } private updateBreakpoint(windowWidth: number): void{ - let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; - let curBp: string = ''; - if (windowWidthVp < CommonConstants.BREAK_POINTS_VALUE_NUMBER[1]) { - curBp = CommonConstants.BREAK_POINT_SM; - } else if (windowWidthVp < CommonConstants.BREAK_POINTS_VALUE_NUMBER[2]) { - curBp = CommonConstants.BREAK_POINT_MD; - } else { - curBp = CommonConstants.BREAK_POINT_LG; + try { + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let curBp: string = ''; + if (windowWidthVp < CommonConstants.BREAK_POINTS_VALUE_NUMBER[1]) { + curBp = CommonConstants.BREAK_POINT_SM; + } else if (windowWidthVp < CommonConstants.BREAK_POINTS_VALUE_NUMBER[2]) { + curBp = CommonConstants.BREAK_POINT_MD; + } else { + curBp = CommonConstants.BREAK_POINT_LG; + } + AppStorage.setOrCreate('breakPoint', curBp); + } catch (error) { + hilog.error(DOMAIN, TAG, `Failed to obtain the default display. Cause code: ${error.code}, message: ${error.message}`) } - AppStorage.setOrCreate('breakPoint', curBp); } onWindowStageDestroy(): void { diff --git a/product/phone/src/main/ets/pages/Index.ets b/product/phone/src/main/ets/pages/Index.ets index 2f0d828a4b79fdecb4360b326943f2b5b09b237c..895f3a07e459d2a0e234ad78918c90dbbfdd3e0c 100644 --- a/product/phone/src/main/ets/pages/Index.ets +++ b/product/phone/src/main/ets/pages/Index.ets @@ -14,10 +14,15 @@ */ import { window } from '@kit.ArkUI'; -import { BreakpointUtil, CommonConstants, RouterConstants } from '@ohos/basic'; -import { AccountPage, AdvertisementDialog, HomeComponent } from '@ohos/home'; -import { Funding, FundingDetail, TrendsPage } from '@ohos/fund'; -import { ComparisonDetailPage, ComparisonInfo } from '@ohos/fundComparison'; +import { BreakpointUtil, CommonConstants, RouterConstants } from 'basic'; +import { AccountPage, AdvertisementDialog, HomeComponent } from 'home'; +import { Funding, FundingDetail, TrendsPage } from 'fund'; +import { ComparisonDetailPage, ComparisonInfo } from 'fundComparison'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +const DOMAIN = 0x0000; +const TAG = 'Index'; // [Start init_pop_custom_style] @Entry @@ -45,24 +50,37 @@ struct Index { // [StartExclude init_pop_custom_style] onPageShow() { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { - let area = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - let topHeight = this.getUIContext().px2vp(area.topRect.height); - let bottomArea = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); - let bottom = this.getUIContext().px2vp(bottomArea.bottomRect.height); - if (topHeight > 0) { - windowStage.setWindowLayoutFullScreen(true); - AppStorage.setOrCreate('avoidArea', topHeight); - AppStorage.setOrCreate('bottom', bottom); + try { + let area = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + let topHeight = this.getUIContext().px2vp(area.topRect.height); + let bottomArea = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); + let bottom = this.getUIContext().px2vp(bottomArea.bottomRect.height); + if (topHeight > 0) { + windowStage.setWindowLayoutFullScreen(true).catch((error:BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`) + }); + AppStorage.setOrCreate('avoidArea', topHeight); + AppStorage.setOrCreate('bottom', bottom); + } + } catch (error) { + hilog.error(DOMAIN, TAG, `Failed to obtain the window avoid area. Cause code: ${error.code}, message: ${error.message}`) } - }); + + }).catch((error: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to obtain the last window. Cause code: ${error.code}, message: ${error.message}`) + }) } onPageHide() { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { if (this.topHeight > 0) { - windowStage.setWindowLayoutFullScreen(false); + windowStage.setWindowLayoutFullScreen(false).catch((error:BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`) + }); } - }); + }).catch((error: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to obtain the last window. Cause code: ${error.code}, message: ${error.message}`) + }) } getTabBarColor(index: number, currentTabIndex: number, breakPoint: string): ResourceColor { @@ -114,12 +132,16 @@ struct Index { .hideTitleBar(true) .onWillShow(() => { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { - windowStage.setWindowLayoutFullScreen(false); + windowStage.setWindowLayoutFullScreen(false).catch((error: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`) + }); }) }) .onWillDisappear(() => { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { - windowStage.setWindowLayoutFullScreen(true); + windowStage.setWindowLayoutFullScreen(true).catch((error: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`) + }); }) }) } else if (name === RouterConstants.FUNDING_DETAIL_URL) { @@ -133,12 +155,16 @@ struct Index { .hideTitleBar(true) .onWillShow(() => { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { - windowStage.setWindowLayoutFullScreen(false); + windowStage.setWindowLayoutFullScreen(false).catch((error:BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`) + }); }) }) .onWillDisappear(() => { window.getLastWindow(this.getUIContext().getHostContext()).then((windowStage: window.Window) => { - windowStage.setWindowLayoutFullScreen(true); + windowStage.setWindowLayoutFullScreen(true).catch((error:BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to set the window layout to full-screen mode. Cause code: ${error.code}, message: ${error.message}`) + }); }) }) }