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 b2bef50c772c2fa241dffd3b936e36cc8fd1b2e3..0000000000000000000000000000000000000000 --- 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 211cdee9d6cd59726f134dd8235f2ae162b5d44e..0000000000000000000000000000000000000000 --- 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 f72d09ccef82ea00ccebbfd66ef1d435fe7ca4bc..0000000000000000000000000000000000000000 --- 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 cd0bccff2b53e2eae681f6df91c4907c52463f1c..0000000000000000000000000000000000000000 --- 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 99cfbd7e0eea67712f7ca2b638d347493c680c40..9401ceb6bf78b94d5d47e03995ab5beb9cf9c512 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 348fe0d50b41a0ec3a13adfa32ae80746b600294..6cb1651467e8a471d7906c393d8498952b44ac3a 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 c7f674dfb1966ae650addfa3939f7fe44aacbb3f..9b12d0964b50432873d7ea71f6b52592d17f7835 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 3e658f935c9ef1692b591aba2f013316427013c4..4f47e78b43e1cedfdeef8e06b230840120f8d676 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 e15223175c8cc8a0378f7b8e17e2c746adc77ba4..7cce897d536f7f0f79266b020c37d9eceee69f1b 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 e464848cd376bb91ba16fdf92bac3fc89a71ac41..aa0ca22fb3a9aa6b1c18db03ef8f3bc14dbf18fa 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -1,5 +1,7 @@ +// [Start deep_link_json] { "module": { + // [StartExclude deep_link_json] "name": "entry", "type": "entry", "description": "$string:module_desc", @@ -10,8 +12,10 @@ "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 +24,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 +34,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 +70,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 0000000000000000000000000000000000000000..fe0368ff0b6852c3ed608f565d2c7085221a5aa1 --- /dev/null +++ b/entry/src/main/resources/rawfile/index.html @@ -0,0 +1,10 @@ + + + + + + Document + + + +