fix: 修复版本号获取 CORS 跨域报错,改用 Gitee API v5
This commit is contained in:
+6
-5
@@ -678,14 +678,15 @@ journalctl -u minesentinel -u minecraft -f # 双服务合并</pre>
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// 自动获取 APP_VERSIONS_LIST 中最新的版本号
|
// 通过 Gitee API(CORS 允许)获取最新版本号
|
||||||
(function() {
|
(function() {
|
||||||
var el = document.getElementById('versionCode');
|
var el = document.getElementById('versionCode');
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
fetch('https://raw.giteeusercontent.com/SCU_team/mine-sentinel/dev/APP_VERSIONS_LIST')
|
fetch('https://gitee.com/api/v5/repos/SCU_team/mine-sentinel/contents/APP_VERSIONS_LIST?ref=dev')
|
||||||
.then(function(r) { if (!r.ok) throw new Error(); return r.text(); })
|
.then(function(r) { if (!r.ok) throw new Error(); return r.json(); })
|
||||||
.then(function(t) {
|
.then(function(data) {
|
||||||
var vs = t.trim().split(/[\r\n]+/).filter(function(l) { return l.trim(); });
|
var decoded = atob(data.content);
|
||||||
|
var vs = decoded.trim().split(/[\r\n]+/).filter(function(l) { return l.trim(); });
|
||||||
if (vs.length) el.textContent = vs[vs.length - 1].trim();
|
if (vs.length) el.textContent = vs[vs.length - 1].trim();
|
||||||
})
|
})
|
||||||
.catch(function() { el.textContent = '获取失败'; });
|
.catch(function() { el.textContent = '获取失败'; });
|
||||||
|
|||||||
Reference in New Issue
Block a user