From c11358dd3e483877b299b3a1960239ea66775a1a Mon Sep 17 00:00:00 2001 From: dhf <1511447814@qq.com> Date: Sat, 15 Mar 2025 17:12:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=BA=9F=E5=BC=83=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 4 +++- entry/src/main/ets/pages/Verify.ets | 23 ++++++++++++++----- entry/src/main/ets/pages/WebIndex.ets | 7 ++++-- entry/src/main/ets/view/LinkButton.ets | 6 ++--- entry/src/main/module.json5 | 1 + .../resources/base/profile/main_pages.json | 3 +-- .../resources/base/profile/route_map.json | 12 ++++++++++ 7 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 entry/src/main/resources/base/profile/route_map.json diff --git a/build-profile.json5 b/build-profile.json5 index 616f5c7..f503535 100755 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -1,6 +1,8 @@ { "app": { - "signingConfigs": [], + "signingConfigs": [ + + ], "products": [ { "name": "default", diff --git a/entry/src/main/ets/pages/Verify.ets b/entry/src/main/ets/pages/Verify.ets index a0fc2b4..bfc629a 100755 --- a/entry/src/main/ets/pages/Verify.ets +++ b/entry/src/main/ets/pages/Verify.ets @@ -17,12 +17,17 @@ import { webview } from '@kit.ArkWeb'; import { showDialog } from '../common/utils/DialogUtil'; import { CommonConstants } from '../common/constants/CommonConstant'; +@Builder +export function VerifyPageBuilder() { + Verify() +} + /** * Page use to verify login free. */ -@Entry @Component -struct Verify { +export struct Verify { + pathStack: NavPathStack = new NavPathStack(); fileAccess: boolean = true; controller: webview.WebviewController = new webview.WebviewController(); isRedirect: boolean = false; @@ -32,8 +37,7 @@ struct Verify { } build() { - Column() { - Navigator({ target: CommonConstants.PAGE_INDEX, type: NavigationType.Back }) { + NavDestination() { Row() { Image($r('app.media.ic_back')) .width(CommonConstants.BACK_WIDTH) @@ -45,9 +49,11 @@ struct Verify { .fontWeight(CommonConstants.FONT_WEIGHT_DEEPER) .fontColor($r('app.color.navigator_black')) } + .onClick(()=>{ + this.pathStack.pop(); + }) .width(CommonConstants.FULL_WIDTH) - } - .width(CommonConstants.FULL_WIDTH) + .margin({ top: CommonConstants.NAVIGATOR_MARGIN_TOP, left: CommonConstants.NAVIGATOR_MARGIN_LEFT @@ -88,5 +94,10 @@ struct Verify { .backgroundColor($r('app.color.page_background_grey')) .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.FULL_HEIGHT) + .hideTitleBar(true) + .hideToolBar(true) + .onReady((context: NavDestinationContext) => { + this.pathStack = context.pathStack; + }) } } diff --git a/entry/src/main/ets/pages/WebIndex.ets b/entry/src/main/ets/pages/WebIndex.ets index cd52b1b..92145b1 100755 --- a/entry/src/main/ets/pages/WebIndex.ets +++ b/entry/src/main/ets/pages/WebIndex.ets @@ -25,9 +25,10 @@ import { showDialog } from '../common/utils/DialogUtil'; @Component struct WebIndex { controller: webview.WebviewController = new webview.WebviewController(); + pathStack: NavPathStack = new NavPathStack(); build() { - Column() { + Navigation(this.pathStack) { Text($r('app.string.navigator_name')) .fontSize(CommonConstants.NAVIGATOR_SIZE) .fontWeight(CommonConstants.FONT_WEIGHT_DEEPER) @@ -70,7 +71,7 @@ struct WebIndex { LinkButton({ buttonType: CommonConstants.CookieOperation[0], isNeedDivider: true }) LinkButton({ buttonType: CommonConstants.CookieOperation[1], isNeedDivider: true }) LinkButton({ buttonType: CommonConstants.CookieOperation[2], isNeedDivider: true }) - LinkButton({ buttonType: CommonConstants.CookieOperation[3], isNeedDivider: false }) + LinkButton({ buttonType: CommonConstants.CookieOperation[3], isNeedDivider: false, pathStack: this.pathStack }) } .justifyContent(FlexAlign.SpaceBetween) .width(CommonConstants.WEB_WIDTH) @@ -78,5 +79,7 @@ struct WebIndex { .backgroundColor($r('app.color.page_background_grey')) .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.FULL_HEIGHT) + .hideTitleBar(true) + .hideToolBar(true) } } \ No newline at end of file diff --git a/entry/src/main/ets/view/LinkButton.ets b/entry/src/main/ets/view/LinkButton.ets index a2478c9..92d542e 100755 --- a/entry/src/main/ets/view/LinkButton.ets +++ b/entry/src/main/ets/view/LinkButton.ets @@ -14,7 +14,6 @@ */ import { webview } from '@kit.ArkWeb'; -import { router } from '@kit.ArkUI'; import { showDialog } from '../common/utils/DialogUtil'; import { CommonConstants } from '../common/constants/CommonConstant'; @@ -25,6 +24,7 @@ import { CommonConstants } from '../common/constants/CommonConstant'; export struct LinkButton { buttonType?: string; isNeedDivider?: boolean; + pathStack: NavPathStack = new NavPathStack(); build() { Row() { @@ -59,9 +59,7 @@ export struct LinkButton { let deleteMessage = $r('app.string.delete_success'); showDialog(deleteMessage); } else { - router.pushUrl({ - url: CommonConstants.PAGE_VERIFY - }) + this.pathStack.pushPathByName('Verify',undefined); } } catch (error) { showDialog('Operation failed.' + JSON.stringify(error)); diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 4080bdc..fb84178 100755 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -10,6 +10,7 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + "routerMap": "$profile:route_map", "abilities": [ { "name": "EntryAbility", diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 47bf9e1..758841e 100755 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ { "src": [ - "pages/WebIndex", - "pages/Verify" + "pages/WebIndex" ] } diff --git a/entry/src/main/resources/base/profile/route_map.json b/entry/src/main/resources/base/profile/route_map.json new file mode 100644 index 0000000..8407685 --- /dev/null +++ b/entry/src/main/resources/base/profile/route_map.json @@ -0,0 +1,12 @@ +{ + "routerMap": [ + { + "name": "Verify", + "pageSourceFile": "src/main/ets/pages/Verify.ets", + "buildFunction": "VerifyPageBuilder", + "data": { + "description" : "this is Verify" + } + } + ] +} \ No newline at end of file -- Gitee From 1fed27d26517b47fa2c12528f632dc0c703b1628 Mon Sep 17 00:00:00 2001 From: dhf <1511447814@qq.com> Date: Sat, 15 Mar 2025 17:32:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/constants/CommonConstant.ets | 1 - entry/src/main/ets/pages/Verify.ets | 30 +++++++++---------- entry/src/main/ets/pages/WebIndex.ets | 2 +- entry/src/main/ets/view/LinkButton.ets | 2 +- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/entry/src/main/ets/common/constants/CommonConstant.ets b/entry/src/main/ets/common/constants/CommonConstant.ets index 1eafe46..fd569e9 100755 --- a/entry/src/main/ets/common/constants/CommonConstant.ets +++ b/entry/src/main/ets/common/constants/CommonConstant.ets @@ -115,7 +115,6 @@ export class CommonConstants { * Length of truncated. */ static readonly SUB_LENGTH: number = 300; - /** * Type of cookie Operation. */ diff --git a/entry/src/main/ets/pages/Verify.ets b/entry/src/main/ets/pages/Verify.ets index bfc629a..f8bc37e 100755 --- a/entry/src/main/ets/pages/Verify.ets +++ b/entry/src/main/ets/pages/Verify.ets @@ -38,21 +38,21 @@ export struct Verify { build() { NavDestination() { - Row() { - Image($r('app.media.ic_back')) - .width(CommonConstants.BACK_WIDTH) - .height(CommonConstants.BACK_HEIGHT) - .objectFit(ImageFit.Contain) + Row() { + Image($r('app.media.ic_back')) + .width(CommonConstants.BACK_WIDTH) + .height(CommonConstants.BACK_HEIGHT) + .objectFit(ImageFit.Contain) - Text($r('app.string.navigator_name')) - .fontSize(CommonConstants.NAVIGATOR_SIZE) - .fontWeight(CommonConstants.FONT_WEIGHT_DEEPER) - .fontColor($r('app.color.navigator_black')) - } - .onClick(()=>{ - this.pathStack.pop(); - }) - .width(CommonConstants.FULL_WIDTH) + Text($r('app.string.navigator_name')) + .fontSize(CommonConstants.NAVIGATOR_SIZE) + .fontWeight(CommonConstants.FONT_WEIGHT_DEEPER) + .fontColor($r('app.color.navigator_black')) + } + .onClick(() => { + this.pathStack.pop(); + }) + .width(CommonConstants.FULL_WIDTH) .margin({ top: CommonConstants.NAVIGATOR_MARGIN_TOP, @@ -87,7 +87,7 @@ export struct Verify { this.isRedirect = true; showDialog(originCookie); } catch (error) { - showDialog('Failed to load the web page.'+JSON.stringify(error)); + showDialog('Failed to load the web page.' + JSON.stringify(error)); } }) } diff --git a/entry/src/main/ets/pages/WebIndex.ets b/entry/src/main/ets/pages/WebIndex.ets index 92145b1..b4be93b 100755 --- a/entry/src/main/ets/pages/WebIndex.ets +++ b/entry/src/main/ets/pages/WebIndex.ets @@ -71,7 +71,7 @@ struct WebIndex { LinkButton({ buttonType: CommonConstants.CookieOperation[0], isNeedDivider: true }) LinkButton({ buttonType: CommonConstants.CookieOperation[1], isNeedDivider: true }) LinkButton({ buttonType: CommonConstants.CookieOperation[2], isNeedDivider: true }) - LinkButton({ buttonType: CommonConstants.CookieOperation[3], isNeedDivider: false, pathStack: this.pathStack }) + LinkButton({ buttonType: CommonConstants.CookieOperation[3], isNeedDivider: false, pathStack: this.pathStack }) } .justifyContent(FlexAlign.SpaceBetween) .width(CommonConstants.WEB_WIDTH) diff --git a/entry/src/main/ets/view/LinkButton.ets b/entry/src/main/ets/view/LinkButton.ets index 92d542e..48370ea 100755 --- a/entry/src/main/ets/view/LinkButton.ets +++ b/entry/src/main/ets/view/LinkButton.ets @@ -59,7 +59,7 @@ export struct LinkButton { let deleteMessage = $r('app.string.delete_success'); showDialog(deleteMessage); } else { - this.pathStack.pushPathByName('Verify',undefined); + this.pathStack.pushPathByName('Verify', undefined); } } catch (error) { showDialog('Operation failed.' + JSON.stringify(error)); -- Gitee