Add Dart feat info and fix wrong use of old function

This commit is contained in:
Aoran Zeng 2024-08-28 19:20:36 +08:00
parent df8e7c2fd7
commit 0e155a6420
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98

View File

@ -4,7 +4,8 @@
* File Authors : Aoran Zeng <ccmywish@qq.com> * File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org> * Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-10> * Created On : <2023-09-10>
* Last Modified : <2024-08-15> * Last Modified : <2024-08-28>
* Revision : 2
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
/** /**
@ -26,6 +27,7 @@ pl_dart_sources[] = {
}; };
def_sources_n(pl_dart); def_sources_n(pl_dart);
void void
pl_dart_getsrc (char *option) pl_dart_getsrc (char *option)
{ {
@ -50,40 +52,67 @@ pl_dart_setsrc (char *option)
{ {
chsrc_yield_source_and_confirm (pl_dart); chsrc_yield_source_and_confirm (pl_dart);
char *towrite = NULL; char *towrite1, *towrite2 = NULL;
char *pub = xy_2strjoin (source.url, "dart-pub"); char *pub = xy_2strjoin (source.url, "dart-pub");
char *flutter = xy_2strjoin (source.url, "flutter"); char *flutter = xy_2strjoin (source.url, "flutter");
if (xy_on_windows) if (xy_on_windows)
{ {
towrite1 = xy_strjoin (3, "$env:PUB_HOSTED_URL = \"", pub, "\"");
towrite2 = xy_strjoin (3, "$env:FLUTTER_STORAGE_BASE_URL = \"", flutter, "\"");
if (xy_file_exist (xy_win_powershell_profile)) if (xy_file_exist (xy_win_powershell_profile))
{ {
towrite = xy_strjoin (4, "$env:PUB_HOSTED_URL = \"", pub, "\""); chsrc_append_to_file (towrite1, xy_win_powershell_profile);
chsrc_append_to_file (towrite, xy_win_powershell_profile); chsrc_append_to_file (towrite2, xy_win_powershell_profile);
towrite = xy_strjoin (4, "$env:FLUTTER_STORAGE_BASE_URL = \"", flutter, "\"");
chsrc_append_to_file (towrite, xy_win_powershell_profile);
} }
if (xy_file_exist (xy_win_powershellv5_profile)) if (xy_file_exist (xy_win_powershellv5_profile))
{ {
towrite = xy_strjoin (4, "$env:PUB_HOSTED_URL = \"", pub, "\""); chsrc_append_to_file (towrite1, xy_win_powershellv5_profile);
chsrc_append_to_file (towrite, xy_win_powershellv5_profile); chsrc_append_to_file (towrite2, xy_win_powershellv5_profile);
towrite = xy_strjoin (4, "$env:FLUTTER_STORAGE_BASE_URL = \"", flutter, "\"");
chsrc_append_to_file (towrite, xy_win_powershellv5_profile);
} }
} }
else else
{ {
towrite = xy_strjoin (3, "export PUB_HOSTED_URL=\"", pub, "\""); char *zshrc = "~/.zshrc";
chsrc_append_to_file (towrite, "~/.bashrc >> ~/.zshrc"); char *bashrc = "~/.bashrc";
towrite = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", flutter, "\""); chsrc_backup (zshrc);
chsrc_append_to_file (towrite, "~/.bashrc >> ~/.zshrc"); towrite1 = xy_strjoin (3, "export PUB_HOSTED_URL=\"", pub, "\"");
towrite2 = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", flutter, "\"");
chsrc_append_to_file (towrite1, zshrc);
chsrc_append_to_file (towrite2, zshrc);
if (xy_file_exist (bashrc))
{
chsrc_backup (bashrc);
chsrc_append_to_file (towrite1, bashrc);
chsrc_append_to_file (towrite2, bashrc);
}
} }
chsrc_conclude (&source, ChsrcTypeUntested); chsrc_conclude (&source, ChsrcTypeUntested);
} }
def_target(pl_dart);
FeatInfo
pl_dart_feat (char *option)
{
FeatInfo fi = {0};
fi.can_get = true;
fi.can_reset = false;
fi.stcan_locally = CanNot;
fi.locally = NULL;
fi.can_english = true;
/* 该换源方案中URL存在拼凑因此不能让用户手动使用某URL来换源 */
fi.can_user_define = false;
fi.note = "该换源通过写入环境变量实现若多次换源请手动清理profile文件";
return fi;
}
def_target_gsf(pl_dart);