diff --git a/entry/build/default/intermediates/res/default/resources/rawfile/index.html b/entry/build/default/intermediates/res/default/resources/rawfile/index.html new file mode 100644 index 0000000000000000000000000000000000000000..d5f13d0f284118c67e3e79c4ee956006624a1f21 --- /dev/null +++ b/entry/build/default/intermediates/res/default/resources/rawfile/index.html @@ -0,0 +1,45 @@ + + + + + + Document + + + + +
+
+
+ +
+ + Web 页面 +
+
Hello Web
+ 跳转回Web页面 + // [Start example1] + 跳转到其他页面 + // [End example1] + // [Start origin_page] + 跳转到ArkTS页面 + // [End origin_page] + // [Start detail1] + 去应用市场下载 + 打开应用 + // [End detail1] + // [Start pull_special] + 拉起指定类型应用 + // [End pull_special] + // [Start select_photo] + 拉起系统应用 + // [End select_photo] +
+ + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..b2bef50c772c2fa241dffd3b936e36cc8fd1b2e3 --- /dev/null +++ b/entry/build/default/intermediates/res/default/resources/rawfile/index1_cn.html @@ -0,0 +1,30 @@ + + + + + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..211cdee9d6cd59726f134dd8235f2ae162b5d44e --- /dev/null +++ b/entry/build/default/intermediates/res/default/resources/rawfile/index1_en.html @@ -0,0 +1,29 @@ + + + + + + Document + + + +
+
+
+ +
+ + Web Page +
+
Hello Web
+ Navigate back to the Web page +
+ + + diff --git a/entry/build/default/intermediates/res/default/resources/rawfile/index2.html b/entry/build/default/intermediates/res/default/resources/rawfile/index2.html new file mode 100644 index 0000000000000000000000000000000000000000..7ff3f835fbf9cb8e4fa8386ec95ad728fec169d8 --- /dev/null +++ b/entry/build/default/intermediates/res/default/resources/rawfile/index2.html @@ -0,0 +1,30 @@ + + + + + + Document + + + + +
+
+
+ +
+ + Web 页面 +
+
Hello Web
+ 跳转回Web页面 +
+ + + diff --git a/entry/build/default/intermediates/res/default/resources/rawfile/index3.html b/entry/build/default/intermediates/res/default/resources/rawfile/index3.html new file mode 100644 index 0000000000000000000000000000000000000000..7ff3f835fbf9cb8e4fa8386ec95ad728fec169d8 --- /dev/null +++ b/entry/build/default/intermediates/res/default/resources/rawfile/index3.html @@ -0,0 +1,30 @@ + + + + + + Document + + + + +
+
+
+ +
+ + Web 页面 +
+
Hello Web
+ 跳转回Web页面 +
+ + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..f72d09ccef82ea00ccebbfd66ef1d435fe7ca4bc --- /dev/null +++ b/entry/build/default/intermediates/res/default/resources/rawfile/index_cn.html @@ -0,0 +1,36 @@ + + + + + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..cd0bccff2b53e2eae681f6df91c4907c52463f1c --- /dev/null +++ b/entry/build/default/intermediates/res/default/resources/rawfile/index_en.html @@ -0,0 +1,38 @@ + + + + + + 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 be9dc3ac02f3d30427ddf44bfdeba26bda8d5a10..7068246d41dbf4531923dbac6b4f5dc6df7cd772 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -133,7 +133,6 @@ struct Index { } build() { - // [Start navigation] Navigation(this.navPathStack) { Column() { Web({ @@ -149,9 +148,8 @@ struct Index { }) } } - // [End navigation] .hideTitleBar(true) .navDestination(this.PageMap) .mode(NavigationMode.Stack) } -} \ No newline at end of file +} diff --git a/entry/src/main/ets/pages/Navigation.ets b/entry/src/main/ets/pages/Navigation.ets new file mode 100644 index 0000000000000000000000000000000000000000..805e17010090647caa40dcef76cdb97f06dfb791 --- /dev/null +++ b/entry/src/main/ets/pages/Navigation.ets @@ -0,0 +1,21 @@ +@Component +export struct Navigation1 { + @Consume('navPathStack') navPathStack: NavPathStack; + + build() { + // [Start navigation] + NavDestination() { + Column() { + Button($r('app.string.back_to_web_page')) + .width('100%') + .height(40) + .onClick(() => { + this.navPathStack.pushPath({ name: 'WebPage' }); + }) + } + // ... + } + .title('ArkTS页面') + // [End navigation] + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Navigation1.ets b/entry/src/main/ets/pages/Navigation1.ets new file mode 100644 index 0000000000000000000000000000000000000000..348fe0d50b41a0ec3a13adfa32ae80746b600294 --- /dev/null +++ b/entry/src/main/ets/pages/Navigation1.ets @@ -0,0 +1,32 @@ +class PathStack{ + pop(){ + return + } +} +@Component +export struct Navigation2 { + private controller:ESObject; + private navPathStack=new PathStack() +build() { + // [Start navigation1] + NavDestination() { + Column() { + Web({ + src: $rawfile('index.html'), + controller: this.controller + }) + .zoomAccess(false) + .onLoadIntercept((event) => { + const url: string = event.data.getRequestUrl(); + if (url === 'arkts://pages/toOriginPage') { + this.navPathStack.pop(); + } + // [StartExclude navigation1] + return false; + // [EndExclude navigation1] + }) + } + } + // [End navigation1] + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Navigation2.ets b/entry/src/main/ets/pages/Navigation2.ets new file mode 100644 index 0000000000000000000000000000000000000000..c83bc3f1f31f69785af2066993ff56527c6f3cb1 --- /dev/null +++ b/entry/src/main/ets/pages/Navigation2.ets @@ -0,0 +1,49 @@ +import { bundleManager, OpenLinkOptions } from "@kit.AbilityKit"; +import { BusinessError } from "@kit.BasicServicesKit"; +// [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; + build() { + // [Start link3] + Navigation(this.navPathStack) { + Column() { + Web({ + src: $rawfile('index2.html'), + controller: this.controller + }) + .zoomAccess(false) + .onLoadIntercept((event) => { + const url: string = event.data.getRequestUrl(); + if (url === 'third-party://pages/toThirdApp') { + const link: string = "appScheme://www.test.com:80/path1"; + // [Start link2] + if (!bundleManager.canOpenLink(link)) { + return true; + } + // [End link1] + // Configuration parameter. + const openLinkOptions: OpenLinkOptions = { + appLinkingOnly: false, + parameters: { + name: 'test' + } + }; + // Open the application using the openLink interface. + this.context.openLink(link, openLinkOptions).then(() => { + console.info('open link success.'); + }).catch((err: BusinessError) => { + console.error(`open link failed. Code is ${err.code}, message is ${err.message}`); + }) + } + return url !== 'resource://rawfile/index2.html'; + }) + } + } + // [End link3] + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Navigation3.ets b/entry/src/main/ets/pages/Navigation3.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e658f935c9ef1692b591aba2f013316427013c4 --- /dev/null +++ b/entry/src/main/ets/pages/Navigation3.ets @@ -0,0 +1,60 @@ +import { hilog } from "@kit.PerformanceAnalysisKit"; +import { common } from "@kit.AbilityKit"; + +class context{ + startAbilityByType(name:string,a:ESObject,b:ESObject){ + return + } +} +@Component +export struct Navigation4 { + private controller:ESObject; + private navPathStack:ESObject + private context=new context() + build() { + // [Start path_stack1] + Navigation(this.navPathStack) { + Column() { + Web({ + src: $rawfile('index.html'), + controller: this.controller + }) + .zoomAccess(false) + .onLoadIntercept((event) => { + const url: string = event.data.getRequestUrl(); + if (url === 'arkts://pullSpeciallyApp') { + const wantParam: Record = { + 'sceneType': 1, + 'destinationLatitude': 32.060844, + 'destinationLongitude': 118.78315, + 'destinationName': 'xx市xx路xx号', + 'destinationPoiIds': { + 1: '111111111111', + 2: '222222222222' + } as Record, + 'originName': 'xx市xx公园', + 'originLatitude': 31.060844, + 'originLongitude': 120.78315, + 'originPoiIds': { + 1: '333333333333', + 2: '444444444444' + } as Record, + 'vehicleType': 0 + }; + const abilityStartCallback: common.AbilityStartCallback = { + onError: (code: number, name: string, message: string) => { + hilog.error(0x0000, 'Sample', '%{public}s', 'onError code ' + code + 'name: ' + name + 'message: ' + message); + }, + onResult: (result:ESObject) => { + hilog.error(0x0000, 'Sample', '%{public}s', 'onResult result: ' + JSON.stringify(result)); + } + }; + this.context.startAbilityByType('navigation', wantParam, abilityStartCallback); + } + return url !== 'resource://rawfile/index.html'; + }) + } + } + // [End path_stack1] + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Navigation4.ets b/entry/src/main/ets/pages/Navigation4.ets new file mode 100644 index 0000000000000000000000000000000000000000..e15223175c8cc8a0378f7b8e17e2c746adc77ba4 --- /dev/null +++ b/entry/src/main/ets/pages/Navigation4.ets @@ -0,0 +1,43 @@ +import { photoAccessHelper } from "@kit.MediaLibraryKit"; +import { BusinessError } from "@kit.BasicServicesKit"; + +@Component +export struct Navigation5 { + private PageMap:ESObject; + private controller:ESObject; + private navPathStack:ESObject + build() { + // [Start path_stack2] + Navigation(this.navPathStack) { + Column() { + Web({ + src: $rawfile('index3.html'), + controller: this.controller + }) + .zoomAccess(false) + .onLoadIntercept((event) => { + const url: string = event.data.getRequestUrl(); + if (url === 'photo://pages/selectPhoto') { + const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions(); + photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGE + photoSelectOptions.maxSelectNumber = 5; // 选择媒体文件的最大数目 + let uris: Array = []; + const photoViewPicker = new photoAccessHelper.PhotoViewPicker(); + photoViewPicker.select(photoSelectOptions) + .then((photoSelectResult: photoAccessHelper.PhotoSelectResult) => { + uris = photoSelectResult.photoUris; + console.info('photoViewPicker.select to file succeed and uris are:' + uris); + }) + .catch((err: BusinessError) => { + console.error(`Invoke photoViewPicker.select failed, code is ${err.code}, message is ${err.message}`); + }) + } + return url !== 'resource://rawfile/index3.html'; + }) + } + } + .hideTitleBar(true) + .navDestination(this.PageMap) + // [End path_stack2] + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 82d268eae8327993fb9e61ae87e6148726ff73b2..e464848cd376bb91ba16fdf92bac3fc89a71ac41 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -58,8 +58,10 @@ ], } ], + // [Start query_schemes] "querySchemes": [ "app1Scheme" ], + // [End query_schemes] } } \ 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..d5f13d0f284118c67e3e79c4ee956006624a1f21 --- /dev/null +++ b/entry/src/main/resources/rawfile/index.html @@ -0,0 +1,45 @@ + + + + + + Document + + + + +
+
+
+ +
+ + Web 页面 +
+
Hello Web
+ 跳转回Web页面 + // [Start example1] + 跳转到其他页面 + // [End example1] + // [Start origin_page] + 跳转到ArkTS页面 + // [End origin_page] + // [Start detail1] + 去应用市场下载 + 打开应用 + // [End detail1] + // [Start pull_special] + 拉起指定类型应用 + // [End pull_special] + // [Start select_photo] + 拉起系统应用 + // [End select_photo] +
+ + + diff --git a/entry/src/main/resources/rawfile/index2.html b/entry/src/main/resources/rawfile/index2.html new file mode 100644 index 0000000000000000000000000000000000000000..7ff3f835fbf9cb8e4fa8386ec95ad728fec169d8 --- /dev/null +++ b/entry/src/main/resources/rawfile/index2.html @@ -0,0 +1,30 @@ + + + + + + Document + + + + +
+
+
+ +
+ + Web 页面 +
+
Hello Web
+ 跳转回Web页面 +
+ + + diff --git a/entry/src/main/resources/rawfile/index3.html b/entry/src/main/resources/rawfile/index3.html new file mode 100644 index 0000000000000000000000000000000000000000..7ff3f835fbf9cb8e4fa8386ec95ad728fec169d8 --- /dev/null +++ b/entry/src/main/resources/rawfile/index3.html @@ -0,0 +1,30 @@ + + + + + + Document + + + + +
+
+
+ +
+ + Web 页面 +
+
Hello Web
+ 跳转回Web页面 +
+ + +