diff --git a/lib/provider/alist_provider.dart b/lib/provider/alist_provider.dart index e5296d8..849c0a7 100644 --- a/lib/provider/alist_provider.dart +++ b/lib/provider/alist_provider.dart @@ -44,11 +44,11 @@ class AlistNotifier extends StateNotifier { var process = await Process.start('$workingDirectory\\alist.exe', alistArgs, workingDirectory: workingDirectory); process.stdout.listen((data) { - String text = TextUtils.stdDecode(data); + String text = TextUtils.stdDecode(data,false); addOutput(text); }); process.stderr.listen((data) { - String text = TextUtils.stdDecode(data); + String text = TextUtils.stdDecode(data,false); addOutput(text); }); } @@ -57,7 +57,7 @@ class AlistNotifier extends StateNotifier { state = state.copyWith(isRunning: false); var process = await Process.start('taskkill', ['/f', '/im', 'alist.exe']); process.stdout.listen((data) { - String text = TextUtils.stdDecode(data); + String text = TextUtils.stdDecode(data,true); addOutput(text); }); } @@ -72,7 +72,7 @@ class AlistNotifier extends StateNotifier { '$workingDirectory\\alist.exe', ['admin'], workingDirectory: workingDirectory); alistAdmin.stderr.listen((data) { - String text = TextUtils.stdDecode(data); + String text = TextUtils.stdDecode(data,false); addOutput(text); }); } @@ -83,7 +83,7 @@ class AlistNotifier extends StateNotifier { '$workingDirectory\\alist.exe', ['version'], workingDirectory: workingDirectory); alistVersion.stdout.listen((data) { - String text = TextUtils.stdDecode(data); + String text = TextUtils.stdDecode(data,false); if (text.contains('Version')) { String versionInfo = text .split('Go Version:')[1] @@ -105,7 +105,7 @@ class AlistNotifier extends StateNotifier { final json = jsonDecode(response.body) as Map; final latest = json['tag_name'] as String; state = state.copyWith(latestVersion: latest); - print('Latest release: $latest'); + //print('Latest release: $latest'); } Future isAlistRunning() async { diff --git a/lib/utils/textutils.dart b/lib/utils/textutils.dart index 1fb8c14..e3be3c0 100644 --- a/lib/utils/textutils.dart +++ b/lib/utils/textutils.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:fast_gbk/fast_gbk.dart'; class TextUtils { @@ -16,8 +18,11 @@ class TextUtils { return input; } - static String stdDecode(List input) { - return removeEscapeSequences(gbk.decode(removeExtraBreaks(input))); + static String stdDecode(List input,bool isGBK) { + if (isGBK) { + return removeEscapeSequences(gbk.decode(removeExtraBreaks(input))); + } + return removeEscapeSequences(utf8.decode(removeExtraBreaks(input))); } static bool isNewVersion(String currentVersion, String latestVersion) {