feat(apps): 重构 UI 架构为 presentation 层并新增 l10n 国际化支持

This commit is contained in:
qzl
2026-03-27 14:05:03 +08:00
parent b1f0eb8921
commit c592cc7854
178 changed files with 10748 additions and 5764 deletions
@@ -0,0 +1,20 @@
import '../../../../core/l10n/l10n.dart';
import '../../data/models/ag_ui_event.dart';
String agUiEventLabel(AgUiEventType type) {
final l10n = L10n.current;
return switch (type) {
AgUiEventType.runStarted => l10n.agUiEventRunStarted,
AgUiEventType.runFinished => l10n.agUiEventRunFinished,
AgUiEventType.runError => l10n.agUiEventRunError,
AgUiEventType.stepStarted => l10n.agUiEventStepStarted,
AgUiEventType.stepFinished => l10n.agUiEventStepFinished,
AgUiEventType.textMessageEnd => l10n.agUiEventTextMessageEnd,
AgUiEventType.toolCallStart => l10n.agUiEventToolCallStart,
AgUiEventType.toolCallArgs => l10n.agUiEventToolCallArgs,
AgUiEventType.toolCallEnd => l10n.agUiEventToolCallEnd,
AgUiEventType.toolCallResult => l10n.agUiEventToolCallResult,
AgUiEventType.toolCallError => l10n.agUiEventToolCallError,
AgUiEventType.unknown => l10n.agUiEventUnknown,
};
}
@@ -1,3 +1,5 @@
import '../../../../core/l10n/l10n.dart';
enum AgentStage { routing, execution, memory }
AgentStage? stageFromStepName(String value) {
@@ -15,9 +17,9 @@ AgentStage? stageFromStepName(String value) {
String stageLabel(AgentStage? stage) {
return switch (stage) {
AgentStage.routing => '意图识别中',
AgentStage.execution => '任务执行中',
AgentStage.memory => '记忆提取中',
null => '任务处理中',
AgentStage.routing => L10n.current.agentStageRouting,
AgentStage.execution => L10n.current.agentStageExecution,
AgentStage.memory => L10n.current.agentStageMemory,
null => L10n.current.agentStageProcessing,
};
}
@@ -2,7 +2,8 @@ import 'dart:typed_data';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:image_picker/image_picker.dart';
import 'package:social_app/core/api/i_api_client.dart';
import 'package:social_app/core/network/i_api_client.dart';
import 'package:social_app/core/l10n/l10n.dart';
import '../../data/models/ag_ui_event.dart';
import '../../data/models/chat_list_item.dart';
@@ -130,7 +131,9 @@ class ChatBloc extends Cubit<ChatState> {
).copyWith(
items: _markActiveToolCallsFailed(
state.items,
reason: isCanceledByUser ? '本次运行已取消' : '本次运行已失败',
reason: isCanceledByUser
? L10n.current.chatRunCanceled
: L10n.current.chatRunFailed,
),
),
);
@@ -428,7 +431,9 @@ class ChatBloc extends Cubit<ChatState> {
isCancelling: false,
currentStage: null,
error: sseClosedBeforeTerminal
? (recoveredFromHistory ? null : '连接中断,请重试')
? (recoveredFromHistory
? null
: L10n.current.chatSseInterruptedRetry)
: error.toString(),
),
);