mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-21 01:10:39 +08:00
重新引入Redis;用户登录与管理员登录完成;引入NanoID代替UUID;调整Spring Boot idea中的启动参数;swagger页面描述信息完善;更新swagger,更新Api文档
This commit is contained in:
17
bookshelfplus-frontend/views/dashboard/admin/index.html
Normal file
17
bookshelfplus-frontend/views/dashboard/admin/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<%- include("../component/header.html"); %>
|
||||
<%- include("../component/header-admin.html"); %>
|
||||
</head>
|
||||
<body>
|
||||
<%- include("../component/navbar.html"); %>
|
||||
<main class="main">
|
||||
<h1><%= title %></h1>
|
||||
<div id="container">
|
||||
|
||||
</div>
|
||||
</main>
|
||||
<%- include("../component/footer-admin.html"); %>
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,6 @@
|
||||
<div class="footer" style="margin-top: 10vh;">
|
||||
<hr>
|
||||
<p>
|
||||
<a href="/status">网站状态检测</a>
|
||||
</p>
|
||||
</div>
|
@@ -0,0 +1,4 @@
|
||||
<div class="footer" style="margin-top: 10vh;">
|
||||
<hr>
|
||||
<p>书栖网</p>
|
||||
</div>
|
@@ -0,0 +1,6 @@
|
||||
<script>
|
||||
if(localStorage.getItem("is_admin") === "false") {
|
||||
// 是普通用户,跳转到普通用户后台页面
|
||||
window.location.href = "/dashboard/user/index";
|
||||
}
|
||||
</script>
|
@@ -0,0 +1,6 @@
|
||||
<script>
|
||||
if(localStorage.getItem("is_admin") === "true") {
|
||||
// 是管理员用户,跳转到管理员用户后台页面
|
||||
window.location.href = "/dashboard/admin/index";
|
||||
}
|
||||
</script>
|
46
bookshelfplus-frontend/views/dashboard/component/header.html
Normal file
46
bookshelfplus-frontend/views/dashboard/component/header.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<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><%= typeof title !=='undefined' ? title : "前端服务出现异常"; %></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;
|
||||
|
||||
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 = "/";
|
||||
}
|
||||
|
||||
getRequest("/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>
|
45
bookshelfplus-frontend/views/dashboard/component/navbar.html
Normal file
45
bookshelfplus-frontend/views/dashboard/component/navbar.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<div class="navbar">
|
||||
<div class="navbar-grid">
|
||||
<div class="grid-item"></div>
|
||||
<div class="grid-item">
|
||||
<nobr>
|
||||
<h1 onclick="location.href='/'" style="cursor: pointer;">书栖网</h1>
|
||||
</nobr>
|
||||
</div>
|
||||
<div class="grid-item exnarrowHide" style="text-align: right; color: white;">
|
||||
<a href="/">首页</a>
|
||||
<a href="/admin/manage">管理</a>
|
||||
<a style="color: grey;" href="javascript:logout();">退出登录</a>
|
||||
</div>
|
||||
<div class="grid-item"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function logout() {
|
||||
getRequest("/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");
|
||||
// alert("退出登录成功");
|
||||
// window.location.href = "/";
|
||||
location.reload();
|
||||
} else {
|
||||
alert("退出登录失败");
|
||||
}
|
||||
} else {
|
||||
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
alert("退出登录失败");
|
||||
});
|
||||
}
|
||||
</script>
|
17
bookshelfplus-frontend/views/dashboard/user/index.html
Normal file
17
bookshelfplus-frontend/views/dashboard/user/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<%- include("../component/header.html"); %>
|
||||
<%- include("../component/header-user.html"); %>
|
||||
</head>
|
||||
<body>
|
||||
<%- include("../component/navbar.html"); %>
|
||||
<main class="main">
|
||||
<h1><%= title %></h1>
|
||||
<div id="container">
|
||||
|
||||
</div>
|
||||
</main>
|
||||
<%- include("../component/footer-user.html"); %>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user