@@ -28,30 +28,30 @@ class BTServerUtils {
2828 final res = dio.get (url);
2929 final remoteVersion = (await res).data["tag_name" ] as String ;
3030 debugPrint ("最新版本: $remoteVersion " );
31- late String structure ;
31+ late String arch ;
3232 late String platform;
3333 if (Platform .isAndroid) {
3434 final supportedAbis = androidDeviceInfo.supportedAbis;
3535 if (supportedAbis.contains ("armeabi-v7a" )) {
36- structure = "arm" ;
36+ arch = "arm" ;
3737 }
3838 if (supportedAbis.contains ("x86_64" )) {
39- structure = "amd64" ;
39+ arch = "amd64" ;
4040 }
4141 if (supportedAbis.contains ("arm64-v8a" )) {
42- structure = "arm64" ;
42+ arch = "arm64" ;
4343 }
4444 platform = "android" ;
4545 }
4646 if (Platform .isWindows) {
47- structure = "amd64.exe" ;
47+ arch = "amd64.exe" ;
4848 platform = "windows" ;
4949 }
5050
51- debugPrint ("下载 bt-server $remoteVersion $platform $structure " );
51+ debugPrint ("下载 bt-server $remoteVersion $platform $arch " );
5252
5353 final downloadUrl =
54- "https://github.com/miru-project/bt-server/releases/download/$remoteVersion /bt-server-$remoteVersion -$platform -$structure " ;
54+ "https://github.com/miru-project/bt-server/releases/download/$remoteVersion /bt-server-$remoteVersion -$platform -$arch " ;
5555
5656 final savePath = await MiruDirectory .getDirectory;
5757 await dio.download (
@@ -75,7 +75,7 @@ class BTServerUtils {
7575
7676 try {
7777 if (Platform .isWindows) {
78- await Process .run (
78+ _process = await Process .start (
7979 btServerPath,
8080 [],
8181 workingDirectory: savePath,
@@ -122,6 +122,27 @@ class BTServerUtils {
122122 });
123123 }
124124
125+ // 检查更新
126+ static Future <String > getRemoteVersion () async {
127+ try {
128+ const url =
129+ "https://api.github.com/repos/miru-project/bt-server/releases/latest" ;
130+ final res = Dio ().get (url);
131+ final remoteVersion = (await res).data["tag_name" ] as String ;
132+ return remoteVersion.replaceFirst ("v" , '' );
133+ } catch (e) {
134+ return Get .find <MainController >().btServerVersion.value;
135+ }
136+ }
137+
138+ // 卸载 bt-server
139+ static Future <void > uninstall () async {
140+ stopServer ();
141+ final savePath = await MiruDirectory .getDirectory;
142+ final btServerPath = path.join (savePath, _getBTServerFilename ());
143+ await File (btServerPath).delete ();
144+ }
145+
125146 static Future <bool > isInstalled () async {
126147 final savePath = await MiruDirectory .getDirectory;
127148 final btServerPath = path.join (savePath, _getBTServerFilename ());
0 commit comments