51 lines
2.5 KiB
Markdown
51 lines
2.5 KiB
Markdown
```text
|
|
lib/
|
|
│
|
|
├─main.dart # 应用入口
|
|
│
|
|
├─core/ # 核心底层
|
|
│ ├─config/ # 全局配置 (Env, Global constants)
|
|
│ ├─domain/ # 业务实体 (纯净的业务对象,不含数据库/接口注解)
|
|
│ ├─network/ # 网络请求封装 (Dio, Interceptors)
|
|
│ ├─storage/ # 基础存储封装 (KV 存储如 SharedPreferences)
|
|
│ ├─theme/ # 主题管理 (Colors, TextStyles, ThemeMode)
|
|
│ ├─event/ # 全局事件总线 (EventBus)
|
|
│ └─utils/ # 工具类 (TimeFormat, Permission, System)
|
|
│
|
|
├─data/ # 数据中心 (核心改动区)
|
|
│ ├─api/ # 网络接口层
|
|
│ │ └─habit_api.dart # 具体接口定义
|
|
│ ├─models
|
|
│ │ └─habit_dto.dart # 后端返回的 DTO
|
|
│ ├─local/ # 本地存储层
|
|
│ │ ├─entity/ # 数据库实体 (Entity: 带 DB 注解的模型)
|
|
│ │ │ └─habit_entity.dart
|
|
│ │ ├─dao/ # 数据访问对象 (Query 逻辑)
|
|
│ │ │ └─habit_dao.dart
|
|
│ │ └─db_client.dart # 数据库初始化 (Isar/Drift/SQLite)
|
|
│ │
|
|
│ │ repository/ # 数据仓库 (UI 唯一的数据入口)
|
|
│ │ ├─habit_repo.dart # 定义接口
|
|
│ │ └─impl/ # 实现类:判断从 Api 还是 Local 获取数据
|
|
│ │─stores #全局状态管理
|
|
│ │ └─habit_dto.dart
|
|
│
|
|
├─pages/ # 业务页面 (按功能模块拆分)
|
|
│ ├─home/
|
|
│ ├─habit/ # 习惯模块
|
|
│ │ ├─list/ # 列表页
|
|
│ │ ├─edit/ # 编辑/创建页
|
|
│ │ │ ├─model/ # 页面专用状态模型 (非全局)
|
|
│ │ │ ├─widgets/ # 页面私有组件
|
|
│ │ │ ├─xxx_page.dart # View 层
|
|
│ │ │ └─xxx_vm.dart # ViewModel 层 (状态管理逻辑)
|
|
│ │ └─detail/ # 详情页
|
|
│ └─... # moments, task, my, system 等模块
|
|
│
|
|
├─router/ # 路由管理
|
|
│ ├─config/ # 路由路径定义
|
|
│ └─modules/ # 拆分的路由模块
|
|
│
|
|
└─widgets/ # 公用 UI 组件库 (Base/Common)
|
|
├─base/ # 原子组件 (Button, Cell, Dialog, Picker)
|
|
``` |