修复路由冲突和补充多语言
This commit is contained in:
@@ -60,6 +60,10 @@ class AppTranslations {
|
||||
/// 托盘相关翻译
|
||||
static final AppTranslationsTray kr_tray = AppTranslationsTray();
|
||||
|
||||
/// 设备管理翻译类
|
||||
static final AppTranslationsDeviceManagement kr_deviceManagement =
|
||||
AppTranslationsDeviceManagement();
|
||||
|
||||
/// 初始化翻译
|
||||
static void kr_initTranslations() {
|
||||
// Get.addTranslations({
|
||||
@@ -429,6 +433,15 @@ class AppTranslationsUserInfo {
|
||||
|
||||
final String download = '下载';
|
||||
final String upload = '上传';
|
||||
|
||||
/// 登录/注册
|
||||
String get loginRegister => 'userInfo.loginRegister'.tr;
|
||||
|
||||
/// 游客ID
|
||||
String guestId(int id) => 'userInfo.guestId'.trParams({'id': id.toString()});
|
||||
|
||||
/// 设备管理
|
||||
String get deviceManagement => 'userInfo.deviceManagement'.tr;
|
||||
}
|
||||
|
||||
class AppTranslationsSetting {
|
||||
@@ -817,6 +830,24 @@ class AppTranslationsDialog {
|
||||
|
||||
/// 我知道了按钮文本
|
||||
String get kr_iKnow => 'dialog.iKnow'.tr;
|
||||
|
||||
/// 提示
|
||||
String get tip => 'dialog.tip'.tr;
|
||||
|
||||
/// 删除
|
||||
String get delete => 'dialog.delete'.tr;
|
||||
|
||||
/// 错误
|
||||
String get error => 'dialog.error'.tr;
|
||||
|
||||
/// 成功
|
||||
String get success => 'dialog.success'.tr;
|
||||
|
||||
/// 设备登录绑定标题
|
||||
String get deviceLoginBindingTitle => 'dialog.deviceLoginBindingTitle'.tr;
|
||||
|
||||
/// 设备登录绑定消息
|
||||
String get deviceLoginBindingMessage => 'dialog.deviceLoginBindingMessage'.tr;
|
||||
}
|
||||
|
||||
/// 更新相关翻译
|
||||
@@ -932,3 +963,54 @@ class AppTranslationsTray {
|
||||
/// 退出应用
|
||||
String get exitApp => 'tray.exit_app'.tr;
|
||||
}
|
||||
|
||||
/// 设备管理模块的翻译类
|
||||
class AppTranslationsDeviceManagement {
|
||||
/// 设备管理标题
|
||||
String get title => 'deviceManagement.title'.tr;
|
||||
|
||||
/// 删除确认标题
|
||||
String get deleteConfirmTitle => 'deviceManagement.deleteConfirmTitle'.tr;
|
||||
|
||||
/// 删除当前设备消息
|
||||
String get deleteCurrentDeviceMessage =>
|
||||
'deviceManagement.deleteCurrentDeviceMessage'.tr;
|
||||
|
||||
/// 删除其他设备消息
|
||||
String get deleteOtherDeviceMessage =>
|
||||
'deviceManagement.deleteOtherDeviceMessage'.tr;
|
||||
|
||||
/// 删除成功
|
||||
String get deleteSuccess => 'deviceManagement.deleteSuccess'.tr;
|
||||
|
||||
/// 删除失败
|
||||
String deleteFailed(String error) =>
|
||||
'deviceManagement.deleteFailed'.trParams({'error': error});
|
||||
|
||||
/// 加载设备列表失败
|
||||
String get loadDeviceListFailed =>
|
||||
'deviceManagement.loadDeviceListFailed'.tr;
|
||||
|
||||
/// 设备登录未启用
|
||||
String get deviceLoginDisabled => 'deviceManagement.deviceLoginDisabled'.tr;
|
||||
|
||||
/// 重新登录成功
|
||||
String get reloginSuccess => 'deviceManagement.reloginSuccess'.tr;
|
||||
|
||||
/// 重新登录失败(带错误信息)
|
||||
String reloginFailed(String error) =>
|
||||
'deviceManagement.reloginFailed'.trParams({'error': error});
|
||||
|
||||
/// 重新登录失败(通用)
|
||||
String get reloginFailedGeneric =>
|
||||
'deviceManagement.reloginFailedGeneric'.tr;
|
||||
|
||||
/// 设备类型
|
||||
String get deviceTypeUnknown => 'deviceManagement.deviceTypes.unknown'.tr;
|
||||
String get deviceTypeAndroid => 'deviceManagement.deviceTypes.android'.tr;
|
||||
String get deviceTypeIos => 'deviceManagement.deviceTypes.ios'.tr;
|
||||
String get deviceTypeIpad => 'deviceManagement.deviceTypes.ipad'.tr;
|
||||
String get deviceTypeMacos => 'deviceManagement.deviceTypes.macos'.tr;
|
||||
String get deviceTypeWindows => 'deviceManagement.deviceTypes.windows'.tr;
|
||||
String get deviceTypeLinux => 'deviceManagement.deviceTypes.linux'.tr;
|
||||
}
|
||||
|
||||
+22
-21
@@ -10,6 +10,7 @@ import 'package:kaer_with_panels/app/services/kr_site_config_service.dart';
|
||||
import 'package:kaer_with_panels/app/services/kr_device_info_service.dart';
|
||||
import 'package:kaer_with_panels/app/services/kr_subscribe_service.dart';
|
||||
import 'package:kaer_with_panels/app/model/enum/kr_request_type.dart';
|
||||
import 'package:kaer_with_panels/app/localization/app_translations.dart';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
@@ -52,7 +53,7 @@ class KRDeviceManagementController extends GetxController {
|
||||
result.fold(
|
||||
(error) {
|
||||
KRLogUtil.kr_e('加载设备列表失败: ${error.msg}', tag: 'DeviceManagement');
|
||||
Get.snackbar('错误', error.msg);
|
||||
Get.snackbar(AppTranslations.kr_dialog.error, error.msg);
|
||||
},
|
||||
(deviceList) {
|
||||
KRLogUtil.kr_i('获取到 ${deviceList.length} 个设备', tag: 'DeviceManagement');
|
||||
@@ -78,7 +79,7 @@ class KRDeviceManagementController extends GetxController {
|
||||
} catch (e, stackTrace) {
|
||||
KRLogUtil.kr_e('加载设备列表异常: $e', tag: 'DeviceManagement');
|
||||
KRLogUtil.kr_e('堆栈跟踪: $stackTrace', tag: 'DeviceManagement');
|
||||
Get.snackbar('错误', '加载设备列表失败');
|
||||
Get.snackbar(AppTranslations.kr_dialog.error, AppTranslations.kr_deviceManagement.loadDeviceListFailed);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
@@ -102,10 +103,10 @@ class KRDeviceManagementController extends GetxController {
|
||||
|
||||
// 显示确认对话框
|
||||
await KRDialog.show(
|
||||
title: '确认删除',
|
||||
title: AppTranslations.kr_deviceManagement.deleteConfirmTitle,
|
||||
message: isCurrent
|
||||
? '确定要删除本机设备吗?删除后将使用设备登录自动重新登录。'
|
||||
: '确定要删除此设备吗?删除后该设备将被强制下线。',
|
||||
? AppTranslations.kr_deviceManagement.deleteCurrentDeviceMessage
|
||||
: AppTranslations.kr_deviceManagement.deleteOtherDeviceMessage,
|
||||
icon: Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
@@ -119,8 +120,8 @@ class KRDeviceManagementController extends GetxController {
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
confirmText: '删除',
|
||||
cancelText: '取消',
|
||||
confirmText: AppTranslations.kr_dialog.delete,
|
||||
cancelText: AppTranslations.kr_dialog.kr_cancel,
|
||||
onConfirm: () {
|
||||
confirmed = true;
|
||||
},
|
||||
@@ -139,7 +140,7 @@ class KRDeviceManagementController extends GetxController {
|
||||
result.fold(
|
||||
(error) {
|
||||
KRLogUtil.kr_e('删除设备失败: ${error.msg}', tag: 'DeviceManagement');
|
||||
Get.snackbar('错误', '删除失败:${error.msg}');
|
||||
Get.snackbar(AppTranslations.kr_dialog.error, AppTranslations.kr_deviceManagement.deleteFailed(error.msg));
|
||||
},
|
||||
(_) async {
|
||||
KRLogUtil.kr_i('设备删除成功', tag: 'DeviceManagement');
|
||||
@@ -156,14 +157,14 @@ class KRDeviceManagementController extends GetxController {
|
||||
} else {
|
||||
// 删除其他设备,从列表中移除
|
||||
devices.removeWhere((device) => device['id'] == id);
|
||||
Get.snackbar('成功', '设备已删除');
|
||||
Get.snackbar(AppTranslations.kr_dialog.success, AppTranslations.kr_deviceManagement.deleteSuccess);
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
KRLogUtil.kr_e('删除设备异常: $e', tag: 'DeviceManagement');
|
||||
KRLogUtil.kr_e('堆栈跟踪: $stackTrace', tag: 'DeviceManagement');
|
||||
Get.snackbar('错误', '删除失败:$e');
|
||||
Get.snackbar(AppTranslations.kr_dialog.error, AppTranslations.kr_deviceManagement.deleteFailed(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ class KRDeviceManagementController extends GetxController {
|
||||
|
||||
if (!isDeviceLoginEnabled) {
|
||||
KRLogUtil.kr_w('设备登录未启用,执行完整退出登录', tag: 'DeviceManagement');
|
||||
Get.snackbar('提示', '设备登录未启用,请手动登录');
|
||||
Get.snackbar(AppTranslations.kr_dialog.tip, AppTranslations.kr_deviceManagement.deviceLoginDisabled);
|
||||
await appRunData.kr_loginOut();
|
||||
return;
|
||||
}
|
||||
@@ -205,7 +206,7 @@ class KRDeviceManagementController extends GetxController {
|
||||
(error) {
|
||||
// 设备登录失败
|
||||
KRLogUtil.kr_e('设备登录失败: ${error.msg}', tag: 'DeviceManagement');
|
||||
Get.snackbar('错误', '自动登录失败:${error.msg},请手动登录');
|
||||
Get.snackbar(AppTranslations.kr_dialog.error, AppTranslations.kr_deviceManagement.reloginFailed(error.msg));
|
||||
|
||||
// 执行完整退出登录,显示登录界面
|
||||
appRunData.kr_loginOut();
|
||||
@@ -238,13 +239,13 @@ class KRDeviceManagementController extends GetxController {
|
||||
KRLogUtil.kr_e('订阅信息刷新失败: $e', tag: 'DeviceManagement');
|
||||
}
|
||||
|
||||
Get.snackbar('成功', '已自动重新登录');
|
||||
Get.snackbar(AppTranslations.kr_dialog.success, AppTranslations.kr_deviceManagement.reloginSuccess);
|
||||
},
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
KRLogUtil.kr_e('设备重新登录异常: $e', tag: 'DeviceManagement');
|
||||
KRLogUtil.kr_e('堆栈跟踪: $stackTrace', tag: 'DeviceManagement');
|
||||
Get.snackbar('错误', '自动登录失败,请手动登录');
|
||||
Get.snackbar(AppTranslations.kr_dialog.error, AppTranslations.kr_deviceManagement.reloginFailedGeneric);
|
||||
|
||||
// 发生异常,执行完整退出登录
|
||||
await KRAppRunData.getInstance().kr_loginOut();
|
||||
@@ -253,26 +254,26 @@ class KRDeviceManagementController extends GetxController {
|
||||
|
||||
/// 获取设备类型和图标
|
||||
Map<String, dynamic> getDeviceTypeInfo(String userAgent) {
|
||||
String deviceType = '未知设备';
|
||||
String deviceType = AppTranslations.kr_deviceManagement.deviceTypeUnknown;
|
||||
String iconName = 'devices';
|
||||
|
||||
if (userAgent.contains('Android') || userAgent.toLowerCase().contains('android')) {
|
||||
deviceType = '安卓设备';
|
||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeAndroid;
|
||||
iconName = 'phone_android';
|
||||
} else if (userAgent.contains('iOS') || userAgent.contains('iPhone') || userAgent.toLowerCase().contains('ios')) {
|
||||
deviceType = 'iOS 设备';
|
||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeIos;
|
||||
iconName = 'phone_iphone';
|
||||
} else if (userAgent.contains('iPad')) {
|
||||
deviceType = 'iPad';
|
||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeIpad;
|
||||
iconName = 'tablet';
|
||||
} else if (userAgent.contains('macOS') || userAgent.contains('Mac') || userAgent.toLowerCase().contains('mac')) {
|
||||
deviceType = 'macOS';
|
||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeMacos;
|
||||
iconName = 'desktop_mac';
|
||||
} else if (userAgent.contains('Windows') || userAgent.toLowerCase().contains('windows')) {
|
||||
deviceType = 'Windows';
|
||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeWindows;
|
||||
iconName = 'computer';
|
||||
} else if (userAgent.contains('Linux') || userAgent.toLowerCase().contains('linux')) {
|
||||
deviceType = 'Linux';
|
||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeLinux;
|
||||
iconName = 'computer';
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ class KRUserInfoView extends GetView<KRUserInfoController> {
|
||||
shouldShowLoginPrompt = false;
|
||||
} else if (isDeviceLogin) {
|
||||
// 设备登录(游客模式)
|
||||
displayText = "登录/注册";
|
||||
displayText = AppTranslations.kr_userInfo.loginRegister;
|
||||
displayColor = const Color(0xFF1797FF); // 使用蓝色提示可以点击
|
||||
displayIcon = Icons.touch_app;
|
||||
shouldShowLoginPrompt = true;
|
||||
@@ -195,7 +195,7 @@ class KRUserInfoView extends GetView<KRUserInfoController> {
|
||||
SizedBox(width: 8.w),
|
||||
Text(
|
||||
appRunData.isDeviceLogin()
|
||||
? "游客ID:${(appRunData.kr_userId.value ?? 0) + 10000}"
|
||||
? AppTranslations.kr_userInfo.guestId((appRunData.kr_userId.value ?? 0) + 10000)
|
||||
: "${AppTranslations.kr_userInfo.balance} ${controller.kr_balance.value.toString()}",
|
||||
style: KrAppTextStyle(
|
||||
fontSize: 12,
|
||||
@@ -667,7 +667,7 @@ class KRUserInfoView extends GetView<KRUserInfoController> {
|
||||
if (showDeviceManagement)
|
||||
_kr_buildShortcutContainer(
|
||||
icon: "my_dns",
|
||||
title: "设备管理",
|
||||
title: AppTranslations.kr_userInfo.deviceManagement,
|
||||
onTap: () {
|
||||
Get.toNamed(Routes.KR_DEVICE_MANAGEMENT);
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:kaer_with_panels/app/common/app_run_data.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/dialogs/kr_dialog.dart';
|
||||
import 'package:kaer_with_panels/app/routes/app_pages.dart';
|
||||
import 'package:kaer_with_panels/app/utils/kr_log_util.dart';
|
||||
import 'package:kaer_with_panels/app/localization/app_translations.dart';
|
||||
|
||||
/// 订阅导航工具类
|
||||
/// 用于统一处理订阅相关的导航逻辑
|
||||
@@ -25,14 +26,16 @@ class KRSubscribeNavigationUtil {
|
||||
// 设备登录用户需要绑定账号
|
||||
KRLogUtil.kr_i('检测到设备登录,显示绑定提示', tag: tag);
|
||||
KRDialog.show(
|
||||
title: '提示',
|
||||
message: '购买套餐需要登录绑定用户',
|
||||
confirmText: '确定',
|
||||
cancelText: '取消',
|
||||
title: AppTranslations.kr_dialog.deviceLoginBindingTitle,
|
||||
message: AppTranslations.kr_dialog.deviceLoginBindingMessage,
|
||||
confirmText: AppTranslations.kr_dialog.kr_ok,
|
||||
cancelText: AppTranslations.kr_dialog.kr_cancel,
|
||||
onConfirm: () {
|
||||
Get.back(); // 关闭对话框
|
||||
// 跳转到登录页面(保持设备登录状态)
|
||||
Get.toNamed(Routes.MR_LOGIN);
|
||||
// 等待对话框完全关闭后再跳转到登录页面
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
Get.toNamed(Routes.MR_LOGIN);
|
||||
});
|
||||
},
|
||||
onCancel: () => Get.back(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user