diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0b9dda19af05cf615a8be3bc063b228131da6b7c --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4b98ef7cab7b5bd7838d9ab630b9b66148a40da2 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d71e5ead1ce20b4ac3384d18e6d104f1ea4d83b4 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/README.md b/README.md index 84f13726b901f4d29780d9189504aeda5dff82a2..5f2b742cd39448925e3196f48529b5f3224fdfd6 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,80 @@ -# MobileInternet Client - - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://git.nju.edu.cn/mobileInternet/mobileInternet_client.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://git.nju.edu.cn/mobileInternet/mobileInternet_client/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +### hw1 + +#### 璁捐 + +> 瀹炵幇涓€涓猼odolist + +##### 涓婚〉闈� + +> 瀵艰埅涓巘ab + +- 灞曠ず宸叉湁鐨則odo椤癸紝鐐瑰嚮鍚庤烦杞埌 璇︽儏瀛愰〉闈⑩湐 +- 娣诲姞鎸夐挳锛岀偣鍑诲悗璺宠浆鍒� 娣诲姞瀛愰〉闈⑩湐 +- 搴曢儴tab鏍忥紝鍖呭惈涓や釜椤甸潰锛氬乏杈逛负鏈湴鐗堬紙鍗充富椤甸潰锛夛紝鍙宠竟涓虹綉椤电増鉁� + +1. 濡備綍璁╀袱涓〉闈㈢殑鏁版嵁鍚屾銆佸叡浜紵鈥斺€� @State & @Link +2. 濡備綍浼犻€掍簨椤圭紪鍙风粰瀛愰〉闈紵 鈥斺€� 浣滀负瀛愰〉闈㈢殑name浼犻€掞紝鍦╬agemap澶勮В鏋� + + + +##### 璇︽儏瀛愰〉闈� + +- 灞曠ずtodolist璇︽儏鉁� +- 杩斿洖涓荤晫闈�/鍒犻櫎 鎸夐挳鉁� + + + +##### 娣诲姞瀛愰〉闈� + +> http锛屾暟鎹簱 + +- 閫氳繃http璇锋眰鑾峰彇绠€鍗曠殑淇℃伅锛氬綋鍓嶆椂闂�/澶╂皵锛熺劧鍚庤繘琛屽寘瑁呭鐞嗏湐 +- 娣诲姞鍚庢妸淇℃伅瀛樺偍鍒版暟鎹簱鉁� +- 杩斿洖/娣诲姞 鎸夐挳鍙婃搷浣溾湐 + +1. 猸愬浣曡娣诲姞鎿嶄綔杩斿洖鍚庯紝鍘熼〉闈㈢珛鍗虫洿鏂帮紵 鈥斺€� pushDestination & onPop锛堢埗瀛愰兘闇€瑕侀厤缃紝涓旂敤push + onPop娌″姙娉曪級 +1. 濡備綍瀛樻暟鎹簱 鈥斺€� preference锛屾妸array杞崲涓簀son鏍煎紡瀛樺偍锛屽啀鎶妀son杞崲涓篴rray灞曠ず锛堟敞鎰忓唴瀹逛负绌虹殑鏃跺€欎笉鑳借浆鎹负json锛屼細鎶ラ敊锛夛紝鍦ㄦ瘡涓€娆dd/delete鎿嶄綔鍚庡鏁版嵁搴撹繘琛屽瓨鍌紙鍥犱负椤甸潰閲嶅惎鍚庢病鏈夊洖璋冿紝鏃犳硶鍦ㄦ渶鍚庤繘琛屽瓨鍌級 + +##### 缃戦〉鐗� + +> WebView + +- 鍙﹀啓涓€涓猦tml鏍煎紡鐨則odolist灞曠ず +- 灞曠ず宸叉湁鐨則odo椤癸紝骞朵笖鍙互鏍囪涓哄凡瀹屾垚锛堝悓姝ワ級 +- 涓嶈繘鍏ヨ鎯呴〉锛屼笉娣诲姞 + + + +##### 鍏跺畠 + +璁╃綉椤电増鍜屾湰鍦扮増鐨勬暟鎹悓姝ワ紙涔熷嵆鈥滃凡瀹屾垚鈥濈殑鐘舵€侊級 + +-> 璁╅〉闈㈣瀵熷埌isCompleted灞炴€х殑鏀瑰彉 鈥斺€� 姣忔鏀瑰彉杩欎竴灞炴€х殑鏃跺€欙紝鏇挎崲鏁翠釜瀵硅薄锛堚瓙鍚﹀垯鍙敼鍙樹簡瀵硅薄鐨勬垚鍛樼殑鍊硷紝瀵硅薄鐨勬寚閽堟病鏈夊彉鍖栵紝椤甸潰鏃犳硶瑙傚療鍒版敼鍙橈級 + +-> 杩欎竴灞炴€ф槸鐢盩odoItem鎺у埗鐨勶紝鍥犳寰€Item涓紶鍏ユ暣涓璞℃暟缁勪互鍙奿ndex + +-> ForEach锛� + +- 閬嶅巻鏃剁殑鍙傛暟鏍煎紡涓嶈兘鏈夎锛佸繀椤诲厛鍐檌tem鍐嶅啓index锛屽惁鍒欎細鎶奿ndex璇嗗埆涓篿tem + + ```ts + ForEach(this.totalTasks, (item: TodoItemModel, index: number) => {...} + ``` + + + +鍦ㄤ氦浜掓椂锛岄亣鍒颁簡杩欐牱鐨勬儏鍐碉細 + +ark鏀瑰彉 - web涓嶆敼鍙� + +web鏀瑰彉 - ark鏀瑰彉 + + + +鍘熷洜锛歸eb涓娴嬩笉鍒版暟鎹殑鍙樺寲锛岃繖涓暟鎹槸鍦╳eb寤虹珛鐨勪竴寮€濮嬩紶鍏ョ殑锛岃€屼笖淇敼涔熶笉鏄€氳繃web锛屽洜姝ゆ棤娉曢€氳繃web鐨勭洃瑙嗗櫒鏉ョ洃鍚紝鐩墠鍙兘鎯冲埌锛氬湪arkts涓洃鍚紝鏈夊彉鍖栨椂鎵嬪姩鏇存柊web鐨勬暟鎹湐 + + + +#### 闂 + +鏈塨ug锛氬彲鑳芥槸鍥犱负鏈湴椤甸潰鐨勭洃瑙嗕笉澶燂紝鍙洃瑙嗕簡瀵硅薄鏁扮粍锛屾病鏈夌洃瑙嗗崟涓璞� \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..45a0ea488f99198532316f1f0b86200ea47d497a --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,41 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code-linter.json5 b/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5cfc74f2f9041c2fa1a5aa26263739cd2f5d67aa --- /dev/null +++ b/code-linter.json5 @@ -0,0 +1,20 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/entry/.gitignore b/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..32abf8fd5e44623ebe60bf2adeee4a366372cc85 --- /dev/null +++ b/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..dfb34f7b9ee6d4be47467380bc43fb8019f98e17 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba9480d0a9291ab74ff5856e77634a1c05d027a9 --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..5ff2b5d0b0fe2e3d2559f39a7a8ad5a94745af6e --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2959d78c50285f912adb2cdff9f613df9a503b44 --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/entry/src/main/ets/common/CommonConstant.ets b/entry/src/main/ets/common/CommonConstant.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d64fc5ea74cd0a251f2476173369a46417f21b1 --- /dev/null +++ b/entry/src/main/ets/common/CommonConstant.ets @@ -0,0 +1,69 @@ +export default class CommonConstants { + + //姣忓垪瀹藉害 + static readonly column_space = 16 + + //浜嬮」妗嗙殑瀹�/楂樺害 + static readonly list_width = '93.3%' + static readonly list_height = '64vp' + static readonly list_margin_top = '13vp' + static readonly list_margin_bottom = '64vp' + + //浜嬮」鎵撳嬀鎸夐挳 + static readonly checkbox_width = '28vp' + static readonly checkbox_margin = '20vp' + //浜嬮」鏂囧瓧 + static readonly item_font_size = '20fp' + static readonly item_font_weight = '500' + //涓嶉€忔槑搴� + static readonly opacity_default = 1 + static readonly opacity_completed = 0.4 + //鍦嗚 + static readonly border_radius = 24 + + //涓嶅甫杩斿洖鎸夐挳鐨� 鏍囬 + static readonly title1_font_size = '33fp' + static readonly title1_font_height = '33vp' + static readonly title1_width = '75%' + static readonly title1_margin_top = '24vp' + static readonly title1_margin_bottom = '12vp' + static readonly title1_margin_left = '12vp' + //鎸夐挳 + static readonly button_font_size = '20fp' //鎸夐挳鐨勬枃鏈� + static readonly button_font_size_yes = '20fp' //鎵撳嬀鎸夐挳鐨勬枃鏈� + static readonly button_size = '45fp' //鎸夐挳澶у皬 + static readonly button_margin_top = '24vp' + static readonly button_margin_bottom = '12vp' + static readonly lb_margin_left = '-270' + static readonly rb_margin_left = '5' + + //涓棿鏍囬鎵€鍗犲搴� + static readonly mid_title_col_width = '70%' + //璇︽儏 + static readonly detail_margin_Left = '30' + static readonly detail_width = '40%' + //璇︽儏妗� + static readonly name_height = '80vp' + static readonly disc_height = '200vp' + static readonly time_height = '80vp' + //璇︽儏瀛椾綋 + static readonly detail_title_font_size = '25fp' + static readonly detail_font_size = '20fp' + static readonly time_font_size = '20fp' + static readonly detail_font_weight = '500' + + //杈撳叆妗� + static readonly add_name_width = '20%' + static readonly input_container_width = '65%' + static readonly input_disc_height = '80%' + static readonly input_margin_left = '5' + + static readonly TODO_DATA: Array<string> = [ + "鏃╄捣鏅ㄧ粌", + "鍑嗗鏃╅", + "闃呰鍚嶈憲", + "瀛︿範ArkTS", + "鐪嬪墽鏀炬澗", + ] + +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..58056ae24532a3848b65321a2fb6ab4148c21acf --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,41 @@ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b72fc477d96447e221cf45c9c6671c8018ae05f3 --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,12 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f12db2a00a8a23b6adafdf2cb9de44925be0e0a9 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,67 @@ +import {LocalPage} from '../pages/LocalPage' +import {WebPage} from '../pages/WebPage' +import DataModel from '../viewmodel/DataModel' +import TodoItemModel from '../viewmodel/TodoItemModel'; + +@Entry +@Component +struct Index { + @State currentIndex: number = 0; //瀵艰埅鏍忎笅鏍� + private tabsController: TabsController = new TabsController(); + + @State totalTasks: Array<TodoItemModel> = [] //todoList - root + + async aboutToAppear(): Promise<void> { //鏁版嵁搴� + await DataModel.getPreferences() + await DataModel.getPreferenceData() + this.totalTasks = DataModel.getData() + } + + @Builder //瀵艰埅鏍� + tabBarBuilder(title: string, targetIndex: number, selectedIcon: Resource, unselectIcon: Resource) { + Column() { + Image(this.currentIndex === targetIndex ? selectedIcon : unselectIcon) + .width(24) + .height(24) + Text(title) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize(10) + .fontColor(this.currentIndex === targetIndex ? '#0A59F7' : 'rgba(0,0,0,0.60)') + .textAlign(TextAlign.Center) + .lineHeight(14) + .fontWeight(500) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + .onClick(() => { + this.currentIndex = targetIndex; + this.tabsController.changeIndex(targetIndex); + }) + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.tabsController }) { + TabContent() { + LocalPage({totalTasks: $totalTasks}) + } + .tabBar(this.tabBarBuilder('鏈湴鐗�', 0, $r('app.media.ic_01_on'), $r('app.media.ic_01_off'))) + + TabContent() { + WebPage({totalTasks: $totalTasks}) + } + .tabBar(this.tabBarBuilder('缃戦〉鐗�', 1, $r('app.media.ic_03_on'), $r('app.media.ic_03_off'))) + } + .vertical(false) + .divider({ + strokeWidth: 0.5, + color: $r('app.color.grey2') + }) + .scrollable(false) + .backgroundColor($r('app.color.grey')) + .height('102%') + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/LocalPage.ets b/entry/src/main/ets/pages/LocalPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a810ecbb0f111f0682542cc1519fad2f7691f81 --- /dev/null +++ b/entry/src/main/ets/pages/LocalPage.ets @@ -0,0 +1,79 @@ +import ToDoItem from '../view/TodoItem' +import CommonConstants from '../common/CommonConstant' +import TodoItemModel from '../viewmodel/TodoItemModel' +import DataModel from '../viewmodel/DataModel' +import AddItem from '../view/AddItem'; +import ItemDetail from '../view/ItemDetail'; + +@Component +export struct LocalPage { + @Link totalTasks: Array<TodoItemModel> //TodoList - link + + @Provide('localPageStack') LocalPageStack: NavPathStack = new NavPathStack(); //router + + @Builder + PageMap(name: string) { + if(name.substring(0, 10) == 'ItemDetail') { + ItemDetail({content: this.totalTasks[parseInt(name.substring(10))]}) + } + else if(name == 'AddItem') { + AddItem() + } + } + + build() { + Navigation(this.LocalPageStack) { + Row() { //椤舵爮 + Text('寰呭姙浜嬮」') + .fontWeight(FontWeight.Bold) + .fontSize(CommonConstants.title1_font_size) + .lineHeight(CommonConstants.title1_font_height) + .width(CommonConstants.title1_width) + .margin({ + top: CommonConstants.title1_margin_top, + bottom: CommonConstants.title1_margin_bottom, + }) + .textAlign(TextAlign.Start) + + Button('+') + .fontSize(CommonConstants.button_font_size) + .width(CommonConstants.button_size) + .height(CommonConstants.button_size) + .margin({ + top: CommonConstants.title1_margin_top, + bottom: CommonConstants.title1_margin_bottom, + left: CommonConstants.rb_margin_left + }) + .onClick(() => { + this.LocalPageStack.pushDestination({name:"AddItem", onPop: ()=> { + this.totalTasks = DataModel.getData() //杩斿洖鏃舵洿鏂版暟鎹紙搴斿娣诲姞鏁版嵁鐨勬儏鍐碉級 + }}) + }) + } + + Scroll() { //浜嬮」 + Column({space: CommonConstants.column_space}) { + ForEach(this.totalTasks, (item: TodoItemModel, index: number) => { + ToDoItem({totalTasks: $totalTasks, myIndex: index, myTask: item}) + .onClick(() => { //鐐瑰嚮杩涘叆璇︽儏椤� + this.LocalPageStack.pushDestination({name: 'ItemDetail' + index, onPop: ()=> { + this.totalTasks = DataModel.getData() //杩斿洖鏃舵洿鏂版暟鎹紙搴斿鍒犻櫎鏁版嵁鐨勬儏鍐碉級 + }}) + // item.itemName = '1' //鍦ㄨ繖閲岀殑鏀瑰彉鏃犳硶琚瓙缁勪欢瀵熻锛岃€屼笖涓嶄細瀛樺偍 + }) + }, (item:string) => JSON.stringify(item)) + } + .margin({bottom:10}) + } + .align(Alignment.Top) + .margin({top: 10}) + .width('100%') + .height('100%') + .backgroundColor($r("app.color.grey")) + .scrollBar(BarState.On) + } + .hideTitleBar(true) + .navDestination(this.PageMap) + .mode(NavigationMode.Stack) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/WebPage.ets b/entry/src/main/ets/pages/WebPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d043d73677c81fcac97b6983d6a79a3ca8060bc --- /dev/null +++ b/entry/src/main/ets/pages/WebPage.ets @@ -0,0 +1,115 @@ +import { webview } from '@kit.ArkWeb' +import TodoItemModel from '../viewmodel/TodoItemModel' +import { http } from '@kit.NetworkKit' +import { promptAction } from '@kit.ArkUI'; + +interface HttpError { + message: string; + code: number; +} + +interface SysTimeResponse { + sysTime1: string; + sysTime2: string; +} + +class TestClass { + + totalTasks: Array<TodoItemModel> + + myTask: TodoItemModel = new TodoItemModel('','','','',false) + + constructor(totalTasks: Array<TodoItemModel>) {this.totalTasks = totalTasks} + + getTasks(): Array<TodoItemModel> { + return this.totalTasks + } + + async markComplete(myIndex:number) { + this.myTask = this.totalTasks[myIndex] + this.myTask.isCompleted = !this.myTask.isCompleted + if(this.myTask.isCompleted) { //宸插畬鎴� + //璇锋眰鏃堕棿 + let httpRequest = http.createHttp(); + let finishTime = '' + let count = 0 + while(finishTime == '' && count<10) { + count++ + await httpRequest.request('http://quan.suning.com/getSysTime.do', { // 鑻忓畞鏃堕棿鎴矨PI + method: http.RequestMethod.GET, + }).then((data) => { + if (data.responseCode === 200) { + let response = data.result + ""; + console.info('Response: ' + response); + + const json_res = JSON.parse(data.result + "") as SysTimeResponse + finishTime = json_res.sysTime2.substring(0,10) + } else { + console.error('Request failed with response code: ' + data.responseCode); + } + }).catch((err:HttpError) => { + console.error('Request error: ' + JSON.stringify(err)); + }) + } + httpRequest.destroy(); // 閿€姣丠TTP璇锋眰瀵硅薄 + //璇锋眰缁撴灉 + if(finishTime == '') { //璇锋眰澶辫触锛屼笉鎿嶄綔 + this.myTask.isCompleted = !this.myTask.isCompleted + promptAction.showToast({ + message: '鏃堕棿璇锋眰澶辫触锛岃閲嶈瘯锛�' + }) + return + } + else { + this.myTask.completeTime = finishTime + } + } + else { //鏇存柊鍚庣姸鎬侊細鏈畬鎴� + this.myTask.completeTime = '' + } + //鏇挎崲鍘熸潵鐨勫璞� + this.myTask = JSON.parse(JSON.stringify(this.myTask)) + this.totalTasks.splice(myIndex, 1, this.myTask) + promptAction.showToast({ + message: '鏇存柊鎴愬姛锛�' + }) + //鍙洿鏂板璞$殑灞炴€� + // let result = DataModel.updateData(this.myTask) + // if(result==-1) { + // promptAction.showToast({ + // message: '鏇存柊澶辫触锛岃鍒锋柊椤甸潰鍚庨噸鏂板皾璇曪紒' + // }) + // } + // else { + // promptAction.showToast({ + // message: '鏇存柊鎴愬姛锛�' + // }) + // } + } +} + +@Component +struct WebPage { + webController: WebviewController = new webview.WebviewController() + + @Link @Watch('onUpdated') totalTasks: Array<TodoItemModel> //TodoList + + onUpdated() { + // this.webController.runJavaScript('myRefresh()') + this.webController.runJavaScript('todoList.innerHTML = \'\'; myRefresh()') + } + + myClass:TestClass = new TestClass(this.totalTasks) + + build() { + Web({src: $rawfile('local/todo.html'), controller: this.webController}) + .javaScriptProxy({ + object: this.myClass, + name: "myClass", + methodList: ["getTasks", "markComplete"], + controller: this.webController + }) + } +} + +export { WebPage } diff --git a/entry/src/main/ets/view/AddItem.ets b/entry/src/main/ets/view/AddItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a8cc1ef70ea934af6b79c36ba3f6d6be3a63a83 --- /dev/null +++ b/entry/src/main/ets/view/AddItem.ets @@ -0,0 +1,230 @@ +import CommonConstants from '../common/CommonConstant' +import { http } from '@kit.NetworkKit' +import { promptAction } from '@kit.ArkUI'; +import DataModel from '../viewmodel/DataModel'; +import TodoItemModel from '../viewmodel/TodoItemModel'; + +interface HttpError { + message: string; + code: number; +} + +interface SysTimeResponse { + sysTime1: string; + sysTime2: string; +} + +@Component +export default struct AddItem { + @Consume('localPageStack') LocalPageStack: NavPathStack + + @State itemName: string = '' + @State itemDisc: string = '' + @State itemTime: string = '鑾峰彇褰撳墠鏃堕棿' + + + build() { + NavDestination() { + Column() { + this.TitleBar() + this.MainPage() + } + .width('100%') + .height('100%') + .backgroundColor($r("app.color.grey")) + .margin({bottom:10}) + } + .hideTitleBar(true) + } + + @Builder + TitleBar() { + Row() { + Column() { + Button('<') + .fontSize(CommonConstants.button_font_size) + .width(CommonConstants.button_size) + .height(CommonConstants.button_size) + .margin({ + top: CommonConstants.button_margin_top, + bottom: CommonConstants.button_margin_bottom, + }) + .onClick(() => { + this.LocalPageStack.pop() + }) + } + + Column() { + Text('娣诲姞浜嬮」') + .fontWeight(FontWeight.Bold) + .fontSize(CommonConstants.title1_font_size) + .lineHeight(CommonConstants.title1_font_height) + .width(CommonConstants.title1_width) + .margin({ + top: CommonConstants.title1_margin_top, + bottom: CommonConstants.title1_margin_bottom, + }) + .textAlign(TextAlign.Center) + } + .width(CommonConstants.mid_title_col_width) + + Column() { + Button('鈭�') + .fontSize(CommonConstants.button_font_size_yes) + .width(CommonConstants.button_size) + .height(CommonConstants.button_size) + .margin({ + top: CommonConstants.button_margin_top, + bottom: CommonConstants.button_margin_bottom, + }) + .onClick(() => { + this.addItem() + }) + } + } + } + + @Builder + MainPage() { + Column() { + Row() { + Text('鍚嶅瓧') + .fontSize(CommonConstants.detail_title_font_size) + .fontWeight(FontWeight.Bold) + .width(CommonConstants.add_name_width) + .margin({ + left: CommonConstants.detail_margin_Left + }) + + TextInput({ placeholder: '璇疯緭鍏ヤ簨椤瑰悕瀛�'}) + .width(CommonConstants.input_container_width) + .margin({ left: CommonConstants.input_margin_left }) + .backgroundColor($r('app.color.grey')) + .caretColor(Color.Blue) //鍏夋爣 + .placeholderColor(Color.Grey) + .placeholderFont({size: CommonConstants.detail_font_size}) + .fontSize(CommonConstants.detail_font_size) + .onChange((value: string) => { + this.itemName = value; + }) + } + } + .margin({ + top: CommonConstants.list_margin_top + }) + .width(CommonConstants.list_width) + .height(CommonConstants.name_height) + .backgroundColor($r('app.color.white')) + .borderRadius(CommonConstants.border_radius) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + + Column() { + Row() { + Text('鎻忚堪') + .fontSize(CommonConstants.detail_title_font_size) + .fontWeight(FontWeight.Bold) + .width(CommonConstants.add_name_width) + .margin({ + left: CommonConstants.detail_margin_Left + }) + + TextArea({ placeholder: '璇疯緭鍏ヤ簨椤规弿杩�'}) + .width(CommonConstants.input_container_width) + .height(CommonConstants.input_disc_height) + .margin({ left: CommonConstants.input_margin_left }) + .backgroundColor($r('app.color.grey')) + .caretColor(Color.Blue) //鍏夋爣 + .placeholderColor(Color.Grey) + .placeholderFont({size: CommonConstants.detail_font_size}) + .fontSize(CommonConstants.detail_font_size) + .onChange((value: string) => { + this.itemDisc = value; + }) + } + } + .margin({ + top: CommonConstants.list_margin_top + }) + .width(CommonConstants.list_width) + .height(CommonConstants.disc_height) + .backgroundColor($r('app.color.white')) + .borderRadius(CommonConstants.border_radius) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + + Column() { + Row() { + Text('鏃堕棿') + .fontSize(CommonConstants.detail_title_font_size) + .fontWeight(FontWeight.Bold) + .width(CommonConstants.add_name_width) + .margin({ + left: CommonConstants.detail_margin_Left + }) + + Button(this.itemTime) + .margin({ left: CommonConstants.input_margin_left }) + .onClick(() => { + this.requestTime(); + }) + } + } + .margin({ + top: CommonConstants.list_margin_top + }) + .width(CommonConstants.list_width) + .height(CommonConstants.time_height) + .backgroundColor($r('app.color.white')) + .borderRadius(CommonConstants.border_radius) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + } + + private requestTime() { + let httpRequest = http.createHttp(); + httpRequest.request('http://quan.suning.com/getSysTime.do', { // 鑻忓畞鏃堕棿鎴矨PI + method: http.RequestMethod.GET, + }).then((data) => { + if (data.responseCode === 200) { + let response = data.result + ""; + console.info('Response: ' + response); + + const json_res = JSON.parse(data.result + "") as SysTimeResponse + this.itemTime = json_res.sysTime2.substring(0,10) + } else { + promptAction.showToast({ + message: '鏃堕棿璇锋眰澶辫触锛岃閲嶈瘯锛�' + }) + console.error('Request failed with response code: ' + data.responseCode); + } + }).catch((err:HttpError) => { + promptAction.showToast({ + message: '鏃堕棿璇锋眰澶辫触锛岃閲嶈瘯锛�' + }) + console.error('Request error: ' + JSON.stringify(err)); + }).finally(() => { + httpRequest.destroy(); // 閿€姣丠TTP璇锋眰瀵硅薄 + }); + } + + private addItem() { + let result = DataModel.addData(new TodoItemModel(this.itemName, this.itemDisc, this.itemTime, '', false)) + if(result == -1) { + promptAction.showToast({ + message: '娣诲姞澶辫触锛屽凡鏈夎鐩爣椤癸紒' + }) + } + else if(result == 0) { + promptAction.showToast({ + message: '娣诲姞澶辫触锛岃妫€鏌ユ槸鍚﹀~鍐欏畬鏁达紒' + }) + } + else { + promptAction.showToast({ + message: '娣诲姞鎴愬姛锛�' + }) + this.LocalPageStack.pop({}, true) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/ItemDetail.ets b/entry/src/main/ets/view/ItemDetail.ets new file mode 100644 index 0000000000000000000000000000000000000000..497eeff960b4c4074179859e4467b0d41282d8f9 --- /dev/null +++ b/entry/src/main/ets/view/ItemDetail.ets @@ -0,0 +1,197 @@ +import CommonConstants from '../common/CommonConstant' +import DataModel from '../viewmodel/DataModel' +import TodoItemModel from '../viewmodel/TodoItemModel' +import { promptAction } from '@kit.ArkUI' + +@Component +export default struct ItemDetail { + @Consume('localPageStack') LocalPageStack: NavPathStack + + content: TodoItemModel = new TodoItemModel('', '', '', '', false) + + build() { + NavDestination() { + Column() { + this.TopBar() + this.MainPage() + } + .width('100%') + .height('100%') + .backgroundColor($r("app.color.grey")) + .margin({bottom:10}) + + } + .hideTitleBar(true) + } + + @Builder + TopBar() { + Row() { + Column() { + Button('<') + .fontSize(CommonConstants.button_font_size) + .width(CommonConstants.button_size) + .height(CommonConstants.button_size) + .margin({ + top: CommonConstants.button_margin_top, + bottom: CommonConstants.button_margin_bottom, + }) + .onClick(() => { + this.LocalPageStack.pop() + }) + } + + Column() { + Text('浜嬮」璇︽儏') + .fontWeight(FontWeight.Bold) + .fontSize(CommonConstants.title1_font_size) + .lineHeight(CommonConstants.title1_font_height) + .width(CommonConstants.title1_width) + .margin({ + top: CommonConstants.title1_margin_top, + bottom: CommonConstants.title1_margin_bottom, + }) + .textAlign(TextAlign.Center) + } + .width(CommonConstants.mid_title_col_width) + + Column() { + Button('脳') + .fontSize(CommonConstants.button_font_size_yes) + .width(CommonConstants.button_size) + .height(CommonConstants.button_size) + .margin({ + top: CommonConstants.button_margin_top, + bottom: CommonConstants.button_margin_bottom, + }) + .onClick(() => { + this.deleteItem() + }) + } + } + } + + @Builder + MainPage() { + Column() { + Row() { + Text('鍚嶅瓧') + .fontSize(CommonConstants.detail_title_font_size) + .fontWeight(FontWeight.Bold) + .width(CommonConstants.detail_width) + .margin({ + left: CommonConstants.detail_margin_Left + }) + + Text(this.content.itemName) + .fontSize(CommonConstants.detail_font_size) + .width(CommonConstants.detail_width) + .textAlign(TextAlign.Center) + } + } + .margin({ + top: CommonConstants.list_margin_top + }) + .width(CommonConstants.list_width) + .height(CommonConstants.name_height) + .backgroundColor($r('app.color.white')) + .borderRadius(CommonConstants.border_radius) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + + Column() { + Row() { + Text('鎻忚堪') + .fontSize(CommonConstants.detail_title_font_size) + .fontWeight(FontWeight.Bold) + .width(CommonConstants.detail_width) + .margin({ + left: CommonConstants.detail_margin_Left + }) + + Scroll() { + Text(this.content.itemDisc) + .fontSize(CommonConstants.detail_font_size) + .width(CommonConstants.detail_width) + .textAlign(TextAlign.Center) + } + } + } + .margin({ + top: CommonConstants.list_margin_top + }) + .width(CommonConstants.list_width) + .height(CommonConstants.disc_height) + .backgroundColor($r('app.color.white')) + .borderRadius(CommonConstants.border_radius) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + + Column() { + Row() { + Text('鏃堕棿') + .fontSize(CommonConstants.detail_title_font_size) + .fontWeight(FontWeight.Bold) + .width(CommonConstants.detail_width) + .margin({ + left: CommonConstants.detail_margin_Left + }) + + Scroll() { + Text(this.content.itemTime) + .fontSize(CommonConstants.detail_font_size) + .width(CommonConstants.detail_width) + .textAlign(TextAlign.Center) + } + } + } + .margin({ + top: CommonConstants.list_margin_top + }) + .width(CommonConstants.list_width) + .height(CommonConstants.time_height) + .backgroundColor($r('app.color.white')) + .borderRadius(CommonConstants.border_radius) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + + if(this.content.isCompleted) { + Column() { + Row() { + Text('瀹屾垚鏃堕棿') + .fontSize(CommonConstants.detail_title_font_size) + .fontWeight(FontWeight.Bold) + .width(CommonConstants.detail_width) + .margin({ + left: CommonConstants.detail_margin_Left + }) + + Scroll() { + Text(this.content.completeTime) + .fontSize(CommonConstants.detail_font_size) + .width(CommonConstants.detail_width) + .textAlign(TextAlign.Center) + } + } + } + .margin({ + top: CommonConstants.list_margin_top + }) + .width(CommonConstants.list_width) + .height(CommonConstants.time_height) + .backgroundColor($r('app.color.white')) + .borderRadius(CommonConstants.border_radius) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + } + + } + + private deleteItem() { + DataModel.deleteData(this.content) + promptAction.showToast({ + message: '鍒犻櫎鎴愬姛锛�' + }) + this.LocalPageStack.pop({},true) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/TodoItem.ets b/entry/src/main/ets/view/TodoItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..a69faa740c72a6c886fea17622f6233e01eaf541 --- /dev/null +++ b/entry/src/main/ets/view/TodoItem.ets @@ -0,0 +1,121 @@ +import CommonConstants from '../common/CommonConstant' +import TodoItemModel from '../viewmodel/TodoItemModel' +import { promptAction } from '@kit.ArkUI' +import { http } from '@kit.NetworkKit' + +interface HttpError { + message: string; + code: number; +} + +interface SysTimeResponse { + sysTime1: string; + sysTime2: string; +} + +@Component +export default struct ToDoItem { + @Link totalTasks: Array<TodoItemModel> //todolist + + @State myIndex: number = 0 //鏈」鐨勪笅鏍� + + @State myTask: TodoItemModel = new TodoItemModel('', '', '', '', false) //鏈」鐨勮鎯� + // 鍔犱簡state鎵嶈兘瀵熻鍒板厓绱犵殑鏀瑰彉锛屼笉鍔犳棤娉曞療瑙� + + @Consume('localPageStack') LocalPageStack: NavPathStack + + @Builder labelIcon(icon: Resource) { + Image(icon) + .objectFit(ImageFit.Contain) + .width(CommonConstants.checkbox_width) + .height(CommonConstants.checkbox_width) + .margin(CommonConstants.checkbox_margin) + .onClick(() => { + // this.myTask.isCompleted = !this.myTask.isCompleted + this.markComplete() + }) + } + + build() { + Row() { + if(this.myTask.isCompleted) { + this.labelIcon($r('app.media.ic_ok')) + } + else { + this.labelIcon($r('app.media.ic_default')) + } + + Text(this.myTask.itemName) + .fontSize(CommonConstants.item_font_size) + .fontWeight(CommonConstants.item_font_weight) + .opacity(this.myTask.isCompleted ? CommonConstants.opacity_completed : CommonConstants.opacity_default) + .decoration({type: this.myTask.isCompleted ? TextDecorationType.LineThrough : TextDecorationType.None}) + } + .backgroundColor($r('app.color.white')) + .width(CommonConstants.list_width) + .height(CommonConstants.list_height) + .borderRadius(CommonConstants.border_radius) + } + + async markComplete() { + this.myTask.isCompleted = !this.myTask.isCompleted + // this.myTask.itemName = 'aaa' //鍦ㄨ繖閲岀殑鏀瑰彉鍙互琚療瑙� + if(this.myTask.isCompleted) { //宸插畬鎴� + //璇锋眰鏃堕棿 + let httpRequest = http.createHttp(); + let finishTime = '' + let count = 0 + while(finishTime == '' && count<10) { //寰幆鐩村埌璇锋眰鍒版椂闂� + count++ + await httpRequest.request('http://quan.suning.com/getSysTime.do', { // 鑻忓畞鏃堕棿鎴矨PI + method: http.RequestMethod.GET, + }).then((data) => { + if (data.responseCode === 200) { + let response = data.result + ""; + console.info('Response: ' + response); + + const json_res = JSON.parse(data.result + "") as SysTimeResponse + finishTime = json_res.sysTime2.substring(0,10) + } else { + console.error('Request failed with response code: ' + data.responseCode); + } + }).catch((err:HttpError) => { + console.error('Request error: ' + JSON.stringify(err)); + }) + } + httpRequest.destroy(); // 閿€姣丠TTP璇锋眰瀵硅薄 + //璇锋眰缁撴灉 + if(finishTime == '') { //璇锋眰澶辫触锛屼笉鎿嶄綔 + this.myTask.isCompleted = !this.myTask.isCompleted + promptAction.showToast({ + message: '鏃堕棿璇锋眰澶辫触锛岃閲嶈瘯锛�' + }) + return + } + else { + this.myTask.completeTime = finishTime + } + } + else { //鏇存柊鍚庣姸鎬侊細鏈畬鎴� + this.myTask.completeTime = '' + } + //鏇挎崲鍘熸潵鐨勫璞� + this.myTask = JSON.parse(JSON.stringify(this.myTask)) + this.totalTasks.splice(this.myIndex, 1, this.myTask) + promptAction.showToast({ + message: '鏇存柊鎴愬姛锛�' + }) + //鍙洿鏂板璞$殑灞炴€� + // let result = DataModel.updateData(this.myTask) + // if(result==-1) { + // promptAction.showToast({ + // message: '鏇存柊澶辫触锛岃鍒锋柊椤甸潰鍚庨噸鏂板皾璇曪紒' + // }) + // } + // else { + // promptAction.showToast({ + // message: '鏇存柊鎴愬姛锛�' + // }) + // } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/DataModel.ets b/entry/src/main/ets/viewmodel/DataModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ed3fe0f920327d07360112b9050a96a242357ef --- /dev/null +++ b/entry/src/main/ets/viewmodel/DataModel.ets @@ -0,0 +1,86 @@ +import TodoItemModel from './TodoItemModel' +import {preferences} from '@kit.ArkData' + +let context = getContext(this) +let preference: preferences.Preferences + +export class DataModel { + private items: Array<TodoItemModel> = [] + + getData(): Array<TodoItemModel> { + return this.items + } + + deleteData(item: TodoItemModel) { + let indexToRemove = this.items.indexOf(item); + if (indexToRemove !== -1) { + this.items.splice(indexToRemove, 1); + this.addPreference() + } + } + + addData(item: TodoItemModel) { + if(item.itemName == '' || item.itemDisc == '' || item.itemTime == '鑾峰彇褰撳墠鏃堕棿') { + return 0; + } + for(let i=0; i<this.items.length; i++) { + if(this.items[i].itemName == item.itemName + && this.items[i].itemDisc == item.itemDisc + && this.items[i].itemTime == item.itemTime) { + return -1; + } + } + this.items.push(item) + this.addPreference() + return 1 + } + + updateData(item: TodoItemModel) { + for(let i=0; i<this.items.length; i++) { + if(this.items[i].itemName == item.itemName + && this.items[i].itemDisc == item.itemDisc + && this.items[i].itemTime == item.itemTime) { + this.items[i] = item + this.addPreference() + return 0 + } + } + return -1 + } + + async getPreferences() { + try { + console.log('get Preferences') + preference = await preferences.getPreferences(context, 'items') + } + catch (err) { + console.error(err) + } + } + + async addPreference() { + try { + await preference.put('item', JSON.stringify(this.items)) + } + catch (err) { + console.error(err) + } + await preference.flush() + } + + async getPreferenceData() { + try { + console.log('get PreferenceData') + let res = await preference.get('item', '') + if(res.toString() != '') { + this.items = JSON.parse(res.toString()) + } + } + catch (err) { + console.warn('getPreferenceData err') + console.error(err) + } + } +} + +export default new DataModel() \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/TodoItemModel.ets b/entry/src/main/ets/viewmodel/TodoItemModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ae4e8dbd5d0608af491727d1439baed14328f16 --- /dev/null +++ b/entry/src/main/ets/viewmodel/TodoItemModel.ets @@ -0,0 +1,19 @@ +export default class TodoItemModel { + itemName: string + + itemDisc: string + + itemTime: string + + completeTime: string + + isCompleted: boolean + + constructor(itemName: string, itemDisc: string, itemTime: string, completeTime: string, isCompleted: boolean) { + this.itemName = itemName + this.itemDisc = itemDisc + this.itemTime = itemTime + this.completeTime = completeTime + this.isCompleted = isCompleted + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..48e2ae648f45c1a2c95249d650f17d231bcc0926 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,57 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:white", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + name: "ohos.permission.INTERNET" + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..2dae8c6c456bc3331171e6c11cea24445acbc3f0 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,20 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + }, + { + "name": "grey", + "value": "#F1F3F5" + }, + { + "name": "grey2", + "value": "#FFE2E1E1" + }, + { + "name": "blue", + "value": "#FF0090DD" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..cf77ca9f7a26d8a6177a5fe833f76252afdee5b4 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,36 @@ +{ + "float": [ + { + "name": "checkbox_width", + "value": "28vp" + }, + { + "name": "checkbox_margin", + "value": "20vp" + }, + { + "name": "item_font_size", + "value": "20fp" + }, + { + "name": "title1_font_size", + "value": "28fp" + }, + { + "name": "title1_font_height", + "value": "33vp" + }, + { + "name": "title1_margin_top", + "value": "24vp" + }, + { + "name": "title1_margin_bottom", + "value": "12vp" + }, + { + "name": "list_item_height", + "value": "64vp" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6b976fb6d0379b826204087d18a5f01872ce4d54 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/ic_01_off.svg b/entry/src/main/resources/base/media/ic_01_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..aa0250739f7304672224fea4f34872e0685a0286 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_01_off.svg @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>ic_01_offmdpi</title> + <g id="ic_01_off" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <rect id="鐭╁舰" x="0" y="0" width="24" height="24"></rect> + <path d="M15.4583333,1 C16.7700096,1 17.8333333,2.0553288 17.8333333,3.35714286 L17.8333333,20.6428571 C17.8333333,21.9446712 16.7700096,23 15.4583333,23 L4.375,23 C3.06332372,23 2,21.9446712 2,20.6428571 L2,3.35714286 C2,2.0553288 3.06332372,1 4.375,1 L15.4583333,1 Z" id="褰㈢姸" fill="#999999" style="mix-blend-mode: multiply;"></path> + <rect id="鐭╁舰" fill="#BFBFBF" x="14.875" y="12.7857143" width="7.125" height="10.2142857" rx="2.35714286"></rect> + <path d="M14.6666667,5.77640641 C14.6666667,6.17703976 14.3394287,6.50184399 13.9357603,6.50184399 C13.7697923,6.50184399 13.6087659,6.44575696 13.4791667,6.34285714 L12.5389418,5.59633273 C12.3943761,5.48154973 12.1889573,5.48154973 12.0443916,5.59633273 L11.1041667,6.34285714 C10.7889545,6.59313079 10.3290007,6.54240909 10.076831,6.22956696 C9.97315169,6.10094216 9.91666667,5.94112654 9.91666667,5.77640641 L9.91666667,1 L14.6666667,1 Z" id="褰㈢姸缁撳悎" fill-opacity="0.401735959" fill="#FFFFFF"></path> + </g> +</svg> \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_01_on.svg b/entry/src/main/resources/base/media/ic_01_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..3244509174bca00c2262537e3bc37939fbcd3fa4 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_01_on.svg @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>ic_01_onmdpi</title> + <g id="ic_01_on" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <path d="M15.4583333,1 C16.7700096,1 17.8333333,2.0553288 17.8333333,3.35714286 L17.8333333,20.6428571 C17.8333333,21.9446712 16.7700096,23 15.4583333,23 L4.375,23 C3.06332372,23 2,21.9446712 2,20.6428571 L2,3.35714286 C2,2.0553288 3.06332372,1 4.375,1 L15.4583333,1 Z" id="褰㈢姸" fill="#0A59F7" style="mix-blend-mode: multiply;"></path> + <rect id="鐭╁舰" fill="#CEDDFD" x="14.875" y="12.7857143" width="7.125" height="10.2142857" rx="2.35714286"></rect> + <path d="M14.6666667,5.77640641 C14.6666667,6.17703976 14.3394287,6.50184399 13.9357603,6.50184399 C13.7697923,6.50184399 13.6087659,6.44575696 13.4791667,6.34285714 L12.5389418,5.59633273 C12.3943761,5.48154973 12.1889573,5.48154973 12.0443916,5.59633273 L11.1041667,6.34285714 C10.7889545,6.59313079 10.3290007,6.54240909 10.076831,6.22956696 C9.97315169,6.10094216 9.91666667,5.94112654 9.91666667,5.77640641 L9.91666667,1 L14.6666667,1 Z" id="褰㈢姸缁撳悎" fill-opacity="0.401735959" fill="#FFFFFF"></path> + </g> +</svg> \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_02_off.svg b/entry/src/main/resources/base/media/ic_02_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..bbdf5acae90a819ccd23078a78c33be85bf0249b --- /dev/null +++ b/entry/src/main/resources/base/media/ic_02_off.svg @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>ic_02_offmdpi</title> + <g id="ic_02_off" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <path d="M20.6842105,2.48053129 C21.9075781,2.48053129 22.9093844,3.46324769 22.9941855,4.70823723 L23,4.87956653 L23,17.5410806 C23,19.2500419 21.842063,20.7124546 20.2461037,21.061605 L20.0443795,21.0993878 L13.0969732,22.1854576 C12.9421409,22.6590953 12.5095003,23 12,23 C11.4904997,23 11.0578592,22.6590953 10.9030267,22.1854576 L3.95562046,21.0993878 C2.25644205,20.8338943 1,19.3212485 1,17.5410806 L1,4.87956653 C1,3.55461595 2.03681426,2.48053129 3.31578948,2.48053129 C3.45560847,2.48053129 3.59514018,2.49364907 3.73267499,2.51972389 L9.15164406,3.54709073 C10.8015172,3.85988545 12,5.34928718 12,7.08685468 L12.0057049,6.8795972 C12.0926488,5.3036515 13.1649591,3.96827453 14.6441766,3.59234005 L14.848356,3.54709073 L20.267325,2.51972389 C20.4048598,2.49364907 20.5443916,2.48053129 20.6842105,2.48053129 Z" id="璺緞" fill-opacity="0.2" fill="#000000" fill-rule="nonzero"></path> + <path d="M6.05026204,1.04243136 L10.1028936,1.84270041 C11.1949979,2.05835713 11.985062,3.04757157 11.985062,4.19930429 L11.985062,18.757371 C11.985062,19.4198462 11.4666549,19.9568885 10.8271673,19.9568885 C10.7544142,19.9568885 10.6818231,19.9497853 10.6103568,19.9356729 L5.1830199,18.8639422 C4.09091562,18.6482855 3.3008515,17.659071 3.3008515,16.5073383 L3.3008515,3.39903524 C3.3008515,2.07408466 4.33766576,1 5.61664097,1 C5.76214713,1 5.90732944,1.01420661 6.05026204,1.04243136 Z" id="璺緞" fill="#FFFFFF" fill-rule="nonzero"></path> + <path d="M14.6741818,1.04243136 L18.7268133,1.84270041 C19.8189177,2.05835713 20.6089818,3.04757157 20.6089818,4.19930429 L20.6089818,18.757371 C20.6089818,19.4198462 20.0905746,19.9568885 19.451087,19.9568885 C19.3783339,19.9568885 19.3057428,19.9497853 19.2342765,19.9356729 L13.8069396,18.8639422 C12.7148354,18.6482855 11.9247712,17.659071 11.9247712,16.5073383 L11.9247712,3.39903524 C11.9247712,2.07408466 12.9615855,1 14.2405607,1 C14.3860668,1 14.5312491,1.01420661 14.6741818,1.04243136 Z" id="璺緞" fill="#FFFFFF" fill-rule="nonzero" transform="translate(16.266876, 10.478444) scale(-1, 1) translate(-16.266876, -10.478444) "></path> + <path d="M6.05026204,1.04243136 L10.1028936,1.84270041 C11.1949979,2.05835713 11.985062,3.04757157 11.985062,4.19930429 L11.985062,18.757371 C11.985062,19.4198462 11.4666549,19.9568885 10.8271673,19.9568885 C10.7544142,19.9568885 10.6818231,19.9497853 10.6103568,19.9356729 L5.1830199,18.8639422 C4.09091562,18.6482855 3.3008515,17.659071 3.3008515,16.5073383 L3.3008515,3.39903524 C3.3008515,2.07408466 4.33766576,1 5.61664097,1 C5.76214713,1 5.90732944,1.01420661 6.05026204,1.04243136 Z" id="璺緞" fill-opacity="0.25" fill="#000000" fill-rule="nonzero"></path> + <path d="M14.6741818,1.04243136 L18.7268133,1.84270041 C19.8189177,2.05835713 20.6089818,3.04757157 20.6089818,4.19930429 L20.6089818,18.757371 C20.6089818,19.4198462 20.0905746,19.9568885 19.451087,19.9568885 C19.3783339,19.9568885 19.3057428,19.9497853 19.2342765,19.9356729 L13.8069396,18.8639422 C12.7148354,18.6482855 11.9247712,17.659071 11.9247712,16.5073383 L11.9247712,3.39903524 C11.9247712,2.07408466 12.9615855,1 14.2405607,1 C14.3860668,1 14.5312491,1.01420661 14.6741818,1.04243136 Z" id="璺緞" fill-opacity="0.4" fill="#000000" fill-rule="nonzero" transform="translate(16.266876, 10.478444) scale(-1, 1) translate(-16.266876, -10.478444) "></path> + </g> +</svg> \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_02_on.svg b/entry/src/main/resources/base/media/ic_02_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..0c620788eed605c5b1c8a9ea11a61d4acfe0cc85 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_02_on.svg @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>ic_02_onmdpi</title> + <g id="ic_02_on" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <path d="M20.6842105,2.48053129 C21.9075781,2.48053129 22.9093844,3.46324769 22.9941855,4.70823723 L23,4.87956653 L23,17.5410806 C23,19.2500419 21.842063,20.7124546 20.2461037,21.061605 L20.0443795,21.0993878 L13.0969732,22.1854576 C12.9421409,22.6590953 12.5095003,23 12,23 C11.4904997,23 11.0578592,22.6590953 10.9030267,22.1854576 L3.95562046,21.0993878 C2.25644205,20.8338943 1,19.3212485 1,17.5410806 L1,4.87956653 C1,3.55461595 2.03681426,2.48053129 3.31578948,2.48053129 C3.45560847,2.48053129 3.59514018,2.49364907 3.73267499,2.51972389 L9.15164406,3.54709073 C10.8015172,3.85988545 12,5.34928718 12,7.08685468 L12.0057049,6.8795972 C12.0926488,5.3036515 13.1649591,3.96827453 14.6441766,3.59234005 L14.848356,3.54709073 L20.267325,2.51972389 C20.4048598,2.49364907 20.5443916,2.48053129 20.6842105,2.48053129 Z" id="璺緞" fill="#0A59F7" fill-rule="nonzero"></path> + <path d="M6.05026204,1.04243136 L10.1028936,1.84270041 C11.1949979,2.05835713 11.985062,3.04757157 11.985062,4.19930429 L11.985062,18.757371 C11.985062,19.4198462 11.4666549,19.9568885 10.8271673,19.9568885 C10.7544142,19.9568885 10.6818231,19.9497853 10.6103568,19.9356729 L5.1830199,18.8639422 C4.09091562,18.6482855 3.3008515,17.659071 3.3008515,16.5073383 L3.3008515,3.39903524 C3.3008515,2.07408466 4.33766576,1 5.61664097,1 C5.76214713,1 5.90732944,1.01420661 6.05026204,1.04243136 Z" id="璺緞" fill="#0A59F7" fill-rule="nonzero"></path> + <path d="M14.6741818,1.04243136 L18.7268133,1.84270041 C19.8189177,2.05835713 20.6089818,3.04757157 20.6089818,4.19930429 L20.6089818,18.757371 C20.6089818,19.4198462 20.0905746,19.9568885 19.451087,19.9568885 C19.3783339,19.9568885 19.3057428,19.9497853 19.2342765,19.9356729 L13.8069396,18.8639422 C12.7148354,18.6482855 11.9247712,17.659071 11.9247712,16.5073383 L11.9247712,3.39903524 C11.9247712,2.07408466 12.9615855,1 14.2405607,1 C14.3860668,1 14.5312491,1.01420661 14.6741818,1.04243136 Z" id="璺緞" fill="#0A59F7" fill-rule="nonzero" transform="translate(16.266876, 10.478444) scale(-1, 1) translate(-16.266876, -10.478444) "></path> + <path d="M6.05026204,1.04243136 L10.1028936,1.84270041 C11.1949979,2.05835713 11.985062,3.04757157 11.985062,4.19930429 L11.985062,18.757371 C11.985062,19.4198462 11.4666549,19.9568885 10.8271673,19.9568885 C10.7544142,19.9568885 10.6818231,19.9497853 10.6103568,19.9356729 L5.1830199,18.8639422 C4.09091562,18.6482855 3.3008515,17.659071 3.3008515,16.5073383 L3.3008515,3.39903524 C3.3008515,2.07408466 4.33766576,1 5.61664097,1 C5.76214713,1 5.90732944,1.01420661 6.05026204,1.04243136 Z" id="璺緞" fill-opacity="0.25" fill="#FFFFFF" fill-rule="nonzero"></path> + <path d="M14.6741818,1.04243136 L18.7268133,1.84270041 C19.8189177,2.05835713 20.6089818,3.04757157 20.6089818,4.19930429 L20.6089818,18.757371 C20.6089818,19.4198462 20.0905746,19.9568885 19.451087,19.9568885 C19.3783339,19.9568885 19.3057428,19.9497853 19.2342765,19.9356729 L13.8069396,18.8639422 C12.7148354,18.6482855 11.9247712,17.659071 11.9247712,16.5073383 L11.9247712,3.39903524 C11.9247712,2.07408466 12.9615855,1 14.2405607,1 C14.3860668,1 14.5312491,1.01420661 14.6741818,1.04243136 Z" id="璺緞" fill-opacity="0.4" fill="#FFFFFF" fill-rule="nonzero" transform="translate(16.266876, 10.478444) scale(-1, 1) translate(-16.266876, -10.478444) "></path> + </g> +</svg> \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_03_off.svg b/entry/src/main/resources/base/media/ic_03_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..07e00c3adbbb4a4457a1f7c75a6aa6d93690be86 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_03_off.svg @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>ic_03_offmdpi</title> + <g id="ic_03_off" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <path d="M6.29561884,1.23609679 C6.36668269,1.64416884 6.09348356,2.03258524 5.6854115,2.10364909 C5.06260385,2.21210814 4.68498237,2.566507 4.56833715,3.19636152 C4.56943353,3.20282656 4.56858748,3.20799979 4.56768604,3.21317618 C4.55480513,3.28714263 4.54502385,3.36335881 4.53828493,3.44172891 C4.51264327,3.76874183 4.54605606,4.15799173 4.63906589,4.61182336 C4.67554606,4.78982445 4.72112934,4.97351547 4.77560514,5.16239838 C6.5642751,2.4498942 9.63831608,0.659891248 13.1304347,0.659891248 C18.6532822,0.659891248 23.1304347,5.13704375 23.1304347,10.6598912 C23.1304347,14.1532921 21.3391169,17.2283083 18.6249113,19.0165099 C18.8149051,19.0715611 18.9996576,19.1174512 19.1786561,19.1541357 C19.5102582,19.2220954 19.8073812,19.2582373 20.0712172,19.2631991 C20.2506014,19.2639295 20.4205429,19.2505665 20.5800256,19.2227933 L20.6179792,19.2202946 C21.2329334,19.0985893 21.5797486,18.7226891 21.6868304,18.1077901 C21.7578942,17.6997181 22.1463106,17.4265189 22.5543827,17.4975828 C22.9624548,17.5686466 23.2356539,17.957063 23.16459,18.3651351 C22.9366329,19.6741403 22.1122883,20.4534372 20.9059197,20.6837587 C20.8840652,20.691284 20.8609429,20.696448 20.8373705,20.700553 C20.3898284,20.7784904 19.8948507,20.7777121 19.3627656,20.7052656 C19.204094,20.6846974 19.0424049,20.6573893 18.8775004,20.6235932 C18.2383844,20.4926105 17.5502082,20.2676553 16.8271214,19.955937 C15.6831949,20.4096864 14.436034,20.6598912 13.1304347,20.6598912 C7.60758715,20.6598912 3.13043465,16.1827387 3.13043465,10.6598912 C3.13043465,9.35355385 3.38092242,8.10572095 3.83648753,6.96180305 C3.82577641,6.93670142 3.81499655,6.91148508 3.80432288,6.88631197 C3.78747481,6.84551654 3.77029185,6.80444474 3.75338608,6.76347623 C3.59499919,6.38058605 3.46218676,6.00857693 3.35536528,5.64903217 C3.05579489,4.64578593 2.95513232,3.72986323 3.08992639,2.95583122 C3.09658055,2.91762083 3.10601719,2.88059298 3.11799189,2.84491958 C3.35721947,1.65987115 4.13366577,0.851303308 5.42806653,0.625889448 C5.83613859,0.554825598 6.22455499,0.828024728 6.29561884,1.23609679 Z" id="褰㈢姸缁撳悎" fill="#999999" fill-rule="nonzero"></path> + <path d="M15.2916125,-0.646674887 C15.6304127,-0.408374098 15.7118836,0.0594587272 15.4735829,0.398258977 C15.2352821,0.737059227 14.7674492,0.818530137 14.428649,0.580229347 C13.9115653,0.216529967 13.3939488,0.200109087 12.8660938,0.563002867 C12.8622976,0.568349607 12.8580413,0.571409377 12.8537436,0.574432227 C12.7923332,0.617626227 12.7315239,0.664602797 12.6713427,0.715253687 C12.4219783,0.928355347 12.1703634,1.227223 11.9152239,1.61389831 C10.916982,3.12677823 10.1589022,5.6805444 9.84274842,8.77778683 C9.66835079,10.4862965 9.64499441,12.2080729 9.74740605,13.8426678 L9.79892315,14.5375779 C9.91331552,15.8718435 10.1118531,17.1361717 10.3800874,18.2731368 C10.7658836,19.8969561 11.2932642,21.2382186 11.913299,22.1779088 C12.0997223,22.4604416 12.2842638,22.6960956 12.4673155,22.8861642 C12.5936428,23.0135245 12.7232587,23.1242423 12.8556685,23.2173749 L12.8842727,23.2424454 C13.4051696,23.591225 13.9162066,23.5706588 14.4267241,23.2115778 C14.7655243,22.973277 15.2333571,23.0547479 15.4716579,23.3935482 C15.7099587,23.7323484 15.6284878,24.2001812 15.2896876,24.438482 C14.202891,25.2028984 13.0689453,25.1710449 12.053052,24.4808754 C12.0322773,24.4707431 12.0122759,24.4580446 11.992705,24.4442791 C11.6211349,24.1829291 11.2716831,23.8323767 10.9466696,23.4049083 C10.8490158,23.2781666 10.753994,23.1445254 10.6612864,23.0040229 C9.82334984,21.7340929 9.15813525,19.9140936 8.72788734,17.7355888 C8.44006539,16.28589 8.26004929,14.7001825 8.20321672,13.0564556 C8.08100722,9.67589273 8.48476018,6.38299686 9.29404069,3.81571852 C9.30735691,3.77391178 9.32043596,3.73282876 9.3336156,3.69195231 C9.35627744,3.62164733 9.37952142,3.55128254 9.40307663,3.48150384 C9.41712926,3.4394831 9.4312123,3.39821843 9.44540081,3.35718021 C9.51120822,3.16768879 9.57961436,2.98149544 9.65032605,2.80012316 C9.67208963,2.74318479 9.69427114,2.68731646 9.71666512,2.63195219 C9.73359845,2.59119208 9.75049042,2.54999974 9.76750534,2.50907645 C9.92625314,2.12633576 10.0953907,1.76937302 10.2740931,1.43960229 C10.7716671,0.518371807 11.348143,-0.200462533 11.9907801,-0.65247201 C12.0225041,-0.67478563 12.0553595,-0.694295565 12.0890518,-0.71105308 C13.096167,-1.37984941 14.2169412,-1.40256277 15.2916125,-0.646674887 Z" id="褰㈢姸缁撳悎" fill="#BFBFBF" fill-rule="nonzero" transform="translate(11.895960, 11.895960) rotate(-45.000000) translate(-11.895960, -11.895960) "></path> + </g> +</svg> \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_03_on.svg b/entry/src/main/resources/base/media/ic_03_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..ac66f01443f5ed3c5ba90f44b24eab9ffff6a0f6 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_03_on.svg @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>ic_03_onmdpi</title> + <g id="ic_03_on" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <path d="M6.29561884,1.23609679 C6.36668269,1.64416884 6.09348356,2.03258524 5.6854115,2.10364909 C5.06260385,2.21210814 4.68498237,2.566507 4.56833715,3.19636152 C4.56943353,3.20282656 4.56858748,3.20799979 4.56768604,3.21317618 C4.55480513,3.28714263 4.54502385,3.36335881 4.53828493,3.44172891 C4.51264327,3.76874183 4.54605606,4.15799173 4.63906589,4.61182336 C4.67554606,4.78982445 4.72112934,4.97351547 4.77560514,5.16239838 C6.5642751,2.4498942 9.63831608,0.659891248 13.1304347,0.659891248 C18.6532822,0.659891248 23.1304347,5.13704375 23.1304347,10.6598912 C23.1304347,14.1532921 21.3391169,17.2283083 18.6249113,19.0165099 C18.8149051,19.0715611 18.9996576,19.1174512 19.1786561,19.1541357 C19.5102582,19.2220954 19.8073812,19.2582373 20.0712172,19.2631991 C20.2506014,19.2639295 20.4205429,19.2505665 20.5800256,19.2227933 L20.6179792,19.2202946 C21.2329334,19.0985893 21.5797486,18.7226891 21.6868304,18.1077901 C21.7578942,17.6997181 22.1463106,17.4265189 22.5543827,17.4975828 C22.9624548,17.5686466 23.2356539,17.957063 23.16459,18.3651351 C22.9366329,19.6741403 22.1122883,20.4534372 20.9059197,20.6837587 C20.8840652,20.691284 20.8609429,20.696448 20.8373705,20.700553 C20.3898284,20.7784904 19.8948507,20.7777121 19.3627656,20.7052656 C19.204094,20.6846974 19.0424049,20.6573893 18.8775004,20.6235932 C18.2383844,20.4926105 17.5502082,20.2676553 16.8271214,19.955937 C15.6831949,20.4096864 14.436034,20.6598912 13.1304347,20.6598912 C7.60758715,20.6598912 3.13043465,16.1827387 3.13043465,10.6598912 C3.13043465,9.35355385 3.38092242,8.10572095 3.83648753,6.96180305 C3.82577641,6.93670142 3.81499655,6.91148508 3.80432288,6.88631197 C3.78747481,6.84551654 3.77029185,6.80444474 3.75338608,6.76347623 C3.59499919,6.38058605 3.46218676,6.00857693 3.35536528,5.64903217 C3.05579489,4.64578593 2.95513232,3.72986323 3.08992639,2.95583122 C3.09658055,2.91762083 3.10601719,2.88059298 3.11799189,2.84491958 C3.35721947,1.65987115 4.13366577,0.851303308 5.42806653,0.625889448 C5.83613859,0.554825598 6.22455499,0.828024728 6.29561884,1.23609679 Z" id="褰㈢姸缁撳悎" fill="#0A59F7" fill-rule="nonzero"></path> + <path d="M15.2916125,-0.646674887 C15.6304127,-0.408374098 15.7118836,0.0594587272 15.4735829,0.398258977 C15.2352821,0.737059227 14.7674492,0.818530137 14.428649,0.580229347 C13.9115653,0.216529967 13.3939488,0.200109087 12.8660938,0.563002867 C12.8622976,0.568349607 12.8580413,0.571409377 12.8537436,0.574432227 C12.7923332,0.617626227 12.7315239,0.664602797 12.6713427,0.715253687 C12.4219783,0.928355347 12.1703634,1.227223 11.9152239,1.61389831 C10.916982,3.12677823 10.1589022,5.6805444 9.84274842,8.77778683 C9.66835079,10.4862965 9.64499441,12.2080729 9.74740605,13.8426678 L9.79892315,14.5375779 C9.91331552,15.8718435 10.1118531,17.1361717 10.3800874,18.2731368 C10.7658836,19.8969561 11.2932642,21.2382186 11.913299,22.1779088 C12.0997223,22.4604416 12.2842638,22.6960956 12.4673155,22.8861642 C12.5936428,23.0135245 12.7232587,23.1242423 12.8556685,23.2173749 L12.8842727,23.2424454 C13.4051696,23.591225 13.9162066,23.5706588 14.4267241,23.2115778 C14.7655243,22.973277 15.2333571,23.0547479 15.4716579,23.3935482 C15.7099587,23.7323484 15.6284878,24.2001812 15.2896876,24.438482 C14.202891,25.2028984 13.0689453,25.1710449 12.053052,24.4808754 C12.0322773,24.4707431 12.0122759,24.4580446 11.992705,24.4442791 C11.6211349,24.1829291 11.2716831,23.8323767 10.9466696,23.4049083 C10.8490158,23.2781666 10.753994,23.1445254 10.6612864,23.0040229 C9.82334984,21.7340929 9.15813525,19.9140936 8.72788734,17.7355888 C8.44006539,16.28589 8.26004929,14.7001825 8.20321672,13.0564556 C8.08100722,9.67589273 8.48476018,6.38299686 9.29404069,3.81571852 C9.30735691,3.77391178 9.32043596,3.73282876 9.3336156,3.69195231 C9.35627744,3.62164733 9.37952142,3.55128254 9.40307663,3.48150384 C9.41712926,3.4394831 9.4312123,3.39821843 9.44540081,3.35718021 C9.51120822,3.16768879 9.57961436,2.98149544 9.65032605,2.80012316 C9.67208963,2.74318479 9.69427114,2.68731646 9.71666512,2.63195219 C9.73359845,2.59119208 9.75049042,2.54999974 9.76750534,2.50907645 C9.92625314,2.12633576 10.0953907,1.76937302 10.2740931,1.43960229 C10.7716671,0.518371807 11.348143,-0.200462533 11.9907801,-0.65247201 C12.0225041,-0.67478563 12.0553595,-0.694295565 12.0890518,-0.71105308 C13.096167,-1.37984941 14.2169412,-1.40256277 15.2916125,-0.646674887 Z" id="褰㈢姸缁撳悎" fill-opacity="0.8" fill="#FFFFFF" fill-rule="nonzero" transform="translate(11.895960, 11.895960) rotate(-45.000000) translate(-11.895960, -11.895960) "></path> + </g> +</svg> \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_back.svg b/entry/src/main/resources/base/media/ic_back.svg new file mode 100644 index 0000000000000000000000000000000000000000..e7aebc78f4b72ad0fd8239b91d1584072dfbb9e8 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_back.svg @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="40px" height="40px" viewBox="0 0 40 40" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>ic_back</title> + <defs> + <path d="M16.7823403,12.1940138 L16.8152459,12.2242889 L23.9739788,18.758314 C24.6607833,19.4278133 24.6750917,20.50462 24.016904,21.1910905 L23.9739788,21.2343699 L16.8140514,27.7814026 C16.6817842,27.9103372 16.5133575,27.9825405 16.3405918,27.9980127 L16.2933902,28.0008258 L16.2461168,28.0008258 C16.0570714,27.9951996 15.8697472,27.9220585 15.7254556,27.7814026 C15.4355841,27.4988349 15.4252316,27.0469724 15.6943979,26.7523123 L15.7254556,26.7202357 L22.5225176,20.5269254 C22.8123891,20.2443577 22.8227416,19.7924952 22.5535753,19.4978351 L22.5225176,19.4657585 L15.7266501,13.2854558 C15.4260426,12.9924226 15.4260426,12.5173221 15.7266501,12.2242889 C15.8715858,12.0830051 16.0599392,12.0098403 16.2498433,12.0047944 L16.2973274,12.0047944 C16.4713765,12.0107338 16.6437969,12.0737544 16.7823403,12.1940138 Z" id="path-1"></path> + </defs> + <g id="ic_back" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <circle id="妞渾褰�" fill-opacity="0.0509803922" fill="#000000" cx="20" cy="20" r="20"></circle> + <mask id="mask-2" fill="white"> + <use xlink:href="#path-1" transform="translate(20.000021, 20.002810) scale(-1, 1) translate(-20.000021, -20.002810) "></use> + </mask> + <use id="璺緞" fill-opacity="0.9" fill="#000000" fill-rule="nonzero" transform="translate(20.000021, 20.002810) scale(-1, 1) translate(-20.000021, -20.002810) " xlink:href="#path-1"></use> + </g> +</svg> \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_default.png b/entry/src/main/resources/base/media/ic_default.png new file mode 100644 index 0000000000000000000000000000000000000000..04b20f2e2bb924ed835f3076015517f73742895f Binary files /dev/null and b/entry/src/main/resources/base/media/ic_default.png differ diff --git a/entry/src/main/resources/base/media/ic_icon.png b/entry/src/main/resources/base/media/ic_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/entry/src/main/resources/base/media/ic_icon.png differ diff --git a/entry/src/main/resources/base/media/ic_ok.png b/entry/src/main/resources/base/media/ic_ok.png new file mode 100644 index 0000000000000000000000000000000000000000..c5db6d88480a41b2d0795b4f3f00ae2215449ce9 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_ok.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..16cf3219a2997a071cd6f0cd4816d3e173b18d15 --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..d742c2f96e7dd0f406f499941f3147345e998f95 --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..14bbd62cb9de385b1f5551945d749bb5e0e5fc2c --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6b976fb6d0379b826204087d18a5f01872ce4d54 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/local/todo.html b/entry/src/main/resources/rawfile/local/todo.html new file mode 100644 index 0000000000000000000000000000000000000000..83f093acd7e1f955dcba064f2ae60fe8009aa3ec --- /dev/null +++ b/entry/src/main/resources/rawfile/local/todo.html @@ -0,0 +1,166 @@ +<!DOCTYPE html> +<html lang="zh-CN"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>寰呭姙浜嬮」</title> + <style> + body { + font-family: Arial, sans-serif; + margin: 20px; + } + h1 { + font-weight: bold; + margin-bottom: 20px; + } + ul { + list-style-type: none; + padding: 0; + } + li { + display: flex; + flex-direction: column; + background-color: #f9f9f9; + padding: 15px; + margin-bottom: 15px; + border-radius: 5px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + } + li.completed label { + text-decoration: line-through; + color: gray; + } + input[type="checkbox"] { + appearance: none; + width: 20px; + height: 20px; + border-radius: 50%; + border: 2px solid #007bff; + margin-right: 10px; + position: relative; + cursor: pointer; + } + input[type="checkbox"]:checked { + background-color: #007bff; + } + input[type="checkbox"]:checked::after { + content: '鉁�'; + position: absolute; + top: 2px; + left: 5px; + font-size: 14px; + color: white; + } + .todo-header { + display: flex; + align-items: center; + justify-content: space-between; + } + .item-name { + font-size: 18px; + font-weight: bold; + } + .item-time { + font-size: 12px; + color: #555; + } + .item-desc { + font-size: 14px; + margin-top: 5px; + color: #333; + } + </style> +</head> +<body> + +<h1>寰呭姙浜嬮」</h1> + +<ul id="todoList"> + <!-- 寰呭姙浜嬮」灏嗛€氳繃JavaScript鍔ㄦ€佹彃鍏� --> +</ul> + +<script> + // // 妫€鏌� todos 鏄惁鎴愬姛浼犲叆 -- console + // console.log("寰呭姙浜嬮」鐨勬暟閲忎负:", JSON.stringify(todos)); + // + // // 妫€鏌� todos 鏄惁鎴愬姛浼犲叆 -- UI + // const todoCountElement = document.createElement('p'); + // todoCountElement.textContent = `寰呭姙浜嬮」鐨勬暟閲�: ${JSON.stringify(todos)}`; + // document.body.insertBefore(todoCountElement, document.body.firstChild); + + const myRefresh = () => { + // 鑾峰彇寰呭姙浜嬮」鍒楄〃鐨勫鍣� + const todosObject = myClass.getTasks(); + const todoList = document.getElementById('todoList'); + const todos = Object.keys(todosObject) + .filter(key => key !== "length") // 鎺掗櫎 length 灞炴€� + .map(key => todosObject[key]); // 杞崲涓烘暟缁� + + // 灏嗗緟鍔炰簨椤瑰姩鎬佹坊鍔犲埌椤甸潰 + todos.forEach((todo, index) => { + const listItem = document.createElement('li'); + + // 鍒涘缓澶嶉€夋 + const checkbox = document.createElement('input'); + checkbox.type = 'checkbox'; + checkbox.checked = todo.isCompleted; + checkbox.id = `todo-${index}`; + + // 鍒涘缓鍚嶇О鍜屾椂闂� + const nameLabel = document.createElement('label'); + nameLabel.classList.add('item-name'); + nameLabel.setAttribute('for', `todo-${index}`); + nameLabel.textContent = todo.itemName; + + const itemTime = document.createElement('span'); + itemTime.classList.add('item-time'); + itemTime.textContent = `璁″垝鏃堕棿: ${todo.itemTime}`; + + // 鍒涘缓鎻忚堪 + const itemDesc = document.createElement('p'); + itemDesc.classList.add('item-desc'); + itemDesc.textContent = todo.itemDisc; + + // 娣诲姞宸插畬鎴愭牱寮� + if (todo.isCompleted) { + listItem.classList.add('completed'); + itemTime.textContent += `锛堝畬鎴愭椂闂�: ${todo.completeTime}锛塦; + } + + // 娣诲姞澶嶉€夋鐘舵€佹敼鍙樹簨浠� + checkbox.addEventListener('change', () => { + myClass.markComplete(index) + todo.isCompleted = checkbox.checked; // 鏇存柊 isCompleted 灞炴€� + if (checkbox.checked) { + listItem.classList.add('completed'); + itemTime.textContent = `璁″垝鏃堕棿: ${todo.itemTime}锛堝畬鎴愭椂闂�: ${new Date().toLocaleString()}锛塦; + todo.completeTime = new Date().toLocaleString(); // 鏇存柊瀹屾垚鏃堕棿 + } else { + listItem.classList.remove('completed'); + itemTime.textContent = `璁″垝鏃堕棿: ${todo.itemTime}`; + todo.completeTime = ''; // 娓呴櫎瀹屾垚鏃堕棿 + } + }); + + // 鍒涘缓涓€涓鍣ㄦ潵鍖呰9澶嶉€夋鍜屽緟鍔炰簨椤圭殑鏍囬 + const headerDiv = document.createElement('div'); + headerDiv.classList.add('todo-header'); + headerDiv.appendChild(checkbox); + headerDiv.appendChild(nameLabel); + + // 灏嗗悇涓厓绱犳坊鍔犲埌鍒楄〃椤逛腑 + listItem.appendChild(headerDiv); + listItem.appendChild(itemTime); + listItem.appendChild(itemDesc); + + // 灏嗗垪琛ㄩ」娣诲姞鍒板緟鍔炰簨椤瑰垪琛ㄤ腑 + todoList.appendChild(listItem); + }); + + } + myRefresh() +</script> + + +</body> +</html> diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..cab069eb230dd1cc6d3c24cd0f1aa46d54af9cc9 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "妯″潡鎻忚堪" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/entry/src/mock/mock-config.json5 b/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e02aef276ea851d71b44c9723088808a9c100bac --- /dev/null +++ b/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ae666e1a9eef300ea97e0859c0c67591aa459a23 --- /dev/null +++ b/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/entry/src/test/List.test.ets b/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/entry/src/test/LocalUnit.test.ets b/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e0bd0d82696bcd6337fc106180834b6a9ac56a5d --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6302d7b6478f11bdd3fdbf2eb20ab70812e86eb5 --- /dev/null +++ b/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.19": { + "name": "@ohos/hypium", + "version": "1.0.19", + "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..dd6b0d408799801607b2f5b3256b2a4969d90e02 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +}