# template_lite **Repository Path**: flu-cli/template_lite ## Basic Information - **Project Name**: template_lite - **Description**: flu-cli Lite 模板 - 轻量级 MVVM 架构 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-17 - **Last Updated**: 2026-01-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Flu Template Lite 轻量级 Flutter MVVM 项目模板,适合快速原型和小型项目。 ## 🚀 快速开始 ### 方式一:VSCode 插件(推荐) 1. 安装 [Flu Helper](https://marketplace.visualstudio.com/items?itemName=psvmc.flu-helper) 插件 2. 按 `Cmd+Shift+P`(Mac)或 `Ctrl+Shift+P`(Windows) 3. 输入 `Flu: New Project` 4. 按提示选择模板和配置 ### 方式二:命令行工具 ```bash # 安装 flu-cli npm install -g flu-cli # 创建项目 flu-cli new my_app -t lite cd my_app flutter run ``` ### 方式三:直接克隆模板 ```bash # 1. 克隆 git clone https://gitee.com/psvmc/template-lite.git my_app cd my_app # 2. 初始化(可选,添加网络层等功能) dart scripts/init.dart # 3. 运行 flutter pub get flutter run ``` ## 📦 项目结构 ``` lib/ ├── core/ # 基础设施层 │ ├── base/ # MVVM 基础组件 │ ├── router/ # 路由 │ └── theme/ # 主题 ├── pages/ # 页面 ├── viewmodels/ # 视图模型 ├── services/ # 服务层 ├── models/ # 数据模型 ├── widgets/ # 通用组件 └── main.dart # 入口 ``` ## 🔧 可选功能 运行 `dart scripts/init.dart` 可添加: - ✅ **网络请求层**(HttpUtil + Dio) - ✅ **本地存储**(StorageUtil + SharedPreferences) - ✅ **应用配置**(AppConfig + 首次启动判断) ### 初始化后的结构 ``` lib/core/ ├── base/ # MVVM 基础(默认) ├── router/ # 路由(默认) ├── theme/ # 主题(默认) ├── config/ # 应用配置(init 后添加) ├── storage/ # 本地存储(init 后添加) └── network/ # 网络请求(init 后添加) ``` ## 📖 使用示例 ### 基础页面 ```dart class HomePage extends BasePage { const HomePage({super.key}); @override State createState() => _HomePageState(); } class _HomePageState extends BasePageState { @override HomeViewModel createViewModel() => HomeViewModel(); @override String get title => '首页'; @override Widget buildContent(BuildContext context) { return Center( child: Text('Hello, ${viewModel.userName}'), ); } } ``` ### 列表页面 ```dart class UserListPage extends BaseListPage { const UserListPage({super.key}); @override State createState() => _UserListPageState(); } class _UserListPageState extends BaseListPageState { @override UserListViewModel createViewModel() => UserListViewModel(); @override String get title => '用户列表'; @override Widget buildItem(BuildContext context, User item, int index) { return ListTile( title: Text(item.name), subtitle: Text(item.email), ); } } ``` ### 网络请求(需先运行 init.dart) ```dart class UserService { final _http = HttpUtil(); Future getUser(String id) async { final data = await _http.get('/users/$id'); return User.fromJson(data); } } ``` ## 📚 文档 - [完整文档](https://psvmc.gitee.io/flu-cli) - [flu-cli 使用指南](https://psvmc.gitee.io/flu-cli/guide/getting-started) - [VSCode 插件使用](https://psvmc.gitee.io/flu-cli/guide/vscode-extension) ## 📄 License MIT