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