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:
87
health_app/lib/widgets/ai_content.dart
Normal file
87
health_app/lib/widgets/ai_content.dart
Normal file
@@ -0,0 +1,87 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
|
||||
import '../core/app_colors.dart';
|
||||
import '../core/app_design_tokens.dart';
|
||||
|
||||
class AiContent {
|
||||
AiContent._();
|
||||
|
||||
static String clean(String text) {
|
||||
var t = text;
|
||||
t = t.replaceAll(RegExp(r'\$\d+'), '');
|
||||
t = t.replaceAll(RegExp(r'<[^>]+>'), '');
|
||||
t = t.replaceAllMapped(RegExp(r'^#{4,}\s', multiLine: true), (_) => '### ');
|
||||
t = t.replaceAll(RegExp(r'\n{3,}'), '\n\n');
|
||||
return t.trim();
|
||||
}
|
||||
|
||||
static String plain(String text) {
|
||||
final cleaned = clean(text);
|
||||
return cleaned
|
||||
.replaceAll(RegExp(r'\*\*(.*?)\*\*'), r'$1')
|
||||
.replaceAll(RegExp(r'__(.*?)__'), r'$1')
|
||||
.replaceAll(RegExp(r'`([^`]+)`'), r'$1')
|
||||
.replaceAll(RegExp(r'^\s*[-*]\s+', multiLine: true), '• ')
|
||||
.trim();
|
||||
}
|
||||
}
|
||||
|
||||
class AiMarkdownView extends StatelessWidget {
|
||||
final String data;
|
||||
final bool selectable;
|
||||
final void Function(String text, String? href, String title)? onTapLink;
|
||||
|
||||
const AiMarkdownView({
|
||||
super.key,
|
||||
required this.data,
|
||||
this.selectable = true,
|
||||
this.onTapLink,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MarkdownBody(
|
||||
data: AiContent.clean(data),
|
||||
selectable: selectable,
|
||||
onTapLink: onTapLink,
|
||||
styleSheet: MarkdownStyleSheet(
|
||||
p: AppTextStyles.chatBody,
|
||||
a: AppTextStyles.chatBody.copyWith(
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.w800,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: AppColors.primary,
|
||||
),
|
||||
strong: AppTextStyles.chatBody.copyWith(fontWeight: FontWeight.w800),
|
||||
h1: AppTextStyles.chatTitle.copyWith(fontSize: 20),
|
||||
h2: AppTextStyles.chatTitle.copyWith(fontSize: 20),
|
||||
h3: AppTextStyles.chatTitle.copyWith(fontSize: 19),
|
||||
listBullet: AppTextStyles.chatBody.copyWith(
|
||||
fontSize: 21,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
listBulletPadding: const EdgeInsets.only(right: 8),
|
||||
blockquote: AppTextStyles.chatBody.copyWith(color: AppColors.textSecondary),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AiGeneratedNote extends StatelessWidget {
|
||||
const AiGeneratedNote({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => const Padding(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.auto_awesome_rounded, size: 15, color: AppColors.textHint),
|
||||
SizedBox(width: 5),
|
||||
Text('内容由 AI 生成', style: AppTextStyles.aiNote),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user