feat(flutter): 增加目录加载诊断与前台重试
This commit is contained in:
1 parent
d68734cdab
commit
730a96559b
10 files changed
+268
-16
No files matched your search
@@ -0,0 +1,47 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../config/app_config.dart';
|
||||
import '../theme/app_colors.dart';
|
||||
|
||||
const TextStyle _debugStyle = TextStyle(
|
||||
color: AppColors.subtle,
|
||||
fontSize: 12,
|
||||
height: 1.35,
|
||||
);
|
||||
|
||||
/// 仅 debug 展示当前服务地址与目录请求的原始错误。
|
||||
class CatalogDebugInfo extends StatelessWidget {
|
||||
const CatalogDebugInfo({super.key, required this.error});
|
||||
|
||||
final String? error;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!kDebugMode) return const SizedBox.shrink();
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'服务地址:${AppConfig.apiBaseUrl}',
|
||||
key: const Key('catalog-debug-endpoint'),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: _debugStyle,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'错误:${error ?? 'unknown'}',
|
||||
key: const Key('catalog-debug-error'),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: _debugStyle,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ class EmptyState extends StatelessWidget {
|
||||
this.actionLabel,
|
||||
this.actionKey,
|
||||
this.onAction,
|
||||
this.footer,
|
||||
this.compact = false,
|
||||
});
|
||||
|
||||
@@ -34,6 +35,7 @@ class EmptyState extends StatelessWidget {
|
||||
final String? actionLabel;
|
||||
final Key? actionKey;
|
||||
final VoidCallback? onAction;
|
||||
final Widget? footer;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
@@ -65,6 +67,7 @@ class EmptyState extends StatelessWidget {
|
||||
actionLabel: hasAction ? actionLabel : null,
|
||||
actionKey: actionKey,
|
||||
onAction: hasAction ? onAction : null,
|
||||
footer: footer,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -101,6 +104,7 @@ class _EmptyCopy extends StatelessWidget {
|
||||
required this.actionLabel,
|
||||
required this.actionKey,
|
||||
required this.onAction,
|
||||
required this.footer,
|
||||
});
|
||||
|
||||
final String title;
|
||||
@@ -108,6 +112,7 @@ class _EmptyCopy extends StatelessWidget {
|
||||
final String? actionLabel;
|
||||
final Key? actionKey;
|
||||
final VoidCallback? onAction;
|
||||
final Widget? footer;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -162,6 +167,7 @@ class _EmptyCopy extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
if (footer != null) ...[const SizedBox(height: 12), footer!],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user