From 213330239743058c3f147f61d63faf6d5a10ace7 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Tue, 7 Nov 2023 18:10:38 +0800 Subject: [PATCH] new: `delete scripts` when delete server --- .dart_tool/flutter_gen/gen_l10n/l10n.dart | 6 ++ .dart_tool/flutter_gen/gen_l10n/l10n_de.dart | 3 + .dart_tool/flutter_gen/gen_l10n/l10n_en.dart | 3 + .dart_tool/flutter_gen/gen_l10n/l10n_id.dart | 3 + .dart_tool/flutter_gen/gen_l10n/l10n_zh.dart | 6 ++ ios/Podfile.lock | 14 ++-- ios/Runner.xcodeproj/project.pbxproj | 36 +++++----- lib/core/persistant_store.dart | 2 +- lib/data/model/app/shell_func.dart | 12 ++-- lib/data/res/build_data.dart | 6 +- lib/l10n/app_de.arb | 1 + lib/l10n/app_en.arb | 1 + lib/l10n/app_id.arb | 1 + lib/l10n/app_zh.arb | 1 + lib/l10n/app_zh_tw.arb | 1 + lib/view/page/home.dart | 2 +- lib/view/page/server/edit.dart | 75 ++++++++++++++------ 17 files changed, 117 insertions(+), 56 deletions(-) diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n.dart b/.dart_tool/flutter_gen/gen_l10n/l10n.dart index 2344f10f..ea00e08b 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n.dart @@ -368,6 +368,12 @@ abstract class S { /// **'Delete'** String get delete; + /// No description provided for @deleteScripts. + /// + /// In en, this message translates to: + /// **'Delete scripts'** + String get deleteScripts; + /// No description provided for @deleteServers. /// /// In en, this message translates to: diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart index b654c2c3..4e7716fa 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart @@ -141,6 +141,9 @@ class SDe extends S { @override String get delete => 'Löschen'; + @override + String get deleteScripts => 'Skripte löschen'; + @override String get deleteServers => 'Batch-Löschung von Servern'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart index 0e5b36e4..fd602602 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart @@ -141,6 +141,9 @@ class SEn extends S { @override String get delete => 'Delete'; + @override + String get deleteScripts => 'Delete scripts'; + @override String get deleteServers => 'Batch delete servers'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart index 701d12b0..ef981888 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart @@ -141,6 +141,9 @@ class SId extends S { @override String get delete => 'Menghapus'; + @override + String get deleteScripts => 'Menghapus skrip'; + @override String get deleteServers => 'Penghapusan server secara batch'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart index 6f120538..097825c7 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart @@ -141,6 +141,9 @@ class SZh extends S { @override String get delete => '删除'; + @override + String get deleteScripts => '同时删除服务器脚本'; + @override String get deleteServers => '批量删除服务器'; @@ -927,6 +930,9 @@ class SZhTw extends SZh { @override String get delete => '刪除'; + @override + String get deleteScripts => '同時刪除服務器腳本'; + @override String get deleteServers => '批量刪除服務器'; diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 14943cee..231dfafb 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,11 +1,13 @@ PODS: - - countly_flutter (23.8.1): + - countly_flutter (23.8.3): - Flutter - file_picker (0.0.1): - Flutter - Flutter (1.0.0) - flutter_native_splash (0.0.1): - Flutter + - flutter_secure_storage (6.0.0): + - Flutter - icloud_storage (0.0.1): - Flutter - local_auth_ios (0.0.1): @@ -32,6 +34,7 @@ DEPENDENCIES: - file_picker (from `.symlinks/plugins/file_picker/ios`) - Flutter (from `Flutter`) - flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`) + - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - icloud_storage (from `.symlinks/plugins/icloud_storage/ios`) - local_auth_ios (from `.symlinks/plugins/local_auth_ios/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) @@ -51,6 +54,8 @@ EXTERNAL SOURCES: :path: Flutter flutter_native_splash: :path: ".symlinks/plugins/flutter_native_splash/ios" + flutter_secure_storage: + :path: ".symlinks/plugins/flutter_secure_storage/ios" icloud_storage: :path: ".symlinks/plugins/icloud_storage/ios" local_auth_ios: @@ -71,18 +76,19 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/watch_connectivity/ios" SPEC CHECKSUMS: - countly_flutter: 9024d787ff03c4a2882bca3578edee80901b4289 + countly_flutter: 5929a8a751abbd19a26e6a667d374eb7b8878636 file_picker: 1d63c4949e05e386da864365f8c13e1e64787675 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef + flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be icloud_storage: d9ac7a33ced81df08ba7ea1bf3099cc0ee58f60a local_auth_ios: c6cf091ded637a88f24f86a8875d8b0f526e2605 path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 plain_notification_token: b36467dc91939a7b6754267c701bbaca14996ee1 r_upgrade: 44d715c61914cce3d01ea225abffe894fd51c114 - share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028 + share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5 shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 - url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 + url_launcher_ios: 68d46cc9766d0c41dbdc884310529557e3cd7a86 watch_connectivity: 715eb484685e05846eab74795348a44bb2809b82 PODFILE CHECKSUM: 7fb15c416f8685fca4966867a8da218ec592ec2e diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2a3ce72d..57a07cb0 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -586,7 +586,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -596,7 +596,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -720,7 +720,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -730,7 +730,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -748,7 +748,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -758,7 +758,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -779,7 +779,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -792,7 +792,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -818,7 +818,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -831,7 +831,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -854,7 +854,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -867,7 +867,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -890,7 +890,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -902,7 +902,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; @@ -931,7 +931,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -943,7 +943,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; @@ -969,7 +969,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 630; + CURRENT_PROJECT_VERSION = 634; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -981,7 +981,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.630; + MARKETING_VERSION = 1.0.634; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; diff --git a/lib/core/persistant_store.dart b/lib/core/persistant_store.dart index 69ebaf7d..73f7f3f1 100644 --- a/lib/core/persistant_store.dart +++ b/lib/core/persistant_store.dart @@ -11,7 +11,7 @@ class SecureStore { SecureStore._(); static const _secureStorage = FlutterSecureStorage(); - + static HiveAesCipher? _cipher; static const _hiveKey = 'hive_key'; diff --git a/lib/data/model/app/shell_func.dart b/lib/data/model/app/shell_func.dart index fb39fc95..3d9d975f 100644 --- a/lib/data/model/app/shell_func.dart +++ b/lib/data/model/app/shell_func.dart @@ -16,8 +16,8 @@ enum ShellFunc { suspend, ; - static const _serverBoxDir = '.config/server_box'; - static const _scriptFileName = 'mobile_v${BuildData.script}.sh'; + static const _srvBoxDir = '.config/server_box'; + static const _scriptFile = 'mobile_v${BuildData.script}.sh'; /// Issue #159 /// @@ -26,15 +26,15 @@ enum ShellFunc { /// So different version of app can run at the same time. /// /// **Can't** use it in SFTP, because SFTP can't recognize `$HOME` - static String getShellPath(String home) => - '$home/$_serverBoxDir/$_scriptFileName'; + static String getShellPath(String home) => '$home/$_srvBoxDir/$_scriptFile'; - static final _installShellPath = getShellPath(_homeVar); + static const srvBoxDir = '$_homeVar/$_srvBoxDir'; + static const _installShellPath = '$_homeVar/$_srvBoxDir/$_scriptFile'; /// Issue #168 /// Use `sh` for compatibility static final installShellCmd = """ -mkdir -p $_homeVar/$_serverBoxDir +mkdir -p $_homeVar/$_srvBoxDir cat << 'EOF' > $_installShellPath ${ShellFunc.allScript} EOF diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 129ad783..55337501 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 630; + static const int build = 634; static const String engine = "3.13.8"; - static const String buildAt = "2023-11-02 13:45:05"; - static const int modifications = 1; + static const String buildAt = "2023-11-03 22:14:11"; + static const int modifications = 2; static const int script = 25; } diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 7c378ca6..135b96a7 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -45,6 +45,7 @@ "decode": "Decode", "decompress": "Dekomprimieren", "delete": "Löschen", + "deleteScripts": "Gleichzeitiges Löschen von Server-Skripten", "deleteServers": "Batch-Löschung von Servern", "dirEmpty": "Stelle sicher, dass der Ordner leer ist.", "disabled": "Behinderte", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index db3d627d..188d048a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -45,6 +45,7 @@ "decode": "Decode", "decompress": "Decompress", "delete": "Delete", + "deleteScripts": "Delete server scripts at the same time", "deleteServers": "Batch delete servers", "dirEmpty": "Make sure dir is empty.", "disabled": "Disabled", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index a44572fc..94961af1 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -45,6 +45,7 @@ "decode": "Membaca sandi", "decompress": "Dekompresi", "delete": "Menghapus", + "deleteScripts": "Menghapus skrip server secara bersamaan", "deleteServers": "Penghapusan server secara batch", "dirEmpty": "Pastikan dir kosong.", "disabled": "Dengan disabilitas", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 9ac1b2ff..5c909ae9 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -45,6 +45,7 @@ "decode": "解码", "decompress": "解压缩", "delete": "删除", + "deleteScripts": "同时删除服务器脚本", "deleteServers": "批量删除服务器", "dirEmpty": "请确保文件夹为空", "disabled": "已禁用", diff --git a/lib/l10n/app_zh_tw.arb b/lib/l10n/app_zh_tw.arb index eeda2c68..1f68b667 100644 --- a/lib/l10n/app_zh_tw.arb +++ b/lib/l10n/app_zh_tw.arb @@ -45,6 +45,7 @@ "decode": "解碼", "decompress": "解壓縮", "delete": "刪除", + "deleteScripts": "同時刪除服務器腳本", "deleteServers": "批量刪除服務器", "dirEmpty": "請確保文件夾為空", "disabled": "已禁用", diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index 6b4c0ca2..a0e78b92 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -96,7 +96,7 @@ class _HomePageState extends State BgRunMC.moveToBg(); } } else { - Pros.server.setDisconnected(); + //Pros.server.setDisconnected(); Pros.server.stopAutoRefresh(); } break; diff --git a/lib/view/page/server/edit.dart b/lib/view/page/server/edit.dart index 6d8382df..f7217c3d 100644 --- a/lib/view/page/server/edit.dart +++ b/lib/view/page/server/edit.dart @@ -4,6 +4,7 @@ import 'package:toolbox/core/extension/context/common.dart'; import 'package:toolbox/core/extension/context/dialog.dart'; import 'package:toolbox/core/extension/context/locale.dart'; import 'package:toolbox/core/extension/context/snackbar.dart'; +import 'package:toolbox/data/model/app/shell_func.dart'; import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/view/widget/expand_tile.dart'; @@ -107,31 +108,59 @@ class _ServerEditPageState extends State { } PreferredSizeWidget _buildAppBar() { - final delBtn = IconButton( - onPressed: () { - context.showRoundDialog( - title: Text(l10n.attention), - child: Text(l10n.askContinue( - '${l10n.delete} ${l10n.server}(${widget.spi!.name})', - )), - actions: [ - TextButton( - onPressed: () { - Pros.server.delServer(widget.spi!.id); - context.pop(); - context.pop(true); - }, - child: Text(l10n.ok, style: UIs.textRed), - ), - ], - ); - }, - icon: const Icon(Icons.delete), - ); - final actions = widget.spi != null ? [delBtn] : null; return CustomAppBar( title: Text(l10n.edit, style: UIs.textSize18), - actions: actions, + actions: widget.spi != null + ? [ + IconButton( + onPressed: () { + var delScripts = false; + context.showRoundDialog( + title: Text(l10n.attention), + child: StatefulBuilder(builder: (ctx, setState) { + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(l10n.askContinue( + '${l10n.delete} ${l10n.server}(${widget.spi!.name})', + )), + UIs.height13, + Row( + children: [ + Checkbox( + value: delScripts, + onChanged: (_) => setState( + () => delScripts = !delScripts, + ), + ), + Text(l10n.deleteScripts), + ], + ) + ], + ); + }), + actions: [ + TextButton( + onPressed: () async { + if (delScripts) { + const cmd = + 'rm ${ShellFunc.srvBoxDir}/mobile_v*.sh'; + await widget.spi?.server?.client?.run(cmd); + } + Pros.server.delServer(widget.spi!.id); + context.pop(); + context.pop(true); + }, + child: Text(l10n.ok, style: UIs.textRed), + ), + ], + ); + }, + icon: const Icon(Icons.delete), + ), + ] + : null, ); }