add download threads setting

This commit is contained in:
2024-11-03 15:49:34 +08:00
parent 28913adc86
commit 45e7f0dfc2
4 changed files with 31 additions and 20 deletions

View File

@@ -155,7 +155,8 @@
"Start": "开始",
"Export App Data": "导出应用数据",
"Import App Data": "导入应用数据",
"Export": "导出"
"Export": "导出",
"Download Threads": "下载线程数"
},
"zh_TW": {
"Home": "首頁",
@@ -313,6 +314,7 @@
"Start": "開始",
"Export App Data": "匯出應用數據",
"Import App Data": "匯入應用數據",
"Export": "匯出"
"Export": "匯出",
"Download Threads": "下載線程數"
}
}

View File

@@ -110,6 +110,7 @@ class _Settings with ChangeNotifier {
'enablePageAnimation': true,
'language': 'system', // system, zh-CN, zh-TW, en-US
'cacheSize': 2048, // in MB
'downloadThreads': 5,
};
operator [](String key) {

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:flutter/widgets.dart' show ChangeNotifier;
import 'package:venera/foundation/appdata.dart';
import 'package:venera/foundation/comic_source/comic_source.dart';
import 'package:venera/foundation/comic_type.dart';
import 'package:venera/foundation/local.dart';
@@ -155,7 +156,7 @@ class ImagesDownloadTask extends DownloadTask with _TransferSpeedMixin {
var tasks = <int, _ImageDownloadWrapper>{};
int get _maxConcurrentTasks => 5;
int get _maxConcurrentTasks => (appdata.settings["downloadThreads"] as num).toInt();
void _scheduleTasks() {
var images = _images![_images!.keys.elementAt(_chapter)]!;

View File

@@ -17,6 +17,13 @@ class _NetworkSettingsState extends State<NetworkSettings> {
title: "Proxy".tl,
builder: () => const _ProxySettingView(),
).toSliver(),
_SliderSetting(
title: "Download Threads".tl,
settingsIndex: 'downloadThreads',
interval: 1,
min: 1,
max: 16,
).toSliver(),
],
);
}