2024-02-07 22:19:43 +08:00
|
|
|
import 'package:starcitizen_doctor/common/io/rs_http.dart';
|
|
|
|
import 'package:starcitizen_doctor/common/rust/http_package.dart';
|
2024-03-01 20:59:43 +08:00
|
|
|
import 'package:starcitizen_doctor/common/utils/log.dart';
|
2024-02-03 12:28:15 +08:00
|
|
|
|
2024-01-29 20:44:00 +08:00
|
|
|
class URLConf {
|
2024-02-03 12:28:15 +08:00
|
|
|
/// HOME API
|
2024-09-04 19:02:31 +08:00
|
|
|
static String gitApiHome = "https://web-proxy.scbox.xkeyc.cn/git";
|
|
|
|
static String rssApiHome = "https://web-proxy.scbox.xkeyc.cn/rss";
|
|
|
|
static const String analyticsApiHome =
|
|
|
|
"https://web-proxy.scbox.xkeyc.cn/analytics/analytics";
|
2024-01-29 20:44:00 +08:00
|
|
|
|
2024-02-07 22:19:43 +08:00
|
|
|
static bool isUrlCheckPass = false;
|
2024-01-29 20:44:00 +08:00
|
|
|
|
2024-02-03 12:28:15 +08:00
|
|
|
/// URLS
|
2024-02-07 22:19:43 +08:00
|
|
|
static String get giteaAttachmentsUrl => "$gitApiHome/SCToolBox/Release";
|
|
|
|
|
|
|
|
static String get gitlabLocalizationUrl =>
|
2024-02-03 12:28:15 +08:00
|
|
|
"$gitApiHome/SCToolBox/LocalizationData";
|
2024-01-29 20:44:00 +08:00
|
|
|
|
2024-05-01 13:48:37 +08:00
|
|
|
static String get gitApiRSILauncherEnhanceUrl =>
|
|
|
|
"$gitApiHome/SCToolBox/RSILauncherEnhance";
|
|
|
|
|
2024-02-07 22:46:18 +08:00
|
|
|
static String get apiRepoPath => "$gitApiHome/SCToolBox/api/raw/branch/main";
|
2024-02-07 22:19:43 +08:00
|
|
|
|
2024-02-07 23:14:02 +08:00
|
|
|
static String get gitlabApiPath => "$gitApiHome/api/v1/";
|
2024-01-29 20:44:00 +08:00
|
|
|
|
2024-02-07 22:19:43 +08:00
|
|
|
static String get webTranslateHomeUrl =>
|
2024-02-03 12:28:15 +08:00
|
|
|
"$gitApiHome/SCToolBox/ScWeb_Chinese_Translate/raw/branch/main/json/locales";
|
2024-01-29 20:44:00 +08:00
|
|
|
|
2024-02-07 22:19:43 +08:00
|
|
|
static String get rssVideoUrl =>
|
2024-02-03 12:28:15 +08:00
|
|
|
"$rssApiHome/bilibili/user/channel/27976358/290653";
|
2024-01-29 20:44:00 +08:00
|
|
|
|
2024-02-07 22:19:43 +08:00
|
|
|
static String get rssTextUrl2 =>
|
2024-02-03 12:28:15 +08:00
|
|
|
"$rssApiHome/baidu/tieba/user/%E7%81%AC%E7%81%ACG%E7%81%AC%E7%81%AC&";
|
2024-01-29 21:58:59 +08:00
|
|
|
|
|
|
|
static const feedbackUrl = "https://txc.qq.com/products/614843";
|
2024-02-03 12:28:15 +08:00
|
|
|
|
2024-02-07 22:19:43 +08:00
|
|
|
static String get devReleaseUrl => "$gitApiHome/SCToolBox/Release/releases";
|
|
|
|
|
|
|
|
static Future<bool> checkHost() async {
|
2024-09-04 17:18:13 +08:00
|
|
|
isUrlCheckPass = true;
|
2024-02-07 22:19:43 +08:00
|
|
|
return isUrlCheckPass;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String?> getFasterUrl(List<String> urls) async {
|
|
|
|
String firstUrl = "";
|
|
|
|
int callLen = 0;
|
|
|
|
|
|
|
|
void onCall(RustHttpResponse? response, String url) {
|
|
|
|
callLen++;
|
|
|
|
if (response != null && response.statusCode == 200 && firstUrl.isEmpty) {
|
|
|
|
firstUrl = url;
|
2024-02-03 12:28:15 +08:00
|
|
|
}
|
|
|
|
}
|
2024-02-07 22:19:43 +08:00
|
|
|
|
|
|
|
for (var value in urls) {
|
|
|
|
RSHttp.head(value).then((resp) => onCall(resp, value), onError: (err) {
|
|
|
|
callLen++;
|
|
|
|
dPrint("RSHttp.head error $err");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
await Future.delayed(const Duration(milliseconds: 16));
|
|
|
|
if (firstUrl.isNotEmpty) {
|
|
|
|
return firstUrl;
|
|
|
|
}
|
|
|
|
if (callLen == urls.length && firstUrl.isEmpty) {
|
|
|
|
return null;
|
2024-02-03 12:28:15 +08:00
|
|
|
}
|
|
|
|
}
|
2024-02-07 22:19:43 +08:00
|
|
|
}
|
2024-01-29 20:44:00 +08:00
|
|
|
}
|