fix: 版本号 commit 哈希截断为 8 位;登录页校验会话有效性,修复登录与项目页互跳循环
build-and-deploy / build-and-deploy (push) Successful in 24s
build-and-deploy / build-and-deploy (push) Successful in 24s
This commit is contained in:
+13
-5
@@ -65,11 +65,6 @@
|
|||||||
.catch(function () {});
|
.catch(function () {});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// 已登录则直接跳转
|
|
||||||
if (localStorage.getItem("registry_token")) {
|
|
||||||
window.location.href = "/projects.html";
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("login-form").addEventListener("submit", async function (e) {
|
document.getElementById("login-form").addEventListener("submit", async function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var error = document.getElementById("login-error");
|
var error = document.getElementById("login-error");
|
||||||
@@ -102,5 +97,18 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script src="/js/api.js"></script>
|
<script src="/js/api.js"></script>
|
||||||
|
<script>
|
||||||
|
// 已登录则校验会话有效性后跳转;token 失效则清理并留在登录页(避免与内页互相跳转)
|
||||||
|
if (localStorage.getItem("registry_token")) {
|
||||||
|
API.getMe()
|
||||||
|
.then(function () {
|
||||||
|
window.location.href = "/projects.html";
|
||||||
|
})
|
||||||
|
.catch(function () {
|
||||||
|
localStorage.removeItem("registry_token");
|
||||||
|
localStorage.removeItem("registry_user");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+6
-2
@@ -22,16 +22,20 @@ function formatDateTime(d) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shortenHash(hash) {
|
||||||
|
return (hash || "unknown").slice(0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
function resolveCommitHash() {
|
function resolveCommitHash() {
|
||||||
if (process.env.GIT_COMMIT && process.env.GIT_COMMIT !== "unknown" && process.env.GIT_COMMIT !== "") {
|
if (process.env.GIT_COMMIT && process.env.GIT_COMMIT !== "unknown" && process.env.GIT_COMMIT !== "") {
|
||||||
return process.env.GIT_COMMIT;
|
return shortenHash(process.env.GIT_COMMIT);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const hash = execFileSync("git", ["rev-parse", "--short=8", "HEAD"], {
|
const hash = execFileSync("git", ["rev-parse", "--short=8", "HEAD"], {
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
stdio: ["ignore", "pipe", "ignore"],
|
stdio: ["ignore", "pipe", "ignore"],
|
||||||
}).trim();
|
}).trim();
|
||||||
return hash || "unknown";
|
return shortenHash(hash);
|
||||||
} catch {
|
} catch {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user