From d7a008614ff5b67705c768accd81d2c0e970dae1 Mon Sep 17 00:00:00 2001 From: tongzihan <15671769870@163.com> Date: Thu, 10 Jul 2025 19:44:54 +0800 Subject: [PATCH 1/2] bug fix --- .../default/resources/rawfile/index1_cn.html | 30 ------------ .../default/resources/rawfile/index1_en.html | 29 ----------- .../default/resources/rawfile/index_cn.html | 36 -------------- .../default/resources/rawfile/index_en.html | 38 --------------- entry/src/main/ets/pages/Index.ets | 16 +++---- entry/src/main/ets/pages/Navigation1.ets | 9 ++-- entry/src/main/ets/pages/Navigation2.ets | 13 +++-- entry/src/main/ets/pages/Navigation3.ets | 8 ++-- entry/src/main/ets/pages/Navigation4.ets | 18 +++++-- entry/src/main/module.json5 | 48 +++++++++++-------- entry/src/main/resources/rawfile/index.html | 10 ++++ 11 files changed, 79 insertions(+), 176 deletions(-) delete mode 100644 entry/build/default/intermediates/res/default/resources/rawfile/index1_cn.html delete mode 100644 entry/build/default/intermediates/res/default/resources/rawfile/index1_en.html delete mode 100644 entry/build/default/intermediates/res/default/resources/rawfile/index_cn.html delete mode 100644 entry/build/default/intermediates/res/default/resources/rawfile/index_en.html create mode 100644 entry/src/main/resources/rawfile/index.html diff --git a/entry/build/default/intermediates/res/default/resources/rawfile/index1_cn.html b/entry/build/default/intermediates/res/default/resources/rawfile/index1_cn.html deleted file mode 100644 index b2bef50..0000000 --- a/entry/build/default/intermediates/res/default/resources/rawfile/index1_cn.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - Document - - - - -
-
-
- -
- - Web 页面 -
-
Hello Web
- 跳转回Web页面 -
- - - diff --git a/entry/build/default/intermediates/res/default/resources/rawfile/index1_en.html b/entry/build/default/intermediates/res/default/resources/rawfile/index1_en.html deleted file mode 100644 index 211cdee..0000000 --- a/entry/build/default/intermediates/res/default/resources/rawfile/index1_en.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Document - - - -
-
-
- -
- - Web Page -
-
Hello Web
- Navigate back to the Web page -
- - - diff --git a/entry/build/default/intermediates/res/default/resources/rawfile/index_cn.html b/entry/build/default/intermediates/res/default/resources/rawfile/index_cn.html deleted file mode 100644 index f72d09c..0000000 --- a/entry/build/default/intermediates/res/default/resources/rawfile/index_cn.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - Document - - - - -
-
Web和应用的跳转与拉起
- -
- - - diff --git a/entry/build/default/intermediates/res/default/resources/rawfile/index_en.html b/entry/build/default/intermediates/res/default/resources/rawfile/index_en.html deleted file mode 100644 index cd0bccf..0000000 --- a/entry/build/default/intermediates/res/default/resources/rawfile/index_en.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - Document - - - - -
-
web and application jump and pull up
- -
- - - diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 99cfbd7..9401ceb 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -17,7 +17,6 @@ import { webview } from '@kit.ArkWeb'; import { common, Want } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { distributedDeviceManager } from '@kit.DistributedServiceKit'; -import { productViewManager } from '@kit.StoreKit'; import { OriginPage } from './OriginPage'; import { Constants } from '../common/Constants'; import { Logger } from '../common/Logger'; @@ -74,16 +73,11 @@ struct Index { this.functionsMap.set('arkts://pages/toOriginPage', () => this.navPathStack.pushPath({ name: Constants.ORIGIN_PAGE })); this.functionsMap.set('third-party://pages/toThirdPage', () => { - const want: Want = { - deviceId: '', - action: 'ohos.want.action.viewData', - entities: ['entity.system.default'], - }; - this.context.startAbility(want).then(() => { - Logger.info('Succeeded in starting FuncAbility.'); + this.context.openLink('appScheme://www.test.com:80/path1').then(() => { + Logger.info('Succeeded in starting FuncAbility'); }).catch((err: BusinessError) => { Logger.error(`Failed to start FuncAbility. Code is ${err.code}, message is ${err.message}`); - }) + }); }); this.functionsMap.set('network://pages/toSystemApp', () => { const want: Want = { @@ -118,6 +112,10 @@ struct Index { } this.context.startAbility(want); } catch (err) { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.not_found_toast'), + duration: 2000 + }) Logger.error(`err: ${err.code} ${err.message}`); } }) diff --git a/entry/src/main/ets/pages/Navigation1.ets b/entry/src/main/ets/pages/Navigation1.ets index 348fe0d..6cb1651 100644 --- a/entry/src/main/ets/pages/Navigation1.ets +++ b/entry/src/main/ets/pages/Navigation1.ets @@ -1,3 +1,5 @@ +import { webview } from "@kit.ArkWeb"; + class PathStack{ pop(){ return @@ -5,9 +7,10 @@ class PathStack{ } @Component export struct Navigation2 { - private controller:ESObject; - private navPathStack=new PathStack() -build() { + @Consume('navPathStack') navPathStack: NavPathStack; + private controller: WebviewController = new webview.WebviewController; + + build() { // [Start navigation1] NavDestination() { Column() { diff --git a/entry/src/main/ets/pages/Navigation2.ets b/entry/src/main/ets/pages/Navigation2.ets index c7f674d..9b12d09 100644 --- a/entry/src/main/ets/pages/Navigation2.ets +++ b/entry/src/main/ets/pages/Navigation2.ets @@ -1,19 +1,22 @@ -import { bundleManager, OpenLinkOptions } from "@kit.AbilityKit"; +import { bundleManager, common, OpenLinkOptions } from "@kit.AbilityKit"; import { BusinessError } from "@kit.BasicServicesKit"; +import { webview } from "@kit.ArkWeb"; + // [Start link1] const link: string = "appScheme://www.test.com:80/path1"; // [End link1] @Component export struct Navigation3 { - private controller:ESObject; - private navPathStack:ESObject - private context:ESObject; + @Consume('navPathStack') navPathStack: NavPathStack; + private controller: WebviewController = new webview.WebviewController; + private context = this.getUIContext().getHostContext() as common.UIAbilityContext; + build() { // [Start link3] Navigation(this.navPathStack) { Column() { Web({ - src: $rawfile('index2.html'), + src: $rawfile('index.html'), controller: this.controller }) .zoomAccess(false) diff --git a/entry/src/main/ets/pages/Navigation3.ets b/entry/src/main/ets/pages/Navigation3.ets index 3e658f9..4f47e78 100644 --- a/entry/src/main/ets/pages/Navigation3.ets +++ b/entry/src/main/ets/pages/Navigation3.ets @@ -1,5 +1,6 @@ import { hilog } from "@kit.PerformanceAnalysisKit"; import { common } from "@kit.AbilityKit"; +import { webview } from "@kit.ArkWeb"; class context{ startAbilityByType(name:string,a:ESObject,b:ESObject){ @@ -8,9 +9,10 @@ class context{ } @Component export struct Navigation4 { - private controller:ESObject; - private navPathStack:ESObject - private context=new context() + @Consume('navPathStack') navPathStack: NavPathStack; + private controller: WebviewController = new webview.WebviewController; + private context = this.getUIContext().getHostContext() as common.UIAbilityContext; + build() { // [Start path_stack1] Navigation(this.navPathStack) { diff --git a/entry/src/main/ets/pages/Navigation4.ets b/entry/src/main/ets/pages/Navigation4.ets index e152231..7cce897 100644 --- a/entry/src/main/ets/pages/Navigation4.ets +++ b/entry/src/main/ets/pages/Navigation4.ets @@ -1,17 +1,27 @@ import { photoAccessHelper } from "@kit.MediaLibraryKit"; import { BusinessError } from "@kit.BasicServicesKit"; +import { webview } from "@kit.ArkWeb"; +import { Constants } from "../common/Constants"; +import { OriginPage } from "./OriginPage"; @Component export struct Navigation5 { - private PageMap:ESObject; - private controller:ESObject; - private navPathStack:ESObject + @Consume('navPathStack') navPathStack: NavPathStack; + private controller: WebviewController = new webview.WebviewController; + + @Builder + PageMap(name: string) { + if (name === Constants.ORIGIN_PAGE) { + OriginPage() + } + } + build() { // [Start path_stack2] Navigation(this.navPathStack) { Column() { Web({ - src: $rawfile('index3.html'), + src: $rawfile('index.html'), controller: this.controller }) .zoomAccess(false) diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index e464848..35b94c9 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -1,17 +1,22 @@ +// [Start deep_link_json] { "module": { + // [StartExclude deep_link_json] "name": "entry", "type": "entry", "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone" + "phone", + "tablet" ], "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + // [EndExclude deep_link_json] "abilities": [ { + // [StartExclude deep_link_json] "name": "EntryAbility", "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", @@ -20,7 +25,9 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", "exported": true, + // [EndExclude deep_link_json] "skills": [ + // [StartExclude deep_link_json] { "entities": [ "entity.system.home" @@ -28,22 +35,28 @@ "actions": [ "action.system.home" ] + }, + // [EndExclude deep_link_json] + { + "entities": [ + "entity.system.browsable" + ], + "actions": [ + "ohos.want.action.viewData" + ], + "uris": [ + { + "scheme": "appScheme", + "host": "www.test.com", + "port": "80", + "path": "path1" + } + ] } ] } ], - "requestPermissions": [ - { - "name": "ohos.permission.DISTRIBUTED_DATASYNC", - "reason": "$string:distributed_permission", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - "when": "inuse" - } - } - ], + // [StartExclude deep_link_json] "extensionAbilities": [ { "name": "EntryBackupAbility", @@ -58,10 +71,7 @@ ], } ], - // [Start query_schemes] - "querySchemes": [ - "app1Scheme" - ], - // [End query_schemes] + // [EndExclude deep_link_json] } -} \ No newline at end of file +} +// [End deep_link_json] \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/index.html b/entry/src/main/resources/rawfile/index.html new file mode 100644 index 0000000..fe0368f --- /dev/null +++ b/entry/src/main/resources/rawfile/index.html @@ -0,0 +1,10 @@ + + + + + + Document + + + + -- Gitee From 519e63770d167cecddf178ef3cdfe55986c0d7dd Mon Sep 17 00:00:00 2001 From: tongzihan <15671769870@163.com> Date: Thu, 10 Jul 2025 19:54:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/module.json5 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 35b94c9..aa0ca22 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -7,8 +7,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet" + "phone" ], "deliveryWithInstall": true, "installationFree": false, -- Gitee