├── AppScope ├── app.json5 └── resources │ └── base │ ├── element │ └── string.json │ └── media │ ├── app_icon.png │ ├── ic_logo.png │ └── ic_logo_n.png ├── README.md ├── build-profile.json5 ├── entry ├── .gitignore ├── build-profile.json5 ├── hvigorfile.ts ├── oh-package.json5 └── src │ ├── main │ ├── ets │ │ ├── badges │ │ │ ├── brown.png │ │ │ ├── caltech.png │ │ │ ├── duke.png │ │ │ ├── harvard.png │ │ │ ├── johns.png │ │ │ ├── mit.png │ │ │ ├── penn.png │ │ │ ├── princeton.png │ │ │ ├── stanford.png │ │ │ └── yale.png │ │ ├── entryability │ │ │ └── EntryAbility.ts │ │ ├── enums │ │ │ ├── AnswerStatus.ets │ │ │ ├── OptionStatus.ets │ │ │ └── PracticeStatus.ets │ │ ├── http │ │ │ ├── Api.ets │ │ │ └── Axios.ets │ │ ├── model │ │ │ ├── AdmissionCases.ets │ │ │ ├── CalendarEvent.ets │ │ │ ├── MajorInfo.ets │ │ │ ├── PostInfo.ets │ │ │ ├── Question.ets │ │ │ └── UniversityInfo.ets │ │ ├── pages │ │ │ ├── AdmissionCaseDetailPage.ets │ │ │ ├── CalendarPage.ets │ │ │ ├── CirclePage.ets │ │ │ ├── Index.ets │ │ │ ├── LoginPage.ets │ │ │ ├── MajorDetailPage.ets │ │ │ ├── MinePage.ets │ │ │ ├── PostHistoryPage.ets │ │ │ ├── PracticePage.ets │ │ │ ├── SplashPage.ets │ │ │ ├── UniversityDetailPage.ets │ │ │ └── UniversityInfoPage.ets │ │ ├── photos │ │ │ ├── brown.png │ │ │ ├── caltech.jpg │ │ │ ├── duke.jpg │ │ │ ├── harvard.jpg │ │ │ ├── johns.jpg │ │ │ ├── mit.jpg │ │ │ ├── penn.jpg │ │ │ ├── princeton.jpg │ │ │ ├── stanford.jpg │ │ │ └── yale.jpeg │ │ └── utils │ │ │ └── DateUtil.ets │ ├── module.json5 │ └── resources │ │ ├── base │ │ ├── element │ │ │ ├── color.json │ │ │ └── string.json │ │ ├── media │ │ │ ├── ic_accuracy.svg │ │ │ ├── ic_accuracy_white.svg │ │ │ ├── ic_arrow_right.svg │ │ │ ├── ic_back.svg │ │ │ ├── ic_circle.svg │ │ │ ├── ic_circle_selected.svg │ │ │ ├── ic_close.svg │ │ │ ├── ic_code.svg │ │ │ ├── ic_complete.svg │ │ │ ├── ic_count.svg │ │ │ ├── ic_count_white.svg │ │ │ ├── ic_empty.png │ │ │ ├── ic_history_date.png │ │ │ ├── ic_incomplete.svg │ │ │ ├── ic_loading.gif │ │ │ ├── ic_logo.png │ │ │ ├── ic_mine.svg │ │ │ ├── ic_mine_about.svg │ │ │ ├── ic_mine_card.svg │ │ │ ├── ic_mine_selected.svg │ │ │ ├── ic_mine_update.svg │ │ │ ├── ic_phone.svg │ │ │ ├── ic_post_like.svg │ │ │ ├── ic_post_like_selected.svg │ │ │ ├── ic_practice.svg │ │ │ ├── ic_practice_selected.svg │ │ │ ├── ic_progress.svg │ │ │ ├── ic_refresh.png │ │ │ ├── ic_right.svg │ │ │ ├── ic_timer.svg │ │ │ ├── ic_timer_white.svg │ │ │ ├── ic_top.png │ │ │ ├── ic_unLogin_bg.png │ │ │ ├── ic_wrong.svg │ │ │ ├── icon.png │ │ │ ├── img_avatar.png │ │ │ ├── img_login_bg.png │ │ │ ├── img_post.png │ │ │ ├── img_post_bg.png │ │ │ ├── img_practice_bg.png │ │ │ └── img_splash_bg.png │ │ └── profile │ │ │ └── main_pages.json │ │ ├── en_US │ │ └── element │ │ │ └── string.json │ │ └── zh_CN │ │ └── element │ │ └── string.json │ └── ohosTest │ ├── ets │ ├── test │ │ ├── Ability.test.ets │ │ └── List.test.ets │ ├── testability │ │ ├── TestAbility.ets │ │ └── pages │ │ │ └── Index.ets │ └── testrunner │ │ └── OpenHarmonyTestRunner.ts │ ├── module.json5 │ └── resources │ └── base │ ├── element │ ├── color.json │ └── string.json │ ├── media │ └── icon.png │ └── profile │ └── test_pages.json ├── hvigor ├── hvigor-config.json5 └── hvigor-wrapper.js ├── hvigorfile.ts ├── hvigorw ├── hvigorw.bat ├── img ├── img-o.png ├── img.png ├── img_1.png ├── img_10.png ├── img_11.png ├── img_12.png ├── img_13.png ├── img_14.png ├── img_2.png ├── img_3.png ├── img_4.png ├── img_5.png ├── img_6.png ├── img_7.png ├── img_8.png ├── img_9.png ├── pic1.png ├── pic10.png ├── pic7.png ├── pic8(1).png └── pic9(1).png ├── local.properties ├── oh-package-lock.json5 ├── oh-package.json5 └── oh_modules ├── .ohpm ├── @ohos+axios@2.2.0 │ └── oh_modules │ │ └── @ohos │ │ └── axios │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── README-EN.md │ │ ├── README.OpenSource │ │ ├── README.md │ │ ├── ResourceTable.txt │ │ ├── build-profile.json5 │ │ ├── hvigorfile.ts │ │ ├── index.d.cts │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── oh-package.json5 │ │ └── src │ │ └── main │ │ ├── ets │ │ └── components │ │ │ └── lib │ │ │ ├── adapters │ │ │ ├── README.md │ │ │ ├── adapters.js │ │ │ ├── http.js │ │ │ ├── ohos │ │ │ │ ├── download.js │ │ │ │ ├── http.js │ │ │ │ ├── index.js │ │ │ │ └── upload.js │ │ │ └── xhr.js │ │ │ ├── axios.js │ │ │ ├── cancel │ │ │ ├── CancelToken.js │ │ │ ├── CanceledError.js │ │ │ └── isCancel.js │ │ │ ├── core │ │ │ ├── Axios.js │ │ │ ├── AxiosError.js │ │ │ ├── AxiosHeaders.js │ │ │ ├── InterceptorManager.js │ │ │ ├── README.md │ │ │ ├── buildFullPath.js │ │ │ ├── dispatchRequest.js │ │ │ ├── mergeConfig.js │ │ │ ├── settle.js │ │ │ └── transformData.js │ │ │ ├── defaults │ │ │ ├── index.js │ │ │ └── transitional.js │ │ │ ├── env │ │ │ ├── README.md │ │ │ ├── classes │ │ │ │ └── FormData.js │ │ │ └── data.js │ │ │ ├── fileFs.js │ │ │ ├── helpers │ │ │ ├── AxiosTransformStream.js │ │ │ ├── AxiosURLSearchParams.js │ │ │ ├── HttpStatusCode.js │ │ │ ├── README.md │ │ │ ├── ZlibHeaderTransformStream.js │ │ │ ├── bind.js │ │ │ ├── buildURL.js │ │ │ ├── combineURLs.js │ │ │ ├── cookies.js │ │ │ ├── deprecatedMethod.js │ │ │ ├── formDataToJSON.js │ │ │ ├── formDataToStream.js │ │ │ ├── fromDataURI.js │ │ │ ├── isAbsoluteURL.js │ │ │ ├── isAxiosError.js │ │ │ ├── isURLSameOrigin.js │ │ │ ├── null.js │ │ │ ├── parseHeaders.js │ │ │ ├── parseProtocol.js │ │ │ ├── readBlob.js │ │ │ ├── speedometer.js │ │ │ ├── spread.js │ │ │ ├── throttle.js │ │ │ ├── toFormData.js │ │ │ ├── toURLEncodedForm.js │ │ │ └── validator.js │ │ │ ├── platform │ │ │ ├── index.js │ │ │ └── ohos │ │ │ │ ├── classes │ │ │ │ ├── FormData.js │ │ │ │ └── URLSearchParams.js │ │ │ │ └── index.js │ │ │ └── utils.js │ │ ├── module.json │ │ └── resources │ │ ├── base │ │ └── element │ │ │ └── string.json │ │ ├── en_US │ │ └── element │ │ │ └── string.json │ │ └── zh_CN │ │ └── element │ │ └── string.json ├── @ohos+hypium@1.0.6 │ └── oh_modules │ │ └── @ohos │ │ └── hypium │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── index.d.ts │ │ ├── index.ets │ │ ├── index.js │ │ ├── oh-package.json5 │ │ └── src │ │ └── main │ │ ├── Constant.js │ │ ├── core.js │ │ ├── event.js │ │ ├── interface.js │ │ ├── module │ │ ├── assert │ │ │ ├── ExpectExtend.js │ │ │ ├── assertClose.js │ │ │ ├── assertContain.js │ │ │ ├── assertFail.js │ │ │ ├── assertFalse.js │ │ │ ├── assertInstanceOf.js │ │ │ ├── assertLarger.js │ │ │ ├── assertLargerOrEqual.js │ │ │ ├── assertLess.js │ │ │ ├── assertLessOrEqual.js │ │ │ ├── assertNaN.js │ │ │ ├── assertNegUnlimited.js │ │ │ ├── assertNull.js │ │ │ ├── assertPosUnlimited.js │ │ │ ├── assertPromiseIsPending.js │ │ │ ├── assertPromiseIsRejected.js │ │ │ ├── assertPromiseIsRejectedWith.js │ │ │ ├── assertPromiseIsRejectedWithError.js │ │ │ ├── assertPromiseIsResolved.js │ │ │ ├── assertPromiseIsResolvedWith.js │ │ │ ├── assertThrowError.js │ │ │ ├── assertUndefined.js │ │ │ ├── deepEquals │ │ │ │ ├── DeepTypeUtils.js │ │ │ │ └── assertDeepEquals.js │ │ │ └── isPromiseLike.js │ │ ├── config │ │ │ ├── DataDriver.js │ │ │ ├── Filter.js │ │ │ └── configService.js │ │ ├── coverage │ │ │ └── coverageCollect.js │ │ ├── kit │ │ │ └── SysTestKit.js │ │ ├── mock │ │ │ ├── ArgumentMatchers.js │ │ │ ├── ExtendInterface.js │ │ │ ├── MockKit.js │ │ │ └── VerificationMode.js │ │ └── report │ │ │ ├── OhReport.js │ │ │ └── ReportExtend.js │ │ └── service.js └── oh_modules │ └── @ohos │ ├── axios │ └── hypium └── @ohos ├── axios └── hypium /AppScope/app.json5: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "bundleName": "com.se.practice", 4 | "vendor": "example", 5 | "versionCode": 1000000, 6 | "versionName": "1.0.0", 7 | "icon": "$media:ic_logo_n", 8 | "label": "$string:app_name" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /AppScope/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "app_name", 5 | "value": "留学助手" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /AppScope/resources/base/media/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/AppScope/resources/base/media/app_icon.png -------------------------------------------------------------------------------- /AppScope/resources/base/media/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/AppScope/resources/base/media/ic_logo.png -------------------------------------------------------------------------------- /AppScope/resources/base/media/ic_logo_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/AppScope/resources/base/media/ic_logo_n.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # 留学助手项目 3 | 4 | B站尚硅谷在线学习视频链接: [尚硅谷2024最新鸿蒙开发HarmonyOS4.0+鸿蒙NEXT星河版零基础教程](https://www.bilibili.com/video/BV1Ti4y1s79B?p=1&vd_source=0aba82a4002c00e3a072b82df5f53868) 5 | 6 | 在线文档1: [HarmonyOS 4.0 应用开发](https://www.yuque.com/danny-sroga/gaguqh/qg2n2d5o04iu1gsm?singleDoc#vCJBv ) 7 | 密码:gps8 8 | 9 | 在线文档2: [HarmonyOS 4.0实战项目之单词打卡](https://www.yuque.com/danny-sroga/gaguqh/eocenh0ig73g9ymq?singleDoc#O56iD) 10 | 密码:za5u 11 | 12 | ## 一、项目简介 13 | 在当今全球化的时代,留学已经成为许多人实现个人及职业发展目标的重要途径之一。由于涉及到语言考试、多项材料的准备、各种信息的获取和各种选择的权衡,许多人可能感到迷茫和无措。留学申请过程的复杂性常常令人望而却步。 14 | 15 | 为了能够帮助各位同学语言技能提升、梳理申请流程,解决他们的疑惑和困惑,同时打造一个留学信息分享、交流的平台。我们团队决定开发留学助手项目,采用敏捷开发方法,以迭代的方式逐步完善功能,以应对用户需求的快速变化。 16 | 17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 | 25 |
26 | 27 | 28 |
29 | 30 | 31 | 32 |
33 | 34 | 35 | ## 二、功能简介 36 | 37 | **单词背诵:** 为了帮助留学生们准备语言类考试,留学小助手提供单词打卡功能。该功能将展示单词、例句和一些选项,由用户从选项中选择正确的释义。程序会根据用户的使用情况记录一些数据,如回答正确率、学习时长等。在每日单词打卡完成后,用户可以发帖记录学习成果。 38 | 39 | **打卡交流:** 为了提升用户的参与感和互动性,提供打卡社区的功能,用于展示所有用户的打卡记录。功能包括显示当前用户的昵称和头像、背诵单词时长、正确个数与答题个数、打卡帖子、帖子点赞数、评论数 40 | 41 | **学校介绍:** 为了帮助留学生们择校,留学小助手提供全球各地的大学介绍,包括学校概况、专业设置、学校排名等信息。用户可以根据自己的兴趣和需求筛选学校并查看详细信息。 42 | 43 | **留学日历:** 为了帮助留学生们规划学习、科研和申请活动,留学小助手提供留学日历功能。除留学所需的常见事项外,用户也可以创建个人化的留学日程。 44 | 45 | ## 三、系统架构 46 | #### 3.1总体系统图 47 | ![img_9.png](img/img_9.png) 48 | 49 | #### 3.2登录背单词打卡系统 50 | ![img_9.png](img/img_11.png) 51 | ![img_9.png](img/img_12.png) 52 | 53 | #### 3.3学校介绍子系统UML图 54 | ![img_9.png](img/img_13.png) 55 | 56 | #### 3.4留学日历子系统UML图 57 | ![img_9.png](img/img_14.png) 58 | -------------------------------------------------------------------------------- /build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | // "signingConfigs": [ 4 | // { 5 | // "name": "default", 6 | // "type": "HarmonyOS", 7 | // "material": { 8 | // "storePassword": "0000001C901BD9086732B7D5C681B616FA9228AE4886B8507C238E4897E61F09D4BE8BEB0FC9B68963FA9241", 9 | // "certpath": "C:/Users/21083/LXZS.cer", 10 | // "keyAlias": "LXZS", 11 | // "keyPassword": "0000001CADDE0BFCE73D3B04FCCC02F23692A5FFEB1460705D2F6B7B03D2663BFCBE7410F79FBADEA5B9F5CA", 12 | // "profile": "C:/Users/21083/LXZSRelease.p7b", 13 | // "signAlg": "SHA256withECDSA", 14 | // "storeFile": "C:/Users/21083/release.p12" 15 | // } 16 | // } 17 | // ], 18 | "compileSdkVersion": 9, 19 | "compatibleSdkVersion": 9, 20 | "products": [ 21 | { 22 | "name": "default", 23 | "signingConfig": "default", 24 | } 25 | ] 26 | }, 27 | "modules": [ 28 | { 29 | "name": "entry", 30 | "srcPath": "./entry", 31 | "targets": [ 32 | { 33 | "name": "default", 34 | "applyToProducts": [ 35 | "default" 36 | ] 37 | } 38 | ] 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /entry/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /.preview 4 | /build 5 | /.cxx 6 | /.test -------------------------------------------------------------------------------- /entry/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": 'stageMode', 3 | "buildOption": { 4 | }, 5 | "targets": [ 6 | { 7 | "name": "default", 8 | "runtimeOS": "HarmonyOS" 9 | }, 10 | { 11 | "name": "ohosTest", 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /entry/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. 2 | export { hapTasks } from '@ohos/hvigor-ohos-plugin'; 3 | -------------------------------------------------------------------------------- /entry/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "license": "", 3 | "devDependencies": {}, 4 | "author": "", 5 | "name": "entry", 6 | "description": "Please describe the basic information.", 7 | "main": "", 8 | "version": "1.0.0", 9 | "dependencies": {} 10 | } 11 | -------------------------------------------------------------------------------- /entry/src/main/ets/badges/brown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/brown.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/caltech.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/caltech.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/duke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/duke.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/harvard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/harvard.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/johns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/johns.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/mit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/mit.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/penn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/penn.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/princeton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/princeton.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/stanford.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/stanford.png -------------------------------------------------------------------------------- /entry/src/main/ets/badges/yale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/badges/yale.png -------------------------------------------------------------------------------- /entry/src/main/ets/entryability/EntryAbility.ts: -------------------------------------------------------------------------------- 1 | import UIAbility from '@ohos.app.ability.UIAbility'; 2 | import hilog from '@ohos.hilog'; 3 | import window from '@ohos.window'; 4 | 5 | export default class EntryAbility extends UIAbility { 6 | onCreate(want, launchParam) { 7 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); 8 | } 9 | 10 | onDestroy() { 11 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); 12 | } 13 | 14 | onWindowStageCreate(windowStage: window.WindowStage) { 15 | // Main window is created, set main page for this ability 16 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); 17 | 18 | windowStage.loadContent('pages/SplashPage', (err, data) => { // 初始界面 19 | if (err.code) { 20 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); 21 | return; 22 | } 23 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); 24 | }); 25 | } 26 | 27 | onWindowStageDestroy() { 28 | // Main window is destroyed, release UI related resources 29 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); 30 | } 31 | 32 | onForeground() { 33 | // Ability has brought to foreground 34 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); 35 | } 36 | 37 | onBackground() { 38 | // Ability has back to background 39 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /entry/src/main/ets/enums/AnswerStatus.ets: -------------------------------------------------------------------------------- 1 | export enum AnswerStatus{ // 作答状态,用于控制选项按钮是否可用 2 | Answering, // 作答中,选项按钮可用 3 | Answered // 已作答,选项按钮不可用 4 | } -------------------------------------------------------------------------------- /entry/src/main/ets/enums/OptionStatus.ets: -------------------------------------------------------------------------------- 1 | export enum OptionStatus { // 选项按钮的状态,用于控制选项按钮的样式 2 | Default, // 默认状态 3 | Right, // 正确状态 4 | Wrong // 错误状态 5 | } -------------------------------------------------------------------------------- /entry/src/main/ets/enums/PracticeStatus.ets: -------------------------------------------------------------------------------- 1 | export enum PracticeStatus { // 答题状态,用于控制控制按钮的样式 2 | Running, // 答题状态 3 | Paused, // 暂停状态 4 | Stopped // 停止状态 5 | } -------------------------------------------------------------------------------- /entry/src/main/ets/http/Api.ets: -------------------------------------------------------------------------------- 1 | // 获取验证码 2 | import { instance } from './Axios'; 3 | export function sendCode(phone: string) { 4 | return instance.get('/word/user/code', { params: { phone: phone } }); 5 | } 6 | 7 | // 登录 8 | export function login(phone: string, code: string) { 9 | return instance.post('/word/user/login', { phone: phone, code: code }); 10 | } 11 | 12 | export function createPost(post: { 13 | rightCount: number, 14 | answeredCount: number, 15 | timeUsed: number 16 | }) { 17 | return instance.post('/word/post/create', post) 18 | } 19 | 20 | // 获取全部打卡列表 21 | export function getAllPost(page: number, size: number) { 22 | return instance.get('/word/post/getAll', { params: { page: page, size: size } }) 23 | } 24 | 25 | // 点赞 26 | export function like(postId: number) { 27 | return instance.get('/word/like/create', { params: { postId: postId } }) 28 | } 29 | 30 | // 取消点赞 31 | export function cancelLike(postId: number) { 32 | return instance.get('/word/like/cancel', { params: { postId: postId } }) 33 | } 34 | 35 | // 获取登录用户信息 36 | export function info() { 37 | return instance.get('/word/user/info') 38 | } 39 | 40 | // 获取我的登录打卡记录 41 | export function getMyPost(page: number, size: number) { 42 | return instance.get('/word/post/getMine', { params: { page: page, size: size } }) 43 | } -------------------------------------------------------------------------------- /entry/src/main/ets/http/Axios.ets: -------------------------------------------------------------------------------- 1 | import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from '@ohos/axios' 2 | import promptAction from '@ohos.promptAction'; 3 | 4 | // 创建axios实例 5 | export const instance = axios.create({ 6 | baseURL: 'http://10.181.92.198:3000', 7 | timeout: 1000 8 | }) 9 | 10 | // 添加请求拦截器 11 | instance.interceptors.request.use((config: InternalAxiosRequestConfig) => { 12 | // 通过 AppStorage 获取 token 13 | const token = AppStorage.Get('token') 14 | if (token) { 15 | // 若 token 存在,则将其添加到请求头 16 | config.headers['token'] = token 17 | } 18 | return config; 19 | }, (error: AxiosError) => { 20 | // 若出现异常,则提示异常信息 21 | promptAction.showToast({ message: error.message }) 22 | return Promise.reject(error); 23 | }); 24 | 25 | // 添加响应拦截器 26 | instance.interceptors.response.use((response: AxiosResponse) => { 27 | // 若服务器返回的是正常数据,不做任何处理 28 | if (response.data.code === 200) { 29 | return response 30 | } else { 31 | // 若服务器返回的是异常数据,则提示异常信息 32 | promptAction.showToast({ message: response.data.message }) 33 | return Promise.reject(response.data.message) 34 | } 35 | }, (error: AxiosError) => { 36 | // 若出现异常,则提示异常信息 37 | promptAction.showToast({ message: error.message }) 38 | return Promise.reject(error); 39 | }); -------------------------------------------------------------------------------- /entry/src/main/ets/model/CalendarEvent.ets: -------------------------------------------------------------------------------- 1 | import { isCancel } from '@ohos/axios' 2 | @Observed 3 | export class CalendarEvent { 4 | name: string 5 | isComplete: boolean 6 | incompleteValue: string 7 | completeValue: string 8 | year: number 9 | month: number 10 | day: number 11 | date: Date 12 | 13 | constructor(name = '新的事件', isComplete = false, incompleteValue = '未完成', completeValue = '已完成', date = new Date()) { 14 | this.name = name 15 | this.isComplete = isComplete 16 | this.incompleteValue = incompleteValue 17 | this.completeValue = completeValue 18 | this.date = date 19 | this.year = date.getFullYear() 20 | this.month = date.getMonth() + 1 21 | this.day = date.getDate() 22 | } 23 | } 24 | 25 | export var calendarEventData: CalendarEvent[] = [ 26 | { 27 | name: "TOEFL", 28 | isComplete: false, 29 | incompleteValue: "背单词、刷题", 30 | completeValue: "成绩:120 分", 31 | year: 2024, 32 | month: 1, 33 | day: 1, 34 | date: new Date('2024-1-1') 35 | }, 36 | { 37 | name: "GRE", 38 | isComplete: false, 39 | incompleteValue: "背单词、刷题", 40 | completeValue: "已完成", 41 | year: 2024, 42 | month: 3, 43 | day: 1, 44 | date: new Date('2024-3-1') 45 | }, 46 | { 47 | name: "实习", 48 | isComplete: false, 49 | incompleteValue: "投递简历", 50 | completeValue: "已完成", 51 | year: 2024, 52 | month: 5, 53 | day: 1, 54 | date: new Date('2024-5-1') 55 | } 56 | ] 57 | 58 | -------------------------------------------------------------------------------- /entry/src/main/ets/model/MajorInfo.ets: -------------------------------------------------------------------------------- 1 | export interface MajorInfo { 2 | name: string; 3 | university: string; 4 | type: string; 5 | category: string; 6 | duration: number; 7 | qsRank: number; 8 | introduction: string; 9 | requiredTOEFL: number; 10 | requiredGRE: number; 11 | requirements: string; 12 | } 13 | 14 | export const majorInfoData: MajorInfo[] = [ 15 | { 16 | name: "计算机科学", 17 | university: "普林斯顿大学", 18 | type: "工学", 19 | category: "计算机", 20 | duration: 2, 21 | qsRank: 14, 22 | introduction: "普林斯顿大学计算机系比较注重对数理逻辑、量子力学等知识的掌握。除了理论研究之外,还在网络与系统,图形与视觉,编程语言等方面展开前沿性研究。截止2020年,共有14位世界计算机最高奖图灵奖得主来自普林斯顿大学。\n\n普林斯顿大学开设的CS硕士项目工程科学硕士是一个为期两年的全日制课程。所有录取的学生最初将注册为工程科学硕士,在第1年春季学期开始时,所有学生都可以选择转到工程硕士继续学习。", 23 | requiredTOEFL: 0, 24 | requiredGRE: 0, 25 | requirements: "研究导向录取,看重学生的研究背景。", 26 | }, 27 | { 28 | name: "金融", 29 | university: "普林斯顿大学", 30 | type: "商科", 31 | category: "金融", 32 | duration: 2, 33 | qsRank: 29, 34 | introduction: "普林斯顿大学金融专业是一个涵盖金融学领域广度与深度的学科体系。在这个专业中,学生将学习金融市场的运作与监管、资本市场、投资管理以及金融工程等相关知识。通过系统学习,培养学生掌握金融理论与实践的能力,为日后在各种机构、企业从事金融分析、金融工程、风险管理等相关工作打下坚实的基础。", 35 | requiredTOEFL: 0, 36 | requiredGRE: 0, 37 | requirements: "希望申请者在中级本科课程水平上熟悉数学,包括线性代数、多元微积分、微分方程以及概率和统计。", 38 | } 39 | ] 40 | 41 | export function getMajorInfoByUniversity(university: string) { 42 | let indexes: number[] = []; 43 | for (let i = 0; i < majorInfoData.length; i++) { 44 | if (majorInfoData[i]["university"] === university) { 45 | indexes.push(i) 46 | } 47 | } 48 | return indexes.map(index => majorInfoData[index]) 49 | } 50 | 51 | -------------------------------------------------------------------------------- /entry/src/main/ets/model/PostInfo.ets: -------------------------------------------------------------------------------- 1 | @Observed 2 | export class PostInfo { 3 | id: number; //打卡文案 4 | postText: string; 5 | rightCount: number; //正确个数 6 | answeredCount: number; //答题个数 7 | timeUsed: number; //用时 8 | createTime: string; //打卡时间 9 | likeCount: number; //点赞个数 10 | nickname: string; //用户昵称 11 | avatarUrl: string //用户头像 12 | isLike: boolean; //当前登录用户是否已点赞 13 | 14 | constructor(post:{id: number, postText: string, rightCount: number, answeredCount: number, timeUsed: number, createTime: string, likeCount: number, nickname: string, avatarUrl: string, isLike: boolean}) { 15 | this.id = post.id; 16 | this.postText = post.postText; 17 | this.rightCount = post.rightCount; 18 | this.answeredCount = post.answeredCount; 19 | this.timeUsed = post.timeUsed; 20 | this.createTime = post.createTime; 21 | this.likeCount = post.likeCount; 22 | this.nickname = post.nickname; 23 | this.avatarUrl = post.avatarUrl; 24 | this.isLike = post.isLike; 25 | } 26 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/Index.ets: -------------------------------------------------------------------------------- 1 | import { CirclePage } from './CirclePage'; 2 | import { MinePage } from './MinePage'; 3 | import { PracticePage } from './PracticePage'; 4 | import { UniversityInfoPage } from './UniversityInfoPage'; 5 | import { CalendarPage } from './CalendarPage'; 6 | 7 | @Entry 8 | @Component 9 | struct Index { 10 | @StorageLink('currentTabIndex') currentTabIndex: number = 0; // 被选中的页签索引 11 | 12 | build() { 13 | Tabs({index:this.currentTabIndex}){ // index 指示 Tabs 显示哪个页面 14 | TabContent(){ 15 | PracticePage() 16 | }.tabBar(this.barBuilder(0, '答题', $r('app.media.ic_practice'), $r('app.media.ic_practice_selected'))) 17 | 18 | TabContent(){ 19 | CirclePage() 20 | }.tabBar(this.barBuilder(1, '圈子', $r('app.media.ic_circle'), $r('app.media.ic_circle_selected'))) 21 | 22 | TabContent(){ 23 | UniversityInfoPage() 24 | }.tabBar(this.barBuilder(2, '选校', $r('app.media.ic_practice'), $r('app.media.ic_practice_selected'))) 25 | 26 | TabContent(){ 27 | CalendarPage() 28 | }.tabBar(this.barBuilder(3, '日历', $r('app.media.ic_circle'), $r('app.media.ic_circle_selected'))) 29 | 30 | TabContent(){ 31 | MinePage() 32 | }.tabBar(this.barBuilder(4, '我的', $r('app.media.ic_mine'), $r('app.media.ic_mine_selected'))) 33 | 34 | }.barPosition(BarPosition.End) // 导航栏位于页面底部 35 | .onChange((index) => { // 选择新的页签时,修改被选中的页签索引 36 | this.currentTabIndex = index; 37 | }) 38 | } 39 | 40 | // 自定义页签结构,根据被选中的页签索引决定每一个页签的样式 41 | @Builder barBuilder(index: number, title: string, icon: Resource, iconSelected: Resource) { 42 | Column() { 43 | Image(this.currentTabIndex === index ? iconSelected : icon) 44 | .width(25) 45 | .height(25) 46 | Text(title) 47 | .tabTitleStyle(this.currentTabIndex === index ? Color.Black:'#959595') 48 | } 49 | } 50 | } 51 | 52 | @Extend(Text) function tabTitleStyle(color: ResourceColor) { 53 | .fontSize(10) 54 | .fontWeight(FontWeight.Medium) 55 | .fontColor(color) //Color.Black 56 | .margin({ bottom: 2 }) 57 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/MinePage.ets: -------------------------------------------------------------------------------- 1 | import router from '@ohos.router'; 2 | import promptAction from '@ohos.promptAction'; 3 | import { info } from '../http/Api'; 4 | 5 | @Component 6 | export struct MinePage { 7 | @StorageLink('token') @Watch('onTokenChange') token: string = '' 8 | @State userInfo: { 9 | nickname?: string, 10 | avatarUrl?: string 11 | } = {}; 12 | 13 | async onTokenChange() { 14 | if (this.token) { 15 | let response = await info() 16 | this.userInfo = response.data.data; 17 | } else { 18 | this.userInfo = {} 19 | } 20 | } 21 | 22 | async aboutToAppear() { 23 | if (this.token) { 24 | let response = await info() 25 | this.userInfo = response.data.data; 26 | } 27 | } 28 | 29 | build() { 30 | Stack() { 31 | Column() { 32 | Image(this.token ? this.userInfo.avatarUrl : $r('app.media.img_avatar')) 33 | .width(100) 34 | .height(100) 35 | .borderRadius(50) 36 | .margin({ top: 120 }) 37 | .onClick(() => { 38 | router.pushUrl({ url: 'pages/LoginPage' }) 39 | }) 40 | 41 | Text(this.token ? this.userInfo.nickname : '暂未登录') 42 | .fontSize(18) 43 | .fontWeight(FontWeight.Bold) 44 | .fontColor(Color.Black) 45 | .margin({ top: 20 }) 46 | 47 | if (!this.token) { 48 | Text('请点击头像登录') 49 | .fontSize(12) 50 | .fontWeight(FontWeight.Medium) 51 | .fontColor(Color.Black) 52 | .margin({ top: 4 }) 53 | } 54 | } 55 | .width('100%') 56 | .height('50%') 57 | .backgroundImage(this.token ? this.userInfo.avatarUrl : $r('app.media.img_avatar')) 58 | .backgroundImageSize({ height: '100%', width: '100%' }) 59 | .backgroundBlurStyle(BlurStyle.Regular) 60 | 61 | Column({ space: 10 }) { 62 | this.mineItemBuilder($r('app.media.ic_mine_card'), '打卡记录', () => { 63 | if (this.token) { 64 | router.pushUrl({ url: 'pages/PostHistoryPage' }) 65 | } else { 66 | promptAction.showToast({ message: '请先点击头像登录' }) 67 | } 68 | }) 69 | Divider() 70 | this.mineItemBuilder($r('app.media.ic_mine_update'), '检查更新', () => { 71 | promptAction.showToast({ message: '已是最新' }) 72 | }) 73 | Divider() 74 | this.mineItemBuilder($r('app.media.ic_mine_about'), '关于', () => { 75 | promptAction.showToast({ message: '没有关于' }) 76 | }) 77 | 78 | Blank() 79 | 80 | if (this.token) { 81 | Button('退出登录') 82 | .width('100%') 83 | .fontSize(18) 84 | .backgroundColor(Color.Gray) 85 | .fontColor(Color.White) 86 | .onClick(() => { 87 | this.token = '' 88 | }) 89 | } 90 | 91 | } 92 | .width('100%') 93 | .height('60%') 94 | .offset({ y: '40%' }) 95 | .borderRadius({ topLeft: 50, topRight: 50 }) 96 | .backgroundColor(Color.White) 97 | .padding(30) 98 | 99 | }.width('100%') 100 | .height('100%') 101 | .alignContent(Alignment.Top) 102 | } 103 | 104 | @Builder 105 | mineItemBuilder(icon: Resource, title: string, callback?: () => void) { 106 | Row({ space: 10 }) { 107 | Image(icon) 108 | .width(24) 109 | .height(24) 110 | Text(title) 111 | .fontSize(16) 112 | .height(24) 113 | .fontWeight(FontWeight.Medium) 114 | Blank() 115 | Image($r('app.media.ic_arrow_right')) 116 | .width(24) 117 | .height(24) 118 | }.width('100%') 119 | .height(40) 120 | .onClick(() => { 121 | callback(); 122 | }) 123 | } 124 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/SplashPage.ets: -------------------------------------------------------------------------------- 1 | import router from '@ohos.router'; 2 | PersistentStorage.PersistProp('token',''); // 在 PersistentStorage 中注册登录 token 3 | AppStorage.SetOrCreate('currentTabIndex',0); // 在 AppStorage 中注册 currentTabIndex 4 | 5 | @Entry 6 | @Component 7 | struct SplashPage { // 启动页面 8 | @State flag:Boolean = false; 9 | 10 | onPageShow(){ 11 | animateTo({duration:1000,onFinish:()=>{ 12 | setTimeout(()=>{ 13 | router.replaceUrl({url:'pages/Index'}) // 切换页面,且不能返回 14 | },200); 15 | }},() => { 16 | this.flag=true; 17 | }); 18 | } 19 | 20 | build() { 21 | Column(){ 22 | if(this.flag){ 23 | Image($r('app.media.ic_logo_n')) 24 | .logoStyle() 25 | .transition({type:TransitionType.Insert,opacity:0,translate:{x:-150}}) 26 | Text("留学助手") 27 | .titleStyle() 28 | .transition({type:TransitionType.Insert,opacity:0,translate:{x:150}}) 29 | } 30 | Blank() 31 | Text("SE Harmony Project") // 最底部 32 | .footerStyle() 33 | }.bgStyle() 34 | } 35 | 36 | } 37 | 38 | @Styles function bgStyle() { 39 | .width('100%') 40 | .height('100%') 41 | .backgroundImage($r('app.media.img_splash_bg')) 42 | .backgroundImageSize({ width: '100%', height: '100%' }) 43 | } 44 | 45 | @Extend(Image) function logoStyle() { 46 | .width(90) 47 | .height(90) 48 | .margin({ top: 120 }) 49 | } 50 | 51 | @Extend(Text) function titleStyle() { 52 | .fontSize(21) 53 | .fontColor(Color.White) 54 | .fontWeight(FontWeight.Bold) 55 | .margin({ top: 15 }) 56 | } 57 | 58 | @Extend(Text) function footerStyle() { 59 | .fontSize(12) 60 | .fontColor('#546B9D') 61 | .fontWeight(FontWeight.Bold) 62 | .margin({ bottom: 30 }) 63 | } -------------------------------------------------------------------------------- /entry/src/main/ets/photos/brown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/brown.png -------------------------------------------------------------------------------- /entry/src/main/ets/photos/caltech.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/caltech.jpg -------------------------------------------------------------------------------- /entry/src/main/ets/photos/duke.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/duke.jpg -------------------------------------------------------------------------------- /entry/src/main/ets/photos/harvard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/harvard.jpg -------------------------------------------------------------------------------- /entry/src/main/ets/photos/johns.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/johns.jpg -------------------------------------------------------------------------------- /entry/src/main/ets/photos/mit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/mit.jpg -------------------------------------------------------------------------------- /entry/src/main/ets/photos/penn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/penn.jpg -------------------------------------------------------------------------------- /entry/src/main/ets/photos/princeton.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/princeton.jpg -------------------------------------------------------------------------------- /entry/src/main/ets/photos/stanford.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/stanford.jpg -------------------------------------------------------------------------------- /entry/src/main/ets/photos/yale.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/ets/photos/yale.jpeg -------------------------------------------------------------------------------- /entry/src/main/ets/utils/DateUtil.ets: -------------------------------------------------------------------------------- 1 | export function convertMillisecondsToTime(timeUsed: number): string { 2 | // 计算小时、分钟和秒 3 | const hours = Math.floor(timeUsed / 3600000); // 1小时 = 3600000毫秒 4 | const minutes = Math.floor((timeUsed % 3600000) / 60000); // 1分钟 = 60000毫秒 5 | const seconds = Math.floor((timeUsed % 60000) / 1000); // 1秒 = 1000毫秒 6 | 7 | // 将结果格式化为时分秒字符串 8 | if (hours > 0) { 9 | return `${hours}时 ${minutes}分 ${seconds}秒` 10 | } else if (minutes > 0) { 11 | return `${minutes}分 ${seconds}秒` 12 | } else { 13 | return `${seconds}秒` 14 | } 15 | } -------------------------------------------------------------------------------- /entry/src/main/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "entry", 4 | "type": "entry", 5 | "description": "$string:module_desc", 6 | "mainElement": "EntryAbility", 7 | "deviceTypes": [ 8 | "phone", 9 | "tablet" 10 | ], 11 | "deliveryWithInstall": true, 12 | "installationFree": false, 13 | "pages": "$profile:main_pages", 14 | "abilities": [ 15 | { 16 | "name": "EntryAbility", 17 | "srcEntry": "./ets/entryability/EntryAbility.ts", 18 | "description": "$string:EntryAbility_desc", 19 | "icon": "$media:ic_logo_n", 20 | "label": "$string:EntryAbility_label", 21 | "startWindowIcon": "$media:icon", 22 | "startWindowBackground": "$color:start_window_background", 23 | "exported": true, 24 | "skills": [ 25 | { 26 | "entities": [ 27 | "entity.system.home" 28 | ], 29 | "actions": [ 30 | "action.system.home" 31 | ] 32 | } 33 | ] 34 | } 35 | ], 36 | "requestPermissions": [ 37 | { 38 | "name": 'ohos.permission.INTERNET' 39 | } 40 | ] 41 | } 42 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/color.json: -------------------------------------------------------------------------------- 1 | { 2 | "color": [ 3 | { 4 | "name": "start_window_background", 5 | "value": "#FFFFFF" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "module description" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "description" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "label" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_accuracy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_accuracy_white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_arrow_right.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_back.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_circle.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_circle_selected.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_code.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_complete.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_count.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_count_white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/ic_empty.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_history_date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/ic_history_date.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_incomplete.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/ic_loading.gif -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/ic_logo.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_mine.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_mine_about.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_mine_card.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_mine_update.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_phone.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_practice.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_practice_selected.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_progress.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/ic_refresh.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_right.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_timer.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_timer_white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/ic_top.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_unLogin_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/ic_unLogin_bg.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_wrong.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/icon.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/img_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/img_avatar.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/img_login_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/img_login_bg.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/img_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/img_post.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/img_post_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/img_post_bg.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/img_practice_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/img_practice_bg.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/img_splash_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/main/resources/base/media/img_splash_bg.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/profile/main_pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "src": [ 3 | "pages/Index", 4 | "pages/SplashPage", 5 | "pages/LoginPage", 6 | "pages/PostHistoryPage", 7 | "pages/UniversityDetailPage", 8 | "pages/AdmissionCaseDetailPage", 9 | "pages/MajorDetailPage" 10 | ] 11 | } -------------------------------------------------------------------------------- /entry/src/main/resources/en_US/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "module description" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "description" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "label" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/main/resources/zh_CN/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "模块描述" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "description" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "留学助手" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/test/Ability.test.ets: -------------------------------------------------------------------------------- 1 | import hilog from '@ohos.hilog'; 2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' 3 | 4 | export default function abilityTest() { 5 | describe('ActsAbilityTest', function () { 6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 7 | beforeAll(function () { 8 | // Presets an action, which is performed only once before all test cases of the test suite start. 9 | // This API supports only one parameter: preset action function. 10 | }) 11 | beforeEach(function () { 12 | // Presets an action, which is performed before each unit test case starts. 13 | // The number of execution times is the same as the number of test cases defined by **it**. 14 | // This API supports only one parameter: preset action function. 15 | }) 16 | afterEach(function () { 17 | // Presets a clear action, which is performed after each unit test case ends. 18 | // The number of execution times is the same as the number of test cases defined by **it**. 19 | // This API supports only one parameter: clear action function. 20 | }) 21 | afterAll(function () { 22 | // Presets a clear action, which is performed after all test cases of the test suite end. 23 | // This API supports only one parameter: clear action function. 24 | }) 25 | it('assertContain',0, function () { 26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); 28 | let a = 'abc' 29 | let b = 'b' 30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 31 | expect(a).assertContain(b) 32 | expect(a).assertEqual(a) 33 | }) 34 | }) 35 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import abilityTest from './Ability.test' 2 | 3 | export default function testsuite() { 4 | abilityTest() 5 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/testability/TestAbility.ets: -------------------------------------------------------------------------------- 1 | import UIAbility from '@ohos.app.ability.UIAbility'; 2 | import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; 3 | import hilog from '@ohos.hilog'; 4 | import { Hypium } from '@ohos/hypium'; 5 | import testsuite from '../test/List.test'; 6 | import window from '@ohos.window'; 7 | 8 | export default class TestAbility extends UIAbility { 9 | onCreate(want, launchParam) { 10 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); 11 | hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); 12 | hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); 13 | var abilityDelegator: any 14 | abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() 15 | var abilityDelegatorArguments: any 16 | abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() 17 | hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); 18 | Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) 19 | } 20 | 21 | onDestroy() { 22 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); 23 | } 24 | 25 | onWindowStageCreate(windowStage: window.WindowStage) { 26 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); 27 | windowStage.loadContent('testability/pages/Index', (err, data) => { 28 | if (err.code) { 29 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); 30 | return; 31 | } 32 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', 33 | JSON.stringify(data) ?? ''); 34 | }); 35 | } 36 | 37 | onWindowStageDestroy() { 38 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); 39 | } 40 | 41 | onForeground() { 42 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); 43 | } 44 | 45 | onBackground() { 46 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); 47 | } 48 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/testability/pages/Index.ets: -------------------------------------------------------------------------------- 1 | import hilog from '@ohos.hilog'; 2 | 3 | @Entry 4 | @Component 5 | struct Index { 6 | aboutToAppear() { 7 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); 8 | } 9 | @State message: string = 'Hello World' 10 | build() { 11 | Row() { 12 | Column() { 13 | Text(this.message) 14 | .fontSize(50) 15 | .fontWeight(FontWeight.Bold) 16 | Button() { 17 | Text('next page') 18 | .fontSize(20) 19 | .fontWeight(FontWeight.Bold) 20 | }.type(ButtonType.Capsule) 21 | .margin({ 22 | top: 20 23 | }) 24 | .backgroundColor('#0D9FFB') 25 | .width('35%') 26 | .height('5%') 27 | .onClick(()=>{ 28 | }) 29 | } 30 | .width('100%') 31 | } 32 | .height('100%') 33 | } 34 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts: -------------------------------------------------------------------------------- 1 | import hilog from '@ohos.hilog'; 2 | import TestRunner from '@ohos.application.testRunner'; 3 | import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; 4 | 5 | var abilityDelegator = undefined 6 | var abilityDelegatorArguments = undefined 7 | 8 | async function onAbilityCreateCallback() { 9 | hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); 10 | } 11 | 12 | async function addAbilityMonitorCallback(err: any) { 13 | hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); 14 | } 15 | 16 | export default class OpenHarmonyTestRunner implements TestRunner { 17 | constructor() { 18 | } 19 | 20 | onPrepare() { 21 | hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); 22 | } 23 | 24 | async onRun() { 25 | hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); 26 | abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() 27 | abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() 28 | var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' 29 | let lMonitor = { 30 | abilityName: testAbilityName, 31 | onAbilityCreate: onAbilityCreateCallback, 32 | }; 33 | abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) 34 | var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName 35 | var debug = abilityDelegatorArguments.parameters['-D'] 36 | if (debug == 'true') 37 | { 38 | cmd += ' -D' 39 | } 40 | hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); 41 | abilityDelegator.executeShellCommand(cmd, 42 | (err: any, d: any) => { 43 | hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); 44 | hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); 45 | hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); 46 | }) 47 | hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); 48 | } 49 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "entry_test", 4 | "type": "feature", 5 | "description": "$string:module_test_desc", 6 | "mainElement": "TestAbility", 7 | "deviceTypes": [ 8 | "phone", 9 | "tablet" 10 | ], 11 | "deliveryWithInstall": true, 12 | "installationFree": false, 13 | "pages": "$profile:test_pages", 14 | "abilities": [ 15 | { 16 | "name": "TestAbility", 17 | "srcEntry": "./ets/testability/TestAbility.ets", 18 | "description": "$string:TestAbility_desc", 19 | "icon": "$media:icon", 20 | "label": "$string:TestAbility_label", 21 | "exported": true, 22 | "startWindowIcon": "$media:icon", 23 | "startWindowBackground": "$color:start_window_background", 24 | "skills": [ 25 | { 26 | "actions": [ 27 | "action.system.home" 28 | ], 29 | "entities": [ 30 | "entity.system.home" 31 | ] 32 | } 33 | ] 34 | } 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/element/color.json: -------------------------------------------------------------------------------- 1 | { 2 | "color": [ 3 | { 4 | "name": "start_window_background", 5 | "value": "#FFFFFF" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_test_desc", 5 | "value": "test ability description" 6 | }, 7 | { 8 | "name": "TestAbility_desc", 9 | "value": "the test ability" 10 | }, 11 | { 12 | "name": "TestAbility_label", 13 | "value": "test label" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/media/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/entry/src/ohosTest/resources/base/media/icon.png -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/profile/test_pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "src": [ 3 | "testability/pages/Index" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /hvigor/hvigor-config.json5: -------------------------------------------------------------------------------- 1 | { 2 | "hvigorVersion": "2.4.2", 3 | "dependencies": { 4 | "@ohos/hvigor-ohos-plugin": "2.4.2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /hvigorfile.ts: -------------------------------------------------------------------------------- 1 | // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. 2 | export { appTasks } from '@ohos/hvigor-ohos-plugin'; -------------------------------------------------------------------------------- /hvigorw: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ---------------------------------------------------------------------------- 4 | # Hvigor startup script, version 1.0.0 5 | # 6 | # Required ENV vars: 7 | # ------------------ 8 | # NODE_HOME - location of a Node home dir 9 | # or 10 | # Add /usr/local/nodejs/bin to the PATH environment variable 11 | # ---------------------------------------------------------------------------- 12 | 13 | HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) 14 | HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 15 | warn() { 16 | echo "" 17 | echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 18 | } 19 | 20 | error() { 21 | echo "" 22 | echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 23 | } 24 | 25 | fail() { 26 | error "$@" 27 | exit 1 28 | } 29 | 30 | # Determine node to start hvigor wrapper script 31 | if [ -n "${NODE_HOME}" ];then 32 | EXECUTABLE_NODE="${NODE_HOME}/bin/node" 33 | if [ ! -x "$EXECUTABLE_NODE" ];then 34 | fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" 35 | fi 36 | else 37 | EXECUTABLE_NODE="node" 38 | which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 39 | fi 40 | 41 | # Check hvigor wrapper script 42 | if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 43 | fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 44 | fi 45 | 46 | # start hvigor-wrapper script 47 | exec "${EXECUTABLE_NODE}" \ 48 | "${HVIGOR_WRAPPER_SCRIPT}" "$@" 49 | -------------------------------------------------------------------------------- /hvigorw.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Hvigor startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 17 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 18 | 19 | set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js 20 | set NODE_EXE=node.exe 21 | 22 | goto start 23 | 24 | :start 25 | @rem Find node.exe 26 | if defined NODE_HOME goto findNodeFromNodeHome 27 | 28 | %NODE_EXE% --version >NUL 2>&1 29 | if "%ERRORLEVEL%" == "0" goto execute 30 | 31 | echo. 32 | echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. 33 | echo. 34 | echo Please set the NODE_HOME variable in your environment to match the 35 | echo location of your NodeJs installation. 36 | 37 | goto fail 38 | 39 | :findNodeFromNodeHome 40 | set NODE_HOME=%NODE_HOME:"=% 41 | set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% 42 | 43 | if exist "%NODE_EXE_PATH%" goto execute 44 | echo. 45 | echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. 46 | echo. 47 | echo Please set the NODE_HOME variable in your environment to match the 48 | echo location of your NodeJs installation. 49 | 50 | goto fail 51 | 52 | :execute 53 | @rem Execute hvigor 54 | "%NODE_EXE%" %WRAPPER_MODULE_PATH% %* 55 | 56 | if "%ERRORLEVEL%" == "0" goto hvigorwEnd 57 | 58 | :fail 59 | exit /b 1 60 | 61 | :hvigorwEnd 62 | if "%OS%" == "Windows_NT" endlocal 63 | 64 | :end 65 | -------------------------------------------------------------------------------- /img/img-o.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img-o.png -------------------------------------------------------------------------------- /img/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img.png -------------------------------------------------------------------------------- /img/img_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_1.png -------------------------------------------------------------------------------- /img/img_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_10.png -------------------------------------------------------------------------------- /img/img_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_11.png -------------------------------------------------------------------------------- /img/img_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_12.png -------------------------------------------------------------------------------- /img/img_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_13.png -------------------------------------------------------------------------------- /img/img_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_14.png -------------------------------------------------------------------------------- /img/img_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_2.png -------------------------------------------------------------------------------- /img/img_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_3.png -------------------------------------------------------------------------------- /img/img_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_4.png -------------------------------------------------------------------------------- /img/img_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_5.png -------------------------------------------------------------------------------- /img/img_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_6.png -------------------------------------------------------------------------------- /img/img_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_7.png -------------------------------------------------------------------------------- /img/img_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_8.png -------------------------------------------------------------------------------- /img/img_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/img_9.png -------------------------------------------------------------------------------- /img/pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/pic1.png -------------------------------------------------------------------------------- /img/pic10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/pic10.png -------------------------------------------------------------------------------- /img/pic7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/pic7.png -------------------------------------------------------------------------------- /img/pic8(1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/pic8(1).png -------------------------------------------------------------------------------- /img/pic9(1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KennyHito/SggHarmony/d6793ec82f416dbd29775adb6c81688ce47d5e28/img/pic9(1).png -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by DevEco Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file should *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # For customization when using a Version Control System, please read the header note. 8 | nodejs.dir=/Users/apple/nodejs 9 | hwsdk.dir=/Users/apple/Library/Huawei/Sdk -------------------------------------------------------------------------------- /oh-package-lock.json5: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", 4 | "specifiers": { 5 | "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6", 6 | "@ohos/axios@^2.2.0": "@ohos/axios@2.2.0" 7 | }, 8 | "packages": { 9 | "@ohos/hypium@1.0.6": { 10 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", 11 | "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" 12 | }, 13 | "@ohos/axios@2.2.0": { 14 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/axios/-/axios-2.2.0.har", 15 | "integrity": "sha512-v1QBWk6DfcN8wUW3D0ieFbHTR1taSI5cOgxp5l6B5cegXuNYhSc8ggKlAIXe6h/14LsfM+NW0ZGfSXcNEIM5yA==" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "license": "", 3 | "devDependencies": { 4 | "@ohos/hypium": "1.0.6" 5 | }, 6 | "author": "", 7 | "name": "englishpractice", 8 | "description": "Please describe the basic information.", 9 | "main": "", 10 | "version": "1.0.0", 11 | "dependencies": { 12 | "@ohos/axios": "^2.2.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [v2.2.0] 2024.02 4 | 发布正式版本 5 | 6 | ## [v2.2.0-rc.4] 2024.02 7 | ## 修复 8 | - 文件上传发送后,先返回了响应空结果,然后开始了上传的进度 9 | 10 | ## [v2.2.0-rc.3] 2024.01 11 | ## 修复 12 | - 上传文件必须添加onUploadProgress事件 13 | - 上传文件为uri必须指定文件名 14 | - 上传文件uri不存在无错误返回 15 | 16 | ## [v2.2.0-rc.2] 2023-12 17 | ## 修复 18 | - 更正文档泛型参数解释 19 | - 删除代码中敏感信息 20 | - header中的headerName不支持带数字 21 | 22 | ## [v2.2.0-rc.1] 2023-12 23 | - 支持证书锁定(API11) 24 | ## 修复 25 | - 由于OH参数变更,修改双向校验密码参数 26 | 27 | ## [v2.2.0-rc.0] 2023-11 28 | - 支持p12格式的CA证书(API11) 29 | - 支持pem,p12格式的客户端证书,实现双向校验(API11) 30 | - 支持设置代理 31 | 32 | ## [v2.1.1] 2023-11 33 | 发布正式版本 34 | 35 | ## [v2.1.1-rc.0] 2023-11 36 | ## 更新 37 | - 放开系统侧5MB限制 38 | 39 | ## [v2.1.0] 2023-11 40 | ## 更新 41 | - 指定返回数据的类型 42 | - 指定自定义证书 43 | - 设置请求优先级 44 | 45 | ## [v2.0.5] 2023-11 46 | 发布正式版本 47 | 48 | ## [v2.0.5-rc.0] 2023-10 49 | ## 修复 50 | - 修复不兼容API9问题,版本升级小版本2.0.4-rc.0 51 | 52 | ## [v2.0.4] 2023-09 53 | ## 更新 54 | - ArkTS语法适配整改 55 | ## 修复 56 | - API 9使用axios报错问题 57 | 58 | ## [v2.0.3] 2023-08 59 | ### 修复 60 | - 上传文件无法获取返回数据。 61 | 62 | ## [v2.0.2] 2023-06 63 | ### 修复 64 | - 已知bug修复。 65 | 66 | ## [v2.0.1] 2023-06 67 | ## 更新 68 | - 适配DevEco Studio: 4.0 Carry1(4.0.3.212) 69 | - 适配SDK: API10(4.0.8.3) 70 | 71 | ## [v2.0.0] 2023-04 72 | ### 新增 73 | 基于[axios](https://github.com/axios/axios) 原库v1.3.4版本进行适配,已适配以下功能: 74 | - 发送 http 请求 ,自动转换JSON data 数据 75 | - 上传/下载文件功能,监听上传下载事件 76 | - request 和 response 拦截器 77 | - 默认设置功能 78 | - Promise API 79 | - 包管理工具切换为OHPM 80 | 81 | ### 移除 82 | - 移除依赖的follow-redirects、form-data、proxy-from-env库 83 | - 移除原库支持的node、浏览器环境 84 | - 移除proxy代理功能 85 | 86 | ## [v1.0.5] 2023-02 87 | 88 | ### 新增 89 | - 兼容新版本IDE 90 | 91 | ## [v1.0.4] 2022-09 92 | 93 | ### 新增 94 | - 更新测试样例页面布局 95 | ### 修复 96 | - 已知bug修复。 97 | 98 | ## [v1.0.2] 2022-08 99 | 100 | ### 修复 101 | - 下载header头部设置问题修复。 102 | - 更改axios导入方式。 103 | - 新版本RON闪退修复。 104 | - 参数错误无反馈问题修复。 105 | - 说明文档新增权限说明。 106 | - 更新说明文档。 107 | 108 | ## [v1.0.1] 2022-07 109 | 110 | ### 修复 111 | - 更新错误的引用路径。 112 | 113 | ## [v1.0.0] 2022-07 114 | 115 | 基于[axios](https://github.com/axios/axios) 原库0.27.2版本进行适配,使其可以运行在 OpenHarmony,并沿用其现有用法和特性。已支持: 116 | - http 请求。 117 | - Promise API。 118 | - request 和 response 拦截器。 119 | - 默认设置。 120 | - 自动转换 JSON data 数据。 -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/LICENSE: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014-present Matt Zabriskie & Collaborators 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/NOTICE: -------------------------------------------------------------------------------- 1 | OPEN SOURCE SOFTWARE NOTICE 2 | 3 | Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders. 4 | 5 | Warranty Disclaimer 6 | THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. 7 | 8 | Copyright Notice and License Texts 9 | 10 | ---------------------------------------------------------------------- 11 | Software: axios 1.3.4 12 | 13 | Copyright notice: 14 | Copyright (c) 2014-present Matt Zabriskie & Collaborators 15 | 16 | License: The MIT License (MIT) 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/README.OpenSource: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Name": "axios", 4 | "License": "MIT", 5 | "License File": " LICENSE ", 6 | "Version Number": "v1.3.4", 7 | "Owner" : "xiafeng@huawei.com", 8 | "Upstream URL": "github.com/axios/axios", 9 | "Description": "Promise based HTTP client for the browser and node.js" 10 | } 11 | ] -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/ResourceTable.txt: -------------------------------------------------------------------------------- 1 | string page_show 0x02000000 -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": "stageMode", 3 | "buildOption": { 4 | }, 5 | "targets": [ 6 | { 7 | "name": "default" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. 2 | export { harTasks } from '@ohos/hvigor-ohos-plugin'; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/index.js: -------------------------------------------------------------------------------- 1 | import axios from './src/main/ets/components/lib/axios.js' 2 | 3 | // This module is intended to unwrap Axios default export as named. 4 | // Keep top-level export same with static properties 5 | // so that it can keep same with es module or cjs 6 | const { 7 | Axios, 8 | AxiosError, 9 | CanceledError, 10 | isCancel, 11 | CancelToken, 12 | VERSION, 13 | all, 14 | Cancel, 15 | isAxiosError, 16 | spread, 17 | toFormData, 18 | AxiosHeaders, 19 | HttpStatusCode, 20 | formToJSON, 21 | mergeConfig, 22 | FormData 23 | } = axios; 24 | 25 | export { 26 | axios as default, 27 | Axios, 28 | AxiosError, 29 | CanceledError, 30 | isCancel, 31 | CancelToken, 32 | VERSION, 33 | all, 34 | Cancel, 35 | isAxiosError, 36 | spread, 37 | toFormData, 38 | AxiosHeaders, 39 | HttpStatusCode, 40 | formToJSON, 41 | mergeConfig, 42 | FormData 43 | } 44 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "types": "index.d.ts", 3 | "keywords": [ 4 | "OpenHarmony", 5 | "HarmonyOS", 6 | "http", 7 | "request", 8 | "axios" 9 | ], 10 | "author": "ohos_tpc", 11 | "ohos": { 12 | "org": "opensource" 13 | }, 14 | "description": "Axios ,是一个基于 promise 的网络请求库。本库基于npm Axios 原库进行适配,使其可以运行在 OpenHarmony,并沿用其现有用法和特性。", 15 | "main": "index.js", 16 | "repository": "https://gitee.com/openharmony-sig/ohos_axios.git", 17 | "type": "module", 18 | "version": "2.2.0", 19 | "tags": [ 20 | "Network" 21 | ], 22 | "dependencies": {}, 23 | "license": "MIT", 24 | "devDependencies": {}, 25 | "name": "@ohos/axios" 26 | } 27 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/adapters/README.md: -------------------------------------------------------------------------------- 1 | # axios // adapters 2 | 3 | The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received. 4 | 5 | ## Example 6 | 7 | ```js 8 | var settle = require('./../core/settle'); 9 | 10 | module.exports = function myAdapter(config) { 11 | // At this point: 12 | // - config has been merged with defaults 13 | // - request transformers have already run 14 | // - request interceptors have already run 15 | 16 | // Make the request using config provided 17 | // Upon response settle the Promise 18 | 19 | return new Promise(function(resolve, reject) { 20 | 21 | var response = { 22 | data: responseData, 23 | status: request.status, 24 | statusText: request.statusText, 25 | headers: responseHeaders, 26 | config: config, 27 | request: request 28 | }; 29 | 30 | settle(resolve, reject, response); 31 | 32 | // From here: 33 | // - response transformers will run 34 | // - response interceptors will run 35 | }); 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/adapters/adapters.js: -------------------------------------------------------------------------------- 1 | import utils from '../utils.js'; 2 | //import httpAdapter from './http.js'; 3 | //import xhrAdapter from './xhr.js'; 4 | import ohosAdapter from './ohos/index.js'; 5 | import AxiosError from "../core/AxiosError.js"; 6 | 7 | const knownAdapters = { 8 | // http: httpAdapter, 9 | // xhr: xhrAdapter, 10 | ohos: ohosAdapter 11 | } 12 | 13 | utils.forEach(knownAdapters, (fn, value) => { 14 | if(fn) { 15 | try { 16 | Object.defineProperty(fn, 'name', {value}); 17 | } catch (e) { 18 | // eslint-disable-next-line no-empty 19 | } 20 | Object.defineProperty(fn, 'adapterName', {value}); 21 | } 22 | }); 23 | 24 | export default { 25 | getAdapter: (adapters) => { 26 | adapters = utils.isArray(adapters) ? adapters : [adapters]; 27 | 28 | const {length} = adapters; 29 | let nameOrAdapter; 30 | let adapter; 31 | 32 | for (let i = 0; i < length; i++) { 33 | nameOrAdapter = adapters[i]; 34 | if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) { 35 | break; 36 | } 37 | } 38 | 39 | if (!adapter) { 40 | if (adapter === false) { 41 | throw new AxiosError( 42 | `Adapter ${nameOrAdapter} is not supported by the environment`, 43 | 'ERR_NOT_SUPPORT' 44 | ); 45 | } 46 | 47 | throw new Error( 48 | utils.hasOwnProp(knownAdapters, nameOrAdapter) ? 49 | `Adapter '${nameOrAdapter}' is not available in the build` : 50 | `Unknown adapter '${nameOrAdapter}'` 51 | ); 52 | } 53 | 54 | if (!utils.isFunction(adapter)) { 55 | throw new TypeError('adapter is not a function'); 56 | } 57 | 58 | return adapter; 59 | }, 60 | adapters: knownAdapters 61 | } 62 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/adapters/ohos/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * Copyright (C) 2023 Huawei Device Co., Ltd. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | */ 15 | 16 | import http from './http.js' 17 | import download from './download.js' 18 | import upload from './upload.js' 19 | import fs from '@ohos.file.fs'; 20 | import FormData from '../../env/classes/FormData.js' 21 | import AxiosError from '../../../lib/core/AxiosError' 22 | 23 | const isXHRAdapterSupported = true 24 | 25 | export default isXHRAdapterSupported && function (config) { 26 | return new Promise(function (resolve, reject) { 27 | if (config.data && config.context 28 | && config.data instanceof FormData 29 | && config.method.toUpperCase() === 'POST') { 30 | // 上传 31 | upload(config, resolve, reject); 32 | } else if (config.filePath && config.method.toUpperCase() === 'GET') { 33 | // 下载。如果文件已存在,则直接返回错误。 34 | try { 35 | let cacheDir = config.context && config.context.cacheDir ? config.context.cacheDir : ''; 36 | let filePath = config.filePath 37 | let path = config.filePath.indexOf(cacheDir) > -1 ? filePath : `${cacheDir}/${filePath}` 38 | 39 | let res = fs.accessSync(path); 40 | if(!res){ 41 | download(config, resolve, reject); 42 | }else { 43 | reject(new AxiosError('The file already exist, please delete the file first!', AxiosError.ERR_BAD_OPTION, null, null, null)); 44 | } 45 | } catch (err) { 46 | reject(new AxiosError(err, AxiosError.ERR_BAD_OPTION, null, null, null)); 47 | } 48 | } else { 49 | // 发送请求 50 | http(config, resolve, reject); 51 | } 52 | }) 53 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/axios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from './utils.js'; 4 | import bind from './helpers/bind.js'; 5 | import Axios from './core/Axios.js'; 6 | import mergeConfig from './core/mergeConfig.js'; 7 | import defaults from './defaults/index.js'; 8 | import formDataToJSON from './helpers/formDataToJSON.js'; 9 | import CanceledError from './cancel/CanceledError.js'; 10 | import CancelToken from './cancel/CancelToken.js'; 11 | import isCancel from './cancel/isCancel.js'; 12 | import {VERSION} from './env/data.js'; 13 | import toFormData from './helpers/toFormData.js'; 14 | import AxiosError from './core/AxiosError.js'; 15 | import spread from './helpers/spread.js'; 16 | import isAxiosError from './helpers/isAxiosError.js'; 17 | import AxiosHeaders from "./core/AxiosHeaders.js"; 18 | import HttpStatusCode from './helpers/HttpStatusCode.js'; 19 | import FormData from './env/classes/FormData.js' 20 | 21 | /** 22 | * Create an instance of Axios 23 | * 24 | * @param {Object} defaultConfig The default config for the instance 25 | * 26 | * @returns {Axios} A new instance of Axios 27 | */ 28 | function createInstance(defaultConfig) { 29 | const context = new Axios(defaultConfig); 30 | const instance = bind(Axios.prototype.request, context); 31 | 32 | // Copy axios.prototype to instance 33 | utils.extend(instance, Axios.prototype, context, {allOwnKeys: true}); 34 | 35 | // Copy context to instance 36 | utils.extend(instance, context, null, {allOwnKeys: true}); 37 | 38 | // Factory for creating new instances 39 | instance.create = function create(instanceConfig) { 40 | return createInstance(mergeConfig(defaultConfig, instanceConfig)); 41 | }; 42 | 43 | return instance; 44 | } 45 | 46 | // Create the default instance to be exported 47 | const axios = createInstance(defaults); 48 | 49 | // Expose Axios class to allow class inheritance 50 | axios.Axios = Axios; 51 | 52 | // Expose Cancel & CancelToken 53 | axios.CanceledError = CanceledError; 54 | axios.CancelToken = CancelToken; 55 | axios.isCancel = isCancel; 56 | axios.VERSION = VERSION; 57 | axios.toFormData = toFormData; 58 | 59 | // Expose AxiosError class 60 | axios.AxiosError = AxiosError; 61 | 62 | // alias for CanceledError for backward compatibility 63 | axios.Cancel = axios.CanceledError; 64 | 65 | // Expose all/spread 66 | axios.all = function all(promises) { 67 | return Promise.all(promises); 68 | }; 69 | 70 | axios.spread = spread; 71 | 72 | // Expose isAxiosError 73 | axios.isAxiosError = isAxiosError; 74 | 75 | // Expose mergeConfig 76 | axios.mergeConfig = mergeConfig; 77 | 78 | axios.AxiosHeaders = AxiosHeaders; 79 | 80 | axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing); 81 | 82 | axios.HttpStatusCode = HttpStatusCode; 83 | 84 | axios.default = axios; 85 | 86 | axios.FormData = FormData 87 | 88 | // this module should only have a default export 89 | export default axios 90 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/cancel/CancelToken.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import CanceledError from './CanceledError.js'; 4 | 5 | /** 6 | * A `CancelToken` is an object that can be used to request cancellation of an operation. 7 | * 8 | * @param {Function} executor The executor function. 9 | * 10 | * @returns {CancelToken} 11 | */ 12 | class CancelToken { 13 | constructor(executor) { 14 | if (typeof executor !== 'function') { 15 | throw new TypeError('executor must be a function.'); 16 | } 17 | 18 | let resolvePromise; 19 | 20 | this.promise = new Promise(function promiseExecutor(resolve) { 21 | resolvePromise = resolve; 22 | }); 23 | 24 | const token = this; 25 | 26 | // eslint-disable-next-line func-names 27 | this.promise.then(cancel => { 28 | if (!token._listeners) return; 29 | 30 | let i = token._listeners.length; 31 | 32 | while (i-- > 0) { 33 | token._listeners[i](cancel); 34 | } 35 | token._listeners = null; 36 | }); 37 | 38 | // eslint-disable-next-line func-names 39 | this.promise.then = onfulfilled => { 40 | let _resolve; 41 | // eslint-disable-next-line func-names 42 | const promise = new Promise(resolve => { 43 | token.subscribe(resolve); 44 | _resolve = resolve; 45 | }).then(onfulfilled); 46 | 47 | promise.cancel = function reject() { 48 | token.unsubscribe(_resolve); 49 | }; 50 | 51 | return promise; 52 | }; 53 | 54 | executor(function cancel(message, config, request) { 55 | if (token.reason) { 56 | // Cancellation has already been requested 57 | return; 58 | } 59 | 60 | token.reason = new CanceledError(message, config, request); 61 | resolvePromise(token.reason); 62 | }); 63 | } 64 | 65 | /** 66 | * Throws a `CanceledError` if cancellation has been requested. 67 | */ 68 | throwIfRequested() { 69 | if (this.reason) { 70 | throw this.reason; 71 | } 72 | } 73 | 74 | /** 75 | * Subscribe to the cancel signal 76 | */ 77 | 78 | subscribe(listener) { 79 | if (this.reason) { 80 | listener(this.reason); 81 | return; 82 | } 83 | 84 | if (this._listeners) { 85 | this._listeners.push(listener); 86 | } else { 87 | this._listeners = [listener]; 88 | } 89 | } 90 | 91 | /** 92 | * Unsubscribe from the cancel signal 93 | */ 94 | 95 | unsubscribe(listener) { 96 | if (!this._listeners) { 97 | return; 98 | } 99 | const index = this._listeners.indexOf(listener); 100 | if (index !== -1) { 101 | this._listeners.splice(index, 1); 102 | } 103 | } 104 | 105 | /** 106 | * Returns an object that contains a new `CancelToken` and a function that, when called, 107 | * cancels the `CancelToken`. 108 | */ 109 | static source() { 110 | let cancel; 111 | const token = new CancelToken(function executor(c) { 112 | cancel = c; 113 | }); 114 | return { 115 | token, 116 | cancel 117 | }; 118 | } 119 | } 120 | 121 | export default CancelToken; 122 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/cancel/CanceledError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import AxiosError from '../core/AxiosError.js'; 4 | import utils from '../utils.js'; 5 | 6 | /** 7 | * A `CanceledError` is an object that is thrown when an operation is canceled. 8 | * 9 | * @param {string=} message The message. 10 | * @param {Object=} config The config. 11 | * @param {Object=} request The request. 12 | * 13 | * @returns {CanceledError} The created error. 14 | */ 15 | function CanceledError(message, config, request) { 16 | // eslint-disable-next-line no-eq-null,eqeqeq 17 | AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request); 18 | this.name = 'CanceledError'; 19 | } 20 | 21 | utils.inherits(CanceledError, AxiosError, { 22 | __CANCEL__: true 23 | }); 24 | 25 | export default CanceledError; 26 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/cancel/isCancel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export default function isCancel(value) { 4 | return !!(value && value.__CANCEL__); 5 | } 6 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/core/AxiosError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from '../utils.js'; 4 | 5 | /** 6 | * Create an Error with the specified message, config, error code, request and response. 7 | * 8 | * @param {string} message The error message. 9 | * @param {string} [code] The error code (for example, 'ECONNABORTED'). 10 | * @param {Object} [config] The config. 11 | * @param {Object} [request] The request. 12 | * @param {Object} [response] The response. 13 | * 14 | * @returns {Error} The created error. 15 | */ 16 | function AxiosError(message, code, config, request, response) { 17 | Error.call(this); 18 | 19 | if (Error.captureStackTrace) { 20 | Error.captureStackTrace(this, this.constructor); 21 | } else { 22 | this.stack = (new Error()).stack; 23 | } 24 | 25 | this.message = message; 26 | this.name = 'AxiosError'; 27 | code && (this.code = code); 28 | config && (this.config = config); 29 | request && (this.request = request); 30 | response && (this.response = response); 31 | } 32 | 33 | utils.inherits(AxiosError, Error, { 34 | toJSON: function toJSON() { 35 | return { 36 | // Standard 37 | message: this.message, 38 | name: this.name, 39 | // Microsoft 40 | description: this.description, 41 | number: this.number, 42 | // Mozilla 43 | fileName: this.fileName, 44 | lineNumber: this.lineNumber, 45 | columnNumber: this.columnNumber, 46 | stack: this.stack, 47 | // Axios 48 | config: utils.toJSONObject(this.config), 49 | code: this.code, 50 | status: this.response && this.response.status ? this.response.status : null 51 | }; 52 | } 53 | }); 54 | 55 | const prototype = AxiosError.prototype; 56 | const descriptors = {}; 57 | 58 | [ 59 | 'ERR_BAD_OPTION_VALUE', 60 | 'ERR_BAD_OPTION', 61 | 'ECONNABORTED', 62 | 'ETIMEDOUT', 63 | 'ERR_NETWORK', 64 | 'ERR_FR_TOO_MANY_REDIRECTS', 65 | 'ERR_DEPRECATED', 66 | 'ERR_BAD_RESPONSE', 67 | 'ERR_BAD_REQUEST', 68 | 'ERR_CANCELED', 69 | 'ERR_NOT_SUPPORT', 70 | 'ERR_INVALID_URL' 71 | // eslint-disable-next-line func-names 72 | ].forEach(code => { 73 | descriptors[code] = {value: code}; 74 | }); 75 | 76 | Object.defineProperties(AxiosError, descriptors); 77 | Object.defineProperty(prototype, 'isAxiosError', {value: true}); 78 | 79 | // eslint-disable-next-line func-names 80 | AxiosError.from = (error, code, config, request, response, customProps) => { 81 | const axiosError = Object.create(prototype); 82 | 83 | utils.toFlatObject(error, axiosError, function filter(obj) { 84 | return obj !== Error.prototype; 85 | }, prop => { 86 | return prop !== 'isAxiosError'; 87 | }); 88 | 89 | AxiosError.call(axiosError, error.message, code, config, request, response); 90 | 91 | axiosError.cause = error; 92 | 93 | axiosError.name = error.name; 94 | 95 | customProps && Object.assign(axiosError, customProps); 96 | 97 | return axiosError; 98 | }; 99 | 100 | export default AxiosError; 101 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/core/InterceptorManager.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from './../utils.js'; 4 | 5 | class InterceptorManager { 6 | constructor() { 7 | this.handlers = []; 8 | } 9 | 10 | /** 11 | * Add a new interceptor to the stack 12 | * 13 | * @param {Function} fulfilled The function to handle `then` for a `Promise` 14 | * @param {Function} rejected The function to handle `reject` for a `Promise` 15 | * 16 | * @return {Number} An ID used to remove interceptor later 17 | */ 18 | use(fulfilled, rejected, options) { 19 | this.handlers.push({ 20 | fulfilled, 21 | rejected, 22 | synchronous: options ? options.synchronous : false, 23 | runWhen: options ? options.runWhen : null 24 | }); 25 | return this.handlers.length - 1; 26 | } 27 | 28 | /** 29 | * Remove an interceptor from the stack 30 | * 31 | * @param {Number} id The ID that was returned by `use` 32 | * 33 | * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise 34 | */ 35 | eject(id) { 36 | if (this.handlers[id]) { 37 | this.handlers[id] = null; 38 | } 39 | } 40 | 41 | /** 42 | * Clear all interceptors from the stack 43 | * 44 | * @returns {void} 45 | */ 46 | clear() { 47 | if (this.handlers) { 48 | this.handlers = []; 49 | } 50 | } 51 | 52 | /** 53 | * Iterate over all the registered interceptors 54 | * 55 | * This method is particularly useful for skipping over any 56 | * interceptors that may have become `null` calling `eject`. 57 | * 58 | * @param {Function} fn The function to call for each interceptor 59 | * 60 | * @returns {void} 61 | */ 62 | forEach(fn) { 63 | utils.forEach(this.handlers, function forEachHandler(h) { 64 | if (h !== null) { 65 | fn(h); 66 | } 67 | }); 68 | } 69 | } 70 | 71 | export default InterceptorManager; 72 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/core/README.md: -------------------------------------------------------------------------------- 1 | # axios // core 2 | 3 | The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are: 4 | 5 | - Dispatching requests 6 | - Requests sent via `adapters/` (see lib/adapters/README.md) 7 | - Managing interceptors 8 | - Handling config 9 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/core/buildFullPath.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import isAbsoluteURL from '../helpers/isAbsoluteURL.js'; 4 | import combineURLs from '../helpers/combineURLs.js'; 5 | 6 | /** 7 | * Creates a new URL by combining the baseURL with the requestedURL, 8 | * only when the requestedURL is not already an absolute URL. 9 | * If the requestURL is absolute, this function returns the requestedURL untouched. 10 | * 11 | * @param {string} baseURL The base URL 12 | * @param {string} requestedURL Absolute or relative URL to combine 13 | * 14 | * @returns {string} The combined full path 15 | */ 16 | export default function buildFullPath(baseURL, requestedURL) { 17 | if (baseURL && !isAbsoluteURL(requestedURL)) { 18 | return combineURLs(baseURL, requestedURL); 19 | } 20 | return requestedURL; 21 | } 22 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/core/dispatchRequest.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import transformData from './transformData.js'; 4 | import isCancel from '../cancel/isCancel.js'; 5 | import defaults from '../defaults/index.js'; 6 | import CanceledError from '../cancel/CanceledError.js'; 7 | import AxiosHeaders from '../core/AxiosHeaders.js'; 8 | import adapters from "../adapters/adapters.js"; 9 | 10 | /** 11 | * Throws a `CanceledError` if cancellation has been requested. 12 | * 13 | * @param {Object} config The config that is to be used for the request 14 | * 15 | * @returns {void} 16 | */ 17 | function throwIfCancellationRequested(config) { 18 | if (config.cancelToken) { 19 | config.cancelToken.throwIfRequested(); 20 | } 21 | 22 | if (config.signal && config.signal.aborted) { 23 | throw new CanceledError(null, config); 24 | } 25 | } 26 | 27 | /** 28 | * Dispatch a request to the server using the configured adapter. 29 | * 30 | * @param {object} config The config that is to be used for the request 31 | * 32 | * @returns {Promise} The Promise to be fulfilled 33 | */ 34 | export default function dispatchRequest(config) { 35 | throwIfCancellationRequested(config); 36 | 37 | config.headers = AxiosHeaders.from(config.headers); 38 | 39 | // Transform request data 40 | config.data = transformData.call( 41 | config, 42 | config.transformRequest 43 | ); 44 | 45 | if (['post', 'put', 'patch'].indexOf(config.method) !== -1) { 46 | config.headers.setContentType('application/x-www-form-urlencoded', false); 47 | } 48 | 49 | const adapter = adapters.getAdapter(config.adapter || defaults.adapter); 50 | 51 | return adapter(config).then(function onAdapterResolution(response) { 52 | throwIfCancellationRequested(config); 53 | 54 | // Transform response data 55 | response.data = transformData.call( 56 | config, 57 | config.transformResponse, 58 | response 59 | ); 60 | 61 | response.headers = AxiosHeaders.from(response.headers); 62 | 63 | return response; 64 | }, function onAdapterRejection(reason) { 65 | if (!isCancel(reason)) { 66 | throwIfCancellationRequested(config); 67 | 68 | // Transform response data 69 | if (reason && reason.response) { 70 | reason.response.data = transformData.call( 71 | config, 72 | config.transformResponse, 73 | reason.response 74 | ); 75 | reason.response.headers = AxiosHeaders.from(reason.response.headers); 76 | } 77 | } 78 | 79 | return Promise.reject(reason); 80 | }); 81 | } 82 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/core/settle.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import AxiosError from './AxiosError.js'; 4 | 5 | /** 6 | * Resolve or reject a Promise based on response status. 7 | * 8 | * @param {Function} resolve A function that resolves the promise. 9 | * @param {Function} reject A function that rejects the promise. 10 | * @param {object} response The response. 11 | * 12 | * @returns {object} The response. 13 | */ 14 | export default function settle(resolve, reject, response) { 15 | const validateStatus = response.config.validateStatus; 16 | if (!response.status || !validateStatus || validateStatus(response.status)) { 17 | resolve(response); 18 | } else { 19 | reject(new AxiosError( 20 | 'Request failed with status code ' + response.status, 21 | [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], 22 | response.config, 23 | response.request, 24 | response 25 | )); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/core/transformData.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from './../utils.js'; 4 | import defaults from '../defaults/index.js'; 5 | import AxiosHeaders from '../core/AxiosHeaders.js'; 6 | 7 | /** 8 | * Transform the data for a request or a response 9 | * 10 | * @param {Array|Function} fns A single function or Array of functions 11 | * @param {?Object} response The response object 12 | * 13 | * @returns {*} The resulting transformed data 14 | */ 15 | export default function transformData(fns, response) { 16 | const config = this || defaults; 17 | const context = response || config; 18 | const headers = AxiosHeaders.from(context.headers); 19 | let data = context.data; 20 | 21 | utils.forEach(fns, function transform(fn) { 22 | data = fn.call(config, data, headers.normalize(), response ? response.status : undefined); 23 | }); 24 | 25 | headers.normalize(); 26 | 27 | return data; 28 | } 29 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/defaults/transitional.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export default { 4 | silentJSONParsing: true, 5 | forcedJSONParsing: true, 6 | clarifyTimeoutError: false 7 | }; 8 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/env/README.md: -------------------------------------------------------------------------------- 1 | # axios // env 2 | 3 | The `data.js` file is updated automatically when the package version is upgrading. Please do not edit it manually. 4 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/env/classes/FormData.js: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * Copyright (C) 2023 Huawei Device Co., Ltd. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | */ 15 | function FormData() { 16 | let data = {}; 17 | 18 | this.append = (name, value, option) => { 19 | if (!Object.hasOwnProperty.call(data, name)) { 20 | data[name] = []; 21 | } 22 | data[name].push({ 23 | value: value, 24 | option: option 25 | }) 26 | } 27 | 28 | this.get = (name) => { 29 | if (Object.hasOwnProperty.call(data, name)) { 30 | return data[name][0]; 31 | } 32 | return undefined; 33 | } 34 | 35 | this.has = (name) => { 36 | return Object.hasOwnProperty.call(data, name); 37 | } 38 | 39 | this.delete = (name) => { 40 | return delete data[name]; 41 | } 42 | 43 | this.set = (name, value, option) => { 44 | data[name] = []; 45 | data[name].push({ 46 | value: value, 47 | option: option 48 | }) 49 | } 50 | 51 | this.forEach = (callback) => { 52 | for (let prop in data) { 53 | for (let item of data[prop]) { 54 | callback(item.value, prop, item.option) 55 | } 56 | } 57 | } 58 | } 59 | 60 | export default FormData; 61 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/env/data.js: -------------------------------------------------------------------------------- 1 | export const VERSION = "1.3.4"; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/fileFs.js: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * Copyright (C) 2023 Huawei Device Co., Ltd. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | */ 15 | 16 | import fs from '@ohos.file.fs'; 17 | import hilog from '@ohos.hilog'; 18 | const TAG = '[tpc].[axios]'; 19 | const DOMAIN = 0x0001 20 | 21 | /** 22 | * write files 23 | * @param path: file path 24 | * @param name: filename 25 | * @param content: file content 26 | */ 27 | const writeFile = (path, name, content) => { 28 | if (!fs.accessSync(path)) { 29 | fs.mkdirSync(path); 30 | } 31 | hilog.info(DOMAIN, TAG, `write file path = ${path}`); 32 | let file = fs.openSync(`${path}/${name}`, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE); 33 | fs.writeSync(file.fd, content); 34 | fs.fsyncSync(file.fd); 35 | fs.closeSync(file); 36 | } 37 | 38 | /** 39 | * Clean up temporary directory files 40 | * @param cacheDir: temporary directory 41 | * @param options: request configuration 42 | */ 43 | const deleteFile = (cacheDir, options) => { 44 | const axios_temp = 'axios_temp' 45 | let path_temp = `${cacheDir}/${axios_temp}/`; 46 | try { 47 | if (options) { 48 | //Delete specified file 49 | options && options.files.forEach(item => { 50 | item.uri && fs.unlink(item.uri.replace(`internal://cache/${axios_temp}/`, path_temp)); 51 | }) 52 | } else { 53 | // Delete files that exceed 12 hours 54 | let filenames = fs.listFileSync(path_temp); 55 | let now = Date.now(); 56 | for (let i = 0; i < filenames.length; i++) { 57 | let path = path_temp + filenames[i]; 58 | let stat = fs.statSync(path); 59 | if (now - stat.atime * 1000 >= 1 * 60 * 60 * 1000) { 60 | fs.unlink(path); 61 | } 62 | } 63 | } 64 | } 65 | catch (err) { 66 | hilog.error(DOMAIN, TAG, `delete file failed with error message message: ${err.message}, code: ${err.code}`); 67 | } 68 | } 69 | 70 | export { writeFile, deleteFile } 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/AxiosURLSearchParams.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import toFormData from './toFormData.js'; 4 | 5 | /** 6 | * It encodes a string by replacing all characters that are not in the unreserved set with 7 | * their percent-encoded equivalents 8 | * 9 | * @param {string} str - The string to encode. 10 | * 11 | * @returns {string} The encoded string. 12 | */ 13 | function encode(str) { 14 | const charMap = { 15 | '!': '%21', 16 | "'": '%27', 17 | '(': '%28', 18 | ')': '%29', 19 | '~': '%7E', 20 | '%20': '+', 21 | '%00': '\x00' 22 | }; 23 | return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) { 24 | return charMap[match]; 25 | }); 26 | } 27 | 28 | /** 29 | * It takes a params object and converts it to a FormData object 30 | * 31 | * @param {Object} params - The parameters to be converted to a FormData object. 32 | * @param {Object} options - The options object passed to the Axios constructor. 33 | * 34 | * @returns {void} 35 | */ 36 | function AxiosURLSearchParams(params, options) { 37 | this._pairs = []; 38 | 39 | params && toFormData(params, this, options); 40 | } 41 | 42 | const prototype = AxiosURLSearchParams.prototype; 43 | 44 | prototype.append = function append(name, value) { 45 | this._pairs.push([name, value]); 46 | }; 47 | 48 | prototype.toString = function toString(encoder) { 49 | const _encode = encoder ? function(value) { 50 | return encoder.call(this, value, encode); 51 | } : encode; 52 | 53 | return this._pairs.map(function each(pair) { 54 | return _encode(pair[0]) + '=' + _encode(pair[1]); 55 | }, '').join('&'); 56 | }; 57 | 58 | export default AxiosURLSearchParams; 59 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/HttpStatusCode.js: -------------------------------------------------------------------------------- 1 | const HttpStatusCode = { 2 | Continue: 100, 3 | SwitchingProtocols: 101, 4 | Processing: 102, 5 | EarlyHints: 103, 6 | Ok: 200, 7 | Created: 201, 8 | Accepted: 202, 9 | NonAuthoritativeInformation: 203, 10 | NoContent: 204, 11 | ResetContent: 205, 12 | PartialContent: 206, 13 | MultiStatus: 207, 14 | AlreadyReported: 208, 15 | ImUsed: 226, 16 | MultipleChoices: 300, 17 | MovedPermanently: 301, 18 | Found: 302, 19 | SeeOther: 303, 20 | NotModified: 304, 21 | UseProxy: 305, 22 | Unused: 306, 23 | TemporaryRedirect: 307, 24 | PermanentRedirect: 308, 25 | BadRequest: 400, 26 | Unauthorized: 401, 27 | PaymentRequired: 402, 28 | Forbidden: 403, 29 | NotFound: 404, 30 | MethodNotAllowed: 405, 31 | NotAcceptable: 406, 32 | ProxyAuthenticationRequired: 407, 33 | RequestTimeout: 408, 34 | Conflict: 409, 35 | Gone: 410, 36 | LengthRequired: 411, 37 | PreconditionFailed: 412, 38 | PayloadTooLarge: 413, 39 | UriTooLong: 414, 40 | UnsupportedMediaType: 415, 41 | RangeNotSatisfiable: 416, 42 | ExpectationFailed: 417, 43 | ImATeapot: 418, 44 | MisdirectedRequest: 421, 45 | UnprocessableEntity: 422, 46 | Locked: 423, 47 | FailedDependency: 424, 48 | TooEarly: 425, 49 | UpgradeRequired: 426, 50 | PreconditionRequired: 428, 51 | TooManyRequests: 429, 52 | RequestHeaderFieldsTooLarge: 431, 53 | UnavailableForLegalReasons: 451, 54 | InternalServerError: 500, 55 | NotImplemented: 501, 56 | BadGateway: 502, 57 | ServiceUnavailable: 503, 58 | GatewayTimeout: 504, 59 | HttpVersionNotSupported: 505, 60 | VariantAlsoNegotiates: 506, 61 | InsufficientStorage: 507, 62 | LoopDetected: 508, 63 | NotExtended: 510, 64 | NetworkAuthenticationRequired: 511, 65 | }; 66 | 67 | Object.entries(HttpStatusCode).forEach(([key, value]) => { 68 | HttpStatusCode[value] = key; 69 | }); 70 | 71 | export default HttpStatusCode; 72 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/README.md: -------------------------------------------------------------------------------- 1 | # axios // helpers 2 | 3 | The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like: 4 | 5 | - Browser polyfills 6 | - Managing cookies 7 | - Parsing HTTP headers 8 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/ZlibHeaderTransformStream.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | import stream from "stream"; 4 | 5 | class ZlibHeaderTransformStream extends stream.Transform { 6 | __transform(chunk, encoding, callback) { 7 | this.push(chunk); 8 | callback(); 9 | } 10 | 11 | _transform(chunk, encoding, callback) { 12 | if (chunk.length !== 0) { 13 | this._transform = this.__transform; 14 | 15 | // Add Default Compression headers if no zlib headers are present 16 | if (chunk[0] !== 120) { // Hex: 78 17 | const header = Buffer.alloc(2); 18 | header[0] = 120; // Hex: 78 19 | header[1] = 156; // Hex: 9C 20 | this.push(header, encoding); 21 | } 22 | } 23 | 24 | this.__transform(chunk, encoding, callback); 25 | } 26 | } 27 | 28 | export default ZlibHeaderTransformStream; 29 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/bind.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export default function bind(fn, thisArg) { 4 | return function wrap() { 5 | return fn.apply(thisArg, arguments); 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/buildURL.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from '../utils.js'; 4 | import AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js'; 5 | 6 | /** 7 | * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their 8 | * URI encoded counterparts 9 | * 10 | * @param {string} val The value to be encoded. 11 | * 12 | * @returns {string} The encoded value. 13 | */ 14 | function encode(val) { 15 | return encodeURIComponent(val). 16 | replace(/%3A/gi, ':'). 17 | replace(/%24/g, '$'). 18 | replace(/%2C/gi, ','). 19 | replace(/%20/g, '+'). 20 | replace(/%5B/gi, '['). 21 | replace(/%5D/gi, ']'); 22 | } 23 | 24 | /** 25 | * Build a URL by appending params to the end 26 | * 27 | * @param {string} url The base of the url (e.g., http://www.google.com) 28 | * @param {object} [params] The params to be appended 29 | * @param {?object} options 30 | * 31 | * @returns {string} The formatted url 32 | */ 33 | export default function buildURL(url, params, options) { 34 | /*eslint no-param-reassign:0*/ 35 | if (!params) { 36 | return url; 37 | } 38 | 39 | const _encode = options && options.encode || encode; 40 | 41 | const serializeFn = options && options.serialize; 42 | 43 | let serializedParams; 44 | 45 | if (serializeFn) { 46 | serializedParams = serializeFn(params, options); 47 | } else { 48 | serializedParams = utils.isURLSearchParams(params) ? 49 | params.toString() : 50 | new AxiosURLSearchParams(params, options).toString(_encode); 51 | } 52 | 53 | if (serializedParams) { 54 | const hashmarkIndex = url.indexOf("#"); 55 | 56 | if (hashmarkIndex !== -1) { 57 | url = url.slice(0, hashmarkIndex); 58 | } 59 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 60 | } 61 | 62 | return url; 63 | } 64 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/combineURLs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Creates a new URL by combining the specified URLs 5 | * 6 | * @param {string} baseURL The base URL 7 | * @param {string} relativeURL The relative URL 8 | * 9 | * @returns {string} The combined URL 10 | */ 11 | export default function combineURLs(baseURL, relativeURL) { 12 | return relativeURL 13 | ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 14 | : baseURL; 15 | } 16 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/cookies.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from './../utils.js'; 4 | import platform from '../platform/index.js'; 5 | 6 | export default platform.isStandardBrowserEnv ? 7 | 8 | // Standard browser envs support document.cookie 9 | (function standardBrowserEnv() { 10 | return { 11 | write: function write(name, value, expires, path, domain, secure) { 12 | const cookie = []; 13 | cookie.push(name + '=' + encodeURIComponent(value)); 14 | 15 | if (utils.isNumber(expires)) { 16 | cookie.push('expires=' + new Date(expires).toGMTString()); 17 | } 18 | 19 | if (utils.isString(path)) { 20 | cookie.push('path=' + path); 21 | } 22 | 23 | if (utils.isString(domain)) { 24 | cookie.push('domain=' + domain); 25 | } 26 | 27 | if (secure === true) { 28 | cookie.push('secure'); 29 | } 30 | 31 | document.cookie = cookie.join('; '); 32 | }, 33 | 34 | read: function read(name) { 35 | const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 36 | return (match ? decodeURIComponent(match[3]) : null); 37 | }, 38 | 39 | remove: function remove(name) { 40 | this.write(name, '', Date.now() - 86400000); 41 | } 42 | }; 43 | })() : 44 | 45 | // Non standard browser env (web workers, react-native) lack needed support. 46 | (function nonStandardBrowserEnv() { 47 | return { 48 | write: function write() {}, 49 | read: function read() { return null; }, 50 | remove: function remove() {} 51 | }; 52 | })(); 53 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/deprecatedMethod.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /*eslint no-console:0*/ 4 | 5 | /** 6 | * Supply a warning to the developer that a method they are using 7 | * has been deprecated. 8 | * 9 | * @param {string} method The name of the deprecated method 10 | * @param {string} [instead] The alternate method to use if applicable 11 | * @param {string} [docs] The documentation URL to get further details 12 | * 13 | * @returns {void} 14 | */ 15 | export default function deprecatedMethod(method, instead, docs) { 16 | try { 17 | console.warn( 18 | 'DEPRECATED method `' + method + '`.' + 19 | (instead ? ' Use `' + instead + '` instead.' : '') + 20 | ' This method will be removed in a future release.'); 21 | 22 | if (docs) { 23 | console.warn('For more information about usage see ' + docs); 24 | } 25 | } catch (e) { /* Ignore */ } 26 | } 27 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/formDataToJSON.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from '../utils.js'; 4 | 5 | /** 6 | * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z'] 7 | * 8 | * @param {string} name - The name of the property to get. 9 | * 10 | * @returns An array of strings. 11 | */ 12 | function parsePropPath(name) { 13 | // foo[x][y][z] 14 | // foo.x.y.z 15 | // foo-x-y-z 16 | // foo x y z 17 | return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => { 18 | return match[0] === '[]' ? '' : match[1] || match[0]; 19 | }); 20 | } 21 | 22 | /** 23 | * Convert an array to an object. 24 | * 25 | * @param {Array} arr - The array to convert to an object. 26 | * 27 | * @returns An object with the same keys and values as the array. 28 | */ 29 | function arrayToObject(arr) { 30 | const obj = {}; 31 | const keys = Object.keys(arr); 32 | let i; 33 | const len = keys.length; 34 | let key; 35 | for (i = 0; i < len; i++) { 36 | key = keys[i]; 37 | obj[key] = arr[key]; 38 | } 39 | return obj; 40 | } 41 | 42 | /** 43 | * It takes a FormData object and returns a JavaScript object 44 | * 45 | * @param {string} formData The FormData object to convert to JSON. 46 | * 47 | * @returns {Object | null} The converted object. 48 | */ 49 | function formDataToJSON(formData) { 50 | function buildPath(path, value, target, index) { 51 | let name = path[index++]; 52 | const isNumericKey = Number.isFinite(+name); 53 | const isLast = index >= path.length; 54 | name = !name && utils.isArray(target) ? target.length : name; 55 | 56 | if (isLast) { 57 | if (utils.hasOwnProp(target, name)) { 58 | target[name] = [target[name], value]; 59 | } else { 60 | target[name] = value; 61 | } 62 | 63 | return !isNumericKey; 64 | } 65 | 66 | if (!target[name] || !utils.isObject(target[name])) { 67 | target[name] = []; 68 | } 69 | 70 | const result = buildPath(path, value, target[name], index); 71 | 72 | if (result && utils.isArray(target[name])) { 73 | target[name] = arrayToObject(target[name]); 74 | } 75 | 76 | return !isNumericKey; 77 | } 78 | 79 | if (utils.isFormData(formData) && utils.isFunction(formData.entries)) { 80 | const obj = {}; 81 | 82 | utils.forEachEntry(formData, (name, value) => { 83 | buildPath(parsePropPath(name), value, obj, 0); 84 | }); 85 | 86 | return obj; 87 | } 88 | 89 | return null; 90 | } 91 | 92 | export default formDataToJSON; 93 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/formDataToStream.js: -------------------------------------------------------------------------------- 1 | import {TextEncoder} from 'util'; 2 | import {Readable} from 'stream'; 3 | import utils from "../utils.js"; 4 | import readBlob from "./readBlob.js"; 5 | 6 | const BOUNDARY_ALPHABET = utils.ALPHABET.ALPHA_DIGIT + '-_'; 7 | 8 | const textEncoder = new TextEncoder(); 9 | 10 | const CRLF = '\r\n'; 11 | const CRLF_BYTES = textEncoder.encode(CRLF); 12 | const CRLF_BYTES_COUNT = 2; 13 | 14 | class FormDataPart { 15 | constructor(name, value) { 16 | const {escapeName} = this.constructor; 17 | const isStringValue = utils.isString(value); 18 | 19 | let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${ 20 | !isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : '' 21 | }${CRLF}`; 22 | 23 | if (isStringValue) { 24 | value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF)); 25 | } else { 26 | headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF}` 27 | } 28 | 29 | this.headers = textEncoder.encode(headers + CRLF); 30 | 31 | this.contentLength = isStringValue ? value.byteLength : value.size; 32 | 33 | this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT; 34 | 35 | this.name = name; 36 | this.value = value; 37 | } 38 | 39 | async *encode(){ 40 | yield this.headers; 41 | 42 | const {value} = this; 43 | 44 | if(utils.isTypedArray(value)) { 45 | yield value; 46 | } else { 47 | yield* readBlob(value); 48 | } 49 | 50 | yield CRLF_BYTES; 51 | } 52 | 53 | static escapeName(name) { 54 | return String(name).replace(/[\r\n"]/g, (match) => ({ 55 | '\r' : '%0D', 56 | '\n' : '%0A', 57 | '"' : '%22', 58 | }[match])); 59 | } 60 | } 61 | 62 | const formDataToStream = (form, headersHandler, options) => { 63 | const { 64 | tag = 'form-data-boundary', 65 | size = 25, 66 | boundary = tag + '-' + utils.generateString(size, BOUNDARY_ALPHABET) 67 | } = options || {}; 68 | 69 | if(!utils.isFormData(form)) { 70 | throw TypeError('FormData instance required'); 71 | } 72 | 73 | if (boundary.length < 1 || boundary.length > 70) { 74 | throw Error('boundary must be 10-70 characters long') 75 | } 76 | 77 | const boundaryBytes = textEncoder.encode('--' + boundary + CRLF); 78 | const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF + CRLF); 79 | let contentLength = footerBytes.byteLength; 80 | 81 | const parts = Array.from(form.entries()).map(([name, value]) => { 82 | const part = new FormDataPart(name, value); 83 | contentLength += part.size; 84 | return part; 85 | }); 86 | 87 | contentLength += boundaryBytes.byteLength * parts.length; 88 | 89 | contentLength = utils.toFiniteNumber(contentLength); 90 | 91 | const computedHeaders = { 92 | 'Content-Type': `multipart/form-data; boundary=${boundary}` 93 | } 94 | 95 | if (Number.isFinite(contentLength)) { 96 | computedHeaders['Content-Length'] = contentLength; 97 | } 98 | 99 | headersHandler && headersHandler(computedHeaders); 100 | 101 | return Readable.from((async function *() { 102 | for(const part of parts) { 103 | yield boundaryBytes; 104 | yield* part.encode(); 105 | } 106 | 107 | yield footerBytes; 108 | })()); 109 | }; 110 | 111 | export default formDataToStream; 112 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/fromDataURI.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import AxiosError from '../core/AxiosError.js'; 4 | import parseProtocol from './parseProtocol.js'; 5 | import platform from '../platform/index.js'; 6 | 7 | const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/; 8 | 9 | /** 10 | * Parse data uri to a Buffer or Blob 11 | * 12 | * @param {String} uri 13 | * @param {?Boolean} asBlob 14 | * @param {?Object} options 15 | * @param {?Function} options.Blob 16 | * 17 | * @returns {Buffer|Blob} 18 | */ 19 | export default function fromDataURI(uri, asBlob, options) { 20 | const _Blob = options && options.Blob || platform.classes.Blob; 21 | const protocol = parseProtocol(uri); 22 | 23 | if (asBlob === undefined && _Blob) { 24 | asBlob = true; 25 | } 26 | 27 | if (protocol === 'data') { 28 | uri = protocol.length ? uri.slice(protocol.length + 1) : uri; 29 | 30 | const match = DATA_URL_PATTERN.exec(uri); 31 | 32 | if (!match) { 33 | throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL); 34 | } 35 | 36 | const mime = match[1]; 37 | const isBase64 = match[2]; 38 | const body = match[3]; 39 | const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8'); 40 | 41 | if (asBlob) { 42 | if (!_Blob) { 43 | throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT); 44 | } 45 | 46 | return new _Blob([buffer], {type: mime}); 47 | } 48 | 49 | return buffer; 50 | } 51 | 52 | throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT); 53 | } 54 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/isAbsoluteURL.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Determines whether the specified URL is absolute 5 | * 6 | * @param {string} url The URL to test 7 | * 8 | * @returns {boolean} True if the specified URL is absolute, otherwise false 9 | */ 10 | export default function isAbsoluteURL(url) { 11 | // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). 12 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 13 | // by any combination of letters, digits, plus, period, or hyphen. 14 | return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); 15 | } 16 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/isAxiosError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from './../utils.js'; 4 | 5 | /** 6 | * Determines whether the payload is an error thrown by Axios 7 | * 8 | * @param {*} payload The value to test 9 | * 10 | * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false 11 | */ 12 | export default function isAxiosError(payload) { 13 | return utils.isObject(payload) && (payload.isAxiosError === true); 14 | } 15 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/isURLSameOrigin.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from './../utils.js'; 4 | import platform from '../platform/index.js'; 5 | 6 | export default platform.isStandardBrowserEnv ? 7 | 8 | // Standard browser envs have full support of the APIs needed to test 9 | // whether the request URL is of the same origin as current location. 10 | (function standardBrowserEnv() { 11 | const msie = /(msie|trident)/i.test(navigator.userAgent); 12 | const urlParsingNode = document.createElement('a'); 13 | let originURL; 14 | 15 | /** 16 | * Parse a URL to discover it's components 17 | * 18 | * @param {String} url The URL to be parsed 19 | * @returns {Object} 20 | */ 21 | function resolveURL(url) { 22 | let href = url; 23 | 24 | if (msie) { 25 | // IE needs attribute set twice to normalize properties 26 | urlParsingNode.setAttribute('href', href); 27 | href = urlParsingNode.href; 28 | } 29 | 30 | urlParsingNode.setAttribute('href', href); 31 | 32 | // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 33 | return { 34 | href: urlParsingNode.href, 35 | protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 36 | host: urlParsingNode.host, 37 | search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 38 | hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 39 | hostname: urlParsingNode.hostname, 40 | port: urlParsingNode.port, 41 | pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 42 | urlParsingNode.pathname : 43 | '/' + urlParsingNode.pathname 44 | }; 45 | } 46 | 47 | originURL = resolveURL(window.location.href); 48 | 49 | /** 50 | * Determine if a URL shares the same origin as the current location 51 | * 52 | * @param {String} requestURL The URL to test 53 | * @returns {boolean} True if URL shares the same origin, otherwise false 54 | */ 55 | return function isURLSameOrigin(requestURL) { 56 | const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 57 | return (parsed.protocol === originURL.protocol && 58 | parsed.host === originURL.host); 59 | }; 60 | })() : 61 | 62 | // Non standard browser envs (web workers, react-native) lack needed support. 63 | (function nonStandardBrowserEnv() { 64 | return function isURLSameOrigin() { 65 | return true; 66 | }; 67 | })(); 68 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/null.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line strict 2 | export default null; 3 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/parseHeaders.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from './../utils.js'; 4 | 5 | // RawAxiosHeaders whose duplicates are ignored by node 6 | // c.f. https://nodejs.org/api/http.html#http_message_headers 7 | const ignoreDuplicateOf = utils.toObjectSet([ 8 | 'age', 'authorization', 'content-length', 'content-type', 'etag', 9 | 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 10 | 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 11 | 'referer', 'retry-after', 'user-agent' 12 | ]); 13 | 14 | /** 15 | * Parse headers into an object 16 | * 17 | * ``` 18 | * Date: Wed, 27 Aug 2014 08:58:49 GMT 19 | * Content-Type: application/json 20 | * Connection: keep-alive 21 | * Transfer-Encoding: chunked 22 | * ``` 23 | * 24 | * @param {String} rawHeaders Headers needing to be parsed 25 | * 26 | * @returns {Object} Headers parsed into an object 27 | */ 28 | export default rawHeaders => { 29 | const parsed = {}; 30 | let key; 31 | let val; 32 | let i; 33 | 34 | rawHeaders && rawHeaders.split('\n').forEach(function parser(line) { 35 | i = line.indexOf(':'); 36 | key = line.substring(0, i).trim().toLowerCase(); 37 | val = line.substring(i + 1).trim(); 38 | 39 | if (!key || (parsed[key] && ignoreDuplicateOf[key])) { 40 | return; 41 | } 42 | 43 | if (key === 'set-cookie') { 44 | if (parsed[key]) { 45 | parsed[key].push(val); 46 | } else { 47 | parsed[key] = [val]; 48 | } 49 | } else { 50 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 51 | } 52 | }); 53 | 54 | return parsed; 55 | }; 56 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/parseProtocol.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export default function parseProtocol(url) { 4 | const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); 5 | return match && match[1] || ''; 6 | } 7 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/readBlob.js: -------------------------------------------------------------------------------- 1 | const {asyncIterator} = Symbol; 2 | 3 | const readBlob = async function* (blob) { 4 | if (blob.stream) { 5 | yield* blob.stream() 6 | } else if (blob.arrayBuffer) { 7 | yield await blob.arrayBuffer() 8 | } else if (blob[asyncIterator]) { 9 | yield* blob[asyncIterator](); 10 | } else { 11 | yield blob; 12 | } 13 | } 14 | 15 | export default readBlob; 16 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/speedometer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Calculate data maxRate 5 | * @param {Number} [samplesCount= 10] 6 | * @param {Number} [min= 1000] 7 | * @returns {Function} 8 | */ 9 | function speedometer(samplesCount, min) { 10 | samplesCount = samplesCount || 10; 11 | const bytes = new Array(samplesCount); 12 | const timestamps = new Array(samplesCount); 13 | let head = 0; 14 | let tail = 0; 15 | let firstSampleTS; 16 | 17 | min = min !== undefined ? min : 1000; 18 | 19 | return function push(chunkLength) { 20 | const now = Date.now(); 21 | 22 | const startedAt = timestamps[tail]; 23 | 24 | if (!firstSampleTS) { 25 | firstSampleTS = now; 26 | } 27 | 28 | bytes[head] = chunkLength; 29 | timestamps[head] = now; 30 | 31 | let i = tail; 32 | let bytesCount = 0; 33 | 34 | while (i !== head) { 35 | bytesCount += bytes[i++]; 36 | i = i % samplesCount; 37 | } 38 | 39 | head = (head + 1) % samplesCount; 40 | 41 | if (head === tail) { 42 | tail = (tail + 1) % samplesCount; 43 | } 44 | 45 | if (now - firstSampleTS < min) { 46 | return; 47 | } 48 | 49 | const passed = startedAt && now - startedAt; 50 | 51 | return passed ? Math.round(bytesCount * 1000 / passed) : undefined; 52 | }; 53 | } 54 | 55 | export default speedometer; 56 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/spread.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Syntactic sugar for invoking a function and expanding an array for arguments. 5 | * 6 | * Common use case would be to use `Function.prototype.apply`. 7 | * 8 | * ```js 9 | * function f(x, y, z) {} 10 | * var args = [1, 2, 3]; 11 | * f.apply(null, args); 12 | * ``` 13 | * 14 | * With `spread` this example can be re-written. 15 | * 16 | * ```js 17 | * spread(function(x, y, z) {})([1, 2, 3]); 18 | * ``` 19 | * 20 | * @param {Function} callback 21 | * 22 | * @returns {Function} 23 | */ 24 | export default function spread(callback) { 25 | return function wrap(arr) { 26 | return callback.apply(null, arr); 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/throttle.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Throttle decorator 5 | * @param {Function} fn 6 | * @param {Number} freq 7 | * @return {Function} 8 | */ 9 | function throttle(fn, freq) { 10 | let timestamp = 0; 11 | const threshold = 1000 / freq; 12 | let timer = null; 13 | return function throttled(force, args) { 14 | const now = Date.now(); 15 | if (force || now - timestamp > threshold) { 16 | if (timer) { 17 | clearTimeout(timer); 18 | timer = null; 19 | } 20 | timestamp = now; 21 | return fn.apply(null, args); 22 | } 23 | if (!timer) { 24 | timer = setTimeout(() => { 25 | timer = null; 26 | timestamp = Date.now(); 27 | return fn.apply(null, args); 28 | }, threshold - (now - timestamp)); 29 | } 30 | }; 31 | } 32 | 33 | export default throttle; 34 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/toURLEncodedForm.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import utils from '../utils.js'; 4 | import toFormData from './toFormData.js'; 5 | import platform from '../platform/index.js'; 6 | 7 | export default function toURLEncodedForm(data, options) { 8 | return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({ 9 | visitor: function(value, key, path, helpers) { 10 | if (platform.isNode && utils.isBuffer(value)) { 11 | this.append(key, value.toString('base64')); 12 | return false; 13 | } 14 | 15 | return helpers.defaultVisitor.apply(this, arguments); 16 | } 17 | }, options)); 18 | } 19 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/helpers/validator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import {VERSION} from '../env/data.js'; 4 | import AxiosError from '../core/AxiosError.js'; 5 | 6 | const validators = {}; 7 | 8 | // eslint-disable-next-line func-names 9 | ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => { 10 | validators[type] = function validator(thing) { 11 | return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; 12 | }; 13 | }); 14 | 15 | const deprecatedWarnings = {}; 16 | 17 | /** 18 | * Transitional option validator 19 | * 20 | * @param {function|boolean?} validator - set to false if the transitional option has been removed 21 | * @param {string?} version - deprecated version / removed since version 22 | * @param {string?} message - some message with additional info 23 | * 24 | * @returns {function} 25 | */ 26 | validators.transitional = function transitional(validator, version, message) { 27 | function formatMessage(opt, desc) { 28 | return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); 29 | } 30 | 31 | // eslint-disable-next-line func-names 32 | return (value, opt, opts) => { 33 | if (validator === false) { 34 | throw new AxiosError( 35 | formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), 36 | AxiosError.ERR_DEPRECATED 37 | ); 38 | } 39 | 40 | if (version && !deprecatedWarnings[opt]) { 41 | deprecatedWarnings[opt] = true; 42 | // eslint-disable-next-line no-console 43 | console.warn( 44 | formatMessage( 45 | opt, 46 | ' has been deprecated since v' + version + ' and will be removed in the near future' 47 | ) 48 | ); 49 | } 50 | 51 | return validator ? validator(value, opt, opts) : true; 52 | }; 53 | }; 54 | 55 | /** 56 | * Assert object's properties type 57 | * 58 | * @param {object} options 59 | * @param {object} schema 60 | * @param {boolean?} allowUnknown 61 | * 62 | * @returns {object} 63 | */ 64 | 65 | function assertOptions(options, schema, allowUnknown) { 66 | if (typeof options !== 'object') { 67 | throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE); 68 | } 69 | const keys = Object.keys(options); 70 | let i = keys.length; 71 | while (i-- > 0) { 72 | const opt = keys[i]; 73 | const validator = schema[opt]; 74 | if (validator) { 75 | const value = options[opt]; 76 | const result = value === undefined || validator(value, opt, options); 77 | if (result !== true) { 78 | throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE); 79 | } 80 | continue; 81 | } 82 | if (allowUnknown !== true) { 83 | throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION); 84 | } 85 | } 86 | } 87 | 88 | export default { 89 | assertOptions, 90 | validators 91 | }; 92 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/platform/index.js: -------------------------------------------------------------------------------- 1 | import platform from './ohos/index.js'; 2 | 3 | export {platform as default} 4 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/platform/ohos/classes/FormData.js: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * Copyright (C) 2023 Huawei Device Co., Ltd. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | */ 15 | import FormData from '../../../env/classes/FormData.js'; 16 | 17 | export default FormData; 18 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/platform/ohos/classes/URLSearchParams.js: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * Copyright (C) 2023 Huawei Device Co., Ltd. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | */ 15 | 'use strict'; 16 | 17 | import Url from '@ohos.url' 18 | export default Url.URLSearchParams; 19 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/ets/components/lib/platform/ohos/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * Copyright (C) 2023 Huawei Device Co., Ltd. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | */ 15 | import URLSearchParams from './classes/URLSearchParams.js' 16 | import FormData from './classes/FormData.js' 17 | 18 | export default { 19 | isNode: true, 20 | classes: { 21 | URLSearchParams, 22 | FormData, 23 | Blob: typeof Blob !== 'undefined' && Blob || null 24 | }, 25 | protocols: [ 'http', 'https', 'file', 'data' ] 26 | }; 27 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "bundleName": "com.example.axios_openharmony", 4 | "debug": true, 5 | "versionCode": 1000000, 6 | "versionName": "1.0.0", 7 | "minAPIVersion": 9, 8 | "targetAPIVersion": 10, 9 | "apiReleaseType": "Beta2", 10 | "compileSdkVersion": "4.0.9.6", 11 | "compileSdkType": "OpenHarmony" 12 | }, 13 | "module": { 14 | "name": "library", 15 | "type": "har", 16 | "deviceTypes": [ 17 | "default", 18 | "tablet" 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from npm package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/resources/en_US/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from npm package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios/src/main/resources/zh_CN/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from npm package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.6 2 | 3 | - 适配模块化编译 4 | - 适配IDE覆盖率数据输出 5 | 6 | ## 1.0.5 7 | 8 | - 优化接口异常场景处理能力 9 | - 修复大规模压力测试下内存溢出问题 10 | - 修复测试脚本定义扩展原型方法与框架的兼容性问题 11 | - 异步promise状态判断断言与取反断言兼容 12 | 13 | ## 1.0.4 14 | 15 | - 新增异步promise状态判断断言 16 | - 新增基础数据判断断言 17 | - 新增断言异常信息描述 18 | - 优化用例计时逻辑,采用相对时间计时 19 | - 修改用例执行过程,异步执行 20 | - 修复用例结果偶现的乱序问题 21 | 22 | ## 1.0.3 23 | 24 | - 新增mock对象的能力,支持mock无参数函数 25 | - 新增测试套、测试用例随机执行功能 26 | - 解决测试套声明不规范,导致用例加载异常的问题 27 | - 修复命令行窗口输出乱序的问题 28 | 29 | ## 1.0.2 30 | 31 | - 新增mock接口,判断当前mock方法状态、使用次数 32 | - 修复用例耗时统计问题 33 | - 修改断言功能,断言失败后,会抛出异常 34 | 35 | ## 1.0.1 36 | - 新增mock基础能力 37 | - 修复部分断言失败后,消息提示异常问题 38 | 39 | ## 1.0.0 40 | - 新增应用日志关键字查询接口,查询hilog日志中是否包含指定字符串 41 | - 支持用例筛选功能,用于指定测试用例的执行。可按用例名称、类型、规模、级别与测试套名称筛选 42 | - 支持新SDK下单元测试 43 | - 支持dry run 功能,通过命令行传参数,返回当前测试套用例名称全集 44 | - 新增框架接口声明文件,用于deveco联想 45 | - 修复用例状态统计问题 -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/index.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License") 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import Core from './src/main/core'; 17 | import {DEFAULT, TestType, Size, Level} from './src/main/Constant'; 18 | import DataDriver from './src/main/module/config/DataDriver'; 19 | import ExpectExtend from './src/main/module/assert/ExpectExtend'; 20 | import OhReport from './src/main/module/report/OhReport'; 21 | import SysTestKit from './src/main/module/kit/SysTestKit'; 22 | import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from './src/main/interface'; 23 | import {MockKit, when} from './src/main/module/mock/MockKit'; 24 | import ArgumentMatchers from './src/main/module/mock/ArgumentMatchers'; 25 | 26 | class Hypium { 27 | static setData(data) { 28 | const core = Core.getInstance(); 29 | const dataDriver = new DataDriver({data}); 30 | core.addService('dataDriver', dataDriver); 31 | } 32 | 33 | static setTimeConfig(systemTime) { 34 | SysTestKit.systemTime = systemTime; 35 | } 36 | 37 | static hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) { 38 | const core = Core.getInstance(); 39 | const expectExtend = new ExpectExtend({ 40 | 'id': 'extend' 41 | }); 42 | core.addService('expect', expectExtend); 43 | const ohReport = new OhReport({ 44 | 'delegator': abilityDelegator, 45 | 'abilityDelegatorArguments': abilityDelegatorArguments 46 | }); 47 | SysTestKit.delegator = abilityDelegator; 48 | core.addService('report', ohReport); 49 | core.init(); 50 | core.subscribeEvent('spec', ohReport); 51 | core.subscribeEvent('suite', ohReport); 52 | core.subscribeEvent('task', ohReport); 53 | const configService = core.getDefaultService('config'); 54 | 55 | let testParameters = {}; 56 | if (abilityDelegatorArguments !== null) { 57 | testParameters = configService.translateParams(abilityDelegatorArguments.parameters); 58 | } 59 | console.info('parameters:' + JSON.stringify(testParameters)); 60 | configService.setConfig(testParameters); 61 | 62 | testsuite(); 63 | if (Object.prototype.hasOwnProperty.call(globalThis, 'setupUiTestEnvironment')) { 64 | globalThis.setupUiTestEnvironment().then(() => { 65 | console.info('UiTestKit::after run uitest setup, start run testcases'); 66 | core.execute(abilityDelegator); 67 | }).catch((error) => { 68 | console.error('UiTestKit:: call setupUiTestEnvironment failure:' + error); 69 | core.execute(abilityDelegator); 70 | }); 71 | } else { 72 | console.info('UiTestKit:: no need to setup uitest, start run testcases'); 73 | core.execute(abilityDelegator); 74 | } 75 | } 76 | } 77 | 78 | export { 79 | Hypium, 80 | Core, 81 | DEFAULT, 82 | TestType, 83 | Size, 84 | Level, 85 | DataDriver, 86 | ExpectExtend, 87 | OhReport, 88 | SysTestKit, 89 | describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, 90 | MockKit, when, 91 | ArgumentMatchers 92 | }; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ohos/hypium", 3 | "version": "1.0.6", 4 | "description": "A unit test framework for OpenHarmony application", 5 | "main": "index.js", 6 | "keywords": [], 7 | "author": "huawei", 8 | "license": "Apache-2.0", 9 | "dependencies": { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/Constant.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | /** 17 | * define the testcase type : TestType, Size , Level 18 | */ 19 | export const DEFAULT = 0B0000; 20 | 21 | export class TestType { 22 | static FUNCTION = 0B1; 23 | static PERFORMANCE = 0B1 << 1; 24 | static POWER = 0B1 << 2; 25 | static RELIABILITY = 0B1 << 3; 26 | static SECURITY = 0B1 << 4; 27 | static GLOBAL = 0B1 << 5; 28 | static COMPATIBILITY = 0B1 << 6; 29 | static USER = 0B1 << 7; 30 | static STANDARD = 0B1 << 8; 31 | static SAFETY = 0B1 << 9; 32 | static RESILIENCE = 0B1 << 10; 33 | } 34 | 35 | export class Size { 36 | static SMALLTEST = 0B1 << 16; 37 | static MEDIUMTEST = 0B1 << 17; 38 | static LARGETEST = 0B1 << 18; 39 | } 40 | 41 | export class Level { 42 | static LEVEL0 = 0B1 << 24; 43 | static LEVEL1 = 0B1 << 25; 44 | static LEVEL2 = 0B1 << 26; 45 | static LEVEL3 = 0B1 << 27; 46 | static LEVEL4 = 0B1 << 28; 47 | } 48 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/event.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class SpecEvent { 17 | constructor(attr) { 18 | this.id = attr.id; 19 | this.coreContext = attr.context; 20 | this.eventMonitors = []; 21 | } 22 | 23 | subscribeEvent(service) { 24 | this.eventMonitors.push(service); 25 | } 26 | 27 | async specStart() { 28 | for (const monitor of this.eventMonitors) { 29 | await monitor['specStart'](); 30 | } 31 | } 32 | 33 | async specDone() { 34 | for (const monitor of this.eventMonitors) { 35 | await monitor['specDone'](); 36 | } 37 | } 38 | } 39 | 40 | class SuiteEvent { 41 | constructor(attr) { 42 | this.id = attr.id; 43 | this.suiteContext = attr.coreContext; 44 | this.eventMonitors = []; 45 | } 46 | 47 | subscribeEvent(service) { 48 | this.eventMonitors.push(service); 49 | } 50 | 51 | async suiteStart() { 52 | for (const monitor of this.eventMonitors) { 53 | await monitor['suiteStart'](); 54 | } 55 | } 56 | 57 | async suiteDone() { 58 | for (const monitor of this.eventMonitors) { 59 | await monitor['suiteDone'](); 60 | } 61 | } 62 | } 63 | 64 | class TaskEvent { 65 | constructor(attr) { 66 | this.id = attr.id; 67 | this.coreContext = attr.coreContext; 68 | this.eventMonitors = []; 69 | } 70 | 71 | subscribeEvent(service) { 72 | this.eventMonitors.push(service); 73 | } 74 | 75 | async taskStart() { 76 | for (const monitor of this.eventMonitors) { 77 | await monitor['taskStart'](); 78 | } 79 | } 80 | 81 | async taskDone() { 82 | for (const monitor of this.eventMonitors) { 83 | await monitor['taskDone'](); 84 | } 85 | } 86 | 87 | incorrectFormat() { 88 | for (const monitor of this.eventMonitors) { 89 | monitor['incorrectFormat'](); 90 | } 91 | } 92 | } 93 | 94 | export {SpecEvent, TaskEvent, SuiteEvent}; 95 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/interface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import Core from './core'; 17 | 18 | const core = Core.getInstance(); 19 | 20 | const describe = function (desc, func) { 21 | return Reflect.has(core, 'describe') ? core.describe(desc, func) : (desc, func) => { }; 22 | }; 23 | const it = function (desc, filter, func) { 24 | return Reflect.has(core, 'it') ? core.it(desc, filter, func) : (desc, filter, func) => { }; 25 | }; 26 | const beforeEach = function (func) { 27 | return Reflect.has(core, 'beforeEach') ? core.beforeEach(func) : (func) => { }; 28 | }; 29 | const afterEach = function (func) { 30 | return Reflect.has(core, 'afterEach') ? core.afterEach(func) : (func) => { }; 31 | }; 32 | const beforeAll = function (func) { 33 | return Reflect.has(core, 'beforeAll') ? core.beforeAll(func) : (func) => { }; 34 | }; 35 | const afterAll = function (func) { 36 | return Reflect.has(core, 'afterAll') ? core.afterAll(func) : (func) => { }; 37 | }; 38 | const expect = function (actualValue) { 39 | return Reflect.has(core, 'expect') ? core.expect(actualValue) : (actualValue) => { }; 40 | }; 41 | 42 | export { 43 | describe, it, beforeAll, beforeEach, afterEach, afterAll, expect 44 | }; 45 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertClose.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertClose(actualValue, expected) { 17 | console.log('expected:' + expected[0] + ',precision:' + expected[1]); 18 | if (actualValue === null && expected[0] === null) { 19 | throw new Error('actualValue and expected can not be both null!!!'); 20 | } 21 | let result; 22 | let diff = Math.abs(expected[0] - actualValue); 23 | let actualAbs = Math.abs(actualValue); 24 | if ((actualAbs - 0) === 0) { 25 | if ((diff - 0) === 0) { 26 | result = true; 27 | } else { 28 | result = false; 29 | } 30 | } else if (diff / actualAbs < expected[1]) { 31 | result = true; 32 | } else { 33 | result = false; 34 | } 35 | return { 36 | pass: result, 37 | message: '|' + actualValue + ' - ' + expected[0] + '|/' + actualValue + ' is not less than ' + expected[1] 38 | }; 39 | } 40 | 41 | export default assertClose; 42 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertContain.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertContain(actualValue, expect) { 17 | let result = false; 18 | if (Object.prototype.toString.call(actualValue).indexOf('Array')) { 19 | for (let i in actualValue) { 20 | if (actualValue[i] == expect[0]) { 21 | result = true; 22 | } 23 | } 24 | } 25 | let type = Object.prototype.toString.call(actualValue); 26 | if (type === '[object String]') { 27 | result = actualValue.indexOf(expect[0]) >= 0; 28 | } 29 | return { 30 | pass: result, 31 | message: 'expect false, ' + actualValue + ' do not have ' + expect[0] 32 | }; 33 | } 34 | 35 | export default assertContain; 36 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertFail.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertFail() { 17 | return { 18 | pass: false, 19 | message: 'fail ' 20 | }; 21 | } 22 | 23 | export default assertFail; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertFalse.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertFalse(actualValue) { 17 | return { 18 | pass: (actualValue) === false, 19 | message: 'expect false, actualValue is ' + actualValue 20 | }; 21 | } 22 | 23 | export default assertFalse; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertInstanceOf.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertInstanceOf(actualValue, expected) { 17 | if (Object.prototype.toString.call(actualValue) == '[object ' + expected[0] + ']') { 18 | return { 19 | pass: true 20 | }; 21 | } else { 22 | return { 23 | pass: false, 24 | message: actualValue + ' is ' + Object.prototype.toString.call(actualValue) + 'not ' + expected[0] 25 | }; 26 | } 27 | } 28 | 29 | export default assertInstanceOf; 30 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertLarger.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLarger(actualValue, expected) { 17 | return { 18 | pass: (actualValue) > expected[0], 19 | message: (actualValue) + ' is not larger than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLarger; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertLargerOrEqual.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLargerOrEqual(actualValue, expected) { 17 | return { 18 | pass: (actualValue) >= expected[0], 19 | message: (actualValue) + ' is not larger than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLargerOrEqual; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertLess.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLess(actualValue, expected) { 17 | return { 18 | pass: (actualValue) < expected[0], 19 | message: (actualValue) + ' is not less than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLess; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertLessOrEqual.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLessOrEqual(actualValue, expected) { 17 | return { 18 | pass: (actualValue) <= expected[0], 19 | message: (actualValue) + ' is not less than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLessOrEqual; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertNaN.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNaN(actualValue) { 17 | return { 18 | pass: actualValue !== actualValue, 19 | message: 'expect NaN, actualValue is ' + actualValue 20 | }; 21 | } 22 | 23 | export default assertNaN; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertNegUnlimited.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNegUnlimited(actualValue) { 17 | return { 18 | pass: actualValue === Number.NEGATIVE_INFINITY, 19 | message: 'Expected actualValue not to be -Infinity. actualValue is,' + actualValue 20 | }; 21 | } 22 | 23 | export default assertNegUnlimited; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertNull.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNull(actualValue) { 17 | return { 18 | pass: (actualValue) === null, 19 | message: 'expect null, actualValue is ' + (actualValue) 20 | }; 21 | } 22 | 23 | export default assertNull; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPosUnlimited.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertPosUnlimited(actualValue) { 17 | return { 18 | pass: actualValue === Number.POSITIVE_INFINITY, 19 | message: 'Expected actualValue is POSITIVE_INFINITY. actualValue is,' + actualValue 20 | }; 21 | } 22 | 23 | export default assertPosUnlimited; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsPending.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsPending(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | const helper = {}; 26 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 27 | function (got) { 28 | return helper === got ? {pass: true, message: 'actualValue is isPending'} 29 | : { 30 | pass: false, 31 | message: 'expect isPending, actualValue is resolve' 32 | }; 33 | }, 34 | function () { 35 | return { 36 | pass: false 37 | , message: 'expect isPending, actualValue is reject' 38 | }; 39 | }); 40 | } 41 | 42 | export default assertPromiseIsPending; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejected.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsRejected(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | const helper = {}; 26 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 27 | function (got) { 28 | return { 29 | pass: false, 30 | message: 'expect isRejected, but actualValue is ' 31 | + (helper === got ? 'isPending' : 'resolve') 32 | }; 33 | }, 34 | function () { 35 | return {pass: true, message: 'actualValue is isRejected'}; 36 | } 37 | ); 38 | } 39 | 40 | export default assertPromiseIsRejected; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWith.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsRejectedWith(actualPromise, expectedValue) { 19 | 20 | if (!isPromiseLike(actualPromise)) { 21 | return Promise.reject().then(function () { 22 | }, function () { 23 | return {pass: false, message: 'Expected not be called on a promise.'}; 24 | }); 25 | } 26 | 27 | function tips(passed) { 28 | return ('Expected a promise ' + (passed ? 'not ' : '') + 29 | 'to be rejected with ' + JSON.stringify(expectedValue[0])); 30 | } 31 | 32 | const helper = {}; 33 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 34 | function (got) { 35 | return { 36 | pass: false, 37 | message: tips(false) + ' but actualValue is ' 38 | + (helper === got ? 'isPending' : 'resolve') 39 | }; 40 | }, 41 | function (actualValue) { 42 | if (JSON.stringify(actualValue) == JSON.stringify(expectedValue[0])) { 43 | return { 44 | pass: true, 45 | message: 'actualValue was rejected with ' + JSON.stringify(actualValue) + '.' 46 | }; 47 | } else { 48 | return { 49 | pass: false, 50 | message: tips(false) + ' but it was rejected with ' + JSON.stringify(actualValue) + '.' 51 | }; 52 | } 53 | } 54 | ); 55 | } 56 | 57 | export default assertPromiseIsRejectedWith; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolved.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsResolved(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | 26 | const helper = {}; 27 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 28 | function (got) { 29 | return helper === got ? { 30 | pass: false, 31 | message: 'expect resolve, actualValue is isPending' 32 | } 33 | : {pass: true, message: 'actualValue is isResolved'}; 34 | }, 35 | function (rej) { 36 | return { 37 | pass: false, 38 | message: 'Expected a promise to be resolved but it was ' + 39 | 'rejected with ' + JSON.stringify(rej) + '.' 40 | }; 41 | } 42 | ); 43 | } 44 | 45 | export default assertPromiseIsResolved; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolvedWith.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsResolvedWith(actualPromise, expectedValue) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | 26 | function tips(passed) { 27 | return ( 28 | 'Expected a promise ' + (passed ? 'not ' : '') + 29 | 'to be resolved with ' + JSON.stringify(expectedValue[0])); 30 | } 31 | 32 | const helper = {}; 33 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 34 | function (got) { 35 | if (helper === got) { 36 | return {pass: false, message: 'expect resolve, actualValue is isPending'}; 37 | } 38 | if (JSON.stringify(got) == JSON.stringify(expectedValue[0])) { 39 | return { 40 | pass: true, 41 | message: 'actualValue was resolved with ' + JSON.stringify(got) + '.' 42 | }; 43 | } 44 | return { 45 | pass: false, 46 | message: tips(false) + ' but it was resolved with ' + 47 | JSON.stringify(got) + '.' 48 | }; 49 | }, 50 | function (rej) { 51 | return { 52 | pass: false, 53 | message: tips(false) + ' but it was rejected with ' + JSON.stringify(rej) + '.' 54 | }; 55 | } 56 | ); 57 | } 58 | 59 | export default assertPromiseIsResolvedWith; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertThrowError.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertThrowError(actualValue, expected) { 17 | let result = false; 18 | let err; 19 | if (typeof actualValue !== 'function') { 20 | throw new Error('actualValue is not a function'); 21 | } 22 | try { 23 | actualValue(); 24 | return { 25 | pass: result, 26 | message: ' An error is not thrown while it is expected!' 27 | }; 28 | } catch (e) { 29 | err = e; 30 | } 31 | 32 | if (err instanceof Error) { 33 | console.log(err.message); 34 | if (err.message == expected[0]) { 35 | result = true; 36 | } 37 | } 38 | return { 39 | pass: result, 40 | message: 'expected throw failed , ' + err.message + ' is not ' + expected[0] 41 | }; 42 | } 43 | 44 | export default assertThrowError; 45 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertUndefined.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertUndefined(actualValue) { 17 | return { 18 | pass: undefined === (actualValue), 19 | message: 'expect Undefined, actualValue is ' + (actualValue) 20 | }; 21 | } 22 | 23 | export default assertUndefined; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/isPromiseLike.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function isPromiseLike(obj) { 17 | return !!obj && isFunction_(obj.then); 18 | } 19 | 20 | function isFunction_(value) { 21 | return isA_('Function', value); 22 | } 23 | 24 | function isA_(typeName, value) { 25 | return getType_(value) === '[object ' + typeName + ']'; 26 | } 27 | 28 | function getType_(value) { 29 | return Object.prototype.toString.apply(value); 30 | } 31 | 32 | export default isPromiseLike; 33 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/config/Filter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ClassFilter { 17 | constructor(suiteName, itName, params) { 18 | this.suiteName = suiteName; 19 | this.itName = itName; 20 | this.params = params; 21 | } 22 | 23 | filterSuite() { 24 | return !this.params.split(',').map(item => item.split('#')[0]).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 25 | } 26 | 27 | filterIt() { 28 | let classArray = this.params.split(',') || []; 29 | let suiteFilterResult = classArray.filter(item => !item.includes('#')).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 30 | let itFilterResult = classArray.filter(item => item.includes('#')).map(item => item == (this.suiteName + '#' + this.itName)).reduce((pre, cur) => pre || cur, false); 31 | return !(suiteFilterResult || itFilterResult); 32 | } 33 | } 34 | 35 | class NotClassFilter { 36 | constructor(suiteName, itName, params) { 37 | this.suiteName = suiteName; 38 | this.itName = itName; 39 | this.params = params; 40 | } 41 | 42 | filterSuite() { 43 | return this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 44 | } 45 | 46 | filterIt() { 47 | return this.params.split(',').some(item => item == (this.suiteName + '#' + this.itName)); 48 | } 49 | } 50 | 51 | class SuiteAndItNameFilter { 52 | constructor(suiteName, itName, params) { 53 | this.suiteName = suiteName; 54 | this.itName = itName; 55 | this.params = params; 56 | } 57 | 58 | filterSuite() { 59 | return !this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 60 | } 61 | 62 | filterIt() { 63 | return !this.params.split(',').map(item => item == this.itName).reduce((pre, cur) => pre || cur, false); 64 | } 65 | } 66 | 67 | 68 | class TestTypesFilter { 69 | constructor(suiteName, itName, fi, params) { 70 | this.suiteName = suiteName; 71 | this.itName = itName; 72 | this.params = params; 73 | this.fi = fi; 74 | } 75 | 76 | filterIt() { 77 | return !((this.params === (this.fi & this.params)) || this.fi === 0); 78 | } 79 | } 80 | 81 | export {ClassFilter, NotClassFilter, SuiteAndItNameFilter, TestTypesFilter}; 82 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/coverage/coverageCollect.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import SysTestKit from "../kit/SysTestKit"; 17 | 18 | export async function collectCoverageData() { 19 | if (globalThis.__coverage__ === undefined) { 20 | return; 21 | } 22 | const strJson = JSON.stringify(globalThis.__coverage__); 23 | const strLen = strJson.length; 24 | const maxLen = 500; 25 | const maxCount = Math.floor(strLen / maxLen); 26 | const OHOS_REPORT_COVERAGE_DATA = 'OHOS_REPORT_COVERAGE_DATA:'; 27 | for (let count = 0; count <= maxCount; count++) { 28 | await SysTestKit.print(`${OHOS_REPORT_COVERAGE_DATA} ${strJson.substring(count * maxLen, (count + 1) * maxLen)}`); 29 | } 30 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/kit/SysTestKit.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class SysTestKit { 17 | 18 | static delegator = null; 19 | static systemTime = null; 20 | 21 | constructor() { 22 | this.id = 'sysTestKit'; 23 | this.index = 0; 24 | } 25 | 26 | static actionStart(tag) { 27 | console.info(JSON.stringify(tag)); 28 | var message = '\n' + 'OHOS_REPORT_ACTIONSTART: ' + JSON.stringify(tag) + '\n'; 29 | SysTestKit.print(message); 30 | console.info(tag + ' actionStart print success'); 31 | } 32 | 33 | static actionEnd(tag) { 34 | console.info(JSON.stringify(tag)); 35 | var message = '\n' + 'OHOS_REPORT_ACTIONEND: ' + JSON.stringify(tag) + '\n'; 36 | SysTestKit.print(message); 37 | console.info(tag + ' actionEnd print success'); 38 | } 39 | 40 | static async existKeyword(keyword, timeout) { 41 | let reg = new RegExp(/^[a-zA-Z0-9]{1,}$/) 42 | if (!reg.test(keyword)) { 43 | throw new Error('keyword must contain more than one string, and only letters and numbers are supported.') 44 | } 45 | timeout = timeout || 4; 46 | 47 | let searchResult = false; 48 | let cmd = 'hilog -x | grep -i \'' + keyword + '\' | wc -l'; 49 | await executePromise(cmd, timeout).then((data) => { 50 | searchResult = data; 51 | }); 52 | return searchResult; 53 | } 54 | static async print(message) { 55 | if ('printSync' in SysTestKit.delegator) { 56 | console.debug(`printSync called ...`); 57 | SysTestKit.delegator.printSync(message); 58 | } else { 59 | await SysTestKit.delegator.print(message); 60 | } 61 | } 62 | 63 | static async getRealTime() { 64 | let currentTime = new Date().getTime(); 65 | if (SysTestKit.systemTime !== null && SysTestKit.systemTime !== undefined) { 66 | await SysTestKit.systemTime.getRealTime().then((time) => { 67 | console.info(`systemTime.getRealTime success data: ${JSON.stringify(time)}`); 68 | currentTime = time; 69 | }).catch((error) => { 70 | console.error(`failed to systemTime.getRealTime because ${JSON.stringify(error)}`); 71 | }); 72 | } 73 | return currentTime; 74 | } 75 | } 76 | 77 | function executePromise(cmd, timeout) { 78 | return new Promise((resolve, reject) => { 79 | SysTestKit.delegator.executeShellCommand(cmd, timeout, 80 | (error, data) => { 81 | console.info('existKeyword CallBack: err : ' + JSON.stringify(error)); 82 | console.info('existKeyword CallBack: data : ' + JSON.stringify(data)); 83 | resolve(parseInt(data.stdResult) > 3 ? true : false); 84 | }); 85 | }); 86 | } 87 | 88 | export default SysTestKit; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/mock/ArgumentMatchers.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ArgumentMatchers { 17 | ANY = ""; 18 | ANY_STRING = ""; 19 | ANY_BOOLEAN = ""; 20 | ANY_NUMBER = ""; 21 | ANY_OBJECT = ""; 22 | ANY_FUNCTION = ""; 23 | MATCH_REGEXS = ""; 24 | 25 | static any() { 26 | } 27 | 28 | static anyString() { 29 | } 30 | 31 | static anyBoolean() { 32 | } 33 | 34 | static anyNumber() { 35 | } 36 | 37 | static anyObj() { 38 | } 39 | 40 | static anyFunction() { 41 | } 42 | 43 | static matchRegexs() { 44 | let regex = arguments[0]; 45 | if (ArgumentMatchers.isRegExp(regex)) { 46 | return regex; 47 | } 48 | throw Error("not a regex"); 49 | } 50 | 51 | static isRegExp(value) { 52 | return Object.prototype.toString.call(value) === "[object RegExp]"; 53 | } 54 | 55 | matcheReturnKey() { 56 | let arg = arguments[0]; 57 | let regex = arguments[1]; 58 | let stubSetKey = arguments[2]; 59 | 60 | if (stubSetKey && stubSetKey == this.ANY) { 61 | return this.ANY; 62 | } 63 | 64 | if (typeof arg === "string" && !regex) { 65 | return this.ANY_STRING; 66 | } 67 | 68 | if (typeof arg === "boolean" && !regex) { 69 | return this.ANY_BOOLEAN; 70 | } 71 | 72 | if (typeof arg === "number" && !regex) { 73 | return this.ANY_NUMBER; 74 | } 75 | 76 | if (typeof arg === "object" && !regex) { 77 | return this.ANY_OBJECT; 78 | } 79 | 80 | if (typeof arg === "function" && !regex) { 81 | return this.ANY_FUNCTION; 82 | } 83 | 84 | if (typeof arg === "string" && regex) { 85 | return regex.test(arg); 86 | } 87 | 88 | return null; 89 | } 90 | 91 | matcheStubKey() { 92 | let key = arguments[0]; 93 | 94 | if (key === ArgumentMatchers.any) { 95 | return this.ANY; 96 | } 97 | 98 | if (key === ArgumentMatchers.anyString) { 99 | return this.ANY_STRING; 100 | } 101 | if (key === ArgumentMatchers.anyBoolean) { 102 | return this.ANY_BOOLEAN; 103 | } 104 | if (key === ArgumentMatchers.anyNumber) { 105 | return this.ANY_NUMBER; 106 | } 107 | if (key === ArgumentMatchers.anyObj) { 108 | return this.ANY_OBJECT; 109 | } 110 | if (key === ArgumentMatchers.anyFunction) { 111 | return this.ANY_FUNCTION; 112 | } 113 | 114 | if (ArgumentMatchers.isRegExp(key)) { 115 | return key; 116 | } 117 | 118 | return null; 119 | } 120 | } 121 | 122 | export default ArgumentMatchers; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/mock/ExtendInterface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ExtendInterface { 17 | constructor(mocker) { 18 | this.mocker = mocker; 19 | } 20 | 21 | stub() { 22 | this.params = arguments; 23 | return this; 24 | } 25 | 26 | stubMockedCall(returnInfo) { 27 | this.mocker.stubApply(this, this.params, returnInfo); 28 | } 29 | 30 | afterReturn(value) { 31 | this.stubMockedCall(function () { 32 | return value; 33 | }); 34 | } 35 | 36 | afterReturnNothing() { 37 | this.stubMockedCall(function () { 38 | return undefined; 39 | }); 40 | } 41 | 42 | afterAction(action) { 43 | this.stubMockedCall(action); 44 | } 45 | 46 | afterThrow(msg) { 47 | this.stubMockedCall(function () { 48 | throw msg; 49 | }); 50 | } 51 | 52 | clear() { 53 | this.mocker.clear(); 54 | } 55 | } 56 | 57 | export default ExtendInterface; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/mock/VerificationMode.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import {expect} from '../../interface'; 17 | 18 | class VerificationMode { 19 | constructor(times) { 20 | this.doTimes = times; 21 | } 22 | 23 | times(count) { 24 | expect(count).assertEqual(this.doTimes); 25 | } 26 | 27 | never() { 28 | console.log(this.doTimes); 29 | expect(0).assertEqual(this.doTimes); 30 | } 31 | 32 | once() { 33 | expect(1).assertEqual(this.doTimes); 34 | } 35 | 36 | atLeast(count) { 37 | if (count > this.doTimes) { 38 | throw Error('failed ' + count + ' greater than the actual execution times of method'); 39 | } 40 | } 41 | 42 | atMost(count) { 43 | if (count < this.doTimes) { 44 | throw Error('failed ' + count + ' less than the actual execution times of method'); 45 | } 46 | } 47 | } 48 | 49 | export default VerificationMode; -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/axios: -------------------------------------------------------------------------------- 1 | ../../@ohos+axios@2.2.0/oh_modules/@ohos/axios -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium: -------------------------------------------------------------------------------- 1 | ../../@ohos+hypium@1.0.6/oh_modules/@ohos/hypium -------------------------------------------------------------------------------- /oh_modules/@ohos/axios: -------------------------------------------------------------------------------- 1 | ../.ohpm/@ohos+axios@2.2.0/oh_modules/@ohos/axios -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium: -------------------------------------------------------------------------------- 1 | ../.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium --------------------------------------------------------------------------------