|
@@ -4,7 +4,6 @@ import 'dart:io';
|
|
|
import 'package:dio/dio.dart';
|
|
|
import 'package:archive/archive.dart';
|
|
|
import 'package:naiyouwl/app/const/const.dart';
|
|
|
-import 'package:naiyouwl/app/const/const.dart';
|
|
|
import 'package:path/path.dart' as path;
|
|
|
|
|
|
final dio = Dio();
|
|
@@ -16,7 +15,7 @@ final depDir = Directory(path.join(assetsPath, 'dep'));
|
|
|
|
|
|
Future downloadLatestClashCore() async {
|
|
|
const version = "v1.16.0";
|
|
|
- final String clashCoreName = 'clash.meta-${ClashName.platform}-$arch-cgo-$version';
|
|
|
+ final String clashCoreName = 'clash.meta-${ClashName.platform}-${ClashName.arch}-cgo-$version';
|
|
|
|
|
|
// Fetching release info from the GitHub API
|
|
|
final info = await dio.get('https://api.github.com/repos/MetaCubeX/Clash.Meta/releases/tags/$version');
|
|
@@ -50,7 +49,7 @@ Future downloadLatestClashCore() async {
|
|
|
Future<void> downloadAndUnarchiveService() async {
|
|
|
// const String token = "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"; // 请确保不在公共代码中硬编码这个token
|
|
|
|
|
|
- final serviceName = 'ccore-service-${ClashName.platform}-$arch';
|
|
|
+ final serviceName = 'ccore-service-${ClashName.platform}-${ClashName.arch}';
|
|
|
// "name" -> "ccore-service-darwin-amd64-v1.0.0.gz"
|
|
|
//final newSericeName = "$serviceName-v1.0.0.gz";
|
|
|
// 获取GitHub release信息
|
|
@@ -92,7 +91,7 @@ Future<void> downloadAndUnarchiveService() async {
|
|
|
}
|
|
|
|
|
|
Future downloadLatestClashService() async {
|
|
|
- final String serviceName = 'ccore-service-${ClashName.platform}-$arch';
|
|
|
+ final String serviceName = 'ccore-service-${ClashName.platform}-${ClashName.arch}';
|
|
|
// // final info = await dio.get('https://api.github.com/repos/alroyso/clash-for-flutter-service/releases/latest');
|
|
|
// // final Map<String, dynamic> latest = (info.data['assets'] as List<dynamic>).firstWhere((it) => (it['name'] as String).contains(serviceName));
|
|
|
// //https://github.com/alroyso/clash-for-flutter-service/releases/download/untagged-8273cca760b55d0725ab/naiyou-service-darwin-arm64-v1.0.1.gz
|
|
@@ -145,7 +144,7 @@ Future downloadWintun() async {
|
|
|
print('Download Success');
|
|
|
print('Unarchiving wintun.zip');
|
|
|
final files = ZipDecoder().decodeBytes(await wintunFile.readAsBytes());
|
|
|
- final file = files.firstWhere((it) => it.name == 'wintun/bin/$arch/wintun.dll');
|
|
|
+ final file = files.firstWhere((it) => it.name == 'wintun/bin/${ClashName.arch}/wintun.dll');
|
|
|
await File(path.join(depDir.path, 'wintun.dll')).writeAsBytes(file.content);
|
|
|
await wintunFile.delete();
|
|
|
print('Unarchiv Success');
|