refactor: 移除前端 Mock API,新增共享组件,优化认证流程

- 删除 mock_api_client、mock_calendar_service、mock_history_service
- 新增 fixed_length_code_input、link_button、message_composer 共享组件
- 优化登录/注册/密码重置页面使用新组件
- 简化 injection.dart 移除 mock 分支
- 更新 env.dart 配置(BACKEND_URL 替换 API_URL)
- 后端 agentscope 工具和测试更新
- 重构 AGENTS.md 文档结构
- 新增 deploy/ 目录和 protocol 文档
This commit is contained in:
qzl
2026-03-12 16:41:45 +08:00
parent d7fbb74bf8
commit 01c36eb32e
70 changed files with 5138 additions and 5829 deletions
@@ -6,6 +6,8 @@ import 'package:go_router/go_router.dart';
import 'package:formz/formz.dart';
import '../../../../core/theme/design_tokens.dart';
import '../../../../shared/widgets/app_button.dart';
import '../../../../shared/widgets/fixed_length_code_input.dart';
import '../../../../shared/widgets/link_button.dart';
import '../../../../shared/widgets/toast/toast.dart';
import '../../../../shared/widgets/toast/toast_type.dart';
import '../../presentation/cubits/register_cubit.dart';
@@ -49,22 +51,10 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
Timer? _countdownTimer;
int _countdown = 0;
bool _firstSendCompleted = false;
bool _hintShown = false;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!_hintShown) {
_hintShown = true;
Toast.show(
context,
'验证码已发送,如未收到请检查垃圾邮件或确认邮箱已注册',
type: ToastType.info,
duration: const Duration(seconds: 5),
);
}
});
}
@override
@@ -200,6 +190,12 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
!_firstSendCompleted) {
_firstSendCompleted = true;
_startCountdown();
Toast.show(
context,
'验证码已发送,如未收到请检查垃圾邮件或确认邮箱已注册',
type: ToastType.info,
duration: const Duration(seconds: 5),
);
}
},
builder: (context, state) {
@@ -246,16 +242,28 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
Expanded(
child: SizedBox(
height: 40,
child: TextField(
child: FixedLengthCodeInput(
controller: _codeController,
length: 6,
semanticLabel: '邮箱验证码输入框',
keyboardType: TextInputType.number,
decoration: const InputDecoration(
hintText: '输入验证码',
contentPadding: EdgeInsets.symmetric(
horizontal: 12,
vertical: 10,
),
),
allowedCharacters: const {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
},
onChanged: (value) {
context.read<RegisterCubit>().verificationCodeChanged(
value,
);
},
),
),
),
@@ -268,36 +276,38 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
}
Widget _buildResendButton(bool canResend, RegisterState state) {
final bgColor = canResend ? AppColors.primary : const Color(0xFFF1F5F9);
final textColor = canResend ? AppColors.white : AppColors.slate400;
final canPress =
canResend && state.status != FormzSubmissionStatus.inProgress;
String text;
if (state.status == FormzSubmissionStatus.inProgress) {
text = '发送中';
} else if (canResend) {
text = '重发';
} else {
text = '${_countdown}s';
}
return GestureDetector(
onTap: canResend ? _handleResendCode : null,
child: Container(
width: 70,
height: 40,
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.circular(6),
),
alignment: Alignment.center,
child: Text(
text,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: textColor,
return SizedBox(
width: 70,
height: 44,
child: TextButton(
onPressed: canPress ? _handleResendCode : null,
style: TextButton.styleFrom(
backgroundColor: canResend ? AppColors.primary : AppColors.slate100,
foregroundColor: canResend ? AppColors.white : AppColors.slate400,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.sm),
),
padding: EdgeInsets.zero,
),
child: state.status == FormzSubmissionStatus.inProgress
? const SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(AppColors.slate400),
),
)
: Text(
canResend ? '重发' : '${_countdown}s',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
);
}
@@ -329,16 +339,6 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
}
Widget _buildFooter() {
return GestureDetector(
onTap: () => context.go('/'),
child: const Text(
'已有账号?去登录',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.slate500,
),
),
);
return LinkButton(text: '已有账号?去登录', onTap: () => context.go('/'));
}
}