From b1da15d047e868a019e8c21a1b2debc651274146 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 28 Apr 2024 19:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3,=E8=A1=A5?= =?UTF-8?q?=E5=85=85flutter=E6=8F=92=E4=BB=B6=E9=A1=B9=E7=9B=AE=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E6=AD=A5=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- ohos/docs/09_specifications/README.md | 3 +- ...56\345\275\225\347\273\223\346\236\204.md" | 20 +++ .../update_flutter_plugin_structure.md | 120 ++++++++++++++++++ 3 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 "ohos/docs/09_specifications/flutter\351\270\277\350\222\231\345\214\226\345\267\245\347\250\213\347\232\204\347\233\256\345\275\225\347\273\223\346\236\204.md" create mode 100644 ohos/docs/09_specifications/update_flutter_plugin_structure.md diff --git a/ohos/docs/09_specifications/README.md b/ohos/docs/09_specifications/README.md index f4587574..cfafa53e 100644 --- a/ohos/docs/09_specifications/README.md +++ b/ohos/docs/09_specifications/README.md @@ -1,3 +1,4 @@ # 规格说明 - \ No newline at end of file +1. [flutter鸿蒙化工程的目录结构](./flutter鸿蒙化工程的目录结构.md) +2. [update_flutter_plugin_structure](./update_flutter_plugin_structure.md) diff --git "a/ohos/docs/09_specifications/flutter\351\270\277\350\222\231\345\214\226\345\267\245\347\250\213\347\232\204\347\233\256\345\275\225\347\273\223\346\236\204.md" "b/ohos/docs/09_specifications/flutter\351\270\277\350\222\231\345\214\226\345\267\245\347\250\213\347\232\204\347\233\256\345\275\225\347\273\223\346\236\204.md" new file mode 100644 index 00000000..0ec39627 --- /dev/null +++ "b/ohos/docs/09_specifications/flutter\351\270\277\350\222\231\345\214\226\345\267\245\347\250\213\347\232\204\347\233\256\345\275\225\347\273\223\346\236\204.md" @@ -0,0 +1,20 @@ +# flutter鸿蒙化工程的目录结构 + +## flutter鸿蒙化工程关键文件 + +1. 配置文件 + 1. ohos/AppScope/app.json5, project配置文件, 应用的全局配置信息,包含应用的包名、开发厂商、版本号等基本信息。 + 2. ohos/build-profile.json5, project配置文件 + 3. ohos/oh-package.json5, project配置文件 + 4. ohos/entry/build-profile.json5, module配置文件 + 5. ohos/entry/oh-package.json5, module配置文件 + 6. ohos/entry/src/main/module.json5, module配置文件, Module的基本配置信息,例如Module名称、类型、描述、支持的设备类型等基本信息。 +2. 代码文件 + 1. ohos/entry/src/main/entryability/EntryAbility.ets, 应用入口文件 + 2. ohos/entry/src/main/pages/Index.ets, 应用加载的第一个页面 + +## 已过时,可删除的目录或文件 + +1. ohos/har/har_product/* , 直接从 flutter_flutter 的模板中复制 +2. ohos/har/flutter_embedding.har , 替换为 ohos/har/flutter.har +3. ohos/dta/icudtl,dat , 直接从 flutter_flutter 的模板中复制 diff --git a/ohos/docs/09_specifications/update_flutter_plugin_structure.md b/ohos/docs/09_specifications/update_flutter_plugin_structure.md new file mode 100644 index 00000000..f71aa6e0 --- /dev/null +++ b/ohos/docs/09_specifications/update_flutter_plugin_structure.md @@ -0,0 +1,120 @@ +# 更新Flutter插件项目结构 + +flutter插件项目中的ohos目录,将从鸿蒙工程project结构,替换为鸿蒙工程module结构。 + +## 更新步骤 + +以 [flutter_flutter](https://gitee.com/openharmony-sig/flutter_flutter) 中的 integration_test 为例的更新步骤如下 + +### 1. integration_test/ohos 目录由 project 结构修改为 module 结构 + +```sh +cd flutter_flutter/packages/integration_test +mv ohos/ohos ./ohos2 +rm -rf ohos +mv ohos2 ohos +cd example +flutter pub get +flutter build hap --local-engine=$ENGINE_DEBUG --debug +``` + +执行`flutter run`后会出现报错,需要修改配置文件中的name字段,还需要修改 hvigorfile.ts。 + +### 2.1 修改 integration_test/ohos/oh-package.json5 + +修改前: + +```json +{ + "name": "ohos", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.11" + } +} +``` + +修改后: + +```json +{ + "name": "integration_test", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@ohos/flutter_ohos": "file:har/flutter.har", + } +} +``` + +### 2.2 修改 integration_test/ohos/src/main/module.json5 + +修改前: + +```json +{ + "module": { + "name": "ohos", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} +``` + +修改后: + +```json +{ + "module": { + "name": "integration_test", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} +``` + +### 2.3 修改 integration_test/ohos/hvigorfile.ts + +修改前: + +```json +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. */ +} +``` + +修改后: + +```json +export { harTasks } from '@ohos/hvigor-ohos-plugin'; +``` + +### 检查是否可以正常运行 + +1. 使用 DevEco-Studio 打开 integration_test/example, 配置签名 +2. 使用命令运行example + +``` +cd integration_test/example +flutter run -d $DEVICE --local-engine=$ENGINE_DEBUG --debug +``` -- Gitee