多语言切换+首次设置语言
This commit is contained in:
@@ -13,6 +13,7 @@ import 'package:maibu_satabot_v2/core/domain/entities/user_entity.dart';
|
||||
import 'package:maibu_satabot_v2/core/network/net_message_dispatcher.dart';
|
||||
|
||||
import '../../../../core/app/app_user_cubit.dart';
|
||||
import '../../../../core/localization/app_localizations.dart';
|
||||
import '../../../../core/infrastructure/logging/sentry_logger_impl.dart';
|
||||
import '../../../../core/logging/i_logger_service.dart';
|
||||
import '../../../../core/network/tcp/tcp_client.dart';
|
||||
@@ -265,15 +266,16 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext dialogContext) {
|
||||
final loc = AppLocalizations.of(dialogContext);
|
||||
return AlertDialog(
|
||||
title: const Text('登录已过期'),
|
||||
content: const Text('账号登录状态已过期,请重新登录'),
|
||||
title: Text(loc.translate('login.token_expired_title')),
|
||||
content: Text(loc.translate('login.token_expired_content')),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
},
|
||||
child: const Text('确定'),
|
||||
child: Text(loc.translate('common.ok')),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -317,9 +319,10 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
context: context,
|
||||
barrierDismissible: false, // 不允许点击背景关闭
|
||||
builder: (BuildContext dialogContext) {
|
||||
final loc = AppLocalizations.of(dialogContext);
|
||||
return AlertDialog(
|
||||
title: const Text('账号被顶下线'),
|
||||
content: const Text('您的账号在其他设备登录,即将退出当前设备...'),
|
||||
title: Text(loc.translate('login.kicked_out_title')),
|
||||
content: Text(loc.translate('login.kicked_out_content')),
|
||||
actions: [],
|
||||
);
|
||||
},
|
||||
@@ -358,6 +361,7 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext dialogContext) {
|
||||
final loc = AppLocalizations.of(dialogContext);
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
content: Column(
|
||||
@@ -365,18 +369,18 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
children: [
|
||||
const Icon(Icons.wifi_off_rounded, size: 48, color: Color(0xFFF53F3F)),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
'连接异常',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
loc.translate('login.reconnect_failed_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'TCP重连认证无效请重新登陆',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFF86909C)),
|
||||
Text(
|
||||
loc.translate('login.reconnect_failed_content'),
|
||||
style: const TextStyle(fontSize: 14, color: Color(0xFF86909C)),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
@@ -395,7 +399,7 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text('取消', style: TextStyle(fontSize: 15)),
|
||||
child: Text(loc.translate('common.cancel'), style: const TextStyle(fontSize: 15)),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
@@ -414,7 +418,7 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text('退出登录', style: TextStyle(fontSize: 15)),
|
||||
child: Text(loc.translate('login.logout'), style: const TextStyle(fontSize: 15)),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -439,10 +443,10 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
final context = navigatorKey.currentContext;
|
||||
if (context != null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('TCP重连中...'),
|
||||
backgroundColor: Color(0xFFFF7D00),
|
||||
duration: Duration(seconds: 4),
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).translate('login.reconnecting')),
|
||||
backgroundColor: const Color(0xFFFF7D00),
|
||||
duration: const Duration(seconds: 4),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -456,10 +460,10 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
if (context != null) {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('连接成功'),
|
||||
backgroundColor: Color(0xFF00B42A),
|
||||
duration: Duration(seconds: 2),
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).translate('login.reconnect_success')),
|
||||
backgroundColor: const Color(0xFF00B42A),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user