-
在admin.html頁面中 創建vue對象管理header標簽,並在created里面請求當前登錄的用戶對象,在methods里面聲明logout方法
<script>
let header_vm = new Vue({
el:"header",
data:{
user:{}
},
created:function () {
//發請求得到當前登錄的用戶對象
axios.get("/currentuser").then(function (response) {
//代表沒有登錄
if (response.data==""){
alert("請先登錄!");
location.href="/login.html";
}
header_vm.user = response.data;
})
},
methods: {
logout:function () {
if (!confirm("您確認退出登錄嗎?")){
return;
}
//發出退出登錄請求
axios.get("/logout").then(function () {
//顯示到首頁
location.href="/index.html";
})
}
}
})
</script> -
UserController里面處理獲取當前用戶的請求 和 退出登錄請求
-
在header標簽里面綁定vue相關標簽
發布作品功能
-
建表:
use vrddb;
create table product(id int primary key auto_increment,title varchar(50),author varchar(50),url varchar(255),view_count int,like_count int,created timestamp,category_id int)charset=utf8;
alter table product add intro varchar(255) after author; -
-
創建ProductMapper 里面提供insert方法