From 0b7097a24706941a847d579aec4960b7659ced4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E4=B8=9C=E6=B5=B7?= Date: Tue, 9 Sep 2025 20:01:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/pages/ContactAddAndEditPage.ets | 18 ++++++++++++++---- entry/src/main/ets/pages/ContactDeletePage.ets | 4 +--- entry/src/main/ets/pages/ContactDetailPage.ets | 12 +++++++----- entry/src/main/ets/pages/ContactHomePage.ets | 9 +++++++-- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/entry/src/main/ets/pages/ContactAddAndEditPage.ets b/entry/src/main/ets/pages/ContactAddAndEditPage.ets index 55791b1..84f0fb7 100644 --- a/entry/src/main/ets/pages/ContactAddAndEditPage.ets +++ b/entry/src/main/ets/pages/ContactAddAndEditPage.ets @@ -169,10 +169,20 @@ struct ContactAddAndEditPage { let contactsKey = CommonConstants.CONTACTS_DATABASE_KEY + contactData.name; // Save the contact information. this.kvManager.addAndSave(contactsKey, JSON.stringify(contactData)); - this.getUIContext().getRouter().replaceUrl({ - url: CommonConstants.PAGE_DETAIL_URL, - params: { key: contactsKey } - }); + if (!this.isEdit) { + this.getUIContext().getRouter().replaceUrl({ + url: CommonConstants.PAGE_DETAIL_URL, + params: { key: contactsKey } + }); + } else { + let params = this.getUIContext().getRouter().getParams() as Record; + this.getUIContext().getRouter().back({ + url: CommonConstants.PAGE_DETAIL_URL, + params: { + key: params.key + } + }) + } } else { this.getUIContext().getPromptAction().showToast({ message: $r('app.string.contact_name'), diff --git a/entry/src/main/ets/pages/ContactDeletePage.ets b/entry/src/main/ets/pages/ContactDeletePage.ets index ac990b8..ae97270 100644 --- a/entry/src/main/ets/pages/ContactDeletePage.ets +++ b/entry/src/main/ets/pages/ContactDeletePage.ets @@ -155,9 +155,7 @@ struct ContactDeletePage { item.checked = isAll ? true : false; return item; }); - let result = this.checkList.filter((item) => { - item.checked; - }); + let result = this.checkList.filter((item) => item.checked); this.count = this.checkList.length === 0 ? 0 : result.length; }, rightClickEvent: () => { diff --git a/entry/src/main/ets/pages/ContactDetailPage.ets b/entry/src/main/ets/pages/ContactDetailPage.ets index eebde10..24249f4 100644 --- a/entry/src/main/ets/pages/ContactDetailPage.ets +++ b/entry/src/main/ets/pages/ContactDetailPage.ets @@ -82,17 +82,17 @@ struct ContractDetailPage { this.dialogController.close(); } - aboutToAppear() { - this.initializeData(); + onPageShow(): void { + let params = this.getUIContext().getRouter().getParams() as Record; + this.initializeData(params.key as string); } /** * Initialize detail page data. */ - initializeData(): void { - let params = this.getUIContext().getRouter().getParams() as Record; + initializeData(key: string): void { // Get contact details. - this.kvManager.getDetails(params.key as string, (err: BusinessError, data) => { + this.kvManager.getDetails(key, (err: BusinessError, data) => { if (err) { hilog.error(0x0000, 'hilog', TAG, `DetailPage.ets Fail to get, error message is ${JSON.stringify(err)}`); return; @@ -167,9 +167,11 @@ struct ContractDetailPage { .borderRadius(40) .margin({ right: 8 }) .onClick(() => { + let params = this.getUIContext().getRouter().getParams() as Record; this.getUIContext().getRouter().pushUrl({ url: 'pages/ContactAddAndEditPage', params: { + key: params.key as string, isEdit: true, name: this.name, address: this.address, diff --git a/entry/src/main/ets/pages/ContactHomePage.ets b/entry/src/main/ets/pages/ContactHomePage.ets index 663b8ce..662da26 100644 --- a/entry/src/main/ets/pages/ContactHomePage.ets +++ b/entry/src/main/ets/pages/ContactHomePage.ets @@ -147,7 +147,7 @@ struct ContactHomePage { } build() { - Column() { + Flex({ direction: FlexDirection.Column }) { this.NavigationTitle(); this.ContactList(); } @@ -214,6 +214,7 @@ struct ContactHomePage { }) } .height(56) + .flexShrink(0) } @Builder @@ -243,10 +244,11 @@ struct ContactHomePage { @Builder dataView() { - Column() { + Flex({ direction: FlexDirection.Column }) { Search({ value: $$this.searchValue, placeholder: Object($r('app.string.search_contact')) }) .width('100%') .height(40) + .flexShrink(0) .borderRadius(24) .placeholderColor('rgba(0, 0, 0, 0.6)') .placeholderFont({ @@ -301,11 +303,14 @@ struct ContactHomePage { } .scrollBar(BarState.Off) .width('100%') + .height('100%') .margin({ bottom: $r('app.float.list_area_height') }) } .width('100%') + .flexGrow(1) } .width('100%') + .flexGrow(1) .margin({ top: 8 }) } -- Gitee