From 227caf3d2e3e2844d7f509c873c24d1b49372b49 Mon Sep 17 00:00:00 2001 From: driftinblock <3480428251@qq.com> Date: Thu, 27 Aug 2026 16:02:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=9B=B4=E6=96=B0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=8E=B7=E5=8F=96=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/minecraft_manager/MainActivity.kt | 2 +- lib/core/utils/command_preset_service.dart | 3 +-- lib/core/utils/update_service.dart | 27 +++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/android/app/src/main/kotlin/com/minecraft_manager/MainActivity.kt b/android/app/src/main/kotlin/com/minecraft_manager/MainActivity.kt index 6aecc6b..32df2dc 100644 --- a/android/app/src/main/kotlin/com/minecraft_manager/MainActivity.kt +++ b/android/app/src/main/kotlin/com/minecraft_manager/MainActivity.kt @@ -87,7 +87,7 @@ class MainActivity : FlutterActivity() { file.delete() val connection = java.net.URL(url).openConnection() - connection.setRequestProperty("User-Agent", "MCServerManager") + connection.setRequestProperty("User-Agent", "ZVManager") connection.connectTimeout = 15_000 connection.readTimeout = 30_000 val total = connection.contentLengthLong diff --git a/lib/core/utils/command_preset_service.dart b/lib/core/utils/command_preset_service.dart index 29a8f52..b9121f2 100644 --- a/lib/core/utils/command_preset_service.dart +++ b/lib/core/utils/command_preset_service.dart @@ -30,7 +30,6 @@ class CommandPresetService { QuickCommandPreset(label: '设为白天', command: 'time set day'), QuickCommandPreset(label: '设为黑夜', command: 'time set night'), QuickCommandPreset(label: '和平难度', command: 'difficulty peaceful'), - QuickCommandPreset(label: '生存模式', command: 'gamemode survival'), QuickCommandPreset(label: '白名单列表', command: 'whitelist list'), QuickCommandPreset(label: '在线公告', command: 'say 服务器已在线,欢迎游玩!'), ]; @@ -55,4 +54,4 @@ class CommandPresetService { final encoded = jsonEncode(presets.map((p) => p.toJson()).toList()); await prefs.setString(_key, encoded); } -} \ No newline at end of file +} diff --git a/lib/core/utils/update_service.dart b/lib/core/utils/update_service.dart index 9ed8d7f..7250a93 100644 --- a/lib/core/utils/update_service.dart +++ b/lib/core/utils/update_service.dart @@ -22,13 +22,14 @@ class UpdateService { /// Gitee 仓库最新发布信息地址 static const _updateInfoUrl = - 'https://gitee.com/api/v5/repos/venti1112/mcserver_manager/releases/latest'; + 'https://gitee.com/api/v5/repos/driftinblock/zvmanager/releases/latest'; /// Android 原生下载安装通道 static const _channel = MethodChannel('mc_server_manager/update'); /// 下载进度事件通道(原生推送) - static const _progressChannel = EventChannel('mc_server_manager/down_progress'); + static const _progressChannel = + EventChannel('mc_server_manager/down_progress'); /// 是否正在下载,用于防止重复触发并发下载到同一文件。 static bool _downloading = false; @@ -50,8 +51,7 @@ class UpdateService { final json = jsonDecode(body) as Map; // Gitee 发布接口的 tag_name 形如 "v1.3.0",去掉开头的 "v" 用于版本号对比 final tag = json['tag_name'] as String? ?? ''; - final latestVersion = - tag.startsWith('v') ? tag.substring(1) : tag; + final latestVersion = tag.startsWith('v') ? tag.substring(1) : tag; // 从 assets 中筛选 APK 安装包,取其直链与文件名 String downloadUrl = ''; @@ -60,10 +60,9 @@ class UpdateService { for (final item in assets) { final name = (item as Map)['name'] as String? ?? ''; if (name.endsWith('.apk')) { - downloadUrl = - (item['browser_download_url'] as String? ?? - item['download_url'] as String? ?? - ''); + downloadUrl = (item['browser_download_url'] as String? ?? + item['download_url'] as String? ?? + ''); apkName = name; break; } @@ -97,7 +96,8 @@ class UpdateService { ? '最新版本: ${info.latestVersion}\n当前版本: $currentVersion' : '当前版本 $currentVersion 已是最新'), actions: [ - TextButton(onPressed: () => Navigator.pop(context), child: const Text('关闭')), + TextButton( + onPressed: () => Navigator.pop(context), child: const Text('关闭')), if (hasUpdate) FilledButton( onPressed: () { @@ -112,7 +112,8 @@ class UpdateService { } /// 调用 Android 原生下载 APK 并调起系统安装器;下载期间展示不可关闭的进度弹窗,失败提示错误。 - static Future downloadAndInstall(BuildContext context, UpdateInfo info) async { + static Future downloadAndInstall( + BuildContext context, UpdateInfo info) async { if (_downloading) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('正在下载,请稍候…')), @@ -162,9 +163,7 @@ class UpdateService { CircularProgressIndicator(value: value), const SizedBox(height: 16), Text( - percent == null - ? '正在下载安装包…' - : '下载中:$percent%', + percent == null ? '正在下载安装包…' : '下载中:$percent%', style: Theme.of(context).textTheme.bodyMedium, ), ], @@ -199,4 +198,4 @@ class UpdateService { _downloading = false; } } -} \ No newline at end of file +}