mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-12 19:51:39 +08:00
45 lines
1.7 KiB
HTML
45 lines
1.7 KiB
HTML
<div class="navbar">
|
|
<div class="navbar-grid">
|
|
<div class="grid-item"></div>
|
|
<div class="grid-item" style="grid-column-start: span 2;">
|
|
<h1 style="display: inline; vertical-align: middle; margin-right: 20px; cursor: pointer;"
|
|
onclick="location.href='/';">
|
|
书栖网
|
|
</h1>
|
|
<% links.forEach(item=> { %>
|
|
<a href="<%= item.url %>" style="vertical-align: middle;">
|
|
<%= item.name %>
|
|
</a>
|
|
<% }); %>
|
|
<a href="javascript:logout();" style="color: grey; vertical-align: middle; float: right;">退出登录</a>
|
|
</div>
|
|
<div class="grid-item"></div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
function logout() {
|
|
postRequest("/user/logout", { token: localStorage.getItem("token") })
|
|
.then(function (response) {
|
|
var axiosData = response.data;
|
|
var status = axiosData.status;
|
|
var data = axiosData.data;
|
|
|
|
if (status === "success") {
|
|
console.log(data);
|
|
if (data) {
|
|
localStorage.clear("token");
|
|
localStorage.clear("is_admin");
|
|
location.href = "/login";
|
|
} else {
|
|
alert("退出登录失败");
|
|
}
|
|
} else {
|
|
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
|
}
|
|
})
|
|
.catch(function (error) {
|
|
console.log(error);
|
|
alert("退出登录失败");
|
|
});
|
|
}
|
|
</script> |