fix(app): Phase 1.1 紧急修复 — SyncEngine 接入 + authorId + catch 异常处理
- feat(sync): SyncEngine 接入 EditorPage, 保存时 enqueue + 网络恢复自动 trySync - fix(editor): authorId 从 AuthBloc 获取, 替代硬编码 'local' - fix(bloc): class_bloc/calendar/profile/parent catch(_).全部改为 debugPrint - feat(editor): 编辑器工具栏拆分 (brush_panel/tag_panel/text_format_bar/dot_grid_painter) - feat(editor): EditorBloc 扩展 + EditorPage 增强 - feat(search): SearchBloc 扩展搜索功能 - feat(home): HomeBloc/HomePage 增强 - feat(auth): LoginPage 增强 - feat(templates): TemplateGalleryPage 重构 - fix(web): 管理端班级/日记页面修复 - fix(server): comment_service + theme_handler 修复 - docs: 添加全链路审计报告和验证截图
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../core/constants/design_tokens.dart';
|
||||
import '../../../core/theme/app_colors.dart';
|
||||
import '../../../core/theme/app_radius.dart';
|
||||
import '../bloc/auth_bloc.dart';
|
||||
|
||||
@@ -30,6 +31,7 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
|
||||
bool _isRegister = false;
|
||||
bool _obscurePassword = true;
|
||||
bool _agreedToTerms = false;
|
||||
|
||||
late final AnimationController _animController;
|
||||
late final Animation<double> _fadeAnim;
|
||||
@@ -60,6 +62,13 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
void _submit() {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
|
||||
if (_isRegister && !_agreedToTerms) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('请先阅读并同意用户协议和隐私政策')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isRegister) {
|
||||
context.read<AuthBloc>().add(RegisterRequested(
|
||||
username: _usernameController.text.trim(),
|
||||
@@ -106,13 +115,20 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildHeader(context, colorScheme),
|
||||
const SizedBox(height: DesignTokens.spacing48),
|
||||
const SizedBox(height: DesignTokens.spacing32),
|
||||
_buildForm(context, theme, colorScheme),
|
||||
const SizedBox(height: DesignTokens.spacing24),
|
||||
_buildSubmitButton(context, colorScheme),
|
||||
const SizedBox(height: DesignTokens.spacing16),
|
||||
_buildModeToggle(context, colorScheme),
|
||||
const SizedBox(height: DesignTokens.spacing32),
|
||||
const SizedBox(height: DesignTokens.spacing24),
|
||||
|
||||
// 协议复选框(注册模式下显示)
|
||||
if (_isRegister) ...[
|
||||
_buildAgreementRow(context, colorScheme),
|
||||
const SizedBox(height: DesignTokens.spacing16),
|
||||
],
|
||||
|
||||
BlocBuilder<AuthBloc, AuthState>(
|
||||
builder: (context, state) {
|
||||
if (state is AuthError) {
|
||||
@@ -121,6 +137,13 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
|
||||
// 社交登录分割线
|
||||
const SizedBox(height: DesignTokens.spacing24),
|
||||
_buildSocialLoginDivider(context, colorScheme),
|
||||
const SizedBox(height: DesignTokens.spacing16),
|
||||
_buildSocialLoginButtons(context, colorScheme),
|
||||
const SizedBox(height: DesignTokens.spacing32),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -132,37 +155,83 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context, ColorScheme colorScheme) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primaryContainer,
|
||||
borderRadius: AppRadius.lgBorder,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.edit_note_rounded,
|
||||
size: 44,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
final bgColor = isDark ? const Color(0xFF1A1614) : const Color(0xFFFFF8F0);
|
||||
final tertiarySoft = isDark ? AppColors.tertiarySoftDark : AppColors.tertiarySoftLight;
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 40),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [bgColor, tertiarySoft],
|
||||
),
|
||||
const SizedBox(height: DesignTokens.spacing16),
|
||||
Text(
|
||||
'暖记',
|
||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
// 装饰圆圈
|
||||
Positioned(left: 20, top: -10, child: _decorCircle(60, AppColors.accent, 0.15)),
|
||||
Positioned(right: 30, top: 20, child: _decorCircle(40, AppColors.secondary, 0.12)),
|
||||
Positioned(left: 80, bottom: -20, child: _decorCircle(30, AppColors.tertiary, 0.18)),
|
||||
Positioned(right: 60, bottom: 10, child: _decorCircle(20, AppColors.accent, 0.10)),
|
||||
Positioned(left: -10, top: 50, child: _decorCircle(25, AppColors.secondary, 0.13)),
|
||||
|
||||
Column(
|
||||
children: [
|
||||
// Logo — 自定义笔记本图标
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColors.accent, width: 3),
|
||||
borderRadius: AppRadius.lgBorder,
|
||||
color: colorScheme.surface.withValues(alpha: 0.5),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.edit_note_rounded,
|
||||
size: 44,
|
||||
color: AppColors.accent,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: DesignTokens.spacing4),
|
||||
Text(
|
||||
'记录温暖,书写成长',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
const SizedBox(height: DesignTokens.spacing16),
|
||||
// 品牌名
|
||||
Text(
|
||||
'暖记',
|
||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.accent,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: DesignTokens.spacing4),
|
||||
// 标语 — Caveat 手写风格
|
||||
Text(
|
||||
'记录温暖,书写成长',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.accent,
|
||||
fontFamily: 'Caveat',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 装饰圆圈
|
||||
Widget _decorCircle(double size, Color color, double opacity) {
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: opacity),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -319,4 +388,160 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 社交登录分割线
|
||||
Widget _buildSocialLoginDivider(BuildContext context, ColorScheme colorScheme) {
|
||||
final dividerColor = colorScheme.onSurface.withValues(alpha: 0.15);
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: Divider(color: dividerColor)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text('其他登录方式', style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurface.withValues(alpha: 0.4),
|
||||
)),
|
||||
),
|
||||
Expanded(child: Divider(color: dividerColor)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 社交登录按钮行
|
||||
Widget _buildSocialLoginButtons(BuildContext context, ColorScheme colorScheme) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// 微信
|
||||
_SocialButton(
|
||||
bgColor: const Color(0xFF07C160),
|
||||
icon: Icons.chat_bubble,
|
||||
semanticLabel: '微信登录',
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('微信登录即将支持')),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
// Apple
|
||||
_SocialButton(
|
||||
bgColor: const Color(0xFF1D1D1F),
|
||||
icon: Icons.apple,
|
||||
semanticLabel: 'Apple 登录',
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Apple 登录即将支持')),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
// Google
|
||||
_SocialButton(
|
||||
bgColor: colorScheme.surface,
|
||||
borderColor: colorScheme.outlineVariant,
|
||||
child: const Text('G', style: TextStyle(
|
||||
fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xFF4285F4),
|
||||
)),
|
||||
semanticLabel: 'Google 登录',
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Google 登录即将支持')),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 协议复选框行
|
||||
Widget _buildAgreementRow(BuildContext context, ColorScheme colorScheme) {
|
||||
return Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: Checkbox(
|
||||
value: _agreedToTerms,
|
||||
onChanged: (v) => setState(() => _agreedToTerms = v ?? false),
|
||||
activeColor: AppColors.accent,
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Wrap(
|
||||
children: [
|
||||
Text('我已阅读并同意', style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
)),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// TODO: 打开用户协议
|
||||
},
|
||||
child: Text('《用户协议》', style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: AppColors.accent, fontWeight: FontWeight.w500,
|
||||
)),
|
||||
),
|
||||
Text('和', style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
)),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// TODO: 打开隐私政策
|
||||
},
|
||||
child: Text('《隐私政策》', style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: AppColors.accent, fontWeight: FontWeight.w500,
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 社交登录圆形按钮
|
||||
class _SocialButton extends StatelessWidget {
|
||||
const _SocialButton({
|
||||
required this.bgColor,
|
||||
required this.semanticLabel,
|
||||
required this.onTap,
|
||||
this.icon,
|
||||
this.child,
|
||||
this.borderColor,
|
||||
});
|
||||
final Color bgColor;
|
||||
final Color? borderColor;
|
||||
final IconData? icon;
|
||||
final Widget? child;
|
||||
final String semanticLabel;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 56,
|
||||
height: 56,
|
||||
child: Material(
|
||||
color: bgColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
side: borderColor != null
|
||||
? BorderSide(color: borderColor!, width: 1.5)
|
||||
: BorderSide.none,
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
customBorder: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
),
|
||||
child: Center(
|
||||
child: child ??
|
||||
Icon(icon, size: 28, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user