diff --git a/lib/core/translations/language/de_de.dart b/lib/core/translations/language/de_de.dart index 7257915fd..91cc04eca 100644 --- a/lib/core/translations/language/de_de.dart +++ b/lib/core/translations/language/de_de.dart @@ -180,6 +180,8 @@ const Map deDE = { 'selecttimbre': 'Klangfarbe Wählen', 'pleaseRead': 'Bitte lesen', 'completeRecording': 'Aufnahme abschließen', + 'deleteAccount': 'Konto löschen', + 'deleteAccountTips': 'Möchten Sie Ihr Konto wirklich dauerhaft löschen? Diese Aktion kann nicht rückgängig gemacht werden.', // 聊天页 diff --git a/lib/core/translations/language/en_us.dart b/lib/core/translations/language/en_us.dart index 1499747be..e9beef86b 100644 --- a/lib/core/translations/language/en_us.dart +++ b/lib/core/translations/language/en_us.dart @@ -185,6 +185,8 @@ const Map enUS = { 'selecttimbre': 'Select Timbre', 'pleaseRead': 'Please Read', 'completeRecording': 'Complete Recording', + 'deleteAccount': 'Delete Account', + 'deleteAccountTips': 'Are you sure you want to permanently delete your account? This action cannot be undone.', // 聊天页 diff --git a/lib/core/translations/language/es_es.dart b/lib/core/translations/language/es_es.dart index f75598743..2261d65f8 100644 --- a/lib/core/translations/language/es_es.dart +++ b/lib/core/translations/language/es_es.dart @@ -180,7 +180,9 @@ const Map esES = { 'selecttimbre': 'Seleccionar Timbre', 'pleaseRead': 'Por favor lea', 'completeRecording': 'Completar grabación', - + 'deleteAccount': 'Eliminar cuenta', + 'deleteAccountTips': '¿Está seguro de que desea eliminar permanentemente su cuenta? Esta acción no se puede deshacer.', + // 聊天页 "clearChatHistory": "Borrar Historial de Chat", diff --git a/lib/core/translations/language/fr_fr.dart b/lib/core/translations/language/fr_fr.dart index ec4381025..1030adc44 100644 --- a/lib/core/translations/language/fr_fr.dart +++ b/lib/core/translations/language/fr_fr.dart @@ -180,7 +180,9 @@ const Map frFR = { 'selecttimbre': 'Sélectionner le Timbre', 'pleaseRead': 'Veuillez lire', 'completeRecording': 'Terminer l\'enregistrement', - + 'deleteAccount': 'Supprimer le compte', + 'deleteAccountTips': 'Êtes-vous sûr de vouloir supprimer définitivement votre compte ? Cette action ne peut pas être annulée.', + // 聊天页 "clearChatHistory": "Effacer l'historique de chat", diff --git a/lib/core/translations/language/it_it.dart b/lib/core/translations/language/it_it.dart index c8de6735e..ca1822d12 100644 --- a/lib/core/translations/language/it_it.dart +++ b/lib/core/translations/language/it_it.dart @@ -188,6 +188,9 @@ const Map itIT = { 'selecttimbre': 'Seleziona timbro vocale', 'pleaseRead': 'Per favore leggi', 'completeRecording': 'Completa registrazione', + 'deleteAccount': 'Elimina account', + 'deleteAccountTips': 'Sei sicuro di voler eliminare definitivamente il tuo account? Questa azione non può essere annullata.', + // 聊天页 "clearChatHistory": "Cancella cronologia chat", diff --git a/lib/core/translations/language/ja_jp.dart b/lib/core/translations/language/ja_jp.dart index 90c4144dd..042df9935 100644 --- a/lib/core/translations/language/ja_jp.dart +++ b/lib/core/translations/language/ja_jp.dart @@ -180,6 +180,9 @@ const Map jaJP = { 'selecttimbre': '音色を選択', 'pleaseRead': '読んでください', 'completeRecording': '録音完了', + 'deleteAccount': 'アカウントを削除', + 'deleteAccountTips': 'アカウントを完全に削除してもよろしいですか?この操作は取り消すことができません。', + // 聊天页 "clearChatHistory": "チャット履歴をクリア", diff --git a/lib/core/translations/language/ko_kr.dart b/lib/core/translations/language/ko_kr.dart index 5018a8a09..7a7d7017a 100644 --- a/lib/core/translations/language/ko_kr.dart +++ b/lib/core/translations/language/ko_kr.dart @@ -180,6 +180,8 @@ const Map koKR = { 'selecttimbre': '음색 선택', 'pleaseRead': '읽어주세요', 'completeRecording': '녹음 완료', + 'deleteAccount': '계정 삭제', + 'deleteAccountTips': '계정을 영구적으로 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.', // 聊天页 diff --git a/lib/core/translations/language/pt_pt.dart b/lib/core/translations/language/pt_pt.dart index deee3e8a7..73cab5e28 100644 --- a/lib/core/translations/language/pt_pt.dart +++ b/lib/core/translations/language/pt_pt.dart @@ -180,7 +180,9 @@ const Map ptPT = { 'selecttimbre': 'Selecionar timbre', 'pleaseRead': 'Por favor leia', 'completeRecording': 'Concluir gravação', - + 'deleteAccount': 'Excluir conta', + 'deleteAccountTips': 'Tem certeza de que deseja excluir permanentemente sua conta? Esta ação não pode ser desfeita.', + // 聊天页 "clearChatHistory": "Limpar Histórico de Chat", diff --git a/lib/core/translations/language/ru_ru.dart b/lib/core/translations/language/ru_ru.dart index cc9fc910a..3b68132be 100644 --- a/lib/core/translations/language/ru_ru.dart +++ b/lib/core/translations/language/ru_ru.dart @@ -180,7 +180,9 @@ const Map ruRU = { 'selecttimbre': 'Выбрать тембр', 'pleaseRead': 'Пожалуйста, прочтите', 'completeRecording': 'Завершить запись', - + 'deleteAccount': 'Удалить аккаунт', + 'deleteAccountTips': 'Вы уверены, что хотите навсегда удалить свой аккаунт? Это действие нельзя отменить.', + // 聊天页 "clearChatHistory": "Очистить историю чата", diff --git a/lib/core/translations/language/vi_vn.dart b/lib/core/translations/language/vi_vn.dart index 05f4896f1..e10041f98 100644 --- a/lib/core/translations/language/vi_vn.dart +++ b/lib/core/translations/language/vi_vn.dart @@ -180,7 +180,8 @@ const Map viVN = { 'selecttimbre': 'Seleziona timbro vocale', 'pleaseRead': 'Vui lòng đọc', 'completeRecording': 'Hoàn thành ghi âm', - + 'deleteAccount': 'Xóa tài khoản', + 'deleteAccountTips': 'Bạn có chắc chắn muốn xóa vĩnh viễn tài khoản của mình không? Hành động này không thể hoàn tác.', // 聊天页 "clearChatHistory": "Xóa lịch sử trò chuyện", diff --git a/lib/core/translations/language/zh_cn.dart b/lib/core/translations/language/zh_cn.dart index 4c4878ef5..420b60bf1 100644 --- a/lib/core/translations/language/zh_cn.dart +++ b/lib/core/translations/language/zh_cn.dart @@ -180,7 +180,10 @@ const Map zhCN = { 'selecttimbre': '选择音色', 'pleaseRead': '请朗读', 'completeRecording': '完成录制', + 'deleteAccount': '注销账号', + 'deleteAccountTips': '确定要永久删除您的账号吗?此操作不可撤销', + // 聊天页 "clearChatHistory": "清空聊天记录", "online": "在线", diff --git a/lib/core/translations/language/zh_hk.dart b/lib/core/translations/language/zh_hk.dart index f3c85edff..73c32d447 100644 --- a/lib/core/translations/language/zh_hk.dart +++ b/lib/core/translations/language/zh_hk.dart @@ -180,7 +180,9 @@ const Map zhHK = { 'selecttimbre': '選擇音色', 'pleaseRead': '請朗讀', 'completeRecording': '完成錄製', - + 'deleteAccount': '註銷賬號', + 'deleteAccountTips': '確定要永久刪除您的賬號嗎?此操作不可撤銷', + // 聊天页 "clearChatHistory": "清空聊天記錄", diff --git a/lib/data/services/network/api.dart b/lib/data/services/network/api.dart index 11c361580..bc985cee0 100644 --- a/lib/data/services/network/api.dart +++ b/lib/data/services/network/api.dart @@ -46,4 +46,13 @@ class Api { params: params, ); } + + //注销账号 + static deleteUser([params]) { + return DioManager().request( + NWMethod.post, + '/api/home/user_del', + params: params, + ); + } } diff --git a/lib/main.dart b/lib/main.dart index 72b596679..70660f16d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -67,6 +67,7 @@ class MainApp extends StatelessWidget { builder: (_, child) { return GetMaterialApp( title: 'DeepSound', + defaultTransition: Transition.noTransition, // 设置默认过渡动画为无动画 theme: AppTheme.lightTheme, darkTheme: AppTheme.darkTheme, themeMode: themeMode, // 使用提前获取的主题模式 diff --git a/lib/modules/profile/controllers/profile_controller.dart b/lib/modules/profile/controllers/profile_controller.dart index dc2863aa9..cd064f593 100644 --- a/lib/modules/profile/controllers/profile_controller.dart +++ b/lib/modules/profile/controllers/profile_controller.dart @@ -195,47 +195,29 @@ class ProfileController extends GetxController { } } - final dio = Dio(BaseOptions( - baseUrl: 'https://www.deapsound.com:443', - headers: { - 'accept': 'application/json', - 'Authorization': _storage.read("logintoken"), - 'Content-Type': 'application/json', - }, - )); - - // 调用API前打印token - Logger().d('当前用户token: ${_storage.read("logintoken")}'); - Logger().d('请求数据: ${{"user": data}}'); - final response = await dio.post( - '/api/home/user_setting', - data: data, - ); - + Logger().d('准备更新用户信息: $data'); // 调用API - //final response = await Api.updateUserSetting(data); - - if (response.statusCode == 200) { - if (response.data['code'] == 0) { - Logger().d('更新成功: ${response.data}'); - Get.snackbar('成功', '同步到服务器成功'); - userInfo.update((u) { - if (u != null) { - u.name = response.data['data']['name'] ?? ''; - u.avatar = response.data['data']['avatar'] ?? ''; - } - }); - Logger().d('更新后的用户信息: ${userInfo.value.toJson()}'); - } else { - throw '更新失败:${response.data['msg'] ?? '未知错误'}'; - } - } else { - throw '服务器响应错误: ${response.statusCode}'; + final response = await Api.updateUserSetting(data); + Logger().d('--更新用户信息响应: $response'); + if(response != null){ + Logger().d('更新成功: $response'); + Get.snackbar('成功', '同步到服务器成功'); + userInfo.update((u) { + if (u!= null) { + u.name = response['name']?? ''; + u.avatar = response['avatar']?? ''; + } + }); + Logger().d('更新后的用户信息: ${userInfo.value.toJson()}'); + }else{ + Logger().e('更新失败: $response'); + Get.snackbar('错误', '同步到服务器失败,请重试'); + return; } } catch (e) { Logger().e('同步到后端失败: $e'); - Get.snackbar('错误', '同步到服务器失败,请重试'); + Get.snackbar('Error', '同步到服务器失败,请重试'); throw e; } } diff --git a/lib/modules/settings/controllers/settings_controller.dart b/lib/modules/settings/controllers/settings_controller.dart index f16bfc2c0..426404958 100644 --- a/lib/modules/settings/controllers/settings_controller.dart +++ b/lib/modules/settings/controllers/settings_controller.dart @@ -14,26 +14,32 @@ import 'package:path_provider/path_provider.dart'; import 'dart:io'; import '../../../routes/app_routes.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import '../../../data/services/network/api.dart'; class SettingsController extends GetxController { // 语言设置 final List languageList = [ LanguageModel( name: 'followingSystem', // 跟随系统.tr - alias: '', + alias: '', value: 'system'), LanguageModel(name: 'english', alias: 'English', value: 'en_US'), // 英语.tr LanguageModel(name: 'chinese', alias: '中文', value: 'zh_CN'), // 中文.tr - LanguageModel(name: 'traditionalChinese', alias: '繁體中文', value: 'zh_HK'), // 添加繁体中文 - LanguageModel(name: 'spanish', alias: 'Español', value: 'es_ES'), // 添加西班牙语选项 - LanguageModel(name: 'portuguese', alias: 'Português', value: 'pt_PT'), // 添加葡萄牙语 - LanguageModel(name: 'japanese', alias: '日本語', value: 'ja_JP'), // 添加日语选项 - LanguageModel(name: 'korean', alias: '한국어', value: 'ko_KR'), // 添加韩语选项 - LanguageModel(name: 'french', alias: 'Français', value: 'fr_FR'), // 添加法语选项 - LanguageModel(name: 'german', alias: 'Deutsch', value: 'de_DE'), // 添加德语选项 - LanguageModel(name: 'russian', alias: 'Русский', value: 'ru_RU'), // 添加俄语选项 - LanguageModel(name: 'vietnamese', alias: 'Tiếng Việt', value: 'vi_VN'), // 添加越南语选项 - LanguageModel(name: 'italian', alias: 'Italiano', value: 'it_IT'), // 添加意大利语选项 + LanguageModel( + name: 'traditionalChinese', alias: '繁體中文', value: 'zh_HK'), // 添加繁体中文 + LanguageModel( + name: 'spanish', alias: 'Español', value: 'es_ES'), // 添加西班牙语选项 + LanguageModel( + name: 'portuguese', alias: 'Português', value: 'pt_PT'), // 添加葡萄牙语 + LanguageModel(name: 'japanese', alias: '日本語', value: 'ja_JP'), // 添加日语选项 + LanguageModel(name: 'korean', alias: '한국어', value: 'ko_KR'), // 添加韩语选项 + LanguageModel(name: 'french', alias: 'Français', value: 'fr_FR'), // 添加法语选项 + LanguageModel(name: 'german', alias: 'Deutsch', value: 'de_DE'), // 添加德语选项 + LanguageModel(name: 'russian', alias: 'Русский', value: 'ru_RU'), // 添加俄语选项 + LanguageModel( + name: 'vietnamese', alias: 'Tiếng Việt', value: 'vi_VN'), // 添加越南语选项 + LanguageModel( + name: 'italian', alias: 'Italiano', value: 'it_IT'), // 添加意大利语选项 ]; Rx language = LanguageModel().obs; @@ -129,11 +135,11 @@ class SettingsController extends GetxController { void loadUserInfo() { final userJson = _storage.read(userKey); Logger().d('加载用户信息: $userJson'); - + if (userJson != null) { userInfo.value = User.instance; Logger().d('用户信息已加载: ${userInfo.value.toJson()}'); - + if (userInfo.value.avatar.isNotEmpty) { Logger().d('开始下载头像'); _downloadAndSaveAvatar(userInfo.value.avatar); @@ -150,10 +156,10 @@ class SettingsController extends GetxController { } // 下载并保存远程头像 - Future _downloadAndSaveAvatar(String url) async { + Future _downloadAndSaveAvatar(String url) async { try { Logger().d('开始下载头像: $url'); - + final dio = Dio(BaseOptions( headers: { 'accept': '*/*', @@ -165,9 +171,9 @@ class SettingsController extends GetxController { url, options: Options(responseType: ResponseType.bytes), ); - + Logger().d('下载状态: ${response.statusCode}'); - + if (response.statusCode == 200) { // 保存到应用文档目录 final appDir = await getApplicationDocumentsDirectory(); @@ -356,4 +362,34 @@ class SettingsController extends GetxController { print('退出登录错误: $e'); } } + + // 注销账号 + Future deleteAccount() async { + try { + // 显示加载提示 + Get.dialog( + const Center(child: CircularProgressIndicator()), + barrierDismissible: false, + ); + + // 删除后台用户数据 + final responce = await Api.deleteUser(); + if (responce == null) { + Get.back(); // 关闭加载提示 + Get.snackbar('错误', '删除用户数据失败'); + return; + } + // 关闭加载提示 + Get.back(); + + signOut(); // 调用 signOut 方法 + + Get.snackbar('Success', 'Account has been permanently deleted'); + Logger().d('账号删除成功'); + } catch (e) { + Get.back(); // 关闭加载提示 + Get.snackbar('错误', '删除账号失败,请重试'); + Logger().d('账号删除失败: $e'); + } + } } diff --git a/lib/modules/settings/views/settings_view.dart b/lib/modules/settings/views/settings_view.dart index 25143691d..0435d71dc 100644 --- a/lib/modules/settings/views/settings_view.dart +++ b/lib/modules/settings/views/settings_view.dart @@ -548,6 +548,73 @@ class SettingsView extends GetView { }, isDarkMode: isDarkMode, ), + Divider( + height: 1, + color: isDarkMode + ? Colors.white.withOpacity(0.1) + : Colors.grey[200]), + + // 注销账号 + _buildSimpleNavigationSetting( + title: 'deleteAccount'.tr, // 注销账号 + icon: Icons.delete_forever, + iconBgColor: isDarkMode + ? Colors.red[900]!.withOpacity(0.3) + : Colors.red[50]!, + iconColor: isDarkMode ? Colors.red[300]! : Colors.red[600]!, + titleColor: + isDarkMode ? Colors.red[300]! : Colors.red[600]!, + onTap: () { + // 注销账号确认对话框 + Get.dialog( + AlertDialog( + backgroundColor: + isDarkMode ? Colors.grey[900] : Colors.white, + title: Text( + 'deleteAccount'.tr, // 注销账号 + style: TextStyle( + color: isDarkMode ? Colors.white : Colors.black87, + ), + ), + content: Text( + 'deleteAccountTips'.tr, // 确定要永久删除您的账号吗?此操作不可撤销 + style: TextStyle( + color: + isDarkMode ? Colors.white70 : Colors.black54, + ), + ), + actions: [ + TextButton( + onPressed: () => Get.back(), + child: Text( + 'cancel'.tr, // 取消 + style: TextStyle( + color: isDarkMode + ? Colors.white70 + : Colors.black54, + ), + ), + ), + TextButton( + onPressed: () { + Get.back(); + controller.deleteAccount(); + }, + child: Text( + 'confirm'.tr, // 确定 + style: TextStyle( + color: isDarkMode + ? Colors.red[300] + : Colors.red[600], + ), + ), + ), + ], + ), + ); + }, + isDarkMode: isDarkMode, + ), ], ), ), @@ -994,7 +1061,7 @@ class SettingsView extends GetView { Expanded( child: Row( children: [ - Container( + Container(//语音服务图标 width: 32.w, height: 32.w, decoration: BoxDecoration( @@ -1010,7 +1077,7 @@ class SettingsView extends GetView { ), ), SizedBox(width: 12.w), - Flexible( + Flexible(//语音服务标题和副标题 child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/modules/translation/views/translation_view.dart b/lib/modules/translation/views/translation_view.dart index 4d1e78046..4689249d2 100644 --- a/lib/modules/translation/views/translation_view.dart +++ b/lib/modules/translation/views/translation_view.dart @@ -257,7 +257,7 @@ class TranslationView extends GetView { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '${item.sourceLanguageName} → ${item.targetLanguageName}', + '${item.sourceLanguageName.tr} → ${item.targetLanguageName.tr}', style: TextStyle( fontSize: 12, color: Theme.of(context).textTheme.bodySmall?.color,