mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-02-06 15:10:20 +00:00
feat: citizen news support
This commit is contained in:
@@ -7,7 +7,7 @@ import 'package:starcitizen_doctor/common/utils/log.dart';
|
||||
class URLConf {
|
||||
/// HOME API
|
||||
static String gitApiHome = "https://git.scbox.xkeyc.cn";
|
||||
static String rssApiHome = "https://rss.scbox.xkeyc.cn";
|
||||
static String newsApiHome = "https://scbox.citizenwiki.cn";
|
||||
static const String analyticsApiHome = "https://scbox.org";
|
||||
|
||||
static bool isUrlCheckPass = false;
|
||||
@@ -15,31 +15,22 @@ class URLConf {
|
||||
/// URLS
|
||||
static String get giteaAttachmentsUrl => "$gitApiHome/SCToolBox/Release";
|
||||
|
||||
static String get gitlabLocalizationUrl =>
|
||||
"$gitApiHome/SCToolBox/LocalizationData";
|
||||
static String get gitlabLocalizationUrl => "$gitApiHome/SCToolBox/LocalizationData";
|
||||
|
||||
static String get gitApiRSILauncherEnhanceUrl =>
|
||||
"$gitApiHome/SCToolBox/RSILauncherEnhance";
|
||||
static String get gitApiRSILauncherEnhanceUrl => "$gitApiHome/SCToolBox/RSILauncherEnhance";
|
||||
|
||||
static String get apiRepoPath => "$gitApiHome/SCToolBox/api/raw/branch/main";
|
||||
|
||||
static String get gitlabApiPath => "$gitApiHome/api/v1/";
|
||||
|
||||
static String get webTranslateHomeUrl =>
|
||||
"$gitApiHome/SCToolBox/ScWeb_Chinese_Translate/raw/branch/main/json/locales";
|
||||
static String get webTranslateHomeUrl => "$gitApiHome/SCToolBox/ScWeb_Chinese_Translate/raw/branch/main/json/locales";
|
||||
|
||||
static String get rssVideoUrl =>
|
||||
"$rssApiHome/bilibili/user/channel/27976358/290653";
|
||||
|
||||
static String get rssTextUrl2 =>
|
||||
"$rssApiHome/baidu/tieba/user/%E7%81%AC%E7%81%ACG%E7%81%AC%E7%81%AC&";
|
||||
|
||||
static const String googleTranslateApiUrl =
|
||||
"https://translate-g-proxy.xkeyc.com";
|
||||
static const String googleTranslateApiUrl = "https://translate-g-proxy.xkeyc.com";
|
||||
|
||||
static const feedbackUrl = "https://support.citizenwiki.cn/all";
|
||||
static const feedbackFAQUrl = "https://support.citizenwiki.cn/t/sc-toolbox";
|
||||
static String nav42KitUrl = "https://payload.citizenwiki.cn/api/community-navs?sort=is_sponsored&depth=2&page=1&limit=1000";
|
||||
static String nav42KitUrl =
|
||||
"https://payload.citizenwiki.cn/api/community-navs?sort=is_sponsored&depth=2&page=1&limit=1000";
|
||||
|
||||
static String get devReleaseUrl => "$gitApiHome/SCToolBox/Release/releases";
|
||||
|
||||
@@ -47,19 +38,19 @@ class URLConf {
|
||||
// 使用 DNS 获取可用列表
|
||||
final gitApiList = _genFinalList(await dnsLookupTxt("git.dns.scbox.org"));
|
||||
dPrint("DNS gitApiList ==== $gitApiList");
|
||||
final fasterGit = await getFasterUrl(gitApiList);
|
||||
final fasterGit = await getFasterUrl(gitApiList, "git");
|
||||
dPrint("gitApiList.Faster ==== $fasterGit");
|
||||
if (fasterGit != null) {
|
||||
gitApiHome = fasterGit;
|
||||
}
|
||||
final rssApiList = _genFinalList(await dnsLookupTxt("rss.dns.scbox.org"));
|
||||
final fasterRss = await getFasterUrl(rssApiList);
|
||||
dPrint("DNS rssApiList ==== $rssApiList");
|
||||
dPrint("rssApiList.Faster ==== $fasterRss");
|
||||
if (fasterRss != null) {
|
||||
rssApiHome = fasterRss;
|
||||
final newsApiList = _genFinalList(await dnsLookupTxt("news.dns.scbox.org"));
|
||||
final fasterNews = await getFasterUrl(newsApiList, "news");
|
||||
dPrint("DNS newsApiList ==== $newsApiList");
|
||||
dPrint("newsApiList.Faster ==== $fasterNews");
|
||||
if (fasterNews != null) {
|
||||
newsApiHome = fasterNews;
|
||||
}
|
||||
isUrlCheckPass = fasterGit != null && fasterRss != null;
|
||||
isUrlCheckPass = fasterGit != null && fasterNews != null;
|
||||
return isUrlCheckPass;
|
||||
}
|
||||
|
||||
@@ -72,7 +63,7 @@ class URLConf {
|
||||
return (await DohClient.resolveTXT(host)) ?? [];
|
||||
}
|
||||
|
||||
static Future<String?> getFasterUrl(List<String> urls) async {
|
||||
static Future<String?> getFasterUrl(List<String> urls, String mode) async {
|
||||
String firstUrl = "";
|
||||
int callLen = 0;
|
||||
|
||||
@@ -83,11 +74,23 @@ class URLConf {
|
||||
}
|
||||
}
|
||||
|
||||
for (var value in urls) {
|
||||
RSHttp.head(value).then((resp) => onCall(resp, value), onError: (err) {
|
||||
callLen++;
|
||||
dPrint("RSHttp.head error $err");
|
||||
});
|
||||
for (var url in urls) {
|
||||
var reqUrl = url;
|
||||
switch (mode) {
|
||||
case "git":
|
||||
reqUrl = "$url/SCToolBox/Api/raw/branch/main/sc_doctor/version.json";
|
||||
break;
|
||||
case "news":
|
||||
reqUrl = "$url/api/latest";
|
||||
break;
|
||||
}
|
||||
RSHttp.head(reqUrl).then(
|
||||
(resp) => onCall(resp, url),
|
||||
onError: (err) {
|
||||
callLen++;
|
||||
dPrint("RSHttp.head error $err");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
|
||||
Reference in New Issue
Block a user