diff --git a/ui/flutter/lib/api/model/downloader_config.dart b/ui/flutter/lib/api/model/downloader_config.dart index 9eea24996..0a5e58fca 100644 --- a/ui/flutter/lib/api/model/downloader_config.dart +++ b/ui/flutter/lib/api/model/downloader_config.dart @@ -79,6 +79,7 @@ class ExtraConfig { String themeMode; String locale; bool lastDeleteTaskKeep; + bool defaultDirectDownload; ExtraConfigBt bt = ExtraConfigBt(); @@ -86,6 +87,7 @@ class ExtraConfig { this.themeMode = '', this.locale = '', this.lastDeleteTaskKeep = false, + this.defaultDirectDownload = false, }); factory ExtraConfig.fromJson(Map? json) => diff --git a/ui/flutter/lib/api/model/downloader_config.g.dart b/ui/flutter/lib/api/model/downloader_config.g.dart index 7d7449e13..ee78f1b4e 100644 --- a/ui/flutter/lib/api/model/downloader_config.g.dart +++ b/ui/flutter/lib/api/model/downloader_config.g.dart @@ -72,6 +72,7 @@ ExtraConfig _$ExtraConfigFromJson(Map json) => ExtraConfig( themeMode: json['themeMode'] as String? ?? '', locale: json['locale'] as String? ?? '', lastDeleteTaskKeep: json['lastDeleteTaskKeep'] as bool? ?? false, + defaultDirectDownload: json['defaultDirectDownload'] as bool? ?? false, )..bt = ExtraConfigBt.fromJson(json['bt'] as Map); Map _$ExtraConfigToJson(ExtraConfig instance) => @@ -79,6 +80,7 @@ Map _$ExtraConfigToJson(ExtraConfig instance) => 'themeMode': instance.themeMode, 'locale': instance.locale, 'lastDeleteTaskKeep': instance.lastDeleteTaskKeep, + 'defaultDirectDownload': instance.defaultDirectDownload, 'bt': instance.bt.toJson(), }; diff --git a/ui/flutter/lib/app/modules/create/controllers/create_controller.dart b/ui/flutter/lib/app/modules/create/controllers/create_controller.dart index 6884c0ebe..9b22d904d 100644 --- a/ui/flutter/lib/app/modules/create/controllers/create_controller.dart +++ b/ui/flutter/lib/app/modules/create/controllers/create_controller.dart @@ -5,6 +5,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:gopeed/api/model/request.dart'; +import '../../app/controllers/app_controller.dart'; + class CreateController extends GetxController with GetSingleTickerProviderStateMixin { // final files = [].obs; @@ -23,6 +25,11 @@ class CreateController extends GetxController void onInit() { super.onInit(); advancedTabController = TabController(length: 2, vsync: this); + directDownload.value = Get.find() + .downloaderConfig + .value + .extra + .defaultDirectDownload; } @override diff --git a/ui/flutter/lib/app/modules/setting/views/setting_view.dart b/ui/flutter/lib/app/modules/setting/views/setting_view.dart index 02b6a29dd..afa7e231d 100644 --- a/ui/flutter/lib/app/modules/setting/views/setting_view.dart +++ b/ui/flutter/lib/app/modules/setting/views/setting_view.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:badges/badges.dart' as badges; import 'package:flutter/material.dart'; -import 'package:path/path.dart' as path; import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:gopeed/app/views/copy_button.dart'; @@ -110,6 +109,28 @@ class SettingView extends GetView { ], ); }); + + final buildDefaultDirectDownload = + _buildConfigItem('defaultDirectDownload'.tr, () { + return appController.downloaderConfig.value.extra.defaultDirectDownload + ? 'on'.tr + : 'off'.tr; + }, (Key key) { + return Container( + alignment: Alignment.centerLeft, + child: Switch( + value: + appController.downloaderConfig.value.extra.defaultDirectDownload, + onChanged: (bool value) async { + appController.downloaderConfig.update((val) { + val!.extra.defaultDirectDownload = value; + }); + await debounceSave(); + }, + ), + ); + }); + buildBrowserExtension() { return ListTile( title: Text('browserExtension'.tr), @@ -904,6 +925,7 @@ class SettingView extends GetView { children: _addDivider([ buildDownloadDir(), buildMaxRunning(), + buildDefaultDirectDownload(), buildBrowserExtension(), buildAutoStartup(), ]), diff --git a/ui/flutter/lib/i18n/langs/en_us.dart b/ui/flutter/lib/i18n/langs/en_us.dart index 32560eb05..c1dfad697 100644 --- a/ui/flutter/lib/i18n/langs/en_us.dart +++ b/ui/flutter/lib/i18n/langs/en_us.dart @@ -36,6 +36,7 @@ const enUS = { 'connections': 'Connections', 'useServerCtime': 'Use server time for file creation', 'maxRunning': 'Max Running Tasks', + 'defaultDirectDownload': 'Check direct download by default', 'items': '@count items', 'subscribeTracker': 'Subscribe Tracker', 'subscribeFail': diff --git a/ui/flutter/lib/i18n/langs/zh_cn.dart b/ui/flutter/lib/i18n/langs/zh_cn.dart index ebdb53267..b65e2c44a 100644 --- a/ui/flutter/lib/i18n/langs/zh_cn.dart +++ b/ui/flutter/lib/i18n/langs/zh_cn.dart @@ -35,6 +35,7 @@ const zhCN = { 'connections': '连接数', 'useServerCtime': '创建文件使用服务器时间', 'maxRunning': '最大下载数', + 'defaultDirectDownload': '默认勾选直接下载', 'items': '@count 项', 'subscribeTracker': '订阅 Tracker', 'subscribeFail': '订阅失败,请检查网络或稍后重试', diff --git a/ui/flutter/lib/i18n/langs/zh_tw.dart b/ui/flutter/lib/i18n/langs/zh_tw.dart index f56ea5d94..c48aa4582 100644 --- a/ui/flutter/lib/i18n/langs/zh_tw.dart +++ b/ui/flutter/lib/i18n/langs/zh_tw.dart @@ -35,6 +35,7 @@ const zhTW = { 'connections': '連接數', 'useServerCtime': '使用伺服器時間作為檔案建立時間', 'maxRunning': '最大執行任務數', + 'defaultDirectDownload': '預設勾選直接下載', 'items': '@count 個項目', 'subscribeTracker': '訂閱 Tracker', 'subscribeFail': '訂閱失敗,請檢查網路或稍後再試',