mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-29 06:09:45 +08:00
26
src/utils/Github.ts
Normal file
26
src/utils/Github.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Github API
|
||||
* @since Beta v0.9.8
|
||||
*/
|
||||
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
|
||||
/**
|
||||
* 获取最新Release版本
|
||||
* @since Beta v0.9.8
|
||||
* @returns 最新版本
|
||||
*/
|
||||
export async function getLatestReleaseVersion(): Promise<string> {
|
||||
const latestReleaseApi: Readonly<string> =
|
||||
"https://api.github.com/repos/BTMuli/TeyvatGuide/releases/latest";
|
||||
try {
|
||||
const latestReleaseResp = await TGHttp<TGApp.Plugins.Github.LastestReleaseResp>(
|
||||
latestReleaseApi,
|
||||
{ method: "GET" },
|
||||
);
|
||||
return latestReleaseResp.tag_name.replace("v", "");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user