Skip to content

Commit

Permalink
create gaiax for harmony project
Browse files Browse the repository at this point in the history
  • Loading branch information
biezhihua committed Sep 20, 2023
1 parent cebc3d3 commit 82b1f6e
Show file tree
Hide file tree
Showing 48 changed files with 774 additions and 0 deletions.
11 changes: 11 additions & 0 deletions GaiaXHarmony/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test
10 changes: 10 additions & 0 deletions GaiaXHarmony/AppScope/app.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"app": {
"bundleName": "com.alibaba.gaiax.demo",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}
8 changes: 8 additions & 0 deletions GaiaXHarmony/AppScope/resources/base/element/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "GaiaXDemo"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions GaiaXHarmony/GaiaX/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
1 change: 1 addition & 0 deletions GaiaXHarmony/GaiaX/Index.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { gaiax } from "./src/main/ets/utils/GaiaX"
11 changes: 11 additions & 0 deletions GaiaXHarmony/GaiaX/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"apiType": "stageMode",
"buildOption": {
},
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
}
]
}
6 changes: 6 additions & 0 deletions GaiaXHarmony/GaiaX/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { hspTasks } from '@ohos/hvigor-ohos-plugin';

export default {
system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}
10 changes: 10 additions & 0 deletions GaiaXHarmony/GaiaX/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "gaiax",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
}
}
17 changes: 17 additions & 0 deletions GaiaXHarmony/GaiaX/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@Entry
@Component
struct Index {
@State message: string = 'Hello World'

build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
3 changes: 3 additions & 0 deletions GaiaXHarmony/GaiaX/src/main/ets/utils/GaiaX.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function gaiax(a:number, b:number) {
return a + b;
}
13 changes: 13 additions & 0 deletions GaiaXHarmony/GaiaX/src/main/module.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"module": {
"name": "GaiaX",
"type": "shared",
"description": "$string:shared_desc",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages"
}
}
8 changes: 8 additions & 0 deletions GaiaXHarmony/GaiaX/src/main/resources/base/element/color.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "shared_desc",
"value": "description"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"src": [
"pages/Index"
]
}
6 changes: 6 additions & 0 deletions GaiaXHarmony/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
14 changes: 14 additions & 0 deletions GaiaXHarmony/app/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"apiType": "stageMode",
"buildOption": {
},
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}
6 changes: 6 additions & 0 deletions GaiaXHarmony/app/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -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. */
}
12 changes: 12 additions & 0 deletions GaiaXHarmony/app/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"license": "",
"devDependencies": {},
"author": "",
"name": "app",
"description": "Please describe the basic information.",
"main": "",
"version": "1.0.0",
"dependencies": {
"gaiax": "file:../GaiaX"
}
}
43 changes: 43 additions & 0 deletions GaiaXHarmony/app/src/main/ets/appability/AppAbility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import hilog from '@ohos.hilog';
import UIAbility from '@ohos.app.ability.UIAbility';
import Want from '@ohos.app.ability.Want';
import window from '@ohos.window';

export default class AppAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
}

onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}

onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');

windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}

onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}

onForeground() {
// Ability has brought to foreground
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}

onBackground() {
// Ability has back to background
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
}
19 changes: 19 additions & 0 deletions GaiaXHarmony/app/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { gaiax } from 'gaiax'

@Entry
@Component
struct Index {
@State message: string = 'Hello GaiaX Demo '

build() {
Row() {
Column() {
Text(this.message + gaiax(1, 1))
.fontSize(28)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
37 changes: 37 additions & 0 deletions GaiaXHarmony/app/src/main/module.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"module": {
"name": "app",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "AppAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "AppAbility",
"srcEntry": "./ets/appability/AppAbility.ts",
"description": "$string:AppAbility_desc",
"icon": "$media:icon",
"label": "$string:AppAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
8 changes: 8 additions & 0 deletions GaiaXHarmony/app/src/main/resources/base/element/color.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
16 changes: 16 additions & 0 deletions GaiaXHarmony/app/src/main/resources/base/element/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "AppAbility_desc",
"value": "description"
},
{
"name": "AppAbility_label",
"value": "label"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"src": [
"pages/Index"
]
}
16 changes: 16 additions & 0 deletions GaiaXHarmony/app/src/main/resources/en_US/element/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "AppAbility_desc",
"value": "description"
},
{
"name": "AppAbility_label",
"value": "GaiaXDemo"
}
]
}
16 changes: 16 additions & 0 deletions GaiaXHarmony/app/src/main/resources/zh_CN/element/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "AppAbility_desc",
"value": "description"
},
{
"name": "AppAbility_label",
"value": "GaiaXDemo"
}
]
}
35 changes: 35 additions & 0 deletions GaiaXHarmony/app/src/ohosTest/ets/test/Ability.test.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'

export default function abilityTest() {
describe('ActsAbilityTest', function () {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(function () {
// 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(function () {
// 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(function () {
// 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(function () {
// 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, function () {
// 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)
})
})
}
Loading

0 comments on commit 82b1f6e

Please sign in to comment.