Skip to content

Commit

Permalink
feat: linux btserver support
Browse files Browse the repository at this point in the history
  • Loading branch information
appdevelpo committed Apr 13, 2024
1 parent fa10bd7 commit 3a0e394
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 43 deletions.
6 changes: 6 additions & 0 deletions lib/utils/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ import 'package:device_info_plus/device_info_plus.dart';
late PackageInfo packageInfo;
late AndroidDeviceInfo androidDeviceInfo;
late WindowsDeviceInfo windowsDeviceInfo;
late LinuxDeviceInfo linuxDeviceInfo;

class ApplicationUtils {
static Future ensureInitialized() async {
packageInfo = await PackageInfo.fromPlatform();
final deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
androidDeviceInfo = await deviceInfo.androidInfo;
return packageInfo;
}
if (Platform.isLinux) {
linuxDeviceInfo = await deviceInfo.linuxInfo;
return packageInfo;
}
if (Platform.isWindows) {
windowsDeviceInfo = await deviceInfo.windowsInfo;
Expand Down
18 changes: 15 additions & 3 deletions lib/utils/bt_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:miru_app/data/providers/bt_server_provider.dart';
import 'package:miru_app/controllers/bt_dialog_controller.dart';
import 'package:miru_app/controllers/main_controller.dart';
import 'package:miru_app/utils/application.dart';
import 'package:miru_app/utils/log.dart';
import 'package:miru_app/utils/miru_directory.dart';
import 'package:miru_app/utils/request.dart';
import 'package:path/path.dart' as path;
Expand All @@ -22,7 +23,7 @@ class BTServerUtils {
debugPrint("检测最新版本");
// 获取最新版本
const url =
"https://api.github.com/repos/miru-project/bt-server/releases/latest";
"https://api.github.com/repos/appdevelpo/bt-server/releases/latest"; // temporary url

final res = dio.get(url);
final remoteVersion = (await res).data["tag_name"] as String;
Expand All @@ -32,7 +33,7 @@ class BTServerUtils {
if (Platform.isAndroid) {
final supportedAbis = androidDeviceInfo.supportedAbis;
if (supportedAbis.contains("armeabi-v7a")) {
arch = "arm";
arch = "armv7a ";
}
if (supportedAbis.contains("x86_64")) {
arch = "amd64";
Expand All @@ -46,11 +47,21 @@ class BTServerUtils {
arch = "amd64.exe";
platform = "windows";
}
if (Platform.isLinux) {
platform = "linux";
final archetechture = await Process.run('uname', ['-m']);
if (archetechture.stdout.toString().contains("x86_64")) {
arch = "amd64";
}
if (archetechture.stdout.toString().contains("arm64")) {
arch = "arm64";
}
}

debugPrint("下载 bt-server $remoteVersion $platform $arch");

final downloadUrl =
"https://github.com/miru-project/bt-server/releases/download/$remoteVersion/bt-server-$remoteVersion-$platform-$arch";
"https://github.com/appdevelpo/bt-server/releases/download/$remoteVersion/bt-server-$remoteVersion-$platform-$arch";

final savePath = MiruDirectory.getDirectory;
await dio.download(
Expand Down Expand Up @@ -87,6 +98,7 @@ class BTServerUtils {
["&"],
workingDirectory: savePath,
);
logger.info("bt-server started");
}
} catch (e) {
final error = e.toString();
Expand Down
40 changes: 0 additions & 40 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.2"
flutter_linux_webview:
dependency: "direct main"
description:
name: flutter_linux_webview
sha256: "6b048d430d74c2f74f6d38b00daab94f866e79162450605739b3af4cd2c08974"
url: "https://pub.dev"
source: hosted
version: "0.1.2"
flutter_localizations:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -1523,38 +1515,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.6"
webview_flutter:
dependency: "direct main"
description:
name: webview_flutter
sha256: "392c1d83b70fe2495de3ea2c84531268d5b8de2de3f01086a53334d8b6030a88"
url: "https://pub.dev"
source: hosted
version: "3.0.4"
webview_flutter_android:
dependency: transitive
description:
name: webview_flutter_android
sha256: "8b3b2450e98876c70bfcead876d9390573b34b9418c19e28168b74f6cb252dbd"
url: "https://pub.dev"
source: hosted
version: "2.10.4"
webview_flutter_platform_interface:
dependency: transitive
description:
name: webview_flutter_platform_interface
sha256: "812165e4e34ca677bdfbfa58c01e33b27fd03ab5fa75b70832d4b7d4ca1fa8cf"
url: "https://pub.dev"
source: hosted
version: "1.9.5"
webview_flutter_wkwebview:
dependency: transitive
description:
name: webview_flutter_wkwebview
sha256: a5364369c758892aa487cbf59ea41d9edd10f9d9baf06a94e80f1bd1b4c7bbc0
url: "https://pub.dev"
source: hosted
version: "2.9.5"
win32:
dependency: transitive
description:
Expand Down

0 comments on commit 3a0e394

Please sign in to comment.