feat: UI 系统中心化 + 趋势图重构 + 法律文档 H5 上线
- UI 系统: 新增 design_tokens / module_visuals / app_buttons / app_status_badge / app_toast / ai_content 六个共享模块; 28 个页面接入, SnackBar 全部替换为 AppToast - 趋势图: 直线折线 + 渐变填充 + 阴影; 去网格线; X 轴日+月份分隔; Y 轴整数刻度最多 4 个; 点击数据点/录入记录显示上方浮层, 选中点变实心 - 法律文档 H5: 后端 wwwroot 托管隐私政策/服务协议/关于/个人信息收集清单/第三方 SDK 清单 + 索引页; Program.cs 启用 UseDefaultFiles + UseStaticFiles - 其他: auth_provider 登录流程调整; api_client IP 适配; 主页智能体栏间距优化
This commit is contained in:
@@ -6,11 +6,8 @@ import '../../core/app_theme.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/chat_provider.dart';
|
||||
import '../../providers/conversation_history_provider.dart';
|
||||
import '../../widgets/app_toast.dart';
|
||||
|
||||
/// 对话历史完整列表页。
|
||||
/// - 左滑删除(真删,删后 ScaffoldMessenger 提示)
|
||||
/// - 顶部"清空全部"按钮(确认弹窗 → 调 deleteAll)
|
||||
/// - 点击一条 → loadConversation → popRoute 回首页
|
||||
class ConversationHistoryPage extends ConsumerWidget {
|
||||
const ConversationHistoryPage({super.key});
|
||||
|
||||
@@ -21,7 +18,7 @@ class ConversationHistoryPage extends ConsumerWidget {
|
||||
return GradientScaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white.withValues(alpha: 0.9),
|
||||
title: const Text('最近 7 次对话'),
|
||||
title: const Text('对话记录'),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => popRoute(ref),
|
||||
@@ -82,18 +79,11 @@ class ConversationHistoryPage extends ConsumerWidget {
|
||||
try {
|
||||
await ref.read(conversationHistoryProvider.notifier).deleteOne(id);
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('已删除'), duration: Duration(seconds: 1)),
|
||||
);
|
||||
AppToast.show(context, '已删除', type: AppToastType.success);
|
||||
}
|
||||
} catch (_) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('删除失败,请稍后重试'),
|
||||
backgroundColor: AppColors.error,
|
||||
),
|
||||
);
|
||||
AppToast.show(context, '删除失败,请稍后重试', type: AppToastType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,18 +113,11 @@ class ConversationHistoryPage extends ConsumerWidget {
|
||||
.read(conversationHistoryProvider.notifier)
|
||||
.clearAll();
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('已清空 $count 条对话')));
|
||||
AppToast.show(context, '已清空 $count 条对话', type: AppToastType.success);
|
||||
}
|
||||
} catch (_) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('清空失败,请稍后重试'),
|
||||
backgroundColor: AppColors.error,
|
||||
),
|
||||
);
|
||||
AppToast.show(context, '清空失败,请稍后重试', type: AppToastType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,6 +127,7 @@ class _HistoryTile extends StatelessWidget {
|
||||
final ConversationListItem item;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback onDelete;
|
||||
|
||||
const _HistoryTile({
|
||||
required this.item,
|
||||
required this.onTap,
|
||||
@@ -157,25 +141,12 @@ class _HistoryTile extends StatelessWidget {
|
||||
direction: DismissDirection.endToStart,
|
||||
background: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
padding: const EdgeInsets.only(right: 22),
|
||||
padding: const EdgeInsets.only(right: 18),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.error,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.delete_outline, color: Colors.white),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(Icons.delete_outline, color: Colors.white),
|
||||
),
|
||||
confirmDismiss: (_) async {
|
||||
onDelete();
|
||||
@@ -185,7 +156,7 @@ class _HistoryTile extends StatelessWidget {
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
@@ -194,57 +165,25 @@ class _HistoryTile extends StatelessWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 38,
|
||||
height: 38,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEFF6FF),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.forum_rounded,
|
||||
color: Color(0xFF2563EB),
|
||||
size: 20,
|
||||
Expanded(
|
||||
child: Text(
|
||||
_displaySummary(item),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_displaySummary(item),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
if (_displayOriginalQuestion(item).isNotEmpty) ...[
|
||||
Text(
|
||||
'首问:${_displayOriginalQuestion(item)}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
Text(
|
||||
'${item.messageCount} 条 · ${_relativeTime(item.updatedAt)}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
),
|
||||
],
|
||||
Text(
|
||||
_shortDate(item.updatedAt),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -254,39 +193,29 @@ class _HistoryTile extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
static String _displayTitle(ConversationListItem item) {
|
||||
final s = item.summary?.trim();
|
||||
if (s != null && s.isNotEmpty) return s;
|
||||
final t = item.title?.trim();
|
||||
if (t != null && t.isNotEmpty) return t;
|
||||
return '未命名对话';
|
||||
}
|
||||
|
||||
static String _displaySummary(ConversationListItem item) {
|
||||
final s = item.summary?.trim();
|
||||
if (s != null && s.isNotEmpty) return s.replaceAll(RegExp(r'\s+'), ' ');
|
||||
return _displayTitle(item);
|
||||
}
|
||||
|
||||
static String _displayOriginalQuestion(ConversationListItem item) {
|
||||
final t = item.title?.trim();
|
||||
if (t == null || t.isEmpty) return '';
|
||||
final summary = item.summary?.trim();
|
||||
if (summary != null && summary.isNotEmpty && summary != t) {
|
||||
return t.replaceAll(RegExp(r'\s+'), ' ');
|
||||
}
|
||||
return '';
|
||||
if (t != null && t.isNotEmpty) return t.replaceAll(RegExp(r'\s+'), ' ');
|
||||
return '未命名对话';
|
||||
}
|
||||
|
||||
static String _relativeTime(DateTime time) {
|
||||
static String _shortDate(DateTime time) {
|
||||
final now = DateTime.now();
|
||||
final local = time.toLocal();
|
||||
final diff = now.difference(local);
|
||||
if (diff.inMinutes < 1) return '刚刚';
|
||||
if (diff.inHours < 1) return '${diff.inMinutes} 分钟前';
|
||||
if (diff.inDays < 1) return '${diff.inHours} 小时前';
|
||||
if (diff.inDays < 7) return '${diff.inDays} 天前';
|
||||
return '${local.year}/${local.month}/${local.day}';
|
||||
if (local.year == now.year &&
|
||||
local.month == now.month &&
|
||||
local.day == now.day) {
|
||||
return '今天';
|
||||
}
|
||||
final yesterday = now.subtract(const Duration(days: 1));
|
||||
if (local.year == yesterday.year &&
|
||||
local.month == yesterday.month &&
|
||||
local.day == yesterday.day) {
|
||||
return '昨天';
|
||||
}
|
||||
return '${local.month}/${local.day}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +243,7 @@ class _EmptyHint extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
Text(
|
||||
'在首页和 AI 健康助手聊聊吧',
|
||||
'在首页和 AI 健康助手聊天后会显示在这里',
|
||||
style: TextStyle(fontSize: 13, color: AppColors.textSecondary),
|
||||
),
|
||||
],
|
||||
@@ -328,6 +257,7 @@ class _EmptyHint extends StatelessWidget {
|
||||
class _ErrorBlock extends StatelessWidget {
|
||||
final String message;
|
||||
final VoidCallback onRetry;
|
||||
|
||||
const _ErrorBlock({required this.message, required this.onRetry});
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user