mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-17 23:46:12 +08:00
63 lines
2.0 KiB
HTML
63 lines
2.0 KiB
HTML
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
|
|
<title><%= htmlTitle %></title>
|
|
|
|
<link rel="stylesheet" href="/assets/stylesheets/style.css">
|
|
<script src="/assets/lib/jquery/3.6.0/jquery.min.js"></script>
|
|
<script src="/assets/lib/axios/0.26.1/axios.min.js"></script>
|
|
|
|
<script src="/assets/javascripts/httpRequest.js"></script>
|
|
<script>
|
|
// API地址
|
|
const APIHOST = '<%= global.site.api.prefix %>';
|
|
axios.defaults.baseURL = APIHOST;
|
|
</script>
|
|
<% if (group == "admin") {%>
|
|
<script>
|
|
// <%= group %>
|
|
if(localStorage.getItem("is_admin") === "false") {
|
|
// 是普通用户,跳转到普通用户后台页面
|
|
window.location.href = "/dashboard/user/index";
|
|
}
|
|
</script>
|
|
<%} else {%>
|
|
<script>
|
|
if(localStorage.getItem("is_admin") === "true") {
|
|
// 是管理员用户,跳转到管理员用户后台页面
|
|
window.location.href = "/dashboard/admin/index";
|
|
}
|
|
</script>
|
|
<%}%>
|
|
<script>
|
|
function getUserStatus() {
|
|
if(!localStorage) {
|
|
window.location.href = "/";
|
|
}
|
|
|
|
if(!localStorage.getItem("token") || !localStorage.getItem("is_admin")) {
|
|
localStorage.clear("token");
|
|
localStorage.clear("is_admin");
|
|
window.location.href = "/";
|
|
}
|
|
|
|
postRequest("/user/getUserStatus", { token: localStorage.getItem("token") })
|
|
.then(function (responseData) {
|
|
var axiosData = responseData.data;
|
|
var status = axiosData.status;
|
|
var data = axiosData.data;
|
|
if (status === "success") {
|
|
console.log(data)
|
|
if(data) {
|
|
|
|
} else {
|
|
window.location.href = "/login";
|
|
}
|
|
} else {
|
|
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
|
}
|
|
});
|
|
}
|
|
getUserStatus();
|
|
</script> |