From 9ac07b518d56b5c76be49b859dc16a5e4b4672d2 Mon Sep 17 00:00:00 2001 From: Cooper Liu Date: Thu, 13 Oct 2022 10:23:52 +0800 Subject: [PATCH 1/2] add button for importing server config --- .../desktop/pages/desktop_setting_page.dart | 150 +++++++++++++++++- src/lang/cn.rs | 4 + src/lang/cs.rs | 4 + src/lang/da.rs | 4 + src/lang/de.rs | 4 + src/lang/eo.rs | 4 + src/lang/es.rs | 4 + src/lang/fr.rs | 4 + src/lang/hu.rs | 4 + src/lang/id.rs | 4 + src/lang/it.rs | 4 + src/lang/ja.rs | 4 + src/lang/ko.rs | 4 + src/lang/kz.rs | 4 + src/lang/pl.rs | 4 + src/lang/pt_PT.rs | 4 + src/lang/ptbr.rs | 4 + src/lang/ru.rs | 4 + src/lang/sk.rs | 4 + src/lang/template.rs | 4 + src/lang/tr.rs | 4 + src/lang/tw.rs | 4 + src/lang/ua.rs | 4 + src/lang/vn.rs | 4 + 24 files changed, 241 insertions(+), 1 deletion(-) diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 7dc18679d..45b1b9a85 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -723,8 +723,10 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin { AbsorbPointer( absorbing: locked, child: Column(children: [ - _Card(title: 'Server', children: [ + _CardRow(title: 'Server', children: [ _Button('ID/Relay Server', changeServer, enabled: enabled), + _Button('Import Server Conf', importServer, + enabled: enabled), ]), _Card(title: 'Proxy', children: [ _Button('Socks5 Proxy', changeSocks5Proxy, @@ -894,6 +896,38 @@ Widget _Card({required String title, required List children}) { ); } +Widget _CardRow({required String title, required List children}) { + return Row( + children: [ + SizedBox( + width: _kCardFixedWidth, + child: Card( + child: Column( + children: [ + Row( + children: [ + Text( + translate(title), + textAlign: TextAlign.start, + style: const TextStyle( + fontSize: _kTitleFontSize, + ), + ), + const Spacer(), + ], + ).marginOnly(left: _kContentHMargin, top: 10, bottom: 10), + Row(children: [ + ...children + .map((e) => e.marginOnly(top: 4, right: _kContentHMargin)), + ]), + ], + ).marginOnly(bottom: 10), + ).marginOnly(left: _kCardLeftMargin, top: 15), + ), + ], + ); +} + Color? _disabledTextColor(BuildContext context, bool enabled) { return enabled ? null @@ -1377,6 +1411,120 @@ void changeServer() async { }); } +void importServer() async { + Future importServerShow(String content) async { + gFFI.dialogManager.show((setState, close) { + return CustomAlertDialog( + title: Text(content), + content: ConstrainedBox( + constraints: const BoxConstraints(minWidth: 500), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 4.0, + ), + ], + ), + ), + actions: [ + TextButton(onPressed: close, child: Text(translate("OK"))), + ], + onCancel: close, + ); + }); + } + + Future submit( + String idServer, String relayServer, String apiServer, String key) async { + Map oldOptions = jsonDecode(await bind.mainGetOptions()); + var idServerMsg = ""; + var relayServerMsg = ""; + if (idServer.isNotEmpty) { + idServerMsg = + translate(await bind.mainTestIfValidServer(server: idServer)); + if (idServerMsg.isEmpty) { + oldOptions['custom-rendezvous-server'] = idServer; + } else { + print('ID Server invalid return'); + return false; + } + } else { + oldOptions['custom-rendezvous-server'] = ""; + } + + if (relayServer.isNotEmpty) { + relayServerMsg = + translate(await bind.mainTestIfValidServer(server: relayServer)); + if (relayServerMsg.isEmpty) { + oldOptions['relay-server'] = relayServer; + } else { + print('Relay Server invalid return'); + return false; + } + } else { + oldOptions['relay-server'] = ""; + } + + if (apiServer.isNotEmpty) { + if (apiServer.startsWith('http://') || apiServer.startsWith("https://")) { + oldOptions['api-server'] = apiServer; + return false; + } else { + print('invalid_http'); + return false; + } + } else { + oldOptions['api-server'] = ""; + } + // ok + oldOptions['key'] = key; + await bind.mainSetOptions(json: jsonEncode(oldOptions)); + print("set ID/Realy Server Ok"); + return true; + } + + Clipboard.getData(Clipboard.kTextPlain).then((value) { + TextEditingController mytext = TextEditingController(); + String? aNullableString = ""; + aNullableString = value?.text; + mytext.text = aNullableString.toString(); + if (mytext.text.isNotEmpty) { + print('Clipboard is not empty'); + try { + Map config = jsonDecode(mytext.text); + print(config); + if (config.containsKey('IdServer') && + config.containsKey('RelayServer')) { + print('IdServer: ${config['IdServer']}'); + print('RelayServer: ${config['RelayServer']}'); + print('ApiServer: ${config['ApiServer']}'); + print('Key: ${config['Key']}'); + Future success = submit(config['IdServer'], + config['RelayServer'], config['ApiServer'], config['Key']); + success.then((value) { + if (value) { + importServerShow( + translate('Import server configuration successfully')); + } else { + importServerShow(translate('Invalid server configuration')); + } + }); + } else { + print('invalid config info'); + importServerShow(translate("Invalid server configuration")); + } + } catch (e) { + print('invalid config info'); + importServerShow(translate("Invalid server configuration")); + } + } else { + print('Clipboard is empty'); + importServerShow(translate("Clipboard is empty")); + } + }); +} + void changeSocks5Proxy() async { var socks = await bind.mainGetSocks(); diff --git a/src/lang/cn.rs b/src/lang/cn.rs index e5f01b185..35e77990c 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "允许建立TCP隧道"), ("IP Whitelisting", "IP白名单"), ("ID/Relay Server", "ID/中继服务器"), + ("Import Server Conf", "导入服务器配置"), + ("Import server configuration successfully", "导入服务器配置信息成功"), + ("Invalid server configuration", "无效服务器配置,请修改后重新拷贝配置信息到剪贴板后点击此按钮"), + ("Clipboard is empty", "拷贝配置信息到剪贴板后点击此按钮,可以自动导入配置"), ("Stop service", "停止服务"), ("Change ID", "改变ID"), ("Website", "网站"), diff --git a/src/lang/cs.rs b/src/lang/cs.rs index 9186454d1..e849dfa3f 100644 --- a/src/lang/cs.rs +++ b/src/lang/cs.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Povolit TCP tunelování"), ("IP Whitelisting", "Povolování pouze z daných IP adres)"), ("ID/Relay Server", "Identifikátor / předávací (relay) server"), + ("Import Server Conf", "Importovat konfiguraci serveru"), + ("Import server configuration successfully", "Konfigurace serveru úspěšně importována"), + ("Invalid server configuration", "Neplatná konfigurace serveru"), + ("Clipboard is empty", "Schránka je prázdná"), ("Stop service", "Zastavit službu"), ("Change ID", "Změnit identifikátor"), ("Website", "Webové stránky"), diff --git a/src/lang/da.rs b/src/lang/da.rs index c5dc87d49..3dd2e0a51 100644 --- a/src/lang/da.rs +++ b/src/lang/da.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Slå TCP-tunneling til"), ("IP Whitelisting", "IP-udgivelsesliste"), ("ID/Relay Server", "ID/forbindelsesserver"), + ("Import Server Conf", "Importér serverkonfiguration"), + ("Import server configuration successfully", "Importér serverkonfigurationen"), + ("Invalid server configuration", "Ugyldig serverkonfiguration"), + ("Clipboard is empty", "Udklipsholderen er tom"), ("Stop service", "Sluk for forbindelsesserveren"), ("Change ID", "Ændre ID"), ("Website", "Hjemmeside"), diff --git a/src/lang/de.rs b/src/lang/de.rs index 255ae932d..38c0f657a 100644 --- a/src/lang/de.rs +++ b/src/lang/de.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "TCP-Tunnel aktivieren"), ("IP Whitelisting", "IP-Whitelist"), ("ID/Relay Server", "ID/Vermittlungsserver"), + ("Import Server Conf", "Serverkonfiguration importieren"), + ("Import server configuration successfully", "Serverkonfiguration erfolgreich importiert"), + ("Invalid server configuration", "Ungültige Serverkonfiguration"), + ("Clipboard is empty", "Zwischenablage ist leer"), ("Stop service", "Vermittlungsdienst deaktivieren"), ("Change ID", "ID ändern"), ("Website", "Webseite"), diff --git a/src/lang/eo.rs b/src/lang/eo.rs index 18d4e0ba2..cee1975b0 100644 --- a/src/lang/eo.rs +++ b/src/lang/eo.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Ebligi tunelado TCP"), ("IP Whitelisting", "Listo de IP akceptataj"), ("ID/Relay Server", "Identigila/Relajsa servilo"), + ("Import Server Conf", "Enporti servilan agordon"), + ("Import server configuration successfully", "Importi servilan agordon sukcese"), + ("Invalid server configuration", "Nevalida servila agordo"), + ("Clipboard is empty", "La poŝo estas malplena"), ("Stop service", "Haltu servon"), ("Change ID", "Ŝanĝi identigilon"), ("Website", "Retejo"), diff --git a/src/lang/es.rs b/src/lang/es.rs index f6e8b803b..d3da5b402 100644 --- a/src/lang/es.rs +++ b/src/lang/es.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Habilitar tunel TCP"), ("IP Whitelisting", "Lista blanca de IP"), ("ID/Relay Server", "Servidor ID/Relay"), + ("Import Server Conf", "Importar configuración de servidor"), + ("Import server configuration successfully", "Configuración de servidor importada con éxito"), + ("Invalid server configuration", "Configuración de servidor inválida"), + ("Clipboard is empty", "El portapapeles está vacío"), ("Stop service", "Parar servicio"), ("Change ID", "Cambiar ID"), ("Website", "Sitio web"), diff --git a/src/lang/fr.rs b/src/lang/fr.rs index 3dae5053c..70a62e49d 100644 --- a/src/lang/fr.rs +++ b/src/lang/fr.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Activer le tunneling TCP"), ("IP Whitelisting", "Liste blanche IP"), ("ID/Relay Server", "ID/Serveur Relais"), + ("Import Server Conf", "Importer la configuration du serveur"), + ("Import server configuration successfully", "Configuration du serveur importée avec succès"), + ("Invalid server configuration", "Configuration du serveur non valide"), + ("Clipboard is empty", "Presse-papier vide"), ("Stop service", "Arrêter le service"), ("Change ID", "Changer d'ID"), ("Website", "Site Web"), diff --git a/src/lang/hu.rs b/src/lang/hu.rs index 14bd1a895..191165b65 100644 --- a/src/lang/hu.rs +++ b/src/lang/hu.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "TCP Tunneling bekapcsolása"), ("IP Whitelisting", "IP Fehérlista"), ("ID/Relay Server", "ID/Relay Szerver"), + ("Import Server Conf", "Szerver Konfiguráció Importálása"), + ("Import server configuration successfully", "Szerver konfiguráció sikeresen importálva"), + ("Invalid server configuration", "Érvénytelen szerver konfiguráció"), + ("Clipboard is empty", "A vágólap üres"), ("Stop service", "Szolgáltatás Kikapcsolása"), ("Change ID", "ID Megváltoztatása"), ("Website", "Weboldal"), diff --git a/src/lang/id.rs b/src/lang/id.rs index d260e0add..96ac3892b 100644 --- a/src/lang/id.rs +++ b/src/lang/id.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Aktifkan TCP Tunneling"), ("IP Whitelisting", "Daftar Putih IP"), ("ID/Relay Server", "ID/Relay Server"), + ("Import Server Conf", "Impor Konfigurasi Server"), + ("Import server configuration successfully", "Impor konfigurasi server berhasil"), + ("Invalid server configuration", "Konfigurasi server tidak valid"), + ("Clipboard is empty", "Papan klip kosong"), ("Stop service", "Hentikan Layanan"), ("Change ID", "Ubah ID"), ("Website", "Website"), diff --git a/src/lang/it.rs b/src/lang/it.rs index fb8d80435..1954eeaae 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Abilita tunnel TCP"), ("IP Whitelisting", "IP autorizzati"), ("ID/Relay Server", "Server ID/Relay"), + ("Import Server Conf", "Importa configurazione Server"), + ("Import server configuration successfully", "Configurazione Server importata con successo"), + ("Invalid server configuration", "Configurazione Server non valida"), + ("Clipboard is empty", "Gli appunti sono vuoti"), ("Stop service", "Arresta servizio"), ("Change ID", "Cambia ID"), ("Website", "Sito web"), diff --git a/src/lang/ja.rs b/src/lang/ja.rs index 4107760c1..0c11db665 100644 --- a/src/lang/ja.rs +++ b/src/lang/ja.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "TCPトンネリングを有効化"), ("IP Whitelisting", "IPホワイトリスト"), ("ID/Relay Server", "認証・中継サーバー"), + ("Import Server Conf", "サーバー設定をインポート"), + ("Import server configuration successfully", "サーバー設定をインポートしました"), + ("Invalid server configuration", "無効なサーバー設定です"), + ("Clipboard is empty", "クリップボードは空です"), ("Stop service", "サービスを停止"), ("Change ID", "IDを変更"), ("Website", "公式サイト"), diff --git a/src/lang/ko.rs b/src/lang/ko.rs index 9a8ef361d..d59d71dc9 100644 --- a/src/lang/ko.rs +++ b/src/lang/ko.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "TCP 터널링 활성화"), ("IP Whitelisting", "IP 화이트리스트"), ("ID/Relay Server", "ID/Relay 서버"), + ("Import Server Conf", "서버 설정 가져오기"), + ("Import server configuration successfully", "서버 설정 가져오기 성공"), + ("Invalid server configuration", "잘못된 서버 설정"), + ("Clipboard is empty", "클립보드가 비어있습니다"), ("Stop service", "서비스 중단"), ("Change ID", "ID 변경"), ("Website", "웹사이트"), diff --git a/src/lang/kz.rs b/src/lang/kz.rs index 517157c83..b4f29894d 100644 --- a/src/lang/kz.rs +++ b/src/lang/kz.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "TCP тунелдеуді қосу"), ("IP Whitelisting", "IP Ақ-тізімі"), ("ID/Relay Server", "ID/Relay сербері"), + ("Import Server Conf", "Серверді импорттау"), + ("Import server configuration successfully", "Сервердің конфигурациясы сәтті импортталды"), + ("Invalid server configuration", "Жарамсыз сервердің конфигурациясы"), + ("Clipboard is empty", "Көшіру-тақта бос"), ("Stop service", "Сербесті тоқтату"), ("Change ID", "ID ауыстыру"), ("Website", "Web-сайт"), diff --git a/src/lang/pl.rs b/src/lang/pl.rs index 14b95a979..03f030507 100644 --- a/src/lang/pl.rs +++ b/src/lang/pl.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Włącz tunelowanie TCP"), ("IP Whitelisting", "Biała lista IP"), ("ID/Relay Server", "Serwer ID/Pośredniczący"), + ("Import Server Conf", "Importuj konfigurację serwera"), + ("Import server configuration successfully", "Importowanie konfiguracji serwera powiodło się"), + ("Invalid server configuration", "Nieprawidłowa konfiguracja serwera"), + ("Clipboard is empty", "Schowek jest pusty"), ("Stop service", "Zatrzymaj usługę"), ("Change ID", "Zmień ID"), ("Website", "Strona internetowa"), diff --git a/src/lang/pt_PT.rs b/src/lang/pt_PT.rs index 8798c90d9..835fae801 100644 --- a/src/lang/pt_PT.rs +++ b/src/lang/pt_PT.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Activar Túnel TCP"), ("IP Whitelisting", "Whitelist de IP"), ("ID/Relay Server", "Servidor ID/Relay"), + ("Import Server Conf", "Importar Configuração do Servidor"), + ("Import server configuration successfully", "Configuração do servidor importada com sucesso"), + ("Invalid server configuration", "Configuração do servidor inválida"), + ("Clipboard is empty", "A área de transferência está vazia"), ("Stop service", "Parar serviço"), ("Change ID", "Alterar ID"), ("Website", "Website"), diff --git a/src/lang/ptbr.rs b/src/lang/ptbr.rs index d59eb0624..280390d7f 100644 --- a/src/lang/ptbr.rs +++ b/src/lang/ptbr.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Habilitar Tunelamento TCP"), ("IP Whitelisting", "Whitelist de IP"), ("ID/Relay Server", "Servidor ID/Relay"), + ("Import Server Conf", "Importar Configuração do Servidor"), + ("Import server configuration successfully", "Configuração do servidor importada com sucesso"), + ("Invalid server configuration", "Configuração do servidor inválida"), + ("Clipboard is empty", "A área de transferência está vazia"), ("Stop service", "Parar serviço"), ("Change ID", "Alterar ID"), ("Website", "Website"), diff --git a/src/lang/ru.rs b/src/lang/ru.rs index b04a80de0..7784d74f0 100644 --- a/src/lang/ru.rs +++ b/src/lang/ru.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Включить туннелирование TCP"), ("IP Whitelisting", "Список разрешенных IP-адресов"), ("ID/Relay Server", "ID/Сервер ретрансляции"), + ("Import Server Conf", "Импортировать конфигурацию сервера"), + ("Import server configuration successfully", "Конфигурация сервера успешно импортирована"), + ("Invalid server configuration", "Недопустимая конфигурация сервера"), + ("Clipboard is empty", "Буфер обмена пуст"), ("Stop service", "Остановить службу"), ("Change ID", "Изменить ID"), ("Website", "Веб-сайт"), diff --git a/src/lang/sk.rs b/src/lang/sk.rs index ec93850fe..0319ddc68 100644 --- a/src/lang/sk.rs +++ b/src/lang/sk.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Povoliť TCP tunelovanie"), ("IP Whitelisting", "Zoznam povolených IP adries"), ("ID/Relay Server", "ID/Prepojovací server"), + ("Import Server Conf", "Importovať konfiguráciu servera"), + ("Import server configuration successfully", "Konfigurácia servera bola úspešne importovaná"), + ("Invalid server configuration", "Neplatná konfigurácia servera"), + ("Clipboard is empty", "Schránka je prázdna"), ("Stop service", "Zastaviť službu"), ("Change ID", "Zmeniť ID"), ("Website", "Webová stránka"), diff --git a/src/lang/template.rs b/src/lang/template.rs index 666e1cf02..b292f917c 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", ""), ("IP Whitelisting", ""), ("ID/Relay Server", ""), + ("Import server configuration successfully", ""), + ("Import Server Conf", ""), + ("Invalid server configuration", ""), + ("Clipboard is empty", ""), ("Stop service", ""), ("Change ID", ""), ("Website", ""), diff --git a/src/lang/tr.rs b/src/lang/tr.rs index 935faea84..1a7912f23 100644 --- a/src/lang/tr.rs +++ b/src/lang/tr.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "TCP Tüneline izin ver"), ("IP Whitelisting", "İzinli IP listesi"), ("ID/Relay Server", "ID/Relay Sunucusu"), + ("Import Server Conf", "Sunucu ayarlarını içe aktar"), + ("Import server configuration successfully", "Sunucu ayarları başarıyla içe aktarıldı"), + ("Invalid server configuration", "Geçersiz sunucu ayarı"), + ("Clipboard is empty", "Kopyalanan geçici veri boş"), ("Stop service", "Servisi Durdur"), ("Change ID", "ID Değiştir"), ("Website", "Website"), diff --git a/src/lang/tw.rs b/src/lang/tw.rs index 9e3a040da..b588f2a33 100644 --- a/src/lang/tw.rs +++ b/src/lang/tw.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "啟用 TCP 通道"), ("IP Whitelisting", "IP 白名單"), ("ID/Relay Server", "ID/轉送伺服器"), + ("Import Server Conf", "匯入伺服器設定"), + ("Import server configuration successfully", "匯入伺服器設定成功"), + ("Invalid server configuration", "無效的伺服器設定"), + ("Clipboard is empty", "剪貼簿是空的"), ("Stop service", "停止服務"), ("Change ID", "更改 ID"), ("Website", "網站"), diff --git a/src/lang/ua.rs b/src/lang/ua.rs index 32f818911..3a5c4afd6 100644 --- a/src/lang/ua.rs +++ b/src/lang/ua.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Увімкнути тунелювання TCP"), ("IP Whitelisting", "Список дозволених IP-адрес"), ("ID/Relay Server", "ID/Сервер ретрансляції"), + ("Import Server Conf", "Імпортувати конфігурацію сервера"), + ("Import server configuration successfully", "Конфігурацію сервера успішно імпортовано"), + ("Invalid server configuration", "Недійсна конфігурація сервера"), + ("Clipboard is empty", "Буфер обміну порожній"), ("Stop service", "Зупинити службу"), ("Change ID", "Змінити ID"), ("Website", "Веб-сайт"), diff --git a/src/lang/vn.rs b/src/lang/vn.rs index 9310c90b7..c245bdd75 100644 --- a/src/lang/vn.rs +++ b/src/lang/vn.rs @@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Enable TCP Tunneling", "Cho phép TCP Tunneling"), ("IP Whitelisting", "Cho phép IP"), ("ID/Relay Server", "Máy chủ ID/Relay"), + ("Import Server Conf", "Nhập cấu hình máy chủ"), + ("Import server configuration successfully", "Nhập cấu hình máy chủ thành công"), + ("Invalid server configuration", "Cấu hình máy chủ không hợp lệ"), + ("Clipboard is empty", "Khay nhớ tạm trống"), ("Stop service", "Dừng dịch vụ"), ("Change ID", "Thay đổi ID"), ("Website", "Trang web"), From 9a5c0b610bda1412252d66e7d64a3281931df422 Mon Sep 17 00:00:00 2001 From: Cooper Liu Date: Thu, 13 Oct 2022 11:29:35 +0800 Subject: [PATCH 2/2] modify print to debugPrint --- .../desktop/pages/desktop_setting_page.dart | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 45b1b9a85..bc0eb7b67 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -1446,7 +1446,7 @@ void importServer() async { if (idServerMsg.isEmpty) { oldOptions['custom-rendezvous-server'] = idServer; } else { - print('ID Server invalid return'); + debugPrint('ID Server invalid return'); return false; } } else { @@ -1459,7 +1459,7 @@ void importServer() async { if (relayServerMsg.isEmpty) { oldOptions['relay-server'] = relayServer; } else { - print('Relay Server invalid return'); + debugPrint('Relay Server invalid return'); return false; } } else { @@ -1471,7 +1471,7 @@ void importServer() async { oldOptions['api-server'] = apiServer; return false; } else { - print('invalid_http'); + debugPrint('invalid_http'); return false; } } else { @@ -1480,7 +1480,7 @@ void importServer() async { // ok oldOptions['key'] = key; await bind.mainSetOptions(json: jsonEncode(oldOptions)); - print("set ID/Realy Server Ok"); + debugPrint("set ID/Realy Server Ok"); return true; } @@ -1490,16 +1490,15 @@ void importServer() async { aNullableString = value?.text; mytext.text = aNullableString.toString(); if (mytext.text.isNotEmpty) { - print('Clipboard is not empty'); + debugPrint('Clipboard is not empty'); try { Map config = jsonDecode(mytext.text); - print(config); if (config.containsKey('IdServer') && config.containsKey('RelayServer')) { - print('IdServer: ${config['IdServer']}'); - print('RelayServer: ${config['RelayServer']}'); - print('ApiServer: ${config['ApiServer']}'); - print('Key: ${config['Key']}'); + debugPrint('IdServer: ${config['IdServer']}'); + debugPrint('RelayServer: ${config['RelayServer']}'); + debugPrint('ApiServer: ${config['ApiServer']}'); + debugPrint('Key: ${config['Key']}'); Future success = submit(config['IdServer'], config['RelayServer'], config['ApiServer'], config['Key']); success.then((value) { @@ -1511,15 +1510,15 @@ void importServer() async { } }); } else { - print('invalid config info'); + debugPrint('invalid config info'); importServerShow(translate("Invalid server configuration")); } } catch (e) { - print('invalid config info'); + debugPrint('invalid config info'); importServerShow(translate("Invalid server configuration")); } } else { - print('Clipboard is empty'); + debugPrint('Clipboard is empty'); importServerShow(translate("Clipboard is empty")); } });