flu-cli-core 1.0.5 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/chunk-BGYZU6TU.js +466 -0
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/factory-LM2CTHPW.js +7 -0
- package/dist/factory-P6ABQFH3.js +7 -0
- package/dist/index.cjs +17766 -3244
- package/dist/index.d.cts +783 -99
- package/dist/index.d.ts +783 -99
- package/dist/index.js +17323 -2942
- package/dist/upgrade_snippets-BJ6CQY5Q.js +9 -0
- package/package.json +3 -3
- package/templates/README.md +12 -0
- package/templates/core_files/auth/auth_middleware.dart.template +33 -0
- package/templates/core_files/auth/auth_service.dart.template +22 -0
- package/templates/core_files/auth/auth_viewmodel_mixin.dart.template +9 -0
- package/templates/core_files/auth/index.dart.template +4 -0
- package/templates/core_files/base/base_service.dart.template +12 -0
- package/templates/core_files/base/index.dart.template +3 -0
- package/templates/core_files/config/agreement_document_page.dart.template +220 -0
- package/templates/core_files/config/app_agreement.dart.template +297 -0
- package/templates/core_files/config/app_config.dart.template +81 -22
- package/templates/core_files/config/app_env.dart.template +107 -0
- package/templates/core_files/config/app_initializer.dart.template +16 -23
- package/templates/core_files/config/index.dart.template +4 -1
- package/templates/core_files/config/privacy_dialog.dart.template +158 -0
- package/templates/core_files/index.dart.template +3 -0
- package/templates/core_files/mixins/page/keep_alive_mixin.dart.template +6 -0
- package/templates/core_files/mixins/page/scroll_controller_mixin.dart.template +7 -0
- package/templates/core_files/mixins/service/request_guard_mixin.dart.template +18 -0
- package/templates/core_files/mixins/viewmodel/debounce_mixin.dart.template +18 -0
- package/templates/core_files/network/app_http.dart.template +19 -4
- package/templates/core_files/network/index.dart.template +4 -0
- package/templates/core_files/network/interceptors/global_params_interceptor.dart.template +77 -0
- package/templates/core_files/network/interceptors/index.dart.template +3 -0
- package/templates/core_files/network/network_monitor.dart.template +18 -0
- package/templates/core_files/network/response_adapter.dart.template +8 -19
- package/templates/core_files/router/app_routes.dart.template +3 -6
- package/templates/core_files/storage/storage_keys.dart.template +6 -0
- package/templates/core_files/theme/app_color_config.dart.template +32 -0
- package/templates/core_files/theme/app_text_size_config.dart.template +22 -0
- package/templates/core_files/theme/app_text_style_config.dart.template +139 -0
- package/templates/core_files/theme/app_theme.dart.template +72 -12
- package/templates/core_files/theme/index.dart.template +3 -0
- package/templates/core_files/utils/loading_util.dart.template +1 -1
- package/templates/examples/eg_list_page.dart.template +1 -2
- package/templates/examples/eg_service.dart.template +27 -4
- package/templates/examples/home_feed_service.dart.template +37 -0
- package/templates/helper_examples/image_picker_example_page.dart.template +289 -0
- package/templates/helper_examples/index.dart.template +4 -0
- package/templates/helper_examples/payment_shell_example_page.dart.template +67 -0
- package/templates/helper_examples/permission_example_page.dart.template +365 -0
- package/templates/helper_examples/webview_example_page.dart.template +44 -0
- package/templates/helpers/image_picker/README.md.template +30 -0
- package/templates/helpers/image_picker/index.dart.template +73 -0
- package/templates/helpers/payment/README.md.template +29 -0
- package/templates/helpers/payment/index.dart.template +66 -0
- package/templates/helpers/permission/README.md.template +30 -0
- package/templates/helpers/permission/index.dart.template +67 -0
- package/templates/helpers/webview/README.md.template +29 -0
- package/templates/helpers/webview/index.dart.template +88 -0
- package/templates/starter_project/.env.dev.template +14 -0
- package/templates/starter_project/.env.prod.example.template +14 -0
- package/templates/starter_project/.env.staging.template +14 -0
- package/templates/starter_project/.vscode/launch.json.template +54 -0
- package/templates/starter_project/.vscode/settings.json.template +14 -0
- package/templates/starter_project/DEVELOPER_GUIDE.md.template +169 -0
- package/templates/starter_project/README.md.template +117 -0
- package/templates/starter_project/analysis_options.yaml.template +28 -0
- package/templates/starter_project/lib/app.dart.template +22 -0
- package/templates/starter_project/lib/main.dart.template +34 -0
- package/templates/starter_project/lib/pages/splash_page.dart.template +154 -0
- package/templates/template_clean/lib/features/home/data/datasources/index.dart +1 -0
- package/templates/template_clean/lib/features/home/data/models/index.dart +1 -0
- package/templates/template_clean/lib/features/home/domain/index.dart +1 -0
- package/templates/template_clean/lib/features/home/presentation/pages/home_page.dart +290 -0
- package/templates/template_clean/lib/features/home/presentation/pages/index.dart +2 -0
- package/templates/template_clean/lib/features/home/presentation/pages/splash_page.dart +154 -0
- package/templates/template_clean/lib/features/home/presentation/viewmodels/home_viewmodel.dart +17 -0
- package/templates/template_clean/lib/features/index.dart +2 -0
- package/templates/template_clean/lib/features/user/data/datasources/home_feed_service.dart +37 -0
- package/templates/template_clean/lib/features/user/data/datasources/index.dart +4 -0
- package/templates/template_clean/lib/features/user/data/models/index.dart +3 -0
- package/templates/template_clean/lib/features/user/data/models/user.dart +15 -0
- package/templates/template_clean/lib/features/user/domain/index.dart +1 -0
- package/templates/template_clean/lib/features/user/presentation/pages/index.dart +1 -0
- package/templates/template_clean/lib/features/user/presentation/pages/user_list_page.dart +27 -0
- package/templates/template_clean/lib/features/user/presentation/viewmodels/user_list_viewmodel.dart +88 -0
- package/templates/template_clean/lib/features/user/presentation/widgets/user_item_card.dart +24 -0
- package/templates/template_clean/lib/shared/extensions/index.dart +1 -0
- package/templates/template_clean/lib/shared/widgets/index.dart +1 -0
- package/templates/template_lite/lib/models/index.dart +1 -0
- package/templates/template_lite/lib/pages/home_page.dart +290 -0
- package/templates/template_lite/lib/pages/index.dart +3 -0
- package/templates/template_lite/lib/pages/splash_page.dart +154 -0
- package/templates/template_lite/lib/pages/user_list_page.dart +29 -0
- package/templates/template_lite/lib/services/home_feed_service.dart +37 -0
- package/templates/template_lite/lib/services/index.dart +5 -0
- package/templates/template_lite/lib/utils/index.dart +1 -0
- package/templates/template_lite/lib/viewmodels/home_viewmodel.dart +34 -0
- package/templates/template_lite/lib/viewmodels/index.dart +2 -0
- package/templates/template_lite/lib/viewmodels/user_list_viewmodel.dart +103 -0
- package/templates/template_lite/lib/widgets/index.dart +1 -0
- package/templates/template_lite/lib/widgets/user_item_widget.dart +57 -0
- package/templates/template_modular/lib/features/home/index.dart +2 -0
- package/templates/template_modular/lib/features/home/models/index.dart +1 -0
- package/templates/template_modular/lib/features/home/pages/home_page.dart +290 -0
- package/templates/template_modular/lib/features/home/pages/index.dart +2 -0
- package/templates/template_modular/lib/features/home/pages/splash_page.dart +154 -0
- package/templates/template_modular/lib/features/home/services/index.dart +1 -0
- package/templates/template_modular/lib/features/home/viewmodels/home_viewmodel.dart +17 -0
- package/templates/template_modular/lib/features/index.dart +2 -0
- package/templates/template_modular/lib/features/user/index.dart +6 -0
- package/templates/template_modular/lib/features/user/pages/user_list_page.dart +26 -0
- package/templates/template_modular/lib/features/user/services/home_feed_service.dart +37 -0
- package/templates/template_modular/lib/features/user/viewmodels/user_list_viewmodel.dart +103 -0
- package/templates/template_modular/lib/features/user/widgets/user_item_widget.dart +24 -0
- package/templates/template_modular/lib/shared/utils/index.dart +1 -0
- package/templates/template_modular/lib/shared/widgets/index.dart +1 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import 'package:flutter/material.dart';
|
|
2
|
+
|
|
3
|
+
import '../../../core/index.dart';
|
|
4
|
+
import '../viewmodels/user_list_viewmodel.dart';
|
|
5
|
+
import '../widgets/user_item_widget.dart';
|
|
6
|
+
|
|
7
|
+
class UserListPage extends BaseListPage<User, UserListViewModel> {
|
|
8
|
+
const UserListPage({super.key});
|
|
9
|
+
|
|
10
|
+
@override
|
|
11
|
+
State<UserListPage> createState() => _UserListPageState();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class _UserListPageState
|
|
15
|
+
extends BaseListPageState<User, UserListViewModel, UserListPage> {
|
|
16
|
+
@override
|
|
17
|
+
String get title => '列表样板';
|
|
18
|
+
|
|
19
|
+
@override
|
|
20
|
+
UserListViewModel createViewModel() => UserListViewModel();
|
|
21
|
+
|
|
22
|
+
@override
|
|
23
|
+
Widget buildItem(BuildContext context, User item, int index) {
|
|
24
|
+
return UserItemWidget(item: item);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{{#if_network_example}}
|
|
2
|
+
import '../../../core/index.dart';
|
|
3
|
+
|
|
4
|
+
class HomeFeedService {
|
|
5
|
+
HomeFeedService({
|
|
6
|
+
AppHttp? http,
|
|
7
|
+
}) : _http = http ?? AppHttp();
|
|
8
|
+
|
|
9
|
+
final AppHttp _http;
|
|
10
|
+
|
|
11
|
+
Future<List<Map<String, dynamic>>> fetchPosts({
|
|
12
|
+
required int page,
|
|
13
|
+
required int pageSize,
|
|
14
|
+
}) async {
|
|
15
|
+
final response = await _http.get<List<Map<String, dynamic>>>(
|
|
16
|
+
'/posts',
|
|
17
|
+
queryParameters: {
|
|
18
|
+
'_page': page,
|
|
19
|
+
'_limit': pageSize,
|
|
20
|
+
},
|
|
21
|
+
showError: false,
|
|
22
|
+
fromJson: (json) {
|
|
23
|
+
final list = json as List;
|
|
24
|
+
return list
|
|
25
|
+
.map((item) => Map<String, dynamic>.from(item as Map))
|
|
26
|
+
.toList();
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (response.isSuccess && response.data != null) {
|
|
31
|
+
return response.data!;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
throw Exception(response.msg);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
{{/if_network_example}}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import '../../../core/index.dart';
|
|
2
|
+
{{#if_network_example}}
|
|
3
|
+
import '../services/home_feed_service.dart';
|
|
4
|
+
{{/if_network_example}}
|
|
5
|
+
|
|
6
|
+
class User {
|
|
7
|
+
final String name;
|
|
8
|
+
|
|
9
|
+
const User(this.name);
|
|
10
|
+
|
|
11
|
+
{{#if_network_example}}
|
|
12
|
+
factory User.fromNetworkJson(Map<String, dynamic> json) {
|
|
13
|
+
final id = json['id'] as int? ?? 0;
|
|
14
|
+
final title = json['title'] as String? ?? '网络记录 #$id';
|
|
15
|
+
final body = json['body'] as String? ?? '';
|
|
16
|
+
|
|
17
|
+
return User(title.isNotEmpty ? title : body);
|
|
18
|
+
}
|
|
19
|
+
{{/if_network_example}}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
enum DemoListMode {
|
|
23
|
+
standard,
|
|
24
|
+
finite,
|
|
25
|
+
empty,
|
|
26
|
+
firstPageError,
|
|
27
|
+
loadMoreError,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class UserListViewModel extends BaseListViewModel<User> {
|
|
31
|
+
{{#if_network_example}}
|
|
32
|
+
UserListViewModel({
|
|
33
|
+
HomeFeedService? feedService,
|
|
34
|
+
}) {
|
|
35
|
+
_feedService = feedService ?? HomeFeedService();
|
|
36
|
+
pageSize = 12;
|
|
37
|
+
}
|
|
38
|
+
{{else}}
|
|
39
|
+
UserListViewModel() {
|
|
40
|
+
pageSize = 12;
|
|
41
|
+
}
|
|
42
|
+
{{/if_network_example}}
|
|
43
|
+
|
|
44
|
+
final DemoListMode mode = _resolveMode();
|
|
45
|
+
{{#if_network_example}}
|
|
46
|
+
late final HomeFeedService _feedService;
|
|
47
|
+
{{/if_network_example}}
|
|
48
|
+
|
|
49
|
+
@override
|
|
50
|
+
Future<List<User>> fetchPage({
|
|
51
|
+
required int page,
|
|
52
|
+
required int pageSize,
|
|
53
|
+
}) async {
|
|
54
|
+
{{#if_network_example}}
|
|
55
|
+
if (!AppConfig.I.useMockData) {
|
|
56
|
+
final posts = await _feedService.fetchPosts(page: page, pageSize: pageSize);
|
|
57
|
+
return posts.map(User.fromNetworkJson).toList();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
{{/if_network_example}}
|
|
61
|
+
await Future<void>.delayed(const Duration(milliseconds: 250));
|
|
62
|
+
|
|
63
|
+
if (mode == DemoListMode.empty && page == 1) {
|
|
64
|
+
return const <User>[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (mode == DemoListMode.firstPageError && page == 1) {
|
|
68
|
+
throw Exception('列表样板加载失败,请点击重试');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (mode == DemoListMode.loadMoreError && page >= 2) {
|
|
72
|
+
throw Exception('分页加载失败,请重试');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (mode == DemoListMode.finite && page >= 3) {
|
|
76
|
+
return List<User>.generate(
|
|
77
|
+
5,
|
|
78
|
+
(index) => User('样板记录 ${(page - 1) * pageSize + index + 1}'),
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return List<User>.generate(
|
|
83
|
+
pageSize,
|
|
84
|
+
(index) => User('样板记录 ${(page - 1) * pageSize + index + 1}'),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static DemoListMode _resolveMode() {
|
|
89
|
+
switch (EnvConfig.demoListMode.trim().toLowerCase()) {
|
|
90
|
+
case 'standard':
|
|
91
|
+
return DemoListMode.standard;
|
|
92
|
+
case 'empty':
|
|
93
|
+
return DemoListMode.empty;
|
|
94
|
+
case 'first_page_error':
|
|
95
|
+
return DemoListMode.firstPageError;
|
|
96
|
+
case 'load_more_error':
|
|
97
|
+
return DemoListMode.loadMoreError;
|
|
98
|
+
case 'finite':
|
|
99
|
+
default:
|
|
100
|
+
return DemoListMode.finite;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import 'package:flutter/material.dart';
|
|
2
|
+
|
|
3
|
+
import '../viewmodels/user_list_viewmodel.dart';
|
|
4
|
+
|
|
5
|
+
class UserItemWidget extends StatelessWidget {
|
|
6
|
+
final User item;
|
|
7
|
+
|
|
8
|
+
const UserItemWidget({
|
|
9
|
+
super.key,
|
|
10
|
+
required this.item,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
@override
|
|
14
|
+
Widget build(BuildContext context) {
|
|
15
|
+
return ListTile(
|
|
16
|
+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
|
17
|
+
tileColor: Colors.white,
|
|
18
|
+
leading: CircleAvatar(child: Text(item.name.substring(0, 1))),
|
|
19
|
+
title: Text(item.name),
|
|
20
|
+
subtitle: Text('${item.name.toLowerCase()}@example.com'),
|
|
21
|
+
trailing: const Icon(Icons.chevron_right),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// 跨模块共享工具导出入口。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// 跨模块共享组件导出入口。
|