Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ohos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
/.previewer
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test
**/BuildProfile.ets
**/oh-package-lock.json5
/package.json
/package-lock.json

**/src/main/resources/rawfile/flutter_assets/
**/libs/**/libapp.so
**/libs/**/libflutter.so
**/libs/**/libvmservice_snapshot.so
**/libs/**/libtdjson.so
10 changes: 10 additions & 0 deletions ohos/AppScope/app.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"app": {
"bundleName": "ad.neko.mithka",
"vendor": "mithka",
"versionCode": 295,
"versionName": "1.8.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}
8 changes: 8 additions & 0 deletions ohos/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": "Mithka"
}
]
}
Binary file added ohos/AppScope/resources/base/media/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions ohos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Mithka HarmonyOS (ohos) 宿主工程

mithka 的 HarmonyOS NEXT 宿主工程,由鸿蒙 Flutter fork 的 `flutter create --platforms ohos` 生成并定制。Dart 侧构建由 `flutter build hap` 驱动,本目录只包含工程结构与应用配置。

## 环境要求

- 鸿蒙 Flutter fork(openharmony-sig/flutter_flutter)3.44.9+ohos 及以上,需在 PATH 中
- DevEco Studio command-line-tools,SDK API 26 及以上(`DEVECO_SDK_HOME` 指向其 sdk 目录)——这是未打补丁的引擎 embedding 所需的 SDK;CI 使用已验证的 API 22 镜像与受控的 embedding HAR 兼容补丁(见 .github/workflows/release.yml 的 `Patch the engine embedding HAR` 步骤)作为同一可支持组合,本地无需补丁时请升级至 API 26
- hvigor / ohpm / node(command-line-tools 自带,加入 PATH)

版本低于要求时的典型症状:hvigor 编译 ArkTS 报 `Namespace 'autoFillManager' has no exported member 'AutoFillType'`——这是引擎 embedding 依赖 API 26 类型,升级 command-line-tools 至 API 26 即可;CI 的 API 22 路径通过 pinned 的 embedding HAR 补丁(本地类型别名 + 仅在 API 26 以下 early-return 的辅助)使同一源码在 API 22 SDK 上可编译,行为保持一致。

## 构建

```sh
# 1. 安装 TDLib 原生库(每次检出后一次;从未签名,产物为 unsigned HAP)
./scripts/build-hap.sh

# 2. 构建 HAP
flutter build hap --target-platform ohos-arm64 --release
```

产物路径:`ohos/entry/build/default/outputs/default/entry-default-signed.hap`(未配置签名时为 unsigned 产物,CI 直接使用)。

首次构建前 flutter 工具会在 `ohos/` 下自动生成 `package.json`、`node_modules/`、`oh_modules/` 等本地文件,均已被 .gitignore 忽略。

## 目录说明

- `AppScope/`:应用级配置(bundleName、版本、图标、名称)
- `entry/`:入口 HAP 模块;`entry/libs/arm64-v8a/` 是 tdjson 安装目标
- `hvigorfile.ts` / `hvigor/` / `build-profile.json5`:hvigor 构建配置
39 changes: 39 additions & 0 deletions ohos/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

{
"app": {
"signingConfigs": [],
"products": [
{
"name": "default",
"signingConfig": "default",
"compatibleSdkVersion": "5.1.0(18)",
"runtimeOS": "HarmonyOS",
}
],
"buildModeSet": [
{
"name": "debug"
},
{
"name": "profile"
},
{
"name": "release"
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
7 changes: 7 additions & 0 deletions ohos/entry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
GeneratedPluginRegistrant.ets
15 changes: 15 additions & 0 deletions ohos/entry/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

{
"apiType": 'stageMode',
"buildOption": {
},
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}
7 changes: 7 additions & 0 deletions ohos/entry/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
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. */
}
11 changes: 11 additions & 0 deletions ohos/entry/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

{
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {},
}

10 changes: 10 additions & 0 deletions ohos/entry/src/main/ets/entryability/EntryAbility.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import { FlutterAbility, FlutterEngine } from '@ohos/flutter_ohos';
import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant';

export default class EntryAbility extends FlutterAbility {
configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
GeneratedPluginRegistrant.registerWith(flutterEngine)
}
}
24 changes: 24 additions & 0 deletions ohos/entry/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

import common from '@ohos.app.ability.common';
import { FlutterPage } from '@ohos/flutter_ohos'

let storage = LocalStorage.getShared()
const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS'

@Entry(storage)
@Component
struct Index {
private context = getContext(this) as common.UIAbilityContext
@LocalStorageLink('viewId') viewId: string = "";

build() {
Column() {
FlutterPage({ viewId: this.viewId })
}
}

onBackPress(): boolean {
this.context.eventHub.emit(EVENT_BACK_PRESS)
return true
}
}
63 changes: 63 additions & 0 deletions ohos/entry/src/main/module.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
},
{
// External deep links: the tg scheme (tg://resolve?domain=…)
// plus the https universal-link host, the same pair Android
// declares. Without these skills the ability can never be a
// launch target for a link and app_links sees nothing to deliver.
"entities": [
"entity.system.browsable"
],
"actions": [
"ohos.want.action.viewData"
],
"uris": [
{
"scheme": "tg"
},
{
"scheme": "https",
"host": "t.me"
}
]
}
]
}
],
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
}
]
}
}
8 changes: 8 additions & 0 deletions ohos/entry/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 ohos/entry/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": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "Mithka"
}
]
}
Binary file added ohos/entry/src/main/resources/base/media/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ohos/entry/src/main/resources/base/profile/main_pages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"src": [
"pages/Index"
]
}
16 changes: 16 additions & 0 deletions ohos/entry/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": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "Mithka"
}
]
}
16 changes: 16 additions & 0 deletions ohos/entry/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": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "Mithka"
}
]
}
35 changes: 35 additions & 0 deletions ohos/entry/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', () => {
// 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);
})
})
}
5 changes: 5 additions & 0 deletions ohos/entry/src/ohosTest/ets/test/List.test.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import abilityTest from './Ability.test'

export default function testsuite() {
abilityTest();
}
Loading
Loading