mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-17 22:03:41 +00:00
feat: support default direct download config (#735)
This commit is contained in:
7 files changed
+37
-1
No files matched your search
@@ -79,6 +79,7 @@ class ExtraConfig {
|
|||||||
String themeMode;
|
String themeMode;
|
||||||
String locale;
|
String locale;
|
||||||
bool lastDeleteTaskKeep;
|
bool lastDeleteTaskKeep;
|
||||||
|
bool defaultDirectDownload;
|
||||||
|
|
||||||
ExtraConfigBt bt = ExtraConfigBt();
|
ExtraConfigBt bt = ExtraConfigBt();
|
||||||
|
|
||||||
@@ -86,6 +87,7 @@ class ExtraConfig {
|
|||||||
this.themeMode = '',
|
this.themeMode = '',
|
||||||
this.locale = '',
|
this.locale = '',
|
||||||
this.lastDeleteTaskKeep = false,
|
this.lastDeleteTaskKeep = false,
|
||||||
|
this.defaultDirectDownload = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ExtraConfig.fromJson(Map<String, dynamic>? json) =>
|
factory ExtraConfig.fromJson(Map<String, dynamic>? json) =>
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ ExtraConfig _$ExtraConfigFromJson(Map<String, dynamic> json) => ExtraConfig(
|
|||||||
themeMode: json['themeMode'] as String? ?? '',
|
themeMode: json['themeMode'] as String? ?? '',
|
||||||
locale: json['locale'] as String? ?? '',
|
locale: json['locale'] as String? ?? '',
|
||||||
lastDeleteTaskKeep: json['lastDeleteTaskKeep'] as bool? ?? false,
|
lastDeleteTaskKeep: json['lastDeleteTaskKeep'] as bool? ?? false,
|
||||||
|
defaultDirectDownload: json['defaultDirectDownload'] as bool? ?? false,
|
||||||
)..bt = ExtraConfigBt.fromJson(json['bt'] as Map<String, dynamic>);
|
)..bt = ExtraConfigBt.fromJson(json['bt'] as Map<String, dynamic>);
|
||||||
|
|
||||||
Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) =>
|
Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) =>
|
||||||
@@ -79,6 +80,7 @@ Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) =>
|
|||||||
'themeMode': instance.themeMode,
|
'themeMode': instance.themeMode,
|
||||||
'locale': instance.locale,
|
'locale': instance.locale,
|
||||||
'lastDeleteTaskKeep': instance.lastDeleteTaskKeep,
|
'lastDeleteTaskKeep': instance.lastDeleteTaskKeep,
|
||||||
|
'defaultDirectDownload': instance.defaultDirectDownload,
|
||||||
'bt': instance.bt.toJson(),
|
'bt': instance.bt.toJson(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:gopeed/api/model/request.dart';
|
import 'package:gopeed/api/model/request.dart';
|
||||||
|
|
||||||
|
import '../../app/controllers/app_controller.dart';
|
||||||
|
|
||||||
class CreateController extends GetxController
|
class CreateController extends GetxController
|
||||||
with GetSingleTickerProviderStateMixin {
|
with GetSingleTickerProviderStateMixin {
|
||||||
// final files = [].obs;
|
// final files = [].obs;
|
||||||
@@ -23,6 +25,11 @@ class CreateController extends GetxController
|
|||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
advancedTabController = TabController(length: 2, vsync: this);
|
advancedTabController = TabController(length: 2, vsync: this);
|
||||||
|
directDownload.value = Get.find<AppController>()
|
||||||
|
.downloaderConfig
|
||||||
|
.value
|
||||||
|
.extra
|
||||||
|
.defaultDirectDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:badges/badges.dart' as badges;
|
import 'package:badges/badges.dart' as badges;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:path/path.dart' as path;
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:gopeed/app/views/copy_button.dart';
|
import 'package:gopeed/app/views/copy_button.dart';
|
||||||
@@ -110,6 +109,28 @@ class SettingView extends GetView<SettingController> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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() {
|
buildBrowserExtension() {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text('browserExtension'.tr),
|
title: Text('browserExtension'.tr),
|
||||||
@@ -904,6 +925,7 @@ class SettingView extends GetView<SettingController> {
|
|||||||
children: _addDivider([
|
children: _addDivider([
|
||||||
buildDownloadDir(),
|
buildDownloadDir(),
|
||||||
buildMaxRunning(),
|
buildMaxRunning(),
|
||||||
|
buildDefaultDirectDownload(),
|
||||||
buildBrowserExtension(),
|
buildBrowserExtension(),
|
||||||
buildAutoStartup(),
|
buildAutoStartup(),
|
||||||
]),
|
]),
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ const enUS = {
|
|||||||
'connections': 'Connections',
|
'connections': 'Connections',
|
||||||
'useServerCtime': 'Use server time for file creation',
|
'useServerCtime': 'Use server time for file creation',
|
||||||
'maxRunning': 'Max Running Tasks',
|
'maxRunning': 'Max Running Tasks',
|
||||||
|
'defaultDirectDownload': 'Check direct download by default',
|
||||||
'items': '@count items',
|
'items': '@count items',
|
||||||
'subscribeTracker': 'Subscribe Tracker',
|
'subscribeTracker': 'Subscribe Tracker',
|
||||||
'subscribeFail':
|
'subscribeFail':
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const zhCN = {
|
|||||||
'connections': '连接数',
|
'connections': '连接数',
|
||||||
'useServerCtime': '创建文件使用服务器时间',
|
'useServerCtime': '创建文件使用服务器时间',
|
||||||
'maxRunning': '最大下载数',
|
'maxRunning': '最大下载数',
|
||||||
|
'defaultDirectDownload': '默认勾选直接下载',
|
||||||
'items': '@count 项',
|
'items': '@count 项',
|
||||||
'subscribeTracker': '订阅 Tracker',
|
'subscribeTracker': '订阅 Tracker',
|
||||||
'subscribeFail': '订阅失败,请检查网络或稍后重试',
|
'subscribeFail': '订阅失败,请检查网络或稍后重试',
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const zhTW = {
|
|||||||
'connections': '連接數',
|
'connections': '連接數',
|
||||||
'useServerCtime': '使用伺服器時間作為檔案建立時間',
|
'useServerCtime': '使用伺服器時間作為檔案建立時間',
|
||||||
'maxRunning': '最大執行任務數',
|
'maxRunning': '最大執行任務數',
|
||||||
|
'defaultDirectDownload': '預設勾選直接下載',
|
||||||
'items': '@count 個項目',
|
'items': '@count 個項目',
|
||||||
'subscribeTracker': '訂閱 Tracker',
|
'subscribeTracker': '訂閱 Tracker',
|
||||||
'subscribeFail': '訂閱失敗,請檢查網路或稍後再試',
|
'subscribeFail': '訂閱失敗,請檢查網路或稍後再試',
|
||||||
|
|||||||
Reference in new issue
Block a user