docs: harness 文档对齐新架构,忽略签名材料
This commit is contained in:
39
AGENTS.md
39
AGENTS.md
@@ -13,8 +13,9 @@ HarmonyOS NEXT app. ArkTS + ArkUI declarative UI, hvigor build, DevEco Studio.
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
单 HAP 模块应用(`entry/`)。页面在 `main_pages.json` 注册;`EntryAbility` 是应用入口 Ability。
|
||||
Single-HAP module (`entry/`). Pages registered in `main_pages.json`; `EntryAbility` is the app entry.
|
||||
单 HAP + 多 HAR 模块化应用:`entry/`(HAP,应用壳 + 业务)、`common/`(HAR,基础设施)、`uikit/`(HAR,通用 UI)。
|
||||
Single-HAP + multi-HAR: `entry/` (HAP shell + business), `common/` (HAR infra), `uikit/` (HAR shared UI).
|
||||
状态管理全量 StateManagement V2(`@ComponentV2/@Local/@Param/@Event/@ObservedV2/@Trace`);导航用 `Navigation` + `NavPathStack`。
|
||||
详见 `docs/architecture.md`。
|
||||
|
||||
## Directory Structure
|
||||
@@ -22,19 +23,27 @@ Single-HAP module (`entry/`). Pages registered in `main_pages.json`; `EntryAbili
|
||||
```
|
||||
harmony-client/
|
||||
├── AppScope/ # 应用级配置(bundleName、应用图标/标签)
|
||||
├── entry/ # 主模块(单 HAP)
|
||||
├── entry/ # HAP 应用壳 + 业务(唯一入口)
|
||||
│ └── src/
|
||||
│ ├── main/
|
||||
│ │ ├── ets/ # ArkTS 源码
|
||||
│ │ │ ├── entryability/ # 应用入口 Ability
|
||||
│ │ ├── ets/
|
||||
│ │ │ ├── entryability/ # 应用入口 Ability(依赖装配)
|
||||
│ │ │ ├── entrybackupability/ # 备份扩展 Ability
|
||||
│ │ │ └── pages/ # 页面(@Entry 组件)
|
||||
│ │ ├── resources/ # 资源(字符串/颜色/媒体,用 $r() 引用)
|
||||
│ │ │ ├── router/ # 路由(AppRouter + RouteMap)
|
||||
│ │ │ ├── di/ # 依赖注入(ServiceLocator)
|
||||
│ │ │ ├── model/ # 领域模型(@ObservedV2 + @Trace)
|
||||
│ │ │ ├── data/ # 数据层(api / repository)
|
||||
│ │ │ ├── viewmodel/ # 视图模型(@ObservedV2 三态)
|
||||
│ │ │ ├── view/ # 业务复用组件
|
||||
│ │ │ └── pages/ # 页面(@Entry @ComponentV2,仅编排)
|
||||
│ │ ├── resources/ # 资源(字符串/媒体,用 $r() 引用)
|
||||
│ │ └── module.json5 # 模块清单(Ability 声明、权限)
|
||||
│ ├── test/ # 本地单元测试(hypium)
|
||||
│ ├── ohosTest/ # 设备集成测试(hypium)
|
||||
│ └── mock/ # mock 配置
|
||||
├── build-profile.json5 # 构建/签名/产品配置
|
||||
├── common/ # HAR 基础设施(网络/日志/状态/工具)
|
||||
├── uikit/ # HAR 通用 UI 组件库 + 主题 token
|
||||
├── build-profile.json5 # 构建/签名/产品/模块配置
|
||||
├── code-linter.json5 # 代码规范(TS ESLint + 安全/性能规则)
|
||||
├── hvigorfile.ts # hvigor 构建入口
|
||||
├── oh-package.json5 # 依赖声明(hypium / hamock)
|
||||
@@ -48,10 +57,10 @@ harmony-client/
|
||||
2. **声明式 UI Declarative UI** — 用状态驱动渲染,禁止命令式直接改 UI。
|
||||
Drive UI via state; never mutate UI imperatively.
|
||||
3. **命名 Naming** — 组件/Ability `PascalCase`(文件 `.ets`);变量/函数/属性 `camelCase`;常量 `UPPER_SNAKE_CASE`。
|
||||
4. **资源 Resources** — 字符串/颜色/媒体一律 `$r('app.xxx')`,禁止硬编码。
|
||||
All strings/colors/media via `$r('app.xxx')`; no hardcoding.
|
||||
5. **分层 Layering** — 页面只做 UI;业务逻辑放 `service/`,数据模型放 `model/`,复用组件放 `components/`。
|
||||
Pages = UI only; logic → `service/`, models → `model/`, reusable components → `components/`.
|
||||
4. **资源 Resources** — 颜色/间距/字号走 `uikit/theme/Theme.ets` 的 token;用户可见文案优先 `$r('app.string.xxx')`;媒体 `$r('app.media.xxx')`。禁止组件内散落魔法值。
|
||||
Colors/spacing/fonts via `uikit/theme/Theme.ets` tokens; copy via `$r('app.string.xxx')`; media via `$r('app.media.xxx')`. No scattered magic values.
|
||||
5. **分层 Layering** — 页面只编排;业务逻辑放 `viewmodel/`,数据放 `data/`(repository/api),模型放 `model/`,复用组件放 `view/`(通用下沉 `uikit/`)。
|
||||
Pages orchestrate only; logic → `viewmodel/`, data → `data/`, models → `model/`, reusable components → `view/` (shared → `uikit/`).
|
||||
6. **安全 Security** — 遵守 `code-linter.json5` 的 `@security/*` 规则(禁用不安全哈希/AES 等)。
|
||||
7. **改后必验证 Verify after change** — 每次改动跑 lint + 相关测试,见 `docs/testing.md`。
|
||||
|
||||
@@ -66,9 +75,9 @@ harmony-client/
|
||||
|
||||
## Common Tasks
|
||||
|
||||
- 加页面 Add a page → `entry/src/main/ets/pages/` + 在 `main_pages.json` 注册
|
||||
- 加复用组件 Reusable component → `entry/src/main/ets/components/`
|
||||
- 写业务逻辑 Business logic → `entry/src/main/ets/service/`
|
||||
- 加页面 Add a page → `entry/src/main/ets/pages/`(Navigation 路由则加 `router/RouteMap.ets`)
|
||||
- 加复用组件 Reusable component → `entry/src/main/ets/view/`(跨模块通用 → `uikit/src/main/ets/components/`)
|
||||
- 写业务逻辑 Business logic → `entry/src/main/ets/viewmodel/` + `entry/src/main/ets/data/`
|
||||
- 加数据模型 Data model → `entry/src/main/ets/model/`
|
||||
- 跑单测 Run tests → `docs/testing.md`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user