diff --git a/.idea/ForestBlog.iml b/.idea/ForestBlog.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/ForestBlog.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..7e94b14
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c9c9203..993b230 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,8 +5,7 @@
-
-
+
@@ -16,28 +15,18 @@
-
-
+
+
+
+
+
+
+
@@ -55,6 +44,7 @@
1733319500475
+
diff --git a/src/webapp/resource/assets/js/back.js b/src/webapp/resource/assets/js/back.js
index 74919ab..5788fed 100644
--- a/src/webapp/resource/assets/js/back.js
+++ b/src/webapp/resource/assets/js/back.js
@@ -1,3 +1,4 @@
+// 检查全选框是否被选中,并根据状态设置其他复选框的选中状态
function DoCheck() {
var ch = document.getElementsByName("ids");
if (document.getElementById("allSelect").checked == true) {
@@ -11,25 +12,25 @@ function DoCheck() {
}
}
+// 确认删除操作,弹出确认对话框,根据用户选择返回true或false
function confirmDelete() {
var msg = "您确定要删除吗?";
- if (confirm(msg)==true){
+ if (confirm(msg) == true) {
return true;
- }else{
+ } else {
return false;
}
}
-//获取相对路径
-function getPath(){
+// 获取当前页面的相对路径
+function getPath() {
var pathName = document.location.pathname;
var index = pathName.substr(1).indexOf("/");
- var result = pathName.substr(0,index+1);
+ var result = pathName.substr(0, index + 1);
return result;
}
-
-//显示和隐藏row-actions
+// 当鼠标进入dashboard-comment-wrap时显示row-actions,离开时隐藏
$(".dashboard-comment-wrap").mouseenter(function () {
$(this).find(".row-actions").show();
})
@@ -37,118 +38,115 @@ $(".dashboard-comment-wrap").mouseleave(function () {
$(this).find(".row-actions").hide();
})
-//删除评论
+// 删除评论,先确认删除,然后发送AJAX请求删除评论,并刷新页面
function deleteComment(id) {
- if(confirmDelete()==true){
+ if (confirmDelete() == true) {
$.ajax({
async: false,
type: "POST",
- url:'/admin/comment/delete/'+id,
- contentType : "application/x-www-form-urlencoded; charset=utf-8",
+ url: '/admin/comment/delete/' + id,
+ contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "text",
- complete:function () {
+ complete: function () {
window.location.reload();
}
})
}
}
-//添加草稿
+// 添加草稿,检查文章内容和标题是否为空,然后发送AJAX请求添加草稿,并刷新页面
function insertDraft() {
- if($("#articleContent").val!=""&&$("#articleTitle").val()!="") {
+ if ($("#articleContent").val != "" && $("#articleTitle").val() != "") {
$.ajax({
async: false,
type: "POST",
- url:'/admin/article/insert',
- contentType : "application/x-www-form-urlencoded; charset=utf-8",
+ url: '/admin/article/insert',
+ contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "text",
- complete:function () {
+ complete: function () {
window.location.reload();
}
- })
+ })
}
-
}
-//删除文章
+// 删除文章,先确认删除,然后发送AJAX请求删除文章,并刷新页面
function deleteArticle(id) {
- if(confirmDelete()==true){
+ if (confirmDelete() == true) {
$.ajax({
async: false,
type: "POST",
- url:'/admin/article/delete/'+id,
- contentType : "application/x-www-form-urlencoded; charset=utf-8",
+ url: '/admin/article/delete/' + id,
+ contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "text",
- complete:function () {
+ complete: function () {
window.location.reload();
}
})
}
}
-//查询文章
+// 查询文章,提交表单到搜索页面
function queryArticle() {
//提交form
$("#articleForm").attr("action", "/admin/article/search");
$("#articleForm").submit();
}
-//批量删除文章
+// 批量删除文章,先确认删除,然后获取选中的文章ID,发送AJAX请求批量删除,并刷新页面
function confirmDeleteArticleBatch() {
- if(confirmDelete()==true){
- var text = $("input:checkbox[name='ids']:checked").map(function(index,elem) {
+ if (confirmDelete() == true) {
+ var text = $("input:checkbox[name='ids']:checked").map(function (index, elem) {
return $(elem).val();
}).get().join(',');
$.ajax({
async: false,
type: "POST",
- url:'/admin/article/deleteBatch',
- data:{ids:text},
- contentType : "application/x-www-form-urlencoded; charset=utf-8",
+ url: '/admin/article/deleteBatch',
+ data: { ids: text },
+ contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "text",
- complete:function () {
+ complete: function () {
window.location.reload();
}
})
}
}
-//退出登录
+// 退出登录,发送AJAX请求退出登录,并刷新页面
function logout() {
$.ajax({
async: false,
type: "POST",
- url:'/admin/logout',
- contentType : "application/x-www-form-urlencoded; charset=utf-8",
+ url: '/admin/logout',
+ contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "text",
- complete:function () {
+ complete: function () {
window.location.reload();
}
})
}
-
-
-//添加用户检查用户名是否存在
+// 添加用户时检查用户名是否存在
function checkUserName() {
var result;
$.ajax({
- async: false,//同步,待请求完毕后再执行后面的代码
+ async: false, //同步,待请求完毕后再执行后面的代码
type: "POST",
url: '/admin/user/checkUserName',
contentType: "application/x-www-form-urlencoded; charset=utf-8",
- data: {"username": $("#userName").val(), "id": $("#userId").val()},
+ data: { "username": $("#userName").val(), "id": $("#userId").val() },
dataType: "json",
success: function (data) {
//用户名存在
- if(data.code==1) {
+ if (data.code == 1) {
$("#userNameTips").html(data.msg);
- result=1;
+ result = 1;
}
//用户名不存在
- if(data.code==0) {
+ if (data.code == 0) {
$("#userNameTips").html(data.msg);
- result=0;
+ result = 0;
}
},
error: function () {
@@ -158,26 +156,26 @@ function checkUserName() {
return result;
}
-//添加用户检查电子邮箱是否存在
+// 添加用户时检查电子邮箱是否存在
function checkUserEmail() {
var result;
$.ajax({
- async: false,//同步,待请求完毕后再执行后面的代码
+ async: false, //同步,待请求完毕后再执行后面的代码
type: "POST",
url: '/admin/user/checkUserEmail',
contentType: "application/x-www-form-urlencoded; charset=utf-8",
- data: {"email": $("#userEmail").val(), "id": $("#userId").val()},
+ data: { "email": $("#userEmail").val(), "id": $("#userId").val() },
dataType: "json",
success: function (data) {
- //用户名存在
- if(data.code==1) {
+ //电子邮箱存在
+ if (data.code == 1) {
$("#userEmailTips").html(data.msg);
- result=1;
+ result = 1;
}
- //用户名不存在
- if(data.code==0) {
+ //电子邮箱不存在
+ if (data.code == 0) {
$("#userEmailTips").html(data.msg);
- result=0;
+ result = 0;
}
},
error: function () {
@@ -187,29 +185,28 @@ function checkUserEmail() {
return result;
}
-
-
-//添加用户验证和编辑用户验证
+// 使用layui框架进行表单验证
layui.use(['form', 'layedit', 'laydate'], function () {
var form = layui.form, layer = layui.layer;
form.verify({
-
+ // 用户名验证规则
userName: function (value) {
if (value.length > 12 || value.length < 4) {
return "用户名必须4到12位";
}
- if(checkUserName()==1) {
+ if (checkUserName() == 1) {
return "用户名已存在";
}
},
+ // 电子邮箱验证规则
userEmail: function () {
- if(checkUserEmail()==1) {
+ if (checkUserEmail() == 1) {
return "电子邮箱已存在";
}
}
-
});
+ // 表单提交事件
form.on('submit(demo1)', function (data) {
return true;
});