diff --git a/ComponentReuse/entry/src/main/ets/pages/Index.ets b/ComponentReuse/entry/src/main/ets/pages/Index.ets index 55f519f4bc74c95be1b8367563a4a70fba24a906..50a8dc29f666bc363582aa5e0af2eecd7e36d8bc 100644 --- a/ComponentReuse/entry/src/main/ets/pages/Index.ets +++ b/ComponentReuse/entry/src/main/ets/pages/Index.ets @@ -66,7 +66,7 @@ struct Index { .height(Constants.LAYOUT_MAX) .width(Constants.LAYOUT_MAX) .backgroundColor('#F1F3F5') - .padding({ top: px2vp(this.topRectHeight) }) + .padding({ top: this.getUIContext().px2vp(this.topRectHeight) }) } @Builder diff --git a/CustomDialogPractice/entry/src/main/ets/pages/CustomDialogDisplayAndExitAnimations.ets b/CustomDialogPractice/entry/src/main/ets/pages/CustomDialogDisplayAndExitAnimations.ets index 8cd016df21300a395060b3e6ea270d8b33d673db..2b889d2839f33f771542181e398067de67e49ae3 100644 --- a/CustomDialogPractice/entry/src/main/ets/pages/CustomDialogDisplayAndExitAnimations.ets +++ b/CustomDialogPractice/entry/src/main/ets/pages/CustomDialogDisplayAndExitAnimations.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -// DocsCode 1 +// [Start CustomDialogDisplayAndExitAnimations_start] import { PromptAction } from '@kit.ArkUI'; @Component @@ -105,5 +105,4 @@ export struct CustomDialogDisplayAndExitAnimations { } } } - -// DocsCode 1 \ No newline at end of file +// [End CustomDialogDisplayAndExitAnimations_start] \ No newline at end of file diff --git a/CustomDialogPractice/entry/src/main/ets/pages/CustomDialogNotDisappear.ets b/CustomDialogPractice/entry/src/main/ets/pages/CustomDialogNotDisappear.ets index 6da504fa756717d38867c79dfcd5afaf336e0edb..d4cd913b0d5c952571fa4b3e2240701b44b8e24e 100644 --- a/CustomDialogPractice/entry/src/main/ets/pages/CustomDialogNotDisappear.ets +++ b/CustomDialogPractice/entry/src/main/ets/pages/CustomDialogNotDisappear.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -// DocsCode 1 +// [Start CustomDialogNotDisappear_start] @Component export struct CustomDialogNotDisappear { @Consume('NavPathStack') pageStack: NavPathStack; @@ -141,5 +141,4 @@ export struct PageOne { .hideTitleBar(true) } } - -// DocsCode 1 \ No newline at end of file +// [End CustomDialogNotDisappear_start] \ No newline at end of file diff --git a/CustomDialogPractice/entry/src/main/ets/pages/GlobalDialogDecoupledFromThePage.ets b/CustomDialogPractice/entry/src/main/ets/pages/GlobalDialogDecoupledFromThePage.ets index a1d2190cf714b006f8dd591186371b6ff1835dad..97dce1327aa4285d05579e536fda2a2776fd69a8 100644 --- a/CustomDialogPractice/entry/src/main/ets/pages/GlobalDialogDecoupledFromThePage.ets +++ b/CustomDialogPractice/entry/src/main/ets/pages/GlobalDialogDecoupledFromThePage.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -// DocsCode 1 +// [Start PromptActionClass_open] import { PromptActionClass } from '../uitls/PromptActionClass'; import { ComponentContent } from '@kit.ArkUI'; @@ -110,5 +110,4 @@ export struct GlobalDialogDecoupledFromThePage { } } } - -// DocsCode 1 \ No newline at end of file +// [End PromptActionClass_open] \ No newline at end of file diff --git a/CustomDialogPractice/entry/src/main/ets/pages/InterceptReturn01.ets b/CustomDialogPractice/entry/src/main/ets/pages/InterceptReturn01.ets index 20e4351c2de25221dd99313d9718d948347a424b..506474473fce3b2c09a807d3344e816ef6caf167 100644 --- a/CustomDialogPractice/entry/src/main/ets/pages/InterceptReturn01.ets +++ b/CustomDialogPractice/entry/src/main/ets/pages/InterceptReturn01.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -// DocsCode 1 +// [Start InterceptReturn01_start] import { PromptAction } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; @@ -104,5 +104,4 @@ export struct InterceptReturn01 { } } } - -// DocsCode 1 \ No newline at end of file +// [End InterceptReturn01_start] \ No newline at end of file diff --git a/CustomDialogPractice/entry/src/main/ets/pages/InterceptReturn02.ets b/CustomDialogPractice/entry/src/main/ets/pages/InterceptReturn02.ets index d8d49ee8bc41b4965f9c0ac90fa8a4567d585040..5019452b4168b569a8707bd6495ac4f427ee7704 100644 --- a/CustomDialogPractice/entry/src/main/ets/pages/InterceptReturn02.ets +++ b/CustomDialogPractice/entry/src/main/ets/pages/InterceptReturn02.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -// DocsCode 1 +// [Start InterceptReturn02_start] @Component export struct InterceptReturn02 { @Consume('NavPathStack') pageStack: NavPathStack; @@ -104,5 +104,4 @@ export struct DialogPage1 { .borderColor(Color.White) } } - -// DocsCode 1 \ No newline at end of file +// [End InterceptReturn02_start] \ No newline at end of file diff --git a/CustomDialogPractice/entry/src/main/ets/uitls/PromptActionClass.ets b/CustomDialogPractice/entry/src/main/ets/uitls/PromptActionClass.ets index 9bcc58ab8ec7e8b5398be23767e77091bd25d092..2787af24313e8519f95905b0382c4167c5f9bc68 100644 --- a/CustomDialogPractice/entry/src/main/ets/uitls/PromptActionClass.ets +++ b/CustomDialogPractice/entry/src/main/ets/uitls/PromptActionClass.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -// DocsCode 1 +// [Start PromptActionClass_start] import { BusinessError } from '@kit.BasicServicesKit'; import { ComponentContent, promptAction } from '@kit.ArkUI'; import { UIContext } from '@ohos.arkui.UIContext'; @@ -66,5 +66,4 @@ export class PromptActionClass { } } } - -// DocsCode 1 \ No newline at end of file +// [End PromptActionClass_start] \ No newline at end of file diff --git a/DealStrideSolution/entry/src/main/ets/pages/PageOne.ets b/DealStrideSolution/entry/src/main/ets/pages/PageOne.ets index 35631465a6b4203591bb1bb05ab37839d0f8deaa..d3402dd15595919abe5f8c3758e71648b330bac3 100644 --- a/DealStrideSolution/entry/src/main/ets/pages/PageOne.ets +++ b/DealStrideSolution/entry/src/main/ets/pages/PageOne.ets @@ -95,8 +95,8 @@ export struct PageOne { Column() { if (this.isShowStridePixel) { Image(this.stridePixel) - .width(px2vp(this.imageWidth)) - .height(px2vp(this.imageHeight)) + .width(this.getUIContext().px2vp(this.imageWidth)) + .height(this.getUIContext().px2vp(this.imageHeight)) .margin({ top: 150 }) .rotate({ z: 0.5, diff --git a/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets b/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets index cbced5a3d71976955aa86919b75b43d79e2c8a25..df3b602cc17a056430052c42d895da9f7d560c98 100644 --- a/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets +++ b/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets @@ -23,6 +23,7 @@ export function PageThreeBuilder() { PageThree() } +// [Start PageThree_start] @Component export struct PageThree { pathStack: NavPathStack = new NavPathStack(); @@ -45,6 +46,7 @@ export struct PageThree { CameraService.releaseCamera(); } + // [StartExclude PageThree_start] @Builder navDestinationTitleImg(res:Resource,fun:()=>void) { Image(res) @@ -89,22 +91,27 @@ export struct PageThree { .backgroundColor('#F1F3F5') } + // [EndExclude PageThree_start] build() { NavDestination() { + // [StartExclude PageThree_start] this.navDestinationTitle() + // [EndExclude PageThree_start] Column() { if (this.isShowStridePixel) { Image(this.stridePixel) - .width(px2vp(this.imageWidth)) - .height(px2vp(this.imageHeight)) + .width(this.getUIContext().px2vp(this.imageWidth)) + .height(this.getUIContext().px2vp(this.imageHeight)) .margin({ top: 150 }) .rotate({ z: 0.5, angle: this.previewRotate }) } + // [StartExclude PageThree_start] Blank() PublishView() + // [EndExclude PageThree_start] } .justifyContent(FlexAlign.Center) .height('90%') @@ -121,6 +128,7 @@ export struct PageThree { }) } } +// [End PageThree_start] // Share components at the bottom of the page @Component diff --git a/DealStrideSolution/entry/src/main/ets/pages/PageTwo.ets b/DealStrideSolution/entry/src/main/ets/pages/PageTwo.ets index 1362df013096288587c6fe61d13d6216044fc6a6..209a1193c7ae665dc9123aea185e4a635ecef8de 100644 --- a/DealStrideSolution/entry/src/main/ets/pages/PageTwo.ets +++ b/DealStrideSolution/entry/src/main/ets/pages/PageTwo.ets @@ -95,8 +95,8 @@ export struct PageTwo { Column() { if (this.isShowStridePixel) { Image(this.stridePixel) - .width(px2vp(this.imageWidth)) - .height(px2vp(this.imageHeight)) + .width(this.getUIContext().px2vp(this.imageWidth)) + .height(this.getUIContext().px2vp(this.imageHeight)) .margin({ top: 150 }) .rotate({ z: 0.5, diff --git a/DealStrideSolution/entry/src/main/ets/utils/CameraServiceOne.ets b/DealStrideSolution/entry/src/main/ets/utils/CameraServiceOne.ets index 76ab4bd3c0e30d1aafedcb04821afe3ef6937754..ef8d2f23c9c3785600b841d5a81090c840915f10 100644 --- a/DealStrideSolution/entry/src/main/ets/utils/CameraServiceOne.ets +++ b/DealStrideSolution/entry/src/main/ets/utils/CameraServiceOne.ets @@ -43,13 +43,20 @@ class CameraService { }; surfaceId: string = ''; + // [Start onImageArrival_start] + // [Start Case1_start] + // [Start Case2_start] onImageArrival(receiver: image.ImageReceiver): void { + // [StartExclude Case1_start] + // [StartExclude Case2_start] receiver.on('imageArrival', () => { receiver.readNextImage((err: BusinessError, nextImage: image.Image) => { if (err || nextImage === undefined) { Logger.error(TAG, `requestPermissionsFromUser call Failed! error: ${err.code}`); return; } + // [EndExclude Case2_start] + // [EndExclude Case1_start] if (nextImage) { nextImage.getComponent(image.ComponentType.JPEG, async (err, component: image.Component) => { @@ -92,6 +99,9 @@ class CameraService { }); }) } + // [End Case2_start] + // [End Case1_start] + // [End onImageArrival_start] getPreviewProfile(cameraOutputCapability: camera.CameraOutputCapability): camera.Profile | undefined { let previewProfiles = cameraOutputCapability.previewProfiles; diff --git a/FramedRendering/entry/src/main/ets/pages/Index.ets b/FramedRendering/entry/src/main/ets/pages/Index.ets index 9d43b2b28947ac1a341b3cce1ff0a498598b0ddc..edc269962b480e67f5805f1b4baecbbf3e59a83d 100644 --- a/FramedRendering/entry/src/main/ets/pages/Index.ets +++ b/FramedRendering/entry/src/main/ets/pages/Index.ets @@ -38,7 +38,7 @@ struct Index { this.pageStack.pushPathByName(CommonConstants.NAV_DESTINATION_ITEM_1, ''); }) } - .padding({ left: 16, right: 16, bottom: (16 + px2vp(this.bottomHeight)) }) + .padding({ left: 16, right: 16, bottom: (16 + this.getUIContext().px2vp(this.bottomHeight)) }) .justifyContent(FlexAlign.End) .alignItems(HorizontalAlign.Center) .width(CommonConstants.FULL_PERCENT) @@ -49,7 +49,7 @@ struct Index { height: 112 }) .navDestination(this.PagesMap) - .padding({ top: px2vp(this.topRectHeight) }) + .padding({ top: this.getUIContext().px2vp(this.topRectHeight) }) .backgroundColor('#F1F3F5') } diff --git a/FuzzySceneOptimization/entry/src/main/ets/pages/MotionBlur.ets b/FuzzySceneOptimization/entry/src/main/ets/pages/MotionBlur.ets index 204041228b5707952f68bc9301d7a007fe3f7328..9ff5d43226c7c6e4a9705a05b525704611c5fbbf 100644 --- a/FuzzySceneOptimization/entry/src/main/ets/pages/MotionBlur.ets +++ b/FuzzySceneOptimization/entry/src/main/ets/pages/MotionBlur.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start dynamic_start] import { window } from '@kit.ArkUI'; @Component @@ -28,7 +29,7 @@ export struct MotionBlur { } // get the height of the bottom navigation bar this.bottomSafeHeight = - px2vp(windowBar.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height); + this.getUIContext().px2vp(windowBar.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height); windowBar.setWindowLayoutFullScreen(true); }); } @@ -74,4 +75,5 @@ export struct MotionBlur { } .hideTitleBar(true) } -} \ No newline at end of file +} +// [End dynamic_start] \ No newline at end of file diff --git a/FuzzySceneOptimization/entry/src/main/ets/pages/StaticBlur.ets b/FuzzySceneOptimization/entry/src/main/ets/pages/StaticBlur.ets index 515439f7fc706222a7e6e9455b365e97ff4e3015..224a1b8e3c9553851613c1b85237a0e9b3e6792a 100644 --- a/FuzzySceneOptimization/entry/src/main/ets/pages/StaticBlur.ets +++ b/FuzzySceneOptimization/entry/src/main/ets/pages/StaticBlur.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start static_start] import { image } from '@kit.ImageKit'; import { effectKit } from '@kit.ArkGraphics2D'; import { window } from '@kit.ArkUI'; @@ -32,7 +33,7 @@ export struct StaticBlur { } // get the height of the bottom navigation bar this.bottomSafeHeight = - px2vp(windowBar.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height); + this.getUIContext().px2vp(windowBar.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height); windowBar.setWindowLayoutFullScreen(true); }); } @@ -108,4 +109,5 @@ export struct StaticBlur { } .hideTitleBar(true) } -} \ No newline at end of file +} +// [End static_start] \ No newline at end of file diff --git a/ImageEditTaskPool/entry/src/main/ets/entryability/EntryAbility.ets b/ImageEditTaskPool/entry/src/main/ets/entryability/EntryAbility.ets index 277bacf40cb22d616fdb360e04391f054d057b9c..a45e4df3aec690dab77039368e800288064e58fa 100644 --- a/ImageEditTaskPool/entry/src/main/ets/entryability/EntryAbility.ets +++ b/ImageEditTaskPool/entry/src/main/ets/entryability/EntryAbility.ets @@ -65,8 +65,8 @@ export default class EntryAbility extends UIAbility { let navigationBarArea: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); let area: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - AppStorage.setOrCreate('naviIndicatorHeight', px2vp(navigationBarArea.bottomRect.height)); - AppStorage.setOrCreate('statusBarHeight', px2vp(area.topRect.height)); + AppStorage.setOrCreate('naviIndicatorHeight', this.getUIContext().px2vp(navigationBarArea.bottomRect.height)); + AppStorage.setOrCreate('statusBarHeight', this.getUIContext().px2vp(area.topRect.height)); windowStage.loadContent('pages/HomePage', (err, data) => { if (err.code) { diff --git a/ImageEditTaskPool/entry/src/main/ets/view/AdjustContentView.ets b/ImageEditTaskPool/entry/src/main/ets/view/AdjustContentView.ets index 2dfc096810ae1c0800372b410c35d75dc17df270..ab5aef38b217381b0de73c370427be680fc6662e 100644 --- a/ImageEditTaskPool/entry/src/main/ets/view/AdjustContentView.ets +++ b/ImageEditTaskPool/entry/src/main/ets/view/AdjustContentView.ets @@ -188,22 +188,28 @@ struct SliderCustom { } } + // [Start postProcess_start] async postProcess(type: AdjustId, value: number) { + // [StartExclude postProcess_start] if (!this.pixelMap) { return; } let sliderValue = type === AdjustId.BRIGHTNESS ? this.brightnessLastSlider : this.saturationLastSlider; const bufferArray = new ArrayBuffer(this.pixelMap.getPixelBytesNumber()); + // [EndExclude postProcess_start] this.pixelMap.readPixelsToBuffer(bufferArray) .then(() => { const buffers: ArrayBuffer[] = splitArrayBuffer(bufferArray, 240); const group = splitTask(buffers, type, sliderValue, value); + // [StartExclude postProcess_start] + // [Start execute_start] taskpool.execute(group, taskpool.Priority.HIGH).then((ret) => { // Combine the results of each task execution const entireArrayBuffer = mergeArrayBuffers(ret); // Update the UI based on the calculation results this.updatePixelMap(entireArrayBuffer); }); + // [End execute_start] if (this.postState) { this.deviceListDialogController.open(); } @@ -213,9 +219,10 @@ struct SliderCustom { } else { this.saturationLastSlider = Math.round(value); } + // [EndExclude postProcess_start] }) } - + // [StartExclude postProcess_start] updatePixelMap(ret: ArrayBuffer) { const newPixel = this.pixelMap as image.PixelMap; newPixel.writeBufferToPixels(ret); @@ -240,7 +247,7 @@ export struct Dialog { } } - +// [EndExclude postProcess_start] /** * Each task processes a portion of the pixel data and adds the task to the task group. * @@ -259,6 +266,7 @@ function splitTask(buffers: ArrayBuffer[], type: AdjustId, sliderValue: number, } return group; } +// [End postProcess_start] @Concurrent async function imageProcessing(args: ImageProcessing) { diff --git a/LIstOptimizationBak/AppScope/app.json5 b/LIstOptimizationBak/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e67e5ca502ae680f92d7a0c37724cfd8f0e3a312 --- /dev/null +++ b/LIstOptimizationBak/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.hdc.rcp", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/LIstOptimizationBak/AppScope/resources/base/element/string.json b/LIstOptimizationBak/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e85cf1908922d1e4526e4dd077ffb2ed8aa1e497 --- /dev/null +++ b/LIstOptimizationBak/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ListOptimization" + } + ] +} diff --git a/LIstOptimizationBak/AppScope/resources/base/media/app_icon.png b/LIstOptimizationBak/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd45accb1dfd2fd0da16c732c72faa6e46b26521 Binary files /dev/null and b/LIstOptimizationBak/AppScope/resources/base/media/app_icon.png differ diff --git a/LIstOptimizationBak/build-profile.json5 b/LIstOptimizationBak/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b2cc02977d74631a63703f33a1ae6c1f94d81219 --- /dev/null +++ b/LIstOptimizationBak/build-profile.json5 @@ -0,0 +1,36 @@ +{ + "app": { + "signingConfigs": [ + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/build-profile.json5 b/LIstOptimizationBak/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b695582d3680556f4cce2ec518f65720a9413ca3 --- /dev/null +++ b/LIstOptimizationBak/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/hvigorfile.ts b/LIstOptimizationBak/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/LIstOptimizationBak/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/LIstOptimizationBak/entry/oh-package.json5 b/LIstOptimizationBak/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/LIstOptimizationBak/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/LIstOptimizationBak/entry/src/main/ets/component/ReusableArticleCardView.ets b/LIstOptimizationBak/entry/src/main/ets/component/ReusableArticleCardView.ets new file mode 100644 index 0000000000000000000000000000000000000000..38c340cf23e1f58f46b50d137420936eb0f73070 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/component/ReusableArticleCardView.ets @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LearningResource } from '../model/LearningResource'; + +// DocsCode 1 +@Component +@Reusable +export struct ReusableArticleCardView { + @Prop articleItem: LearningResource = new LearningResource(); + @Prop isCollected: boolean = false; + @Prop isLiked: boolean = false; + onCollected?: () => void; + onLiked?: () => void; + + aboutToReuse(params: Record): void { + this.onCollected = params.onCollected as () => void; + this.onLiked = params.onLiked as () => void; + } + + build() { + // DocsDot + Row({ space: 16 }) { + Column() { + Column() { + Text(this.articleItem.title) + .fontSize($r('app.float.md_font_size')) + .fontFamily('HarmonyHeiTi') + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .opacity(0.9) + .maxLines(2) + .margin({ bottom: $r('app.float.xs_padding_margin') }) + + Text(this.articleItem.brief) + .fontSize($r('app.float.sm_font_size')) + .fontFamily('HarmonyHeiTi') + .opacity(0.6) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .textAlign(TextAlign.Start) + } + .alignItems(HorizontalAlign.Start) + .layoutWeight(1) + + Row() { + ActionButtonBuilder( + $r('app.media.ic_eye_open'), + this.articleItem.viewsCount, + $r('app.float.view_count_icon_width') + ) + + ActionButtonBuilder( + this.isLiked ? $r('app.media.btn_good_on') : $r('app.media.btn_good_normal'), + this.articleItem.likesCount, + $r('app.float.like_icon_width') + ) + + ActionButtonBuilder( + this.isCollected ? $r('app.media.btn_favorites_on') : $r('app.media.btn_favorites_normal'), + this.articleItem.collectionCount, + $r('app.float.star_icon_width') + ) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + } + .layoutWeight(1) + .height('100%') + .justifyContent(FlexAlign.SpaceAround) + + Image(this.articleItem.headerImageUrl) + .interpolation(ImageInterpolation.High) + .height($r('app.float.article_card_image_height')) + .width($r('app.float.article_card_image_width')) + .borderRadius($r('app.float.md_border_radius')) + .alt($r('app.media.img_placeholder')) + .objectFit(ImageFit.Cover) + } + .padding($r('app.float.md_padding_margin')) + .borderRadius($r('app.float.lg_border_radius')) + .backgroundColor(Color.White) + .alignItems(VerticalAlign.Top) + .width('100%') + .height($r('app.float.article_card_height')) + // DocsDot + } +} +// DocsCode 1 + +@Builder +function ActionButtonBuilder(imgResource: Resource, count: number, textWidth: Resource) { + Row() { + Image(imgResource) + .size({ width: 16, height: 16 }) + .margin({ right: $r('app.float.action_button_margin_right') }) + Text(count.toString()) + .fontFamily('HarmonyHeiTi') + .fontSize($r('app.float.small_text_size')) + .width(textWidth) + .opacity(0.6) + } + .width($r('app.float.action_button_width')) + .padding({ top: $r('app.float.small_padding') }) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + +} + diff --git a/LIstOptimizationBak/entry/src/main/ets/components/ArticleCardView.ets b/LIstOptimizationBak/entry/src/main/ets/components/ArticleCardView.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c4fa2cd7d396358aafd936ac06b8b53568e4b97 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/components/ArticleCardView.ets @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { SongInfoItem } from '../model/LearningResource'; + +@Component +export struct ArticleCardView { + @Prop articleItem: SongInfoItem; + @Prop isCollected: boolean = false; + @Prop isLiked: boolean = false; + + build() { + Row({ space: 16 }) { + Column() { + Column() { + Text($r('app.string.reusable_article_cardView_title')) + .fontSize($r('app.float.md_font_size')) + .fontFamily('HarmonyHeiTi') + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .opacity(0.9) + .maxLines(2) + .margin({ bottom: $r('app.float.xs_padding_margin') }) + + Text($r('app.string.reusable_article_cardView_content')) + .fontSize($r('app.float.sm_font_size')) + .fontFamily('HarmonyHeiTi') + .opacity(0.6) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .textAlign(TextAlign.Start) + } + .alignItems(HorizontalAlign.Start) + .layoutWeight(1) + + Row() { + ActionButtonBuilder( + $r('app.media.ic_eye_open'), + 130, + $r('app.float.view_count_icon_width') + ) + + ActionButtonBuilder( + this.isLiked ? $r('app.media.btn_good_on') : $r('app.media.btn_good_normal'), + 43, + $r('app.float.like_icon_width') + ) + + ActionButtonBuilder( + this.isCollected ? $r('app.media.btn_favorites_on') : $r('app.media.btn_favorites_normal'), + 25, + $r('app.float.star_icon_width') + ) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + } + .layoutWeight(1) + .height('100%') + .justifyContent(FlexAlign.SpaceAround) + + Image(this.articleItem.cachedImage) + .interpolation(ImageInterpolation.High) + .height($r('app.float.article_card_image_height')) + .width($r('app.float.article_card_image_width')) + .borderRadius($r('app.float.md_border_radius')) + .alt($r('app.media.img_placeholder')) + .objectFit(ImageFit.Cover) + } + .padding($r('app.float.md_padding_margin')) + .borderRadius($r('app.float.lg_border_radius')) + .backgroundColor(Color.White) + .alignItems(VerticalAlign.Top) + .width('100%') + .height($r('app.float.article_card_height')) + + } +} + +@Builder +function ActionButtonBuilder(imgResource: Resource, count: number, textWidth: Resource) { + Row() { + Image(imgResource) + .size({ width: 16, height: 16 }) + .margin({ right: $r('app.float.action_button_margin_right') }) + Text(count.toString()) + .fontFamily('HarmonyHeiTi') + .fontSize($r('app.float.small_text_size')) + .width(textWidth) + .opacity(0.6) + } + .width($r('app.float.action_button_width')) + .padding({ top: $r('app.float.small_padding') }) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + +} + diff --git a/LIstOptimizationBak/entry/src/main/ets/components/CustomTabBar.ets b/LIstOptimizationBak/entry/src/main/ets/components/CustomTabBar.ets new file mode 100644 index 0000000000000000000000000000000000000000..e78db36d8f97275d06aabbff19ed554104a51b90 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/components/CustomTabBar.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AppConstants } from '../model/AppConstants'; +import { TabBarData, TabBarType, TabsInfo } from '../model/TabBarModel'; + +@Component +export struct CustomTabBar { + @Link currentIndex: TabBarType; + @StorageProp('naviIndicatorHeight') naviIndicatorHeight: number = 0; + + build() { + Flex({ + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.SpaceAround + }) { + ForEach(TabsInfo, (item: TabBarData) => { + TabItem({ + index: item.id, + selectedIndex: this.currentIndex, + }) + }, (item: TabBarData) => item.id.toString()) + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + .padding({ bottom: 20 }) + .clip(false) + .height(80) + .width(AppConstants.FULL_PERCENT) + } +} + +@Component +struct TabItem { + @Prop index: number + @Prop selectedIndex: number; + @State showAnimation: boolean = false; + onChange: (index: number) => void = () => { + }; + private mainRenderingSettings: RenderingContextSettings = new RenderingContextSettings(true); + private mainCanvasRenderingContext: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.mainRenderingSettings); + + build() { + Column() { + Image(this.selectedIndex === this.index ? + (this.showAnimation ? TabsInfo[this.index].animationIcon : TabsInfo[this.index].activeIcon) : + TabsInfo[this.index].defaultIcon) + .size(this.index === TabBarType.CHALLENGE ? + { width: $r('app.float.tab_big_img_width'), height: $r('app.float.tab_big_img_height') } : + { width: $r('app.float.tab_img_size'), height: $r('app.float.tab_img_size') }) + .margin({ top: this.index === TabBarType.CHALLENGE ? $r('app.float.tab_margin') : 0 }) + Text(TabsInfo[this.index].title) + .fontSize($r('app.float.tab_font_size')) + .margin({ top: $r('app.float.tab_title_margin') }) + .fontWeight(AppConstants.TAB_FONT_WEIGHT) + .fontColor($r('sys.color.ohos_id_color_bottom_tab_text_off')) + } + .clip(false) + .padding({ top: $r('app.float.sm_padding_margin'), bottom: $r('app.float.sm_padding_margin') }) + .layoutWeight(1) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/components/PageViewModel.ets b/LIstOptimizationBak/entry/src/main/ets/components/PageViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..dcdbddfaf5b270373e3309a698e494a31784515a --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/components/PageViewModel.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { SongInfoItem } from '../model/LearningResource'; +import { SongInfoProvider } from './SongInfoProvider' + +export class PageViewModel { + private static readonly LIST_SIZE: number = 10000; + private readonly songInfoProvider: SongInfoProvider = new SongInfoProvider(PageViewModel.LIST_SIZE); + private readonly listItems: Array; + + constructor() { + this.listItems = this.songInfoProvider.getItems(); + } + + getItems(): Array { + return this.listItems; + } +} + +const pageViewModel = new PageViewModel(); + +export default pageViewModel; \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/components/ReusableArticleCardView.ets b/LIstOptimizationBak/entry/src/main/ets/components/ReusableArticleCardView.ets new file mode 100644 index 0000000000000000000000000000000000000000..9666874692a3ce3b3d3e6ad5b901b69e20b87b88 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/components/ReusableArticleCardView.ets @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { SongInfoItem } from '../model/LearningResource'; + +@Component +@Reusable +export struct ReusableArticleCardView { + @Prop articleItem: SongInfoItem; + @Prop isCollected: boolean = false; + @Prop isLiked: boolean = false; + + build() { + Row({ space: 16 }) { + Column() { + Column() { + Text($r('app.string.reusable_article_cardView_title')) + .fontSize($r('app.float.md_font_size')) + .fontFamily('HarmonyHeiTi') + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .opacity(0.9) + .maxLines(2) + .margin({ bottom: $r('app.float.xs_padding_margin') }) + + Text($r('app.string.reusable_article_cardView_content')) + .fontSize($r('app.float.sm_font_size')) + .fontFamily('HarmonyHeiTi') + .opacity(0.6) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .textAlign(TextAlign.Start) + } + .alignItems(HorizontalAlign.Start) + .layoutWeight(1) + + Row() { + ActionButtonBuilder( + $r('app.media.ic_eye_open'), + 130, + $r('app.float.view_count_icon_width') + ) + + ActionButtonBuilder( + this.isLiked ? $r('app.media.btn_good_on') : $r('app.media.btn_good_normal'), + 43, + $r('app.float.like_icon_width') + ) + + ActionButtonBuilder( + this.isCollected ? $r('app.media.btn_favorites_on') : $r('app.media.btn_favorites_normal'), + 25, + $r('app.float.star_icon_width') + ) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + } + .layoutWeight(1) + .height('100%') + .justifyContent(FlexAlign.SpaceAround) + + Image(this.articleItem.cachedImage) + .interpolation(ImageInterpolation.High) + .height($r('app.float.article_card_image_height')) + .width($r('app.float.article_card_image_width')) + .borderRadius($r('app.float.md_border_radius')) + .alt($r('app.media.img_placeholder')) + .objectFit(ImageFit.Cover) + } + .padding($r('app.float.md_padding_margin')) + .borderRadius($r('app.float.lg_border_radius')) + .backgroundColor(Color.White) + .alignItems(VerticalAlign.Top) + .width('100%') + .height($r('app.float.article_card_height')) + + } +} + +@Builder +function ActionButtonBuilder(imgResource: Resource, count: number, textWidth: Resource) { + Row() { + Image(imgResource) + .size({ width: 16, height: 16 }) + .margin({ right: $r('app.float.action_button_margin_right') }) + Text(count.toString()) + .fontFamily('HarmonyHeiTi') + .fontSize($r('app.float.small_text_size')) + .width(textWidth) + .opacity(0.6) + } + .width($r('app.float.action_button_width')) + .padding({ top: $r('app.float.small_padding') }) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + +} + diff --git a/LIstOptimizationBak/entry/src/main/ets/components/SongInfoProvider.ets b/LIstOptimizationBak/entry/src/main/ets/components/SongInfoProvider.ets new file mode 100644 index 0000000000000000000000000000000000000000..a902c1464324b7ed207aef4bb0679fe0c76581fc --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/components/SongInfoProvider.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { SongInfoItem } from '../model/LearningResource'; + +export class SongInfoProvider { + private readonly _size: number; + private readonly _data: SongInfoItem[] = [] + + constructor(size: number) { + if (size < 0 || size > 10000) { + throw RangeError('size must be in range[0,10000]') + } + this._size = size + for (let song_id = 0; song_id < size; song_id++) { + // 数据库中图片相关地址 + const album_url: string = `https://alliance-communityfile-drcn.dbankcdn.com/FileServer/getFile/cmtyPub/011/111/111/0000000000011111111.20210812153006.19036712329616269503297775966549:50520811073032:2800:74A29B5C2732F774A4394EC7D08A3691D84E7BF93C9A60FC64BBC1C3DD38194E.jpg`; + this._data.push(new SongInfoItem(song_id, `Song ${song_id}`, 0, album_url)) + } + } + + get size(): number { + return this._size + } + + get(id: number): SongInfoItem { + return this._data[id] + } + + getItems(): Array { + return this._data + } + +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/constants/Constants.ets b/LIstOptimizationBak/entry/src/main/ets/constants/Constants.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e5ba3e101f18a80a5d7c65776502c1718510710 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/constants/Constants.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Constants { + /** + * percent + */ + static readonly FULL_SCREEN: string = '100%'; + + static readonly SPACE_16: number = 16; + static readonly SPACE_12: number = 12; +} diff --git a/LIstOptimizationBak/entry/src/main/ets/entryability/EntryAbility.ets b/LIstOptimizationBak/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b38cbf1fe8f26d39489ac51b3656c818b74dc9f3 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { UIAbility , Want ,AbilityConstant } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit' +import { Logger } from '../utils/Logger'; + +const TAG: string = 'EntryAbility'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + Logger.info(TAG, 'EntryAbility onCreate'); + Logger.info(`want: ${JSON.stringify(want)}, launchParam: ${JSON.stringify(launchParam)}`); + } + + onDestroy(): void { + Logger.info(TAG, 'EntryAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + Logger.info(TAG, 'EntryAbility onWindowStageCreate'); + requestFullScreen(windowStage, this.context); + windowStage.loadContent('pages/Index'); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + Logger.info(TAG, 'MainAbility onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + Logger.info(TAG, 'MainAbility onForeground'); + } + + onBackground(): void { + // Ability has back to background + Logger.info(TAG, 'MainAbility onBackground'); + } +} + +function requestFullScreen(windowStage: window.WindowStage, context: Context): void { + windowStage.getMainWindow((err: BusinessError, data: window.Window) => { + if (err.code) { + Logger.error(TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + return; + } + let windowClass: window.Window = data; + Logger.info(TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + + // Realize the immersive effect + let isLayoutFullScreen = true; + try { + let type = window.AvoidAreaType.TYPE_SYSTEM; + // Get status bar height. + let area: window.AvoidArea = windowClass.getWindowAvoidArea(type); + getDeviceSize(context, area); + let promise: Promise = windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); + promise.then(() => { + Logger.info(TAG, 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + Logger.error(TAG, 'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + }); + } catch { + Logger.error(TAG, 'Failed to set the window layout to full-screen mode. '); + } + }); +} + +function getDeviceSize(context: Context, area: window.AvoidArea): void { + // Get device height. + window.getLastWindow(context).then((data: window.Window) => { + let properties = data.getWindowProperties(); + if (area.topRect.height > 0) { + AppStorage.setOrCreate('statusBarHeight', px2vp(area.topRect.height)); + } + AppStorage.setOrCreate('deviceHeight', px2vp(properties.windowRect.height)); + AppStorage.setOrCreate('deviceWidth', px2vp(properties.windowRect.width)); + }); +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/model/AppConstants.ets b/LIstOptimizationBak/entry/src/main/ets/model/AppConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..68e1d29230c33ec11c9f020d8671c8b8cb7e1124 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/model/AppConstants.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class AppConstants { + static readonly FULL_PERCENT: string = '100%'; + static readonly TAB_PERCENT: string = '15%'; + static readonly TAB_FONT_WEIGHT: number = 600; + static readonly DEFAULT_STATUS_HEIGHT: number = 32; + static readonly TAB_HEIGHT: number = 56; +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/model/ArticleListData.ets b/LIstOptimizationBak/entry/src/main/ets/model/ArticleListData.ets new file mode 100644 index 0000000000000000000000000000000000000000..8dac313d3cd9f382d8273a0e9ea29bcb0b9fad56 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/model/ArticleListData.ets @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// DocsCode 1 +import { SongInfoItem } from '../model/LearningResource'; +import { HashMap } from '@kit.ArkTS'; +import { fileIo } from '@kit.CoreFileKit'; +import { IDataSourcePrefetching } from '@kit.ArkUI'; +import { rcp } from '@kit.RemoteCommunicationKit'; + +let PREFETCH_ENABLED: boolean = false; +const CANCEL_CODE: number = 1007900992; +const IMADE_UNAVAILABLE = $r('app.media.startIcon'); + +export default class DataSourcePrefetching implements IDataSourcePrefetching { + private dataArray: Array; + private listeners: DataChangeListener[] = []; + private readonly requestsInFlight: HashMap = new HashMap(); + private readonly session: rcp.Session = rcp.createSession(); + private readonly cachePath = getContext().getApplicationContext().cacheDir; + + constructor(dataArray: Array) { + this.dataArray = dataArray; + } + + async prefetch(index: number): Promise { + PREFETCH_ENABLED = true; + if (this.requestsInFlight.hasKey(index)) { + throw new Error('Already being prefetched') + } + const item = this.dataArray[index]; + if (item.cachedImage) { + return; + } + // 数据请求 + const request = new rcp.Request(item.albumUrl, 'GET'); + // 缓存网络请求对象,便于在需要取消请求的时候进行处理 + this.requestsInFlight.set(index, request); + try { + // 发送http请求获得响应 + const response = await this.session.fetch(request); + if (response.statusCode !== 200 || !response.body) { + throw new Error('Bad response'); + } + // 将加载的数据信息存储到缓存文件中 + item.cachedImage = await this.cache(item.songId, response.body); + // 删除指定元素 + this.requestsInFlight.remove(index); + } catch (err) { + if (err.code !== CANCEL_CODE) { + item.cachedImage = IMADE_UNAVAILABLE; + // 移除有异常的网络请求任务 + this.requestsInFlight.remove(index); + } + throw err as Error; + } + } + + cancel(index: number) { + if (this.requestsInFlight.hasKey(index)) { + // 返回MAP对象指定元素 + const request = this.requestsInFlight.get(index); + // 取消数据请求 + this.session.cancel(request); + // 移除被取消的网络请求对象 + this.requestsInFlight.remove(index); + } + } + // DocsDot + + getData(index: number): SongInfoItem { + if (!PREFETCH_ENABLED) { + this.dataArray[index].cachedImage = this.dataArray[index].albumUrl; + } + return this.dataArray[index]; + } + + totalCount(): number { + return this.dataArray.length; + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + this.listeners.splice(pos, 1); + } + } + + private async cache(songId: number, data: ArrayBuffer): Promise { + const path = `file://${this.cachePath}/${songId}.jpg`; + const file = await fileIo.open(path, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); + await fileIo.write(file.fd, data); + await fileIo.close(file); + return path; + } + // DocsDot +} +// DocsCode 1 \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/model/LearningResource.ets b/LIstOptimizationBak/entry/src/main/ets/model/LearningResource.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2ca32cee466f38df746a57411d55466b658418a --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/model/LearningResource.ets @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { util } from '@kit.ArkTS'; + +@Observed +export class SongInfoItem { + readonly songId: number; + readonly songName: string; + readonly albumId: number; + readonly albumUrl: string; + cachedImage: ResourceStr | undefined; + + constructor(songId: number, songName: string, albumId: number, albumUrl: string) { + this.songId = songId; + this.songName = songName; + this.albumId = albumId; + this.albumUrl = albumUrl; + } +} + + +@Observed +export class LearningResource { + /** + * Randomly generated unique ID + */ + uuid: string; + /** + * Resource id + */ + id: string = ''; + /** + * Resource title + */ + title: string = ''; + /** + * Resource brief + */ + brief?: string = ''; + /** + * Resource type + */ + type: string = 'feed'; + /** + * Resource detail Web URL + */ + webUrl: string = ''; + /** + * Resource publish date + */ + publishDate: Date = new Date(); + /** + * Resource cover image used on card + */ + headerImageUrl: string = ''; + /** + * Topics to which the resource belongs. + */ + topics: string[] = []; + /** + * Resource views count + */ + viewsCount: number = 0; + /** + * Resource collection count + */ + collectionCount: number = 0; + /** + * Resource likes count + */ + likesCount: number = 0; + /** + * Resource tag + */ + tag: string = 'normal'; + /** + * Indicates whether the resource is added to likes list of the current user. + */ + isLiked: boolean = false; + /** + * Indicates whether the resource is added to favorites of the current user + */ + isCollected: boolean = false; + /** + * Whether the resource has been browsed by the current user + */ + isViewed: boolean = false; + /** + * Resource detail media URL + */ + mediaSrc: string = ''; + /** + * Resource banner image URL + */ + bannerSrc: string = ''; + + constructor(resource?: LearningResource) { + this.uuid = util.generateRandomUUID(false); + if (resource !== undefined) { + this.id = resource.id; + this.title = resource.title; + this.type = resource.type; + this.tag = resource.tag; + this.brief = resource.brief; + this.webUrl = resource.webUrl; + this.publishDate = resource.publishDate; + this.headerImageUrl = resource.headerImageUrl; + this.bannerSrc = resource.bannerSrc; + this.mediaSrc = resource.mediaSrc; + this.topics = resource.topics; + this.viewsCount = resource.viewsCount; + this.collectionCount = resource.collectionCount; + this.likesCount = resource.likesCount; + this.isLiked = resource.isLiked; + this.isCollected = resource.isCollected; + this.isViewed = resource.isViewed; + } + } +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/model/TabBarModel.ets b/LIstOptimizationBak/entry/src/main/ets/model/TabBarModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..c1a499832efc8f65dd8c6f96c9b7bb2bd217fd4a --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/model/TabBarModel.ets @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface TabBarData { + id: TabBarType; + title: ResourceStr; + activeIcon: ResourceStr; + animationIcon: ResourceStr; + defaultIcon: ResourceStr; +} + +export enum TabBarType { + DISCOVER = 0, + LEARNING, + CHALLENGE, + ACTIVITY, + MINE +} + +export const TabsInfo: TabBarData[] = [ + { + id: TabBarType.DISCOVER, + title: $r('app.string.tab_discover'), + animationIcon: $r('app.media.ic_tab_explore'), + activeIcon: $r('app.media.ic_tab_explore_on'), + defaultIcon: $r('app.media.ic_tab_explore_off') + }, + { + id: TabBarType.LEARNING, + title: $r('app.string.tab_learning'), + animationIcon: $r('app.media.ic_tab_study'), + activeIcon: $r('app.media.ic_tab_study_on'), + defaultIcon: $r('app.media.ic_tab_study_off') + }, + { + id: TabBarType.CHALLENGE, + title: $r('app.string.tab_challenge'), + animationIcon: $r('app.media.ic_challenge_on'), + activeIcon: $r('app.media.ic_challenge_on'), + defaultIcon: $r('app.media.ic_challenge_off') + }, + { + id: TabBarType.ACTIVITY, + title: $r('app.string.tab_activity'), + animationIcon: $r('app.media.ic_tab_conference'), + activeIcon: $r('app.media.ic_tab_conference_on'), + defaultIcon: $r('app.media.ic_tab_conference_off') + }, + { + id: TabBarType.MINE, + title: $r('app.string.tab_mine'), + animationIcon: $r('app.media.ic_tab_mine'), + activeIcon: $r('app.media.ic_tab_mine_on'), + defaultIcon: $r('app.media.ic_tab_mine_off') + } +] \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/pages/ForEachListPage.ets b/LIstOptimizationBak/entry/src/main/ets/pages/ForEachListPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..1aef82570c908ffbfc9a7bd3c413cc1d85193551 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/pages/ForEachListPage.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import { ObservedArray } from '../utils/ObservedArray'; +import { SongInfoItem } from '../model/LearningResource'; +import { ArticleCardView } from '../components/ArticleCardView'; +import Constants from '../constants/Constants'; +import PageViewModel from '../components/PageViewModel'; + + +@Entry +@Component +export struct ForEachListPage { + @State articleList: SongInfoItem[] = PageViewModel.getItems(); + @State collectedIds: ObservedArray = ['1', '2', '3', '4', '5', '6']; + @State likedIds: ObservedArray = ['1', '2', '3', '4', '5', '6']; + @State isListReachEnd: boolean = false; + + isCollected(resourceId: string): boolean { + return this.collectedIds.some((id: string) => id === resourceId); + } + + isLiked(resourceId: string): boolean { + return this.likedIds.some((id: string) => id === resourceId); + } + + + build() { + Column() { + Header() + List({ space: Constants.SPACE_16 }) { + ForEach(this.articleList, (item: SongInfoItem) => { + ListItem() { + Column({ space: Constants.SPACE_12 }) { + ArticleCardView({ articleItem: item }) + } + } + }) + } + .width(Constants.FULL_SCREEN) + .height(Constants.FULL_SCREEN) + .padding({ left: 10, right: 10 }) + .layoutWeight(1) + } + .backgroundColor($r('app.color.text_background')) + } +} + +@Builder +function Header() { + Row() { + Text($r('app.string.foreach')) + .fontSize($r('app.float.header_font_size')) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .width('100%') + .fontFamily('HarmonyHeiTi-Bold') + .padding({ left: $r('app.float.md_padding_margin') }) + } + .height($r('app.float.top_navigation_height')) + .margin({ top: $r('app.float.lg_padding_margin') }) +} diff --git a/LIstOptimizationBak/entry/src/main/ets/pages/Index.ets b/LIstOptimizationBak/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4151245c881deda3387b81250bd720bd82e53eac --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,46 @@ +import { ForEachListPage } from './ForEachListPage'; +import { LazyForEachListPage } from './LazyForEachListPage'; + +@Entry +@Component +struct Index { + @Provide('NavPathStack') pageStack: NavPathStack = new NavPathStack(); + + @Builder + PagesMap(name: string, param: object) { + NavDestination() { + if (name === 'ForEachListPage') { + ForEachListPage() + } else if (name === 'LazyForEachListPage') { + LazyForEachListPage() + } + } + .hideTitleBar(true) + } + + build() { + Navigation(this.pageStack) { + Row() { + Column() { + Button('ForEach') + .width(200) + .margin(10) + .onClick(() => { + this.pageStack.pushPathByName('ForEachListPage', ''); + }) + Button('LazyForEach') + .width(200) + .margin(10) + .onClick(() => { + this.pageStack.pushPathByName('LazyForEachListPage', ''); + }) + } + .width('100%') + } + .height('100%') + } + .hideTitleBar(true) + .mode(NavigationMode.Stack) + .navDestination(this.PagesMap) + } +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/pages/LazyForEachListPage.ets b/LIstOptimizationBak/entry/src/main/ets/pages/LazyForEachListPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..d59563d2bb95669b9d54bfeb018e267f4f47d891 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/pages/LazyForEachListPage.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// DocsCode 1 +import { SongInfoItem } from '../model/LearningResource'; +import DataSourcePrefetching from '../model/ArticleListData'; +import { ObservedArray } from '../utils/ObservedArray'; +import { ReusableArticleCardView } from '../components/ReusableArticleCardView'; +import Constants from '../constants/Constants'; +import PageViewModel from '../components/PageViewModel'; +import { BasicPrefetcher } from '@kit.ArkUI'; + +@Entry +@Component +export struct LazyForEachListPage { + @State collectedIds: ObservedArray = ['1', '2', '3', '4', '5', '6']; + @State likedIds: ObservedArray = ['1', '2', '3', '4', '5', '6']; + @State isListReachEnd: boolean = false; + // 创建DataSourcePrefetching对象,具备任务预取、取消能力的数据源 + private readonly dataSource = new DataSourcePrefetching(PageViewModel.getItems()); + // 创建BasicPrefetcher对象,默认的动态预取算法实现 + private readonly prefetcher = new BasicPrefetcher(this.dataSource); + + build() { + Column() { + Header() + List({ space: Constants.SPACE_16 }) { + LazyForEach(this.dataSource, (item: SongInfoItem) => { + ListItem() { + ReusableArticleCardView({ articleItem: item }) + } + .reuseId('article') + }) + } + .cachedCount(5) + .onScrollIndex((start: number, end: number) => { + // 列表滚动触发visibleAreaChanged,实时更新预取范围,触发调用prefetch、cancel接口 + this.prefetcher.visibleAreaChanged(start, end) + }) + .width(Constants.FULL_SCREEN) + .height(Constants.FULL_SCREEN) + .padding({ left: 10, right: 10 }) + .layoutWeight(1) + } + .backgroundColor($r('app.color.text_background')) + } +} +// DocsCode 1 + +@Builder +function Header() { + Row() { + Text($r('app.string.lazy_foreach')) + .fontSize($r('app.float.header_font_size')) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .width('100%') + .fontFamily('HarmonyHeiTi-Bold') + .padding({ left: $r('app.float.md_padding_margin') }) + } + .height($r('app.float.top_navigation_height')) + .margin({ top: $r('app.float.lg_padding_margin') }) +} diff --git a/LIstOptimizationBak/entry/src/main/ets/utils/Logger.ets b/LIstOptimizationBak/entry/src/main/ets/utils/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8ddcebc9ef9d95577b6ccaaa9dd1e393d3eac99 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/utils/Logger.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; + +export class Logger { + private static domain: number = 0xFF00; + private static prefix: string = 'ListOptimization'; + private static format: string = '%{public}s, %{public}s'; + + static debug(...args: string[]): void { + hilog.debug(Logger.domain, Logger.prefix, Logger.format, args); + } + + static info(...args: string[]): void { + hilog.info(Logger.domain, Logger.prefix, Logger.format, args); + } + + static warn(...args: string[]): void { + hilog.warn(Logger.domain, Logger.prefix, Logger.format, args); + } + + static error(...args: string[]): void { + hilog.error(Logger.domain, Logger.prefix, Logger.format, args); + } +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/ets/utils/ObservedArray.ets b/LIstOptimizationBak/entry/src/main/ets/utils/ObservedArray.ets new file mode 100644 index 0000000000000000000000000000000000000000..78cc6a06c6c9db49422762ce9ce8bf1b708148ee --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/ets/utils/ObservedArray.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Wraps an array as an observed object + */ +@Observed +export class ObservedArray extends Array { + constructor(args?: T[]) { + if (args instanceof Array) { + super(...args); + } else { + super(); + } + } +} diff --git a/LIstOptimizationBak/entry/src/main/module.json5 b/LIstOptimizationBak/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7d861193c1b7eb9e22ea92a5826ea17b26c83f63 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/module.json5 @@ -0,0 +1,43 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ] + } +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/element/color.json b/LIstOptimizationBak/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..45406af38def38c9e2ffc34ddd9c57ffdb97fe17 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/element/color.json @@ -0,0 +1,16 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "text_background", + "value": "#FAFAFA" + }, + { + "name": "challenge_light", + "value": "#00CCD7" + } + ] +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/element/float.json b/LIstOptimizationBak/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..e90d5a871fe9ad3e089cfb338b315af9d5b886b2 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/element/float.json @@ -0,0 +1,232 @@ +{ + "float": [ + { + "name": "action_button_margin_right", + "value": "4vp" + }, + { + "name": "small_text_size", + "value": "12fp" + }, + { + "name": "action_button_width", + "value": "56vp" + }, + { + "name": "small_padding", + "value": "8vp" + }, + { + "name": "header_font_size", + "value": "24fp" + }, + { + "name": "lg_padding_margin", + "value": "24vp" + }, + { + "name": "top_navigation_height", + "value": "56vp" + }, + { + "name": "md_font_size", + "value": "14fp" + }, + { + "name": "xs_padding_margin", + "value": "4vp" + }, + { + "name": "sm_font_size", + "value": "12fp" + }, + { + "name": "view_count_icon_width", + "value": "36vp" + }, + { + "name": "like_icon_width", + "value": "22vp" + }, + { + "name": "star_icon_width", + "value": "16vp" + }, + { + "name": "article_card_image_height", + "value": "64vp" + }, + { + "name": "article_card_image_width", + "value": "108vp" + }, + { + "name": "md_border_radius", + "value": "12vp" + }, + { + "name": "lg_border_radius", + "value": "16vp" + }, + { + "name": "article_card_height", + "value": "102vp" + }, + { + "name": "little_text_size", + "value": "10fp" + }, + { + "name": "normal_text_size", + "value": "14fp" + }, + { + "name": "splash_normal_text_size", + "value": "16fp" + }, + { + "name": "title_text_size", + "value": "20fp" + }, + { + "name": "splash_title_text_size", + "value": "24fp" + }, + { + "name": "tool_bar_height", + "value": "56vp" + }, + { + "name": "tool_bar_width", + "value": "96vp" + }, + { + "name": "tab_font_size", + "value": "10fp" + }, + { + "name": "tab_border_width", + "value": "0.5vp" + }, + { + "name": "tab_img_size", + "value": "24vp" + }, + { + "name": "tab_big_img_width", + "value": "40vp" + }, + { + "name": "tab_big_img_height", + "value": "38vp" + }, + { + "name": "tab_margin", + "value": "-15vp" + }, + { + "name": "tab_title_margin", + "value": "5vp" + }, + { + "name": "splash_swiper_indicator", + "value": "5vp" + }, + { + "name": "button_borderRadius", + "value": "20vp" + }, + { + "name": "image_width", + "value": "300vp" + }, + { + "name": "privacy_gutter", + "value": "24vp" + }, + { + "name": "safe_logo_sm_md", + "value": "72vp" + }, + { + "name": "safe_logo_lg", + "value": "96vp" + }, + { + "name": "grid_gutter", + "value": "24vp" + }, + { + "name": "safe_logo_margin", + "value": "136vp" + }, + { + "name": "welcome_line_height", + "value": "19vp" + }, + { + "name": "safe_title_font_size", + "value": "30fp" + }, + { + "name": "safe_title_line_height", + "value": "40vp" + }, + { + "name": "safe_icon_size", + "value": "24vp" + }, + { + "name": "safe_icon_margin_bottom", + "value": "16vp" + }, + { + "name": "safe_desc_line_height", + "value": "14vp" + }, + { + "name": "safe_button_margin_bottom", + "value": "45vp" + }, + { + "name": "button_height", + "value": "40vp" + }, + { + "name": "title_line_height", + "value": "28vp" + }, + { + "name": "ss_padding_margin", + "value": "4vp" + }, + { + "name": "sm_padding_margin", + "value": "8vp" + }, + { + "name": "md_padding_margin", + "value": "12vp" + }, + { + "name": "xxl_padding_margin", + "value": "24vp" + }, + { + "name": "card_item_padding", + "value": "10vp" + }, + { + "name": "font_size", + "value": "14fp" + }, + { + "name": "card_img_size", + "value": "36vp" + }, + { + "name": "sm_border_radius", + "value": "8vp" + } + ] +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/element/string.json b/LIstOptimizationBak/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c080eac64c856059519249d5a40b98dc015a269b --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/element/string.json @@ -0,0 +1,52 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ListOptimization" + }, + { + "name": "foreach", + "value": "ForEach" + }, + { + "name": "lazy_foreach", + "value": "LazyForEach" + }, + { + "name": "tab_discover", + "value": "探索" + }, + { + "name": "tab_learning", + "value": "学习" + }, + { + "name": "tab_challenge", + "value": "溪村挑战赛" + }, + { + "name": "tab_activity", + "value": "活动" + }, + { + "name": "tab_mine", + "value": "我的" + }, + { + "name": "reusable_article_cardView_title", + "value":"差异化构建打包,提升多版本应用开发效率" + }, + { + "name": "reusable_article_cardView_content", + "value":"差异化构建打包,在面对多场景开发时开发者经常使用" + } + ] +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/btn_favorites_normal.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/btn_favorites_normal.svg new file mode 100644 index 0000000000000000000000000000000000000000..52c26e69c664245209df700a59060382c1c8a3f4 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/btn_favorites_normal.svg @@ -0,0 +1,13 @@ + + + btn_Favorites_normal + + + + + + + + + + \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/btn_favorites_on.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/btn_favorites_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..dd5fb3b7163cb548aa335dc11065d4babe0f99ba --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/btn_favorites_on.svg @@ -0,0 +1,13 @@ + + + ic_Favorites_on + + + + + + + + + + \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/btn_good_normal.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/btn_good_normal.svg new file mode 100644 index 0000000000000000000000000000000000000000..989a5ad1dd88cbf2e11bc7b7a3cf8dd62f033a79 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/btn_good_normal.svg @@ -0,0 +1,13 @@ + + + btn_good_normal + + + + + + + + + + \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/btn_good_on.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/btn_good_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..9e7a40a38974b17c18e810347b7c30e2935bcacc --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/btn_good_on.svg @@ -0,0 +1,13 @@ + + + btn_good_on + + + + + + + + + + \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_challenge_off.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_challenge_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..c7bc9b756b362ebbf0e8ab76c5307526cc875bf1 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_challenge_off.svg @@ -0,0 +1,69 @@ + + + 编组 8@1x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_challenge_on.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_challenge_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..ddf97d878ed4969a0cf0ee2a7ede6724ad8011eb --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_challenge_on.svg @@ -0,0 +1,102 @@ + + + 编组@2x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_eye_open.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_eye_open.svg new file mode 100644 index 0000000000000000000000000000000000000000..542bd36a21ad2a6a73a57d6c3758980fb638215d --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_eye_open.svg @@ -0,0 +1,13 @@ + + + ic_eye_open + + + + + + + + + + \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference.gif b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference.gif new file mode 100644 index 0000000000000000000000000000000000000000..7641297fd1db4ef9bab18b412348b15a29432b16 Binary files /dev/null and b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference.gif differ diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference_off.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..72ffc8b4a44f1e672b2410eb30074501e5563a1a --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference_off.svg @@ -0,0 +1,17 @@ + + + Created with Pixso. + + + + + + + + + + + + + + diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference_on.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..f63e7f9e2fe71c256623bee98949f26d7548652d --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_conference_on.svg @@ -0,0 +1,17 @@ + + + Created with Pixso. + + + + + + + + + + + + + + diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore.gif b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore.gif new file mode 100644 index 0000000000000000000000000000000000000000..fcdde2db33256003efa11dbcfaea983670302540 Binary files /dev/null and b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore.gif differ diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore_off.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..c09e0b913928ff21595212c2dfba71d1be9cc345 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore_off.svg @@ -0,0 +1,18 @@ + + + Created with Pixso. + + + + + + + + + + + + + + + diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore_on.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..d2fc1a252d717b0d23c46b042f56b1476d751fe1 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_explore_on.svg @@ -0,0 +1,18 @@ + + + Created with Pixso. + + + + + + + + + + + + + + + diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine.gif b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine.gif new file mode 100644 index 0000000000000000000000000000000000000000..131284ac5297f9a6d5fe4f33947d5cfc26d387ba Binary files /dev/null and b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine.gif differ diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine_off.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..c88554af0e8a3ea66f9fb02bae4b0d443a521848 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine_off.svg @@ -0,0 +1,8 @@ + + + Created with Pixso. + + + + + diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine_on.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..742041618f2584397e12e8d2b7f3d1f99bc33a2d --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_mine_on.svg @@ -0,0 +1,8 @@ + + + Created with Pixso. + + + + + diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study.gif b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study.gif new file mode 100644 index 0000000000000000000000000000000000000000..62479526ebe6c667897dbd664eabd6285de7b3db Binary files /dev/null and b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study.gif differ diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study_off.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..510c196ca12ee5d4b94ada3ea5f1c376863d9ed5 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study_off.svg @@ -0,0 +1,14 @@ + + + Created with Pixso. + + + + + + + + + + + diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study_on.svg b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..761ceb26bbc6c0b516c232715bbed2ac5e68e3c0 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/media/ic_tab_study_on.svg @@ -0,0 +1,14 @@ + + + Created with Pixso. + + + + + + + + + + + diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/icon.png b/LIstOptimizationBak/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd45accb1dfd2fd0da16c732c72faa6e46b26521 Binary files /dev/null and b/LIstOptimizationBak/entry/src/main/resources/base/media/icon.png differ diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/img_placeholder.png b/LIstOptimizationBak/entry/src/main/resources/base/media/img_placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..f9b5440a2b7abc295a852ff8ca8e3b0ad284c77a Binary files /dev/null and b/LIstOptimizationBak/entry/src/main/resources/base/media/img_placeholder.png differ diff --git a/LIstOptimizationBak/entry/src/main/resources/base/media/startIcon.png b/LIstOptimizationBak/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..366f76459ffd4494ec40d0ddd5c59385b9c5da11 Binary files /dev/null and b/LIstOptimizationBak/entry/src/main/resources/base/media/startIcon.png differ diff --git a/LIstOptimizationBak/entry/src/main/resources/base/profile/main_pages.json b/LIstOptimizationBak/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..477bb6f3b6258d82455054838d9112394e8812c8 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/Index", + "pages/LazyForEachListPage" + ] +} diff --git a/LIstOptimizationBak/entry/src/main/resources/en_US/element/string.json b/LIstOptimizationBak/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1224b0fd275e4771a678c55e09e626508c71b462 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ListOptimization" + }, + { + "name": "foreach", + "value": "ForEach" + }, + { + "name": "lazy_foreach", + "value": "LazyForEach" + } + ] +} \ No newline at end of file diff --git a/LIstOptimizationBak/entry/src/main/resources/zh_CN/element/string.json b/LIstOptimizationBak/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..13986b951e10b513dbd96a5d5315442e5e5e1707 --- /dev/null +++ b/LIstOptimizationBak/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ListOptimization" + }, + { + "name": "foreach", + "value": "ForEach" + }, + { + "name": "lazy_foreach", + "value": "搜索" + } + ] +} \ No newline at end of file diff --git a/LIstOptimizationBak/hvigor/hvigor-config.json5 b/LIstOptimizationBak/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8c56bf6a23806e1ce92f72ed34a38613e27c494f --- /dev/null +++ b/LIstOptimizationBak/hvigor/hvigor-config.json5 @@ -0,0 +1,21 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ + } +} \ No newline at end of file diff --git a/LIstOptimizationBak/hvigorfile.ts b/LIstOptimizationBak/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/LIstOptimizationBak/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/LIstOptimizationBak/oh-package.json5 b/LIstOptimizationBak/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..693299dad66e4498e166be26906a2f216835eae5 --- /dev/null +++ b/LIstOptimizationBak/oh-package.json5 @@ -0,0 +1,16 @@ +{ + "modelVersion": "5.0.0", + "name": "listoptimization", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.15", + "@ohos/hamock": "1.0.0" + }, + "dynamicDependencies": {} +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/AppScope/app.json5 b/WebDevelopOptimizationInterJS/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9369e20036253686ba5c7b3e1c9e69c8235ae05d --- /dev/null +++ b/WebDevelopOptimizationInterJS/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.myinterjs", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/WebDevelopOptimizationInterJS/AppScope/resources/base/element/string.json b/WebDevelopOptimizationInterJS/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0cb38e345660f59f21121ea8fecc757bfb224525 --- /dev/null +++ b/WebDevelopOptimizationInterJS/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyInterJS" + } + ] +} diff --git a/WebDevelopOptimizationInterJS/AppScope/resources/base/media/app_icon.png b/WebDevelopOptimizationInterJS/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/WebDevelopOptimizationInterJS/AppScope/resources/base/media/app_icon.png differ diff --git a/WebDevelopOptimizationInterJS/README.md b/WebDevelopOptimizationInterJS/README.md new file mode 100644 index 0000000000000000000000000000000000000000..db36efccc8ee206a831bb42b6310324eb71cb68c --- /dev/null +++ b/WebDevelopOptimizationInterJS/README.md @@ -0,0 +1,4 @@ +#Performance + +最佳实践“性能”板块目录 +WebDevelopOptimization Web场景性能优化指导#资源拦截替换的JavaScript生成字节码缓存 \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/build-profile.json5 b/WebDevelopOptimizationInterJS/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9112e921430528e84202ab51adc032d815bf9ddc --- /dev/null +++ b/WebDevelopOptimizationInterJS/build-profile.json5 @@ -0,0 +1,34 @@ +{ + "app": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/build-profile.json5 b/WebDevelopOptimizationInterJS/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b695582d3680556f4cce2ec518f65720a9413ca3 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/hvigorfile.ts b/WebDevelopOptimizationInterJS/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/WebDevelopOptimizationInterJS/entry/src/main/ets/entryability/EntryAbility.ets b/WebDevelopOptimizationInterJS/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8335b7692d4cac1f8b5d78ce7bc1c45a453d563e --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,41 @@ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/WebDevelopOptimizationInterJS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/WebDevelopOptimizationInterJS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc55c03d3eea7ce53d5346c732a39ce9bf5267e1 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,12 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/ets/pages/Index.ets b/WebDevelopOptimizationInterJS/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6681adc11b43207f0d15c96a80ba883cb58c141a --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,46 @@ +// DocsCode 1 +// Index.ets +import { webview } from '@kit.ArkWeb'; +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + responseResource: WebResourceResponse = new WebResourceResponse(); + // 开发者自定义响应数据,响应数据长度需大于等于1024才会生成CodeCache + @State jsData: string = 'JavaScript Data'; + + build() { + Column() { + Web({ src: $rawfile('index.html'), controller: this.controller }) + .onInterceptRequest((event) => { + // 拦截页面请求 + if (event?.request.getRequestUrl() === 'https://www.example.com/test.js') { + // 构造响应数据 + this.responseResource.setResponseHeader([ + { + // 格式:不超过13位纯数字。js识别码,Js有更新时必须更新该字段 + headerKey: 'ResponseDataID', + headerValue: '0000000000001' + }]); + this.responseResource.setResponseData(this.jsData); + this.responseResource.setResponseEncoding('utf-8'); + this.responseResource.setResponseMimeType('application/javascript'); + this.responseResource.setResponseCode(200); + this.responseResource.setReasonMessage('OK'); + return this.responseResource; + } + return null; + }) + .onPageBegin(() => { + hiTraceMeter.startTrace('getMessageData', 0); + }) + .onPageEnd(() => { + hiTraceMeter.finishTrace('getMessageData', 0); + }) + } + } +} + +// DocsCode 1 \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/module.json5 b/WebDevelopOptimizationInterJS/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/base/element/color.json b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/base/element/string.json b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/background.png b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/background.png differ diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/foreground.png b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/foreground.png differ diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/layered_image.json b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/startIcon.png b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/media/startIcon.png differ diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/base/profile/backup_config.json b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/base/profile/main_pages.json b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/en_US/element/string.json b/WebDevelopOptimizationInterJS/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/rawfile/index.html b/WebDevelopOptimizationInterJS/entry/src/main/resources/rawfile/index.html new file mode 100644 index 0000000000000000000000000000000000000000..d37aebdb22f8b9776ef3c33d74abd3babe391426 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/resources/rawfile/index.html @@ -0,0 +1,23 @@ + + + + + + + + +
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+ + + + \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/main/resources/zh_CN/element/string.json b/WebDevelopOptimizationInterJS/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..597ecf95e61d7e30367c22fe2f8638008361b044 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/mock/mock-config.json5 b/WebDevelopOptimizationInterJS/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/ohosTest/ets/test/Ability.test.ets b/WebDevelopOptimizationInterJS/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/ohosTest/ets/test/List.test.ets b/WebDevelopOptimizationInterJS/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/ohosTest/module.json5 b/WebDevelopOptimizationInterJS/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/WebDevelopOptimizationInterJS/entry/src/test/List.test.ets b/WebDevelopOptimizationInterJS/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/entry/src/test/LocalUnit.test.ets b/WebDevelopOptimizationInterJS/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/WebDevelopOptimizationInterJS/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/WebDevelopOptimizationInterJS/hvigor/hvigor-config.json5 b/WebDevelopOptimizationInterJS/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/WebDevelopOptimizationInterJS/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/WebDevelopOptimizationInterJS/hvigorfile.ts b/WebDevelopOptimizationInterJS/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/WebDevelopOptimizationInterJS/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/WebDevelopOptimizationInterJS/oh-package.json5 b/WebDevelopOptimizationInterJS/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2549faf34cdde34a70f24390f26bf4cb9fa5058b --- /dev/null +++ b/WebDevelopOptimizationInterJS/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.18", + "@ohos/hamock": "1.0.1-rc2" + } +} diff --git a/WebDevelopOptimizationRender/AppScope/app.json5 b/WebDevelopOptimizationRender/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..29c43d06dffeb0b315f8c13e7f5c69a097dd36fc --- /dev/null +++ b/WebDevelopOptimizationRender/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.myrender", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/WebDevelopOptimizationRender/AppScope/resources/base/element/string.json b/WebDevelopOptimizationRender/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..296573727fe16c3846e154216ca2cf16057a06f7 --- /dev/null +++ b/WebDevelopOptimizationRender/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyRender" + } + ] +} diff --git a/WebDevelopOptimizationRender/AppScope/resources/base/media/app_icon.png b/WebDevelopOptimizationRender/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/WebDevelopOptimizationRender/AppScope/resources/base/media/app_icon.png differ diff --git a/WebDevelopOptimizationRender/README.md b/WebDevelopOptimizationRender/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0afa916d4c470eada855b189a9600a36979dcd34 --- /dev/null +++ b/WebDevelopOptimizationRender/README.md @@ -0,0 +1,4 @@ +#Performance + +最佳实践“性能”板块目录 +WebDevelopOptimization Web场景性能优化指导#预启动Web Render \ No newline at end of file diff --git a/WebDevelopOptimizationRender/build-profile.json5 b/WebDevelopOptimizationRender/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9112e921430528e84202ab51adc032d815bf9ddc --- /dev/null +++ b/WebDevelopOptimizationRender/build-profile.json5 @@ -0,0 +1,34 @@ +{ + "app": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/build-profile.json5 b/WebDevelopOptimizationRender/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b695582d3680556f4cce2ec518f65720a9413ca3 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/hvigorfile.ts b/WebDevelopOptimizationRender/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/WebDevelopOptimizationRender/entry/oh-package.json5 b/WebDevelopOptimizationRender/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/WebDevelopOptimizationRender/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/WebDevelopOptimizationRender/entry/src/main/ets/entryability/EntryAbility.ets b/WebDevelopOptimizationRender/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b2fbef170f29654f6849a4c93724149e9e481774 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,15 @@ +// DocsCode 1 +// 载体Ability +import { UIAbility } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { createNWeb } from '../pages/common'; + +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + // 预先创建一个空的ArkWeb动态组件(需传入UIContext),拉起渲染进程 + createNWeb('about://blank', windowStage.getMainWindowSync().getUIContext()); + }); + } +} +// DocsCode 1 \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/WebDevelopOptimizationRender/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc55c03d3eea7ce53d5346c732a39ce9bf5267e1 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,12 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/ets/pages/Index.ets b/WebDevelopOptimizationRender/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..36cf8465faed49de8b03c9c7feff31b0c33712c9 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,25 @@ +// DocsCode 1 +// Index.ets +@Entry +@Component +struct Index { + pageInfos: NavPathStack = new NavPathStack(); + + build() { + Navigation(this.pageInfos) { + Column() { + Button('加载测试页面', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + // 将name指定的NavDestination页面信息入栈 + this.pageInfos.pushPath({ name: 'pageOne' }); + }) + } + } + .title('NavIndex') + } +} + +// DocsCode 1 \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/ets/pages/Index2.ets b/WebDevelopOptimizationRender/entry/src/main/ets/pages/Index2.ets new file mode 100644 index 0000000000000000000000000000000000000000..bcb0928e70006df41f37b7597b54c64b1b3ddd80 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/ets/pages/Index2.ets @@ -0,0 +1,33 @@ +// DocsCode 1 +// Second.ets +import { webview } from '@kit.ArkWeb'; +import { getNWeb } from './common'; + +@Builder +export function PageOneBuilder() { + Second() +} + +@Component +export struct Second { + webviewController: webview.WebviewController = new webview.WebviewController(); + aboutToAppear(): void { + // 输出Web页面开始加载时间 + console.info(`load page start time: ${Date.now()}`); + } + build() { + NavDestination() { + Row() { + Column() { + // url请替换为真实地址 + NodeContainer(getNWeb('https://www.example.com')) + .height('100%') + .width('100%') + } + .width('100%') + } + .height('100%') + } + } +} +// DocsCode 1 \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/ets/pages/common.ets b/WebDevelopOptimizationRender/entry/src/main/ets/pages/common.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1e15111295e0d91ab439e1a307b9940ff97c868 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/ets/pages/common.ets @@ -0,0 +1,127 @@ +// DocsCode 1 +// 创建NodeController +// common.ets +import { UIContext } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; +import { NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; + +// @Builder中为动态组件的具体组件内容 +// Data为入参封装类 +class Data { + url: string = 'https://www.example.com'; + controller: WebviewController = new webview.WebviewController(); +} + +@Builder +function webBuilder(data: Data) { + Column() { + Web({ src: data.url, controller: data.controller }) + .domStorageAccess(true) + .zoomAccess(true) + .fileAccess(true) + .mixedMode(MixedMode.All) + .width('100%') + .height('100%') + .onPageEnd((event) => { + // 输出Web页面加载完成时间 + console.info(`load page end time: ${Date.now()}`); + }) + } +} + +let wrap = wrapBuilder(webBuilder); + +// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用 +export class MyNodeController extends NodeController { + private rootnode: BuilderNode | null = null; + private root: FrameNode | null = null; + private rootWebviewController: webview.WebviewController | null = null; + + // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContainer中 + // 在对应NodeContainer创建的时候调用、或者通过rebuild方法调用刷新 + makeNode(uiContext: UIContext): FrameNode | null { + console.info(' uicontext is undifined : ' + (uiContext === undefined)); + if (this.rootnode != null) { + const parent = this.rootnode.getFrameNode()?.getParent(); + if (parent) { + console.info(JSON.stringify(parent.getInspectorInfo())); + parent.removeChild(this.rootnode.getFrameNode()); + this.root = null; + } + this.root = new FrameNode(uiContext); + this.root.appendChild(this.rootnode.getFrameNode()); + // 返回FrameNode节点 + return this.root; + } + // 返回null控制动态组件脱离绑定节点 + return null; + } + + // 当布局大小发生变化时进行回调 + aboutToResize(size: Size) { + console.info('aboutToResize width : ' + size.width + ' height : ' + size.height); + } + + // 当controller对应的NodeContainer在Appear的时候进行回调 + aboutToAppear() { + console.info('aboutToAppear'); + } + + // 当controller对应的NodeContainer在Disappear的时候进行回调 + aboutToDisappear() { + console.info('aboutToDisappear'); + } + + // 此函数为自定义函数,可作为初始化函数使用 + // 通过UIContext初始化BuilderNode,再通过BuilderNode中的build接口初始化@Builder中的内容 + initWeb(url: string, uiContext: UIContext, control: WebviewController) { + if (this.rootnode != null) { + return; + } + // 绑定预创建的WebviewController + this.rootWebviewController = control; + // 创建节点,需要uiContext + this.rootnode = new BuilderNode(uiContext); + // 创建动态Web组件 + this.rootnode.build(wrap, { url: url, controller: control }); + } + + // 此函数为自定义函数,可作为初始化函数使用 + loadUrl(url: string) { + if (this.rootWebviewController !== null) { + // 复用预创建组件,重新加载url + this.rootWebviewController.loadUrl(url); + } + } +} + +// 创建Map保存所需要的NodeController +let NodeMap: Map = new Map(); +// 创建Map保存所需要的WebViewController +let controllerMap: Map = new Map(); + +// 初始化需要UIContext 需在Ability获取 +export const createNWeb = (url: string, uiContext: UIContext) => { + // 创建NodeController + let baseNode = new MyNodeController(); + let controller = new webview.WebviewController(); + // 初始化自定义web组件 + baseNode.initWeb(url, uiContext, controller); + controllerMap.set(url, controller); + NodeMap.set(url, baseNode); +}; + +// 自定义获取NodeController接口 +export const getNWeb = (url: string): MyNodeController | undefined => { + // 加载新的Url时,建议复用预创建的Web组件 + if (!NodeMap.get(url) && NodeMap.get('about://blank')) { + // 获取预创建的Web组件 + let webNode = NodeMap.get('about://blank') as MyNodeController; + // 重新加载url + webNode.loadUrl(url); + return webNode; + } + return NodeMap.get(url); +}; + +// DocsCode 1 \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/module.json5 b/WebDevelopOptimizationRender/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..16fb573fa02404f661aad33d6fb8eb4a38e6a6ad --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/module.json5 @@ -0,0 +1,58 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ], + "routerMap": "$profile:router_map" + } +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/element/color.json b/WebDevelopOptimizationRender/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/element/string.json b/WebDevelopOptimizationRender/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/media/background.png b/WebDevelopOptimizationRender/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/WebDevelopOptimizationRender/entry/src/main/resources/base/media/background.png differ diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/media/foreground.png b/WebDevelopOptimizationRender/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/WebDevelopOptimizationRender/entry/src/main/resources/base/media/foreground.png differ diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/media/layered_image.json b/WebDevelopOptimizationRender/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/media/startIcon.png b/WebDevelopOptimizationRender/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/WebDevelopOptimizationRender/entry/src/main/resources/base/media/startIcon.png differ diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/backup_config.json b/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/main_pages.json b/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/router_map.json b/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/router_map.json new file mode 100644 index 0000000000000000000000000000000000000000..3e9dedc19b46cbd313005f3ec7b6eb6f14450316 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/resources/base/profile/router_map.json @@ -0,0 +1,9 @@ +{ + "routerMap": [ + { + "name": "pageOne", + "pageSourceFile": "src/main/ets/pages/Index2.ets", + "buildFunction": "PageOneBuilder" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/en_US/element/string.json b/WebDevelopOptimizationRender/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/main/resources/zh_CN/element/string.json b/WebDevelopOptimizationRender/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..597ecf95e61d7e30367c22fe2f8638008361b044 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/mock/mock-config.json5 b/WebDevelopOptimizationRender/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/ohosTest/ets/test/Ability.test.ets b/WebDevelopOptimizationRender/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/ohosTest/ets/test/List.test.ets b/WebDevelopOptimizationRender/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/ohosTest/module.json5 b/WebDevelopOptimizationRender/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/WebDevelopOptimizationRender/entry/src/test/List.test.ets b/WebDevelopOptimizationRender/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/entry/src/test/LocalUnit.test.ets b/WebDevelopOptimizationRender/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/WebDevelopOptimizationRender/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/WebDevelopOptimizationRender/hvigor/hvigor-config.json5 b/WebDevelopOptimizationRender/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/WebDevelopOptimizationRender/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/WebDevelopOptimizationRender/hvigorfile.ts b/WebDevelopOptimizationRender/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/WebDevelopOptimizationRender/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/WebDevelopOptimizationRender/oh-package.json5 b/WebDevelopOptimizationRender/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2549faf34cdde34a70f24390f26bf4cb9fa5058b --- /dev/null +++ b/WebDevelopOptimizationRender/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.18", + "@ohos/hamock": "1.0.1-rc2" + } +}