fix(update): 切换 check_for_update 至 GitHub Releases API
- URL: git.codingplan.site Gitea API -> api.github.com/repos/billowliu2/KimiSwitch - 增加 User-Agent header (GitHub 403 without UA) - User-Agent: KimiSwitch/<CARGO_PKG_VERSION> - 包目标只跟随 v0.6.0+ 历史版本仍留在 git.codingplan.site
This commit is contained in:
1 parent
fb530c85ca
commit
084883a54a
1 file changed
+14
-2
@@ -740,9 +740,21 @@ fn version_lt(current: &str, latest: &str) -> bool {
|
||||
#[tauri::command]
|
||||
pub async fn check_for_update() -> Result<UpdateInfo, String> {
|
||||
let current = env!("CARGO_PKG_VERSION").to_string();
|
||||
let url = "https://git.codingplan.site/api/v1/repos/admin/KimiCodeSwitch/releases?limit=1";
|
||||
// GitHub Releases API for billowliu2/KimiSwitch. Historical versions
|
||||
// (v0.5.x and earlier) live on git.codingplan.site and are not exposed
|
||||
// here — only v0.6.0+ is published via GitHub.
|
||||
let url = "https://api.github.com/repos/billowliu2/KimiSwitch/releases?per_page=1";
|
||||
|
||||
let resp = reqwest::get(url)
|
||||
// GitHub returns 403 without a User-Agent header. Bundle the app version
|
||||
// so the source is identifiable in any rate-limit / abuse reports.
|
||||
let client = reqwest::Client::builder()
|
||||
.user_agent(concat!("KimiSwitch/", env!("CARGO_PKG_VERSION")))
|
||||
.build()
|
||||
.map_err(|e| format!("client build failed: {e}"))?;
|
||||
|
||||
let resp = client
|
||||
.get(url)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("request failed: {e}"))?;
|
||||
|
||||
|
||||
Reference in new issue
Block a user