Files

26 lines
681 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 版本号加载器
* 读取 /api/version 并将版本号填充到页面元素的 #version-text(或 .statusbar-version)
*/
(function () {
function fill(text) {
var el = document.getElementById("version-text");
if (!el) el = document.querySelector(".statusbar-version");
if (!el) return;
el.textContent = text;
}
try {
fetch("/api/version")
.then(function (r) {
if (!r.ok) throw new Error("bad status");
return r.json();
})
.then(function (data) {
if (data && data.success && data.data) {
fill(data.data.version || "");
}
})
.catch(function () {});
} catch (e) {}
})();