diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..33289a7a14b0a3ea3dc892ad5602ba7d49441e43 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer +**/oh-package-lock.json5 +*.build.json +/issue.build.json \ No newline at end of file diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7cc3e0d4d55ca72be85bdf7cdfac7775ce88589f --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.scenedemos", + "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..b4fb3b1c5c115adea28eb7348cb713018f87b8ef --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "IssueSolutionDemos" + } + ] +} 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/case.bat b/case.bat new file mode 100644 index 0000000000000000000000000000000000000000..4bae58ec1d03ae74702cb796c60f506d89381e21 --- /dev/null +++ b/case.bat @@ -0,0 +1,81 @@ +@echo off +setlocal enabledelayedexpansion + +if "%1"=="" ( + echo Usage: + echo case.bat add ^ - Add case demo to build + echo case.bat clear - Clear all case configurations + echo case.bat new ^ - create new case demo + echo case.bat buildall - build demos hap with all cases + echo case.bat build ^ - build demos hap with specified cases + exit /b 1 +) + +if "%1"=="add" ( + if "%2"=="" ( + echo Error: caseNO is required + echo Example: case.bat add case001 + exit /b 1 + ) + echo Adding case demo %2... + call hvigorw caseAdd -p caseNO=%2 + call ohpm install --all --registry https://ohpm.openharmony.cn/ohpm/ --strict_ssl false + call hvigorw --sync + exit /b 0 +) + +if "%1"=="clear" ( + echo Clearing case configurations... + call hvigorw caseClear + call ohpm install --all --registry https://ohpm.openharmony.cn/ohpm/ --strict_ssl false + call hvigorw --sync + exit /b 0 +) + +if "%1"=="new" ( + if "%2"=="" ( + echo Error: demoname is required + echo Example: case.bat new ArkUI-case001-test + exit /b 1 + ) + echo new case demo %2... + call hvigorw generateModule -p demoname=%2 + call ohpm install --all --registry https://ohpm.openharmony.cn/ohpm/ --strict_ssl false + call hvigorw --sync + exit /b 0 +) + +if "%1"=="buildall" ( + echo execute clear case demos.... + call hvigorw caseClear + echo execute add all case demos.... + call hvigorw caseAddAll + echo execute install hars.... + ohpm install --all --registry https://ohpm.openharmony.cn/ohpm/ --strict_ssl false + call hvigorw --sync + echo execute build hap.... + call hvigorw --mode module -p module=default@default -p product=default assembleHap + exit /b 0 +) + +if "%1"=="build" ( + if "%2"=="" ( + echo Error: caseNO is required + echo Example: case.bat build case001 + exit /b 1 + ) + echo execute clear case demos.... + call hvigorw caseClear + echo execute add case demo %2... + call hvigorw caseAdd -p caseNO=%2 + echo execute install hars.... + ohpm install --all --registry https://ohpm.openharmony.cn/ohpm/ --strict_ssl false + call hvigorw --sync + echo execute build hap.... + call hvigorw --mode module -p module=default@default -p product=default assembleHap + exit /b 0 +) + +echo Error: Unknown command '%1' +echo Valid commands are: add, clear +exit /b 1 \ No newline at end of file diff --git a/cases/ArkTS/.gitkeep b/cases/ArkTS/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/ArkUI/.gitkeep b/cases/ArkUI/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/Audio/.gitkeep b/cases/Audio/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/DFX/.gitkeep b/cases/DFX/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/Graphics/.gitkeep b/cases/Graphics/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/Network/.gitkeep b/cases/Network/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/Picker/.gitkeep b/cases/Picker/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/Video/.gitkeep b/cases/Video/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/cases/Web/.gitkeep b/cases/Web/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/code-linter.json5 b/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0d334fd88e017e33bffc75e2de0c04795ca794ae --- /dev/null +++ b/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "error", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/common/framework/.gitignore b/common/framework/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/common/framework/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/common/framework/Index.ets b/common/framework/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42bf4161c271e1b14d42a7ab98c982acc9bc3592 --- /dev/null +++ b/common/framework/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/common/framework/build-profile.json5 b/common/framework/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cda3307123ec7c43181580a86ef7e82a18319a34 --- /dev/null +++ b/common/framework/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/common/framework/consumer-rules.txt b/common/framework/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/common/framework/hvigorfile.ts b/common/framework/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/common/framework/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/common/framework/obfuscation-rules.txt b/common/framework/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/common/framework/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/common/framework/oh-package.json5 b/common/framework/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..820af24ea2feb750e5320b57c701f10b34572e7f --- /dev/null +++ b/common/framework/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "framework", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/common/framework/src/main/ets/components/MainPage.ets b/common/framework/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..82fd16d8801677076fb8d1ec1cff2c833e0408e5 --- /dev/null +++ b/common/framework/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }); + } + .width('100%'); + } + .height('100%'); + } +} diff --git a/common/framework/src/main/module.json5 b/common/framework/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0acced9700dde5832aa318af0cbe44246537cedd --- /dev/null +++ b/common/framework/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "framework", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/common/framework/src/main/resources/base/element/float.json b/common/framework/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/common/framework/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/common/framework/src/main/resources/base/element/string.json b/common/framework/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/common/framework/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/common/framework/template/moduleTemplate/.gitignore b/common/framework/template/moduleTemplate/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/common/framework/template/moduleTemplate/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/common/framework/template/moduleTemplate/BuildProfile.ets b/common/framework/template/moduleTemplate/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/common/framework/template/moduleTemplate/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/common/framework/template/moduleTemplate/Index.ets b/common/framework/template/moduleTemplate/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42bf4161c271e1b14d42a7ab98c982acc9bc3592 --- /dev/null +++ b/common/framework/template/moduleTemplate/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/common/framework/template/moduleTemplate/build-profile.json5 b/common/framework/template/moduleTemplate/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cda3307123ec7c43181580a86ef7e82a18319a34 --- /dev/null +++ b/common/framework/template/moduleTemplate/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/common/framework/template/moduleTemplate/consumer-rules.txt b/common/framework/template/moduleTemplate/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/common/framework/template/moduleTemplate/hvigorfile.ts b/common/framework/template/moduleTemplate/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..cebe3fbf9e3463c16c342f7b83fd582a2cd0a516 --- /dev/null +++ b/common/framework/template/moduleTemplate/hvigorfile.ts @@ -0,0 +1,7 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; +import {harPlugin} from '@hadss/hmrouter-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[harPlugin()] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/common/framework/template/moduleTemplate/manifest.json b/common/framework/template/moduleTemplate/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..347e80b605239ebb461c8eb1557d749e277cfa6a --- /dev/null +++ b/common/framework/template/moduleTemplate/manifest.json @@ -0,0 +1,6 @@ +{ + "caseNO": "${caseNO}", + "desc": "${desc}", + "home": "${home}", + "dependencies": [] +} \ No newline at end of file diff --git a/common/framework/template/moduleTemplate/obfuscation-rules.txt b/common/framework/template/moduleTemplate/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/common/framework/template/moduleTemplate/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/common/framework/template/moduleTemplate/oh-package.json5 b/common/framework/template/moduleTemplate/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..66095483f3e90e79cd7020628f21b7e5ea49aac8 --- /dev/null +++ b/common/framework/template/moduleTemplate/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "caseNO", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/common/framework/template/moduleTemplate/src/main/ets/components/MainPage.ets b/common/framework/template/moduleTemplate/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..f39e6f8d27c066367d197b4fc1da2131eccba263 --- /dev/null +++ b/common/framework/template/moduleTemplate/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +import { HMRouter } from '@hadss/hmrouter'; + +@HMRouter({pageUrl:'${caseNO}/home'}) +@Component +export struct MainPage { + @State message: string = 'hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/common/framework/template/moduleTemplate/src/main/module.json5 b/common/framework/template/moduleTemplate/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e2e37679203eb9caccdb0e4403fe9516e7f40cc7 --- /dev/null +++ b/common/framework/template/moduleTemplate/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "caseNO", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/common/ui_components/.gitignore b/common/ui_components/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/common/ui_components/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/common/ui_components/Index.ets b/common/ui_components/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42bf4161c271e1b14d42a7ab98c982acc9bc3592 --- /dev/null +++ b/common/ui_components/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/common/ui_components/build-profile.json5 b/common/ui_components/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cda3307123ec7c43181580a86ef7e82a18319a34 --- /dev/null +++ b/common/ui_components/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/common/ui_components/consumer-rules.txt b/common/ui_components/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/common/ui_components/hvigorfile.ts b/common/ui_components/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/common/ui_components/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/common/ui_components/obfuscation-rules.txt b/common/ui_components/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/common/ui_components/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/common/ui_components/oh-package.json5 b/common/ui_components/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..803e980195549357856b04dffb21325730d7b111 --- /dev/null +++ b/common/ui_components/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "ui_components", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/common/ui_components/src/main/ets/components/MainPage.ets b/common/ui_components/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..82fd16d8801677076fb8d1ec1cff2c833e0408e5 --- /dev/null +++ b/common/ui_components/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }); + } + .width('100%'); + } + .height('100%'); + } +} diff --git a/common/ui_components/src/main/module.json5 b/common/ui_components/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5e8bae7bb2de1a409b634a1313bc3382a0a92e49 --- /dev/null +++ b/common/ui_components/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "ui_components", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/common/ui_components/src/main/resources/base/element/float.json b/common/ui_components/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/common/ui_components/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/common/ui_components/src/main/resources/base/element/string.json b/common/ui_components/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/common/ui_components/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/common/utils/.gitignore b/common/utils/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/common/utils/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/common/utils/Index.ets b/common/utils/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42bf4161c271e1b14d42a7ab98c982acc9bc3592 --- /dev/null +++ b/common/utils/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/common/utils/build-profile.json5 b/common/utils/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cda3307123ec7c43181580a86ef7e82a18319a34 --- /dev/null +++ b/common/utils/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/common/utils/consumer-rules.txt b/common/utils/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/common/utils/hvigorfile.ts b/common/utils/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/common/utils/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/common/utils/obfuscation-rules.txt b/common/utils/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/common/utils/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/common/utils/oh-package.json5 b/common/utils/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..11c2609f7fa5cb92fead549d01cbc2509d6c332a --- /dev/null +++ b/common/utils/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "utils", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/common/utils/src/main/ets/components/MainPage.ets b/common/utils/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..82fd16d8801677076fb8d1ec1cff2c833e0408e5 --- /dev/null +++ b/common/utils/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }); + } + .width('100%'); + } + .height('100%'); + } +} diff --git a/common/utils/src/main/module.json5 b/common/utils/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2355b2eb8e10f153a118897f44ea0932765b15be --- /dev/null +++ b/common/utils/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "utils", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/common/utils/src/main/resources/base/element/float.json b/common/utils/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/common/utils/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/common/utils/src/main/resources/base/element/string.json b/common/utils/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/common/utils/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100644 index 0000000000000000000000000000000000000000..daea455459fcc6e6c32e1557fa5146e6a588175c --- /dev/null +++ b/hooks/pre-commit @@ -0,0 +1,9 @@ +#!/bin/sh + +# 自动回退指定文件的修改 +FILE="./build-profile.json5" +echo "正在撤销文件更改: $FILE" +git restore --source=HEAD --staged --worktree "$FILE" +FILE="./products/default/oh-package.json5" +echo "正在撤销文件更改: $FILE" +git restore --source=HEAD --staged --worktree "$FILE" \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f7689385e5c752268a777cbadee7366e35275048 --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,23 @@ +{ + "modelVersion": "5.0.2", + "dependencies": { + "@hadss/hmrouter-plugin": "^1.0.0-rc.11" + }, + "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": true /* 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..feb86d2558bb2e98721745175432a4e36f95fda3 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,68 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin' +import { hvigor, HvigorNode, getNode } from '@ohos/hvigor' +import { preCommit } from './scripts/gitHooks.ts' +import { caseAdd, caseClear, generateModule, caseAddAll } from './scripts/caseTasks.ts' + +// 获取当前hvigorNode节点对象 +const node: HvigorNode = getNode(__filename) + +/** + * 自动执行git hooks + */ +hvigor.buildFinished(buildResult => { + runGitHooks(node); +}) + +function runGitHooks(node) { + console.log('run git hooks...') + preCommit(node); +} + +/** + * 注册 caseAdd 任务 + * 用于生成case模块的编译配置文件并添加到构建配置中 + */ +node.registerTask({ + name: 'caseAdd', + run() { + caseAdd(node) + } +}) + +/** + * 注册 caseAdd 任务 + * 用于生成case模块的编译配置文件并添加到构建配置中 + */ +node.registerTask({ + name: 'caseAddAll', + run() { + caseAddAll(node) + } +}) + +/** + * 注册 caseClear 任务 + * 用于清理所有case相关配置 + */ +node.registerTask({ + name: 'caseClear', + run() { + caseClear(node) + } +}) + +/** + * 注册生成模块任务 + * 用于创建新模块 + */ +node.registerTask({ + name: 'generateModule', + run() { + generateModule(node); + } +}) + +export default { + system: appTasks, + plugins: [] +} \ No newline at end of file diff --git a/issue.sh b/issue.sh new file mode 100644 index 0000000000000000000000000000000000000000..99bf55815d781085ec958b24c2a7570ddd820e81 --- /dev/null +++ b/issue.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# 显示使用说明 +show_usage() { + echo "Usage:" + echo " ./issue.sh add - Add issue demo to build" + echo " ./issue.sh clear - Clear all issue configurations" + exit 1 +} + +# 检查命令参数 +if [ $# -eq 0 ]; then + show_usage +fi + +case "$1" in + "add") + if [ -z "$2" ]; then + echo "Error: issueNO is required" + echo "Example: ./issue.sh add 20250001" + exit 1 + fi + echo "Adding issue demo $2..." + hvigorw issueAdd -p issueNO=$2 + ;; + "clear") + echo "Clearing issue configurations..." + hvigorw issueClear + ;; + *) + echo "Error: Unknown command '$1'" + echo "Valid commands are: add, clear" + exit 1 + ;; +esac \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..351f4a2c3ce1ae36eabd4ba09c09064b1b1e3200 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "modelVersion": "5.0.2", + "description": "Please describe the basic information.", + "dependencies": { + "@hadss/hmrouter": "^1.0.0-rc.11", + "@hadss/dialoghub": "^1.0.0-rc.1" + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + }, + "dynamicDependencies": {} +} \ No newline at end of file diff --git a/products/default/.gitignore b/products/default/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/products/default/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/products/default/build-profile.json5 b/products/default/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0311b505dbf43f0d22662c8d783c5f4464d15b15 --- /dev/null +++ b/products/default/build-profile.json5 @@ -0,0 +1,25 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + } + ] +} \ No newline at end of file diff --git a/products/default/hvigorfile.ts b/products/default/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c61296b89aa19028f59c2d2dd37d0ba61a6655f --- /dev/null +++ b/products/default/hvigorfile.ts @@ -0,0 +1,161 @@ +import { FileUtil, getLogger, getNode, hvigor, HvigorNode, HvigorPlugin } from '@ohos/hvigor' +import { hapTasks, OhosAppContext, OhosHapContext, OhosPluginId } from '@ohos/hvigor-ohos-plugin' +import { hapPlugin } from '@hadss/hmrouter-plugin' +import path from 'path' +import fs from 'fs' +/** + * Case编译插件 + * 用于自动处理Case模块的构建配置和依赖关系 + */ +export function casePlugin(): HvigorPlugin { + return { + pluginId: 'casePlugin', + context() { + return { + name: 'casePlugin' + } + }, + async apply(currentNode: HvigorNode): Promise { + const logger = getLogger('casePlugin') + const hapContext = currentNode.getContext(OhosPluginId.OHOS_HAP_PLUGIN) as OhosHapContext + if (!hapContext) { + return + } + + // 在节点评估完成后处理issue + hvigor.nodesEvaluated(() => { + hapContext.targets(target => { + currentNode.registerTask({ + name: 'caseRun', + run() { + generateNavigationPage(currentNode, hapContext, logger) + }, + postDependencies: [target.getTargetName() + '@PreBuild'] + }) + }) + }) + + hvigor.buildFinished(() => { + const homepagePath = `${hapContext.getModulePath()}/src/main/ets/pages/HomePage.ets` + if (FileUtil.exist(homepagePath)) { + fs.unlinkSync(homepagePath) + logger.info('Deleted HomePage.ets') + } + }) + } + } +} + +/** + * 生成导航页面 + */ +function generateNavigationPage(currentNode: HvigorNode, hapContext: OhosHapContext, logger: any) { + try { + const appContext: OhosAppContext = currentNode.getParentNode()?.getContext(OhosPluginId.OHOS_APP_PLUGIN) + const projectPath = appContext.getProjectPath() + const buildJsonPath = path.join(projectPath, 'case.build.json') + + if (!FileUtil.exist(buildJsonPath)) { + logger.warn('No case build configuration found') + return + } + + const buildConfig = JSON.parse(FileUtil.readFileSync(buildJsonPath).toString()) + if (!buildConfig.modules?.length) { + return + } + + // 读取每个模块的manifest配置并生成按钮代码 + const issueItems = buildConfig.modules.map(module => { + const manifestPath = path.join(projectPath, module.srcPath, 'manifest.json') + if (!FileUtil.exist(manifestPath)) { + logger.warn(`No manifest.json found for module ${module.name}`) + return null + } + + const manifest = JSON.parse(FileUtil.readFileSync(manifestPath).toString()) + return { + name: module.name, + caseNO: manifest.caseNO, + desc: manifest.desc, + home: manifest.home + } + }).filter(Boolean) + + // 生成列表项代码 + const listItemsCode = issueItems + .map( + item => ` ListItem() { + Column() { + Row() { + Column() { + Text('Issue-${item.caseNO}') + .fontSize(16) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 4 }) + Text('${item.desc}') + .fontSize(14) + .opacity(0.6) + } + .alignItems(HorizontalAlign.Start) + .layoutWeight(1) + + Button('查看详情') + .onClick(() => { + HMRouterMgr.push({ pageUrl: '${item.home}' }); + }) + .height(32) + .fontSize(14) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + } + .width('100%') + .padding(16) + .backgroundColor(Color.White) + .borderRadius(8) + } + .margin({ bottom: 8 })` + ) + .join('\n') + + // 生成页面内容 + const pageContent = `import { HMRouter, HMRouterMgr } from "@hadss/hmrouter"; + +@HMRouter({ pageUrl: 'homePage' }) +@Component +export struct HomePage { + build() { + Column() { + Text('Issue Demo 导航') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 20, bottom: 16 }) + + List() { +${listItemsCode} + } + .width('100%') + .layoutWeight(1) + .padding({ left: 16, right: 16 }) + } + .width('100%') + .height('100%') + .backgroundColor('#F5F5F5'); + } +}` + + const homepagePath = `${hapContext.getModulePath()}/src/main/ets/pages/HomePage.ets` + FileUtil.ensureFileSync(homepagePath) + FileUtil.writeFileSync(homepagePath, pageContent) + logger.info('Generated HomePage.ets with navigation buttons') + } catch (error) { + logger.error(`Failed to generate navigation page: ${error}`) + } +} + +export default { + system: hapTasks, + plugins: [casePlugin(), hapPlugin()] +} diff --git a/products/default/obfuscation-rules.txt b/products/default/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/products/default/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/products/default/src/main/ets/entryability/EntryAbility.ets b/products/default/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..75a9c7340e84b6db0f40fdf9eb1899c1f55a4bdc --- /dev/null +++ b/products/default/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,15 @@ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { HMRouterMgr } from '@hadss/hmrouter'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + HMRouterMgr.init({ + context: this.context + }); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index'); + } +}; \ No newline at end of file diff --git a/products/default/src/main/ets/pages/Index.ets b/products/default/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..acd79a91d4c3cdcc17e8d2f4901191b7a9551a57 --- /dev/null +++ b/products/default/src/main/ets/pages/Index.ets @@ -0,0 +1,25 @@ +import { HMNavigation } from '@hadss/hmrouter'; +import { AttributeUpdater } from '@kit.ArkUI'; + +class Modifier extends AttributeUpdater { + initializeModifier(instance: NavigationAttribute): void { + instance.hideNavBar(true); + } +} + +@Entry +@Component +struct Index { + private modifier: Modifier = new Modifier(); + + build() { + Column() { + HMNavigation({ + navigationId: 'ISSUE_DEMO_NAVIGATION', homePageUrl: 'homePage', options: { + modifier: this.modifier + } + }); + }.width('100%') + .height('100%'); + } +} \ No newline at end of file diff --git a/products/default/src/main/module.json5 b/products/default/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ee3e0dff67d528c321c7f909c2ca000b75215f9b --- /dev/null +++ b/products/default/src/main/module.json5 @@ -0,0 +1,38 @@ +{ + "module": { + "name": "default", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + } +} \ No newline at end of file diff --git a/products/default/src/main/resources/base/element/color.json b/products/default/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/products/default/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/products/default/src/main/resources/base/element/float.json b/products/default/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/products/default/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/products/default/src/main/resources/base/element/string.json b/products/default/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/products/default/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/products/default/src/main/resources/base/media/background.png b/products/default/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/products/default/src/main/resources/base/media/background.png differ diff --git a/products/default/src/main/resources/base/media/foreground.png b/products/default/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/products/default/src/main/resources/base/media/foreground.png differ diff --git a/products/default/src/main/resources/base/media/layered_image.json b/products/default/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/products/default/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/products/default/src/main/resources/base/media/startIcon.png b/products/default/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/products/default/src/main/resources/base/media/startIcon.png differ diff --git a/products/default/src/main/resources/base/profile/backup_config.json b/products/default/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/products/default/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/products/default/src/main/resources/base/profile/main_pages.json b/products/default/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/products/default/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/products/default/src/main/resources/dark/element/color.json b/products/default/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/products/default/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/scripts/caseTasks.ts b/scripts/caseTasks.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fc6a26a46407b8dd432131a6c1eef52ae6ee395 --- /dev/null +++ b/scripts/caseTasks.ts @@ -0,0 +1,312 @@ +import { OhosPluginId, OhosAppContext } from '@ohos/hvigor-ohos-plugin' +import { hvigor, HvigorNode, FileUtil } from '@ohos/hvigor' +import * as fs from 'fs' +import * as path from 'path' + + +/** + * caseAdd 任务实现 + * 根据caseNO生成对应的编译配置文件并添加到构建配置中 + * @param node - Hvigor节点对象 + */ +export function caseAdd(node: HvigorNode) { + const caseNO = hvigor.getParameter().getExtParam('caseNO'); + addCaseByNO(caseNO, node); +} + +/** + * caseAddAll 任务实现 + * 遍历所有的caseNO生成对应的编译配置文件并添加到构建配置中 + * @param node - Hvigor节点对象 + */ +export function caseAddAll(node: HvigorNode) { + const appContext: OhosAppContext = node.getContext(OhosPluginId.OHOS_APP_PLUGIN); + const projectPath = appContext.getProjectPath(); + const caseDirRootPath = FileUtil.pathResolve(projectPath, 'cases'); + + // 递归查找所有的case模块 + function addAllCaseConfig(dir: string): string | null { + let files = fs.readdirSync(dir, { withFileTypes: true }) + for (let file of files) { + const filePath = FileUtil.pathResolve(dir, file.name); + if (file.isDirectory()) { + if (file.name.startsWith('case')) { + const moduleName = file.name; + const moduleRelativePath = path.relative(projectPath, filePath).replace(/\\/g, '/'); + addCaseConfig(projectPath, { name: moduleName, relativePath: moduleRelativePath }); + } else { + addAllCaseConfig(filePath); + } + } + } + } + + addAllCaseConfig(caseDirRootPath); +} + +/** + * caseClear 任务实现 + * 清理所有case相关配置 + */ +export function caseClear(node: HvigorNode) { + const appContext: OhosAppContext = node.getContext(OhosPluginId.OHOS_APP_PLUGIN) + const projectPath = appContext.getProjectPath() + const buildJsonPath = path.join(projectPath, 'case.build.json') + const buildProfilePath = path.join(projectPath, 'build-profile.json5') + const defaultPackagePath = path.join(projectPath, 'products/default/oh-package.json5') + + // 清理 case.build.json + if (FileUtil.exist(buildJsonPath)) { + fs.unlinkSync(buildJsonPath) + console.log('Cleared case build configuration') + } + + // 还原 build-profile.json5 + if (FileUtil.exist(buildProfilePath)) { + const buildProfile = FileUtil.readJson5(buildProfilePath) + // 只保留非case模块 + buildProfile.modules = buildProfile.modules.filter( + module => !module.srcPath.startsWith('./cases/') + ) + FileUtil.writeFileSync(buildProfilePath, JSON.stringify(buildProfile, null, 2)) + console.log('Restored build-profile.json5') + } + + // 还原 default 模块依赖 + if (FileUtil.exist(defaultPackagePath)) { + const defaultPackage = FileUtil.readJson5(defaultPackagePath) + // 移除所有case模块的依赖 + if (defaultPackage.dependencies) { + Object.keys(defaultPackage.dependencies).forEach(key => { + if (key.startsWith('case')) { + delete defaultPackage.dependencies[key] + } + }) + FileUtil.writeFileSync(defaultPackagePath, JSON.stringify(defaultPackage, null, 2)) + console.log('Restored default module dependencies') + } + } +} + +/** + * generateModule 任务实现 + * 创建新模块 + * @param node + */ +export function generateModule(node: HvigorNode) { + const appContext: OhosAppContext = node.getContext(OhosPluginId.OHOS_APP_PLUGIN) + const projectPath = appContext.getProjectPath(); + + const demoname = hvigor.getParameter().getExtParam('demoname') + if (!demoname) { + throw new Error('Parameter demoname is required') + } + + let params = demoname.split('-'); + if (params.length < 2) { + throw new Error('Parameter' + demoname + 'is invalid') + } + + const typeName = params[0]; + const typePath = FileUtil.pathResolve(projectPath, 'cases', typeName); + if (!fs.existsSync(typePath)) { + throw new Error(typeName + 'not found') + } + + const caseNO = params[1]; + let desc = ''; + if (params.length > 2) { + desc = params[2]; + } + + const modulePath = FileUtil.pathResolve(projectPath, 'cases', typeName, caseNO); + const templatePath = FileUtil.pathResolve(projectPath, 'common', 'framework', 'template', 'moduleTemplate'); + + // 校验case编号重复 + if (fs.existsSync(modulePath)) { + throw new Error(modulePath + ' exists') + } + + // 创建模块 + fs.mkdirSync(modulePath); + copyFiles(templatePath, modulePath); + + // 修改文件 + // 修改oh-package.json5文件 + modifyOhPackage(caseNO, modulePath); + // 修改manifest.json文件 + modifyManifest(caseNO, desc, modulePath); + // 修改module.json5文件 + modifyModuleJson5(caseNO, modulePath); + // 修改MainPage.ets文件 + modifyMainPage(caseNO, modulePath); + + addCaseByNO(caseNO, node); +} + +function addCaseByNO(caseNO, node) { + if (!caseNO) { + throw new Error('Parameter caseNO is required') + } + + const appContext: OhosAppContext = node.getContext(OhosPluginId.OHOS_APP_PLUGIN) + const projectPath = appContext.getProjectPath() + + // 查找匹配的模块 + const casesDir = FileUtil.pathResolve(projectPath, 'cases') + if (!FileUtil.exist(casesDir)) { + throw new Error(`cases directory not found at: ${casesDir}`) + } + + // 递归查找匹配的模块 + function findModuleInDir(dir: string): string | null { + const items = fs.readdirSync(dir) + for (const item of items) { + const itemPath = FileUtil.pathResolve(dir, item) + const stat = fs.statSync(itemPath) + + if (stat.isDirectory()) { + if (item.includes(caseNO)) { + return itemPath + } + const result = findModuleInDir(itemPath) + if (result) { + return result + } + } + } + return null + } + + const modulePath = findModuleInDir(casesDir) + if (!modulePath) { + throw new Error(`No matching module found for case ID: ${caseNO}`) + } + + const moduleName = path.basename(modulePath) + const moduleRelativePath = path.relative(projectPath, modulePath).replace(/\\/g, '/'); + + addCaseConfig(projectPath, { name: moduleName, relativePath: moduleRelativePath }); +} + +interface caseModuleData { + name: string + relativePath: string +} + +/** + * 模块配置接口定义 + */ +interface ModuleConfig { + name: string // 模块名称 + srcPath: string // 模块源码路径 + [key: string]: string // 添加索引签名 +} + +function addCaseConfig(projectPath: string, caseModuleData: caseModuleData) { + const buildJsonPath = FileUtil.pathResolve(projectPath, 'case.build.json') + const buildProfilePath = FileUtil.pathResolve(projectPath, 'build-profile.json5') + + // 读取现有配置或创建新配置 + let buildConfig = { + modules: [] as ModuleConfig[] + } + + // 如果存在配置文件,读取现有配置 + if (FileUtil.exist(buildJsonPath)) { + buildConfig = FileUtil.readJson5(buildJsonPath) + } + + // 读取 build-profile.json5 + const buildProfile = FileUtil.exist(buildProfilePath) + ? FileUtil.readJson5(buildProfilePath) + : { modules: [] } + + // 检查模块是否已存在,如果不存在则添加 + if (!buildConfig.modules.some(m => m.name === caseModuleData.name)) { + buildConfig.modules.push({ + name: caseModuleData.name, + srcPath: `./${caseModuleData.relativePath}` + }) + } + + // 更新 build-profile.json5,添加新模块 + buildConfig.modules.forEach(module => { + if (!buildProfile.modules.some(m => m.name === module.name)) { + buildProfile.modules.push({ + name: module.name, + srcPath: module.srcPath + }) + } + }) + FileUtil.writeFileSync(buildProfilePath, JSON.stringify(buildProfile, null, 2)) + + // 更新 default 模块的依赖 + const defaultPackagePath = FileUtil.pathResolve(projectPath, 'products/default/oh-package.json5') + let defaultPackage = FileUtil.exist(defaultPackagePath) + ? FileUtil.readJson5(defaultPackagePath) + : { dependencies: {} } + + // 确保所有模块的依赖都存在 + buildConfig.modules.forEach(module => { + const relativePath = path.relative( + path.join(projectPath, 'products/default'), + path.join(projectPath, module.srcPath) + ) + defaultPackage.dependencies[module.name.toLowerCase()] = `file:${relativePath}` + }) + + FileUtil.writeFileSync(defaultPackagePath, JSON.stringify(defaultPackage, null, 2)) + + // 保存 case.build.json + FileUtil.ensureFileSync(buildJsonPath) + FileUtil.writeFileSync(buildJsonPath, JSON.stringify(buildConfig, null, 2)) +} + +function copyFiles(from, to) { + let files = fs.readdirSync(from, { withFileTypes: true }); + for (let file of files) { + const fromFilePath = FileUtil.pathResolve(from, file.name); + const toFilePath = FileUtil.pathResolve(to, file.name); + if (!file.isDirectory()) { + fs.copyFileSync(fromFilePath, toFilePath); + } else { + fs.mkdirSync(toFilePath); + copyFiles(fromFilePath, toFilePath); + } + } +} + +function modifyOhPackage(caseNO, modulePath) { + const oh_package_path = FileUtil.pathResolve(modulePath, 'oh-package.json5'); + const oh_package_content = FileUtil.readFileSync(oh_package_path).toString(); + const result = oh_package_content.replace('caseNO', caseNO); + FileUtil.writeFileSync(oh_package_path, result); +} + +function modifyManifest(caseNO, desc, modulePath) { + const manifest_path = FileUtil.pathResolve(modulePath, 'manifest.json'); + const manifest_content = FileUtil.readFileSync(manifest_path).toString(); + const data = { + "caseNO": caseNO, + "desc": desc, + "home": caseNO + "/home", + "dependencies": [] + } + const result = manifest_content.replace(/\${(.*?)}/g, (match, key) => data[key]); + FileUtil.writeFileSync(manifest_path, result); +} + +function modifyModuleJson5(caseNO, modulePath) { + const module_json5_path = FileUtil.pathResolve(modulePath, 'src', 'main', 'module.json5'); + const module_json5_content = FileUtil.readFileSync(module_json5_path).toString(); + const result = module_json5_content.replace('caseNO', caseNO); + FileUtil.writeFileSync(module_json5_path, result); +} + +function modifyMainPage(caseNO, modulePath) { + const mainPage_path = FileUtil.pathResolve(modulePath, 'src', 'main', 'ets', 'components', 'MainPage.ets'); + const mainPage_content = FileUtil.readFileSync(mainPage_path).toString(); + const result = mainPage_content.replace('${caseNO}', caseNO); + FileUtil.writeFileSync(mainPage_path, result); +} diff --git a/scripts/gitHooks.ts b/scripts/gitHooks.ts new file mode 100644 index 0000000000000000000000000000000000000000..c52d9071a917eadd02a196c67192fd1cfa20cf52 --- /dev/null +++ b/scripts/gitHooks.ts @@ -0,0 +1,22 @@ +import { OhosPluginId, OhosAppContext } from '@ohos/hvigor-ohos-plugin' +import { FileUtil, HvigorNode } from '@ohos/hvigor' +import * as child_process from 'child_process' +import * as os from 'os' + +/** + * gitHooks 任务实现 + * 执行git hooks命令 + */ +export function preCommit(node: HvigorNode) { + const platform = os.platform(); + const appContext: OhosAppContext = node.getContext(OhosPluginId.OHOS_APP_PLUGIN); + const hooksPath = FileUtil.pathResolve(appContext.getProjectPath(), 'hooks'); + let command = 'git config core.hooksPath ' + hooksPath; + if (platform === 'win32') { + child_process.execSync(command); + } else if (platform === 'darwin') { + command += ' && chmod 700 ' + hooksPath + '/*'; + child_process.execSync(command); + } +} +