commit b16fc67aa9d77bac2bcdf78de3344fc0e88a4a82 Author: JackLee <809262979@qq.com> Date: Fri Feb 13 23:31:20 2026 +0800 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d2ff2014 --- /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 00000000..a94925a7 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.opencax", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "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 00000000..f79c7b24 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "OpenCAX" + } + ] +} diff --git a/AppScope/resources/base/media/background.png b/AppScope/resources/base/media/background.png new file mode 100644 index 00000000..923f2b3f Binary files /dev/null and b/AppScope/resources/base/media/background.png differ diff --git a/AppScope/resources/base/media/foreground.png b/AppScope/resources/base/media/foreground.png new file mode 100644 index 00000000..eb942758 Binary files /dev/null and b/AppScope/resources/base/media/foreground.png differ diff --git a/AppScope/resources/base/media/layered_image.json b/AppScope/resources/base/media/layered_image.json new file mode 100644 index 00000000..fb499204 --- /dev/null +++ b/AppScope/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/build-profile.json5 b/build-profile.json5 new file mode 100644 index 00000000..2c0b056d --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,43 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "6.0.2(22)", + "compatibleSdkVersion": "6.0.2(22)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "nativeCompiler": "BiSheng", + "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 00000000..073990fa --- /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": "warn", + "@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/entry/.gitignore b/entry/.gitignore new file mode 100644 index 00000000..e2713a27 --- /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 00000000..1f1e4af6 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,48 @@ +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + }, + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "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 00000000..b0e3a1ab --- /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. */ +} \ No newline at end of file diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 00000000..1e7e54e1 --- /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/source-obfuscation + +# 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-lock.json5 b/entry/oh-package-lock.json5 new file mode 100644 index 00000000..7c36300c --- /dev/null +++ b/entry/oh-package-lock.json5 @@ -0,0 +1,19 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry" + }, + "packages": { + "libentry.so@src/main/cpp/types/libentry": { + "name": "libentry.so", + "version": "1.0.0", + "resolved": "src/main/cpp/types/libentry", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 00000000..54cb0662 --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/entry/src/main/cpp/CMakeLists.txt b/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 00000000..97c40974 --- /dev/null +++ b/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,15 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(OpenCAX) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/entry/src/main/cpp/napi_init.cpp b/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 00000000..987bd48b --- /dev/null +++ b/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,53 @@ +#include "napi/native_api.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; + +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/entry/src/main/cpp/types/libentry/Index.d.ts b/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 00000000..e44f3615 --- /dev/null +++ b/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1 @@ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/entry/src/main/cpp/types/libentry/oh-package.json5 b/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 00000000..ea410725 --- /dev/null +++ b/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ 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 00000000..091797f5 --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,48 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err)); + } + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 00000000..8e4de992 --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ 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 00000000..e8c6f982 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,33 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; +import { edgeColors } from '@kit.ArkUI'; +import {TitleTab} from './titleTab' +import {LeftSideTab} from './leftSideTab' + +const DOMAIN = 0x0000; + +@Entry +@Component +struct Index { + build() { + //OpenCAX主界面整体布局,采用多行布局 + Flex({ direction: FlexDirection.Column }) { + //头部导航功能区 + TitleTab().height('auto').borderWidth('1') + Row() { + //左侧边导航区 + LeftSideTab().borderWidth('1').width('20%'); + //中间操作区域 + Row() { + Text('操作区') + Blank().height('100%').width('100%') + }.width('80%') + .height('100%') + .borderWidth('1') + }.height('80%') + Column(){ + Text('状态栏').height('100%').width('100%') + }.height('5%').borderWidth('1') + } + } +} diff --git a/entry/src/main/ets/pages/btnRowTab.ets b/entry/src/main/ets/pages/btnRowTab.ets new file mode 100644 index 00000000..6609eb32 --- /dev/null +++ b/entry/src/main/ets/pages/btnRowTab.ets @@ -0,0 +1,79 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; + +export class ToolButton{ + //功能 + str:string=''; + //图标 + icon:string=''; + //按钮提示 + tips:string=''; + //事件 + event:string=''; +} + +@ComponentV2 +export struct BtnRowTab { + @Param rowsBtn: Array>>=new Array>>; + @Param rightBtn:Array>=new Array>; + @Builder + ToolsMenu(menus:Array) { + Menu() { + ForEach(menus,(item:ToolButton, index: number)=>{ + MenuItem({ startIcon: $r('app.media.startIcon'), content: item.str }) + .width('150') + .margin({ top: 2,left:2,bottom:2,right:2}) + }) + } + } + @Builder + TButton(strIcon:string,strName:string){ + Column(){ + // 请将$r('app.media.loading')替换为实际资源文件 + Image($r('app.media.startIcon')) + .width(50) + .height(40) + .objectFit(ImageFit.Contain) + Text(strName) + .fontSize(12) + .width(50) + .height(10) + .textAlign(TextAlign.Center) + } + .height('50') + .width('50') + .padding('1') + } + build() { + Column({space: 5}){ + ForEach(this.rowsBtn,(rowBtn:Array>, index: number)=>{ + Row({ space: 2 }) { + ForEach(rowBtn,(btn:ToolButton|Array, index: number)=>{ + if (Array.isArray(btn)) { + if(( btn as Array).length>0){ + Button(( btn as Array)[0].str) + .bindMenu(this.ToolsMenu(( btn as Array))) + .height('50') + .width('50') + .padding('1') + //.type(ButtonType.Normal) + } + }else{ + this.TButton((btn as ToolButton).icon,(btn as ToolButton).str); + } + }) + } + }) + }.margin({ top: 2,left:2,bottom:2,right:2}) + .padding('1') + .onMouse((event: MouseEvent) => { + if (event) { + // 鼠标右键菜单事件 + switch (event.button) { + case MouseButton.Right: + + break; + } + } + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/footStateTab.ets b/entry/src/main/ets/pages/footStateTab.ets new file mode 100644 index 00000000..e69de29b diff --git a/entry/src/main/ets/pages/leftSideTab.ets b/entry/src/main/ets/pages/leftSideTab.ets new file mode 100644 index 00000000..f95673db --- /dev/null +++ b/entry/src/main/ets/pages/leftSideTab.ets @@ -0,0 +1,60 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; + + +interface LeftSideTabName { + //标签名 + str: string; + //图标名 + ico: string; + //页面名 + page:string; +} + +@Component +export struct LeftSideTab { + @State leftSideBarTabsName:Array=[ + {str:'建模树',ico:'',page:''}, + {str:'组装树',ico:'',page:''}, + ] + private leftSideBarTabs: TabsController = new TabsController(); + @State leftSideBarFocusIndex: number = 0; + build() { + Row() { + Scroll() { + Flex({ direction: FlexDirection.Column }) { + ForEach(this.leftSideBarTabsName, (item: LeftSideTabName, index: number) => { + Column({ space: 5 }) { + Button(item.str) + .fontWeight(index === this.leftSideBarFocusIndex ? FontWeight.Bold : FontWeight.Normal) + .height(50) + .width(50) + .padding(5) + .type(ButtonType.Normal) + } + .padding({ left: 5, right: 5 }) + .margin({ top: 2,left:2,bottom:2,right:2}) + .onClick(() => { + this.leftSideBarTabs.changeIndex(index); + this.leftSideBarFocusIndex = index; + }) + }) + Blank().height('80%') + } + } + .align(Alignment.Start) + .scrollable(ScrollDirection.Vertical) + .scrollBar(BarState.Off) + .width('30%') + + Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) { + ForEach(this.leftSideBarTabsName, (item: LeftSideTabName, index: number) => { + TabContent() { + Text(item.str) + .fontSize(30) + } + }) + }.barHeight(0) + .width('70%') + }.borderWidth('1') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/rightSideTab.ets b/entry/src/main/ets/pages/rightSideTab.ets new file mode 100644 index 00000000..e69de29b diff --git a/entry/src/main/ets/pages/titleTab.ets b/entry/src/main/ets/pages/titleTab.ets new file mode 100644 index 00000000..4d267498 --- /dev/null +++ b/entry/src/main/ets/pages/titleTab.ets @@ -0,0 +1,154 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { ArrayList } from '@kit.ArkTS'; +import { AddFormMenuItem } from '@ohos.arkui.advanced.FormMenu'; +import {ToolButton,BtnRowTab}from './btnRowTab' +import { SceneResourceType } from '@kit.ArkGraphics3D'; + +const DOMAIN = 0x0000; + +class TitleTabName { + //标题 + str: string=''; + //图标名 + icon: string=''; + //页面名 + page:string=''; + //提示 + tips:string=''; + //Content的内容 + rowsBtn:Array>>=new Array>>; +} + +//测试数据 +let testPagInfo:Array=[ + //第一个tab + {str:'文件',icon:'',page:'',tips:'',rowsBtn:[]}, + //第二个tab + {str:'主页',icon:'',page:'',tips:'',rowsBtn:[ + //第一行按钮组 + [ + //第一个按钮 + {str:'新建',icon:'',tips:'',event:''} as ToolButton, + {str:'打开',icon:'',tips:'',event:''} as ToolButton, + [ + {str:'功能',icon:'',tips:'',event:''} as ToolButton, + {str:'功能1',icon:'',tips:'',event:''} as ToolButton, + {str:'功能2',icon:'',tips:'',event:''} as ToolButton, + {str:'功能3',icon:'',tips:'',event:''} as ToolButton, + ] as Array, + {str:'设置',icon:'',tips:'',event:''} as ToolButton, + ] as Array, + //第二行按钮组 + [ + //第一个按钮 + {str:'首选',icon:'',tips:'',event:''} as ToolButton, + {str:'保存',icon:'',tips:'',event:''} as ToolButton, + [ + {str:'功能',icon:'',tips:'',event:''} as ToolButton, + {str:'功能1',icon:'',tips:'',event:''} as ToolButton, + {str:'功能2',icon:'',tips:'',event:''} as ToolButton, + {str:'功能3',icon:'',tips:'',event:''} as ToolButton, + ] as Array, + {str:'删除',icon:'',tips:'',event:''} as ToolButton, + ] as Array, + ]}, + {str:'曲线',icon:'',page:'',tips:'',rowsBtn:[ + [ + [ + {str:'文本',icon:'',tips:'',event:''} as ToolButton, + {str:'点',icon:'',tips:'',event:''} as ToolButton, + {str:'直线',icon:'',tips:'',event:''} as ToolButton, + {str:'圆弧/圆',icon:'',tips:'',event:''} as ToolButton, + ] as Array, + {str:'艺术样条',icon:'',tips:'',event:''} as ToolButton, + {str:'曲面上的曲线',icon:'',tips:'',event:''} as ToolButton, + {str:'脊线',icon:'',tips:'',event:''} as ToolButton, + {str:'投影曲线',icon:'',tips:'',event:''} as ToolButton, + {str:'组合投影',icon:'',tips:'',event:''} as ToolButton, + ], + [ + [ + {str:'曲线编辑',icon:'',tips:'',event:''} as ToolButton, + {str:'延申曲线',icon:'',tips:'',event:''} as ToolButton, + {str:'桥接',icon:'',tips:'',event:''} as ToolButton, + {str:'镜像曲线',icon:'',tips:'',event:''} as ToolButton, + ] as Array, + {str:'曲线编辑',icon:'',tips:'',event:''} as ToolButton, + {str:'延申曲线',icon:'',tips:'',event:''} as ToolButton, + {str:'桥接曲线',icon:'',tips:'',event:''} as ToolButton, + {str:'抛物线',icon:'',tips:'',event:''} as ToolButton, + {str:'镜像曲线',icon:'',tips:'',event:''} as ToolButton, + ] + ]}, + {str:'曲面',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'装配',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'多边建模',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'分析',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'选择',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'显示',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'工具',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'应用模块',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'设置',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'帮助',icon:'',page:'',tips:'',rowsBtn:[]}, + {str:'关于',icon:'',page:'',tips:'',rowsBtn:[]}, +] + +@Component +export struct TitleTab { + titleBarTabsName:Array=new Array; + //顶部导航组件 + private titleBarTabs: TabsController = new TabsController(); + //当前的顶部导航选择页 + @State titleBarFocusIndex: number = 0; + @State titleBarDefaultFocusIndex: number = 1; + LoadData(): void { + this.titleBarTabsName=testPagInfo; + } + aboutToAppear() { + this.LoadData(); + } + + build() { + Flex({ direction: FlexDirection.Column }){ + Scroll() { + Row() { + ForEach(this.titleBarTabsName, (item: TitleTabName, index: number) => { + Row({ space: 1 }) { + Button(item.str) + .fontWeight(index === this.titleBarFocusIndex ? FontWeight.Bold : FontWeight.Normal) + .height(25) + .width(60) + .padding(5) + .type(ButtonType.Normal) + }.onClick(() => { + if(index!=0){ + this.titleBarTabs.changeIndex(index); + this.titleBarFocusIndex = index; + }else{ + this.titleBarTabs.changeIndex(this.titleBarDefaultFocusIndex); + this.titleBarFocusIndex = this.titleBarDefaultFocusIndex; + } + }) + }) + } + } + .align(Alignment.Start) + .scrollable(ScrollDirection.Horizontal) + .scrollBar(BarState.Off) + .margin({ top: 2,left:2,bottom:2,right:2}) + .width('100%') + Tabs({barPosition: BarPosition.Start, index: this.titleBarDefaultFocusIndex,controller: this.titleBarTabs}){ + ForEach(this.titleBarTabsName,(item:TitleTabName, index: number)=>{ + TabContent() { + BtnRowTab({rowsBtn:item.rowsBtn}); + }.align(Alignment.Start) + .margin({ top: 2,left:2,bottom:2,right:2}) + }) + }.barHeight(0) + .margin({ top: 2,left:2,bottom:2,right:2}) + .height('auto') + .barMode(BarMode.Fixed) + }.borderWidth('1') + .height('auto') + } +} diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 00000000..de201a99 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "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": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 00000000..3c712962 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json new file mode 100644 index 00000000..33ea2230 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} 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 00000000..664db65c --- /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": "OpenCAX" + } + ] +} \ 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 00000000..923f2b3f 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 00000000..97014d3e Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.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 00000000..fb499204 --- /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 00000000..205ad8b5 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 00000000..78f40ae7 --- /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 00000000..1898d94f --- /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/dark/element/color.json b/entry/src/main/resources/dark/element/color.json new file mode 100644 index 00000000..79b11c27 --- /dev/null +++ b/entry/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/entry/src/mock/Libentry.mock.ets b/entry/src/mock/Libentry.mock.ets new file mode 100644 index 00000000..c2171716 --- /dev/null +++ b/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,7 @@ +const NativeMock: Record = { + 'add': (a: number, b: number) => { + return a + b; + }, +}; + +export default NativeMock; \ 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 00000000..6540976c --- /dev/null +++ b/entry/src/mock/mock-config.json5 @@ -0,0 +1,5 @@ +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ 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 00000000..85c78f67 --- /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 00000000..794c7dc4 --- /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 00000000..2cd102a2 --- /dev/null +++ b/entry/src/ohosTest/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "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 00000000..bb5b5c37 --- /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 00000000..165fc161 --- /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 00000000..fac94d0d --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,23 @@ +{ + "modelVersion": "6.0.2", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | 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 */ + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ + }, + "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 00000000..47113e2e --- /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. */ +} \ No newline at end of file diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 new file mode 100644 index 00000000..c5a91ec3 --- /dev/null +++ b/oh-package-lock.json5 @@ -0,0 +1,28 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "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.25": "@ohos/hypium@1.0.25" + }, + "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.25": { + "name": "@ohos/hypium", + "version": "1.0.25", + "integrity": "sha512-l6uO2pjl8HyEKdekLqQt7tUpWbDqX/42zoAzkagtUVZAW9jT6lMvbe54MVjoLxq/RwQGygRvi6j4GpypSMFSHw==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.25.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 00000000..c95806db --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "6.0.2", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.25", + "@ohos/hamock": "1.0.0" + } +}