mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-07 17:10:29 +00:00
feat: add auto-start incomplete tasks on application startup (#1203)
This commit is contained in:
1 parent
24db9bb58b
commit
71c9e6947a
13 files changed
+50
-8
No files matched your search
@@ -84,6 +84,7 @@ class ExtraConfig {
|
||||
bool defaultDirectDownload;
|
||||
bool defaultBtClient;
|
||||
bool notifyWhenNewVersion;
|
||||
bool autoStartTasks;
|
||||
List<DownloadCategory> downloadCategories;
|
||||
|
||||
ExtraConfigBt bt = ExtraConfigBt();
|
||||
@@ -96,6 +97,7 @@ class ExtraConfig {
|
||||
this.defaultDirectDownload = false,
|
||||
this.defaultBtClient = true,
|
||||
this.notifyWhenNewVersion = true,
|
||||
this.autoStartTasks = false,
|
||||
this.downloadCategories = const [],
|
||||
});
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ ExtraConfig _$ExtraConfigFromJson(Map<String, dynamic> json) => ExtraConfig(
|
||||
defaultDirectDownload: json['defaultDirectDownload'] as bool? ?? false,
|
||||
defaultBtClient: json['defaultBtClient'] as bool? ?? true,
|
||||
notifyWhenNewVersion: json['notifyWhenNewVersion'] as bool? ?? true,
|
||||
autoStartTasks: json['autoStartTasks'] as bool? ?? false,
|
||||
downloadCategories: (json['downloadCategories'] as List<dynamic>?)
|
||||
?.map((e) => DownloadCategory.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
@@ -98,6 +99,7 @@ Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) =>
|
||||
'defaultDirectDownload': instance.defaultDirectDownload,
|
||||
'defaultBtClient': instance.defaultBtClient,
|
||||
'notifyWhenNewVersion': instance.notifyWhenNewVersion,
|
||||
'autoStartTasks': instance.autoStartTasks,
|
||||
'downloadCategories':
|
||||
instance.downloadCategories.map((e) => e.toJson()).toList(),
|
||||
'bt': instance.bt.toJson(),
|
||||
|
||||
@@ -53,14 +53,6 @@ const _$ProtocolEnumMap = {
|
||||
Protocol.bt: 'bt',
|
||||
};
|
||||
|
||||
const _$ExtractStatusEnumMap = {
|
||||
ExtractStatus.none: '',
|
||||
ExtractStatus.extracting: 'extracting',
|
||||
ExtractStatus.done: 'done',
|
||||
ExtractStatus.error: 'error',
|
||||
ExtractStatus.waitingParts: 'waitingParts',
|
||||
};
|
||||
|
||||
Progress _$ProgressFromJson(Map<String, dynamic> json) => Progress(
|
||||
used: (json['used'] as num).toInt(),
|
||||
speed: (json['speed'] as num).toInt(),
|
||||
@@ -82,3 +74,11 @@ Map<String, dynamic> _$ProgressToJson(Progress instance) => <String, dynamic>{
|
||||
'extractStatus': _$ExtractStatusEnumMap[instance.extractStatus]!,
|
||||
'extractProgress': instance.extractProgress,
|
||||
};
|
||||
|
||||
const _$ExtractStatusEnumMap = {
|
||||
ExtractStatus.none: '',
|
||||
ExtractStatus.extracting: 'extracting',
|
||||
ExtractStatus.done: 'done',
|
||||
ExtractStatus.error: 'error',
|
||||
ExtractStatus.waitingParts: 'waitingParts',
|
||||
};
|
||||
@@ -150,6 +150,25 @@ class SettingView extends GetView<SettingController> {
|
||||
);
|
||||
});
|
||||
|
||||
final buildAutoStartTasks = _buildConfigItem('autoStartTasks', () {
|
||||
return appController.downloaderConfig.value.extra.autoStartTasks
|
||||
? 'on'.tr
|
||||
: 'off'.tr;
|
||||
}, (Key key) {
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Switch(
|
||||
value: appController.downloaderConfig.value.extra.autoStartTasks,
|
||||
onChanged: (bool value) async {
|
||||
appController.downloaderConfig.update((val) {
|
||||
val!.extra.autoStartTasks = value;
|
||||
});
|
||||
await debounceSave();
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
// Archive auto extract configuration
|
||||
final buildAutoExtract = _buildConfigItem('autoExtract', () {
|
||||
return appController.downloaderConfig.value.archive.autoExtract
|
||||
@@ -1394,6 +1413,7 @@ class SettingView extends GetView<SettingController> {
|
||||
buildDownloadCategories(),
|
||||
buildMaxRunning(),
|
||||
buildDefaultDirectDownload(),
|
||||
buildAutoStartTasks(),
|
||||
buildBrowserExtension(),
|
||||
buildAutoStartup(),
|
||||
buildMenubarMode(),
|
||||
|
||||
@@ -41,6 +41,7 @@ const deDE = {
|
||||
'useServerCtime': 'Serverzeit für die Dateierstellung verwenden',
|
||||
'maxRunning': 'Maximale Anzahl ausgeführter Aufgaben',
|
||||
'defaultDirectDownload': 'Direkten Download standardmäßig aktivieren',
|
||||
'autoStartTasks': 'Unvollständige Aufgaben beim Start automatisch starten',
|
||||
'items': '@count Artikel',
|
||||
'subscribeTracker': 'Abonnement-Tracker',
|
||||
'subscribeFail':
|
||||
|
||||
@@ -38,6 +38,7 @@ const enUS = {
|
||||
'useServerCtime': 'Use server time for file creation',
|
||||
'maxRunning': 'Max Running Tasks',
|
||||
'defaultDirectDownload': 'Check direct download by default',
|
||||
'autoStartTasks': 'Auto-start incomplete tasks on startup',
|
||||
'items': '@count items',
|
||||
'subscribeTracker': 'Subscribe Tracker',
|
||||
'subscribeFail':
|
||||
|
||||
@@ -38,6 +38,7 @@ const esES = {
|
||||
'connections': 'Conexiones',
|
||||
'useServerCtime': 'Usar tiempo del servidor para la creación de archivos',
|
||||
'maxRunning': 'Máximo de Tareas en Ejecución',
|
||||
'autoStartTasks': 'Iniciar automáticamente tareas incompletas al arrancar',
|
||||
'items': '@count elementos',
|
||||
'subscribeTracker': 'Suscribirse al Tracker',
|
||||
'subscribeFail':
|
||||
|
||||
@@ -38,6 +38,7 @@ const frFR = {
|
||||
'useServerCtime':
|
||||
'Utiliser l\'heure du serveur pour la création de fichier',
|
||||
'maxRunning': 'Tâches en cours maximum',
|
||||
'autoStartTasks': 'Démarrer automatiquement les tâches incomplètes au lancement',
|
||||
'items': '@count éléments',
|
||||
'subscribeTracker': 'S\'abonner au tracker',
|
||||
'subscribeFail':
|
||||
|
||||
@@ -29,6 +29,7 @@ const jaJP = {
|
||||
'downloadDirValid': 'ダウンロードディレクトリを選択してください',
|
||||
'connections': '接続',
|
||||
'maxRunning': '最大実行タスク',
|
||||
'autoStartTasks': '起動時に未完了のタスクを自動的に開始',
|
||||
'items': '@count アイテム',
|
||||
'subscribeTracker': 'トラッカーを購読',
|
||||
'subscribeFail': '登録に失敗しました。ネットワークを確認するか、後でもう一度お試しください',
|
||||
|
||||
@@ -39,6 +39,7 @@ const ruRU = {
|
||||
'useServerCtime': 'Использовать время сервера для создания файла',
|
||||
'maxRunning': 'Максимальное количество активных задач',
|
||||
'defaultDirectDownload': 'Прямая загрузка по умолчанию',
|
||||
'autoStartTasks': 'Автоматически запускать незавершённые задачи при старте',
|
||||
'items': '@подсчет элементов',
|
||||
'subscribeTracker': 'Подпись трекера',
|
||||
'subscribeFail':
|
||||
|
||||
@@ -38,6 +38,7 @@ const zhCN = {
|
||||
'useServerCtime': '创建文件使用服务器时间',
|
||||
'maxRunning': '最大下载数',
|
||||
'defaultDirectDownload': '默认勾选直接下载',
|
||||
'autoStartTasks': '启动时自动开始未完成的任务',
|
||||
'items': '@count 项',
|
||||
'subscribeTracker': '订阅 Tracker',
|
||||
'subscribeFail': '订阅失败,请检查网络或稍后重试',
|
||||
|
||||
@@ -38,6 +38,7 @@ const zhTW = {
|
||||
'useServerCtime': '使用伺服器時間作為檔案建立時間',
|
||||
'maxRunning': '最大執行任務數',
|
||||
'defaultDirectDownload': '預設勾選直接下載',
|
||||
'autoStartTasks': '啟動時自動開始未完成的任務',
|
||||
'items': '@count 個項目',
|
||||
'subscribeTracker': '訂閱 Tracker',
|
||||
'subscribeFail': '訂閱失敗,請檢查網路或稍後再試',
|
||||
|
||||
@@ -133,6 +133,16 @@ Future<void> init(Args args) async {
|
||||
logger.e("load config fail", e);
|
||||
}
|
||||
|
||||
// Auto-start incomplete tasks if enabled
|
||||
if (controller.downloaderConfig.value.extra.autoStartTasks) {
|
||||
try {
|
||||
await api.continueAllTasks(null);
|
||||
logger.i("auto-start tasks completed");
|
||||
} catch (e) {
|
||||
logger.w("auto-start tasks fail", e);
|
||||
}
|
||||
}
|
||||
|
||||
() async {
|
||||
if (Util.isDesktop()) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user