Define most content in prelude()

This commit is contained in:
Aoran Zeng 2025-08-09 18:34:18 +08:00
parent 777f9175e4
commit 8ffe5bc12d
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
2 changed files with 42 additions and 33 deletions

View File

@ -168,3 +168,13 @@ TargetRegisterInfo_t;
#define def_target_gsr(t) Target_t t##_target = {def_target_inner_gsr(t),def_target_sourcesn(t)}
#define def_target_gsf(t) Target_t t##_target = {def_target_inner_gsf(t),def_target_sourcesn(t)}
#define def_target_gsrf(t) Target_t t##_target = {def_target_inner_gsrf(t),def_target_sourcesn(t)}
#define define_target(t) void t##_getsrc(char *option);void t##_setsrc(char *option);void t##_resetsrc(char *option); Target_t t##_target={0};
/* 以下宏仅能放在 prelude() 中使用 */
#define use_this(t) Target_t *this = &t##_target;
#define def_sources_begin() static Source_t sources[] = {
#define def_sources_end() }; this->sources = sources; this->sources_n = xy_arylen(sources);
#define def_upstream_provider(url) SourceProvider_t upstream = UpstreamProvider; upstream.site = url;

View File

@ -5,46 +5,44 @@
* Contributors : Jialin Lyu <jialinlvcn@aliyun.com>
* |
* Created On : <2023-09-11>
* Last Modified : <2025-05-27>
* Last Modified : <2025-08-09>
* ------------------------------------------------------------*/
define_target(wr_flathub);
/**
* @update 2025-05-27
*/
static SourceProvider_t wr_flathub_upstream =
{
def_upstream, "https://flathub.org/repo",
{NotSkip, NA, NA, "https://flathub.org/repo/flathub.gpg", ROUGH}
},
/**
void
wr_flathub_prelude ()
{
use_this(wr_flathub);
def_upstream_provider("https://flathub.org/repo");
def_sources_begin()
{&upstream, "https://flathub.org/repo", DelegateToUpstream},
{&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/flathub", DelegateToMirror},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/flathub", DelegateToMirror},
def_sources_end()
/**
* @note 使使访 (GitHub-#178)
* : flathub.gpg
* 访
* 使
*/
chsrc_set_provider_speed_measure_url (&upstream, "https://flathub.org/repo/flathub.gpg");
/* upstream 默认是 ACCURATE 的,但是我们给了一个超小的文件,测速效果严重失真,所以改为 ROUGH */
chsrc_set_provider_speed_measure_accuracy (&upstream, ROUGH);
wr_flathub_siyuan =
{
IS_DedicatedMirrorSite,
"sjtu-sy", "SJTUG-siyuan", "上海交通大学思源镜像站Flathub", "https://mirror.sjtu.edu.cn/",
{NotSkip, NA, NA, "https://mirror.sjtu.edu.cn/flathub/flathub.gpg", ROUGH} /* 由于实在找不到其他可测文件,所以这也只能是 ROUGH */
},
wr_flathub_zhiyuan =
{
IS_DedicatedMirrorSite,
"sjtu-zy", "SJTUG-zhiyuan", "上海交通大学致远镜像站Flathub", "https://mirrors.sjtug.sjtu.edu.cn/",
{NotSkip, NA, NA, "https://mirrors.sjtug.sjtu.edu.cn/flathub/flathub.gpg", ROUGH}
};
static Source_t wr_flathub_sources[] =
{
{&wr_flathub_upstream, "https://flathub.org/repo", NULL},
{&wr_flathub_siyuan, "https://mirror.sjtu.edu.cn/flathub", DelegateToMirror},
{&wr_flathub_zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/flathub", DelegateToMirror},
};
def_sources_n(wr_flathub);
chsrc_set_provider_speed_measure_url (&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/flathub/flathub.gpg");
chsrc_set_provider_speed_measure_url (&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/flathub/flathub.gpg");
/* 由于实在找不到其他可测文件,所以这也只能是 ROUGH */
chsrc_set_provider_speed_measure_accuracy (&Sjtug_Siyuan, ROUGH);
chsrc_set_provider_speed_measure_accuracy (&Sjtug_Zhiyuan, ROUGH);
}
/**
@ -64,7 +62,8 @@ wr_flathub_getsrc (char *option)
void
wr_flathub_setsrc (char *option)
{
chsrc_yield_source_and_confirm (wr_flathub);
// chsrc_yield_source_and_confirm (wr_flathub);
Source_t source;
chsrc_alert2 ("若出现问题,可先调用以下命令:");
char *note = xy_strjoin (3,
@ -117,4 +116,4 @@ wr_flathub_feat (char *option)
return f;
}
def_target_gsrf (wr_flathub);
// def_target_gsrf (wr_flathub);