fix: improve Aria2c session handling and adjust translation timer

This commit is contained in:
xkeyC 2025-11-15 20:57:52 +08:00
parent 3219129094
commit d82cfb41aa
2 changed files with 15 additions and 12 deletions

View File

@ -52,7 +52,8 @@ class Aria2cModel extends _$Aria2cModel {
try {
final sessionFile = File("$aria2cDir\\aria2.session");
//
if (await sessionFile.exists() && (await sessionFile.readAsString()).trim().isNotEmpty) {
if (await sessionFile.exists ()
&& (await sessionFile.readAsString()).trim().isNotEmpty) {
dPrint("launch Aria2c daemon");
await launchDaemon(appGlobalState.applicationBinaryModuleDir!);
} else {
@ -212,7 +213,9 @@ class Aria2cModel extends _$Aria2cModel {
if (aria2c == null) return false;
for (var value in [...await aria2c.tellActive(), ...await aria2c.tellWaiting(0, 100000)]) {
final t = HomeDownloaderUIModel.getTaskTypeAndName(value);
return (t.key == "torrent" && t.value.contains(name));
if (t.key == "torrent" && t.value.contains(name)) {
return true;
}
}
return false;
}

View File

@ -171,7 +171,7 @@ class InputMethodDialogUIModel extends _$InputMethodDialogUIModel {
if (state.isEnableAutoTranslate) {
if (_translateTimer != null) _translateTimer?.cancel();
state = state.copyWith(isAutoTranslateWorking: true);
_translateTimer = Timer(Duration(milliseconds: webMessage ? 1 : 400), () async {
_translateTimer = Timer(Duration(milliseconds: webMessage ? 150 : 400), () async {
try {
final inputText = sourceText.replaceAll("\n", " ");
final r = await doTranslateText(inputText);