-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
34 lines (31 loc) · 1.37 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<html>
<body>
<h1>这里是qaqFei/PhigrosPlayer的Github Page</h1>
<button onclick="downloadLatest()">下载最新PhigrosPlayer! (需调用Github Rest API, 请检查网络环境)</button>
<br><br>
<a href="./src/webphiplayer.html">webphiplayer</a>
</body>
</html>
<script>
const api = "https://api.github.com";
const github = "https://github.com";
const repoName = "qaqFei/PhigrosPlayer";
function bytes2Size(bytes) {
var sizes = ["Bytes", "KB", "MB", "GB", "TB"];
if (bytes == 0) return "0 Byte";
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return `${Math.round(bytes / Math.pow(1024, i), 2)} ${sizes[i]}`;
}
async function downloadLatest() {
let artifacts = await fetch(`${api}/repos/${repoName}/actions/artifacts`).then(res => res.json());
for (let item of artifacts.artifacts) {
if (item.name === "artifact") {
let download_url = `${github}/${repoName}/actions/runs/${item.workflow_run.id}/artifacts/${item.id}`;
alert(`找到符合要求的artifact\n更新时间: ${item.created_at}\n大小: ${bytes2Size(item.size_in_bytes)}\n\n点击确定下载`);
window.location.href = download_url;
return;
}
}
alert("没有找到符合要求的artifact");
}
</script>