diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/CommentController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/CommentController.java index 1d4a18fa..91a804f5 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/CommentController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/CommentController.java @@ -157,7 +157,10 @@ public class CommentController { if (comment.getFromUid().equals(userRolesVo.getUid()) || SecurityUtils.getSubject().hasRole("root") || SecurityUtils.getSubject().hasRole("admin") || SecurityUtils.getSubject().hasRole("problem_admin")) { - // 删除该数据 + // 获取需要删除该评论的回复数 + int replyNum = replyService.count(new UpdateWrapper().eq("comment_id", comment.getId())); + + // 删除该数据 包括关联外键的reply表数据 boolean isDeleteComment = commentService.remove(new UpdateWrapper().eq("id", comment.getId())); // 同时需要删除该评论的回复表数据 @@ -168,7 +171,7 @@ public class CommentController { if (comment.getDid() != null) { UpdateWrapper discussionUpdateWrapper = new UpdateWrapper<>(); discussionUpdateWrapper.eq("id", comment.getDid()) - .setSql("comment_num=comment_num-1"); + .setSql("comment_num=comment_num" + (replyNum + 1)); discussionService.update(discussionUpdateWrapper); } return CommonResult.successResponse(null, "删除成功"); diff --git a/hoj-vue/package-lock.json b/hoj-vue/package-lock.json index ff33aaf3..b79e6c36 100644 --- a/hoj-vue/package-lock.json +++ b/hoj-vue/package-lock.json @@ -1089,6 +1089,14 @@ "@hapi/hoek": "^8.3.0" } }, + "@iktakahiro/markdown-it-katex": { + "version": "4.0.1", + "resolved": "https://registry.npm.taobao.org/@iktakahiro/markdown-it-katex/download/@iktakahiro/markdown-it-katex-4.0.1.tgz", + "integrity": "sha1-Zf+dEq/UwLdoTdJHq+fOQvwe2sM=", + "requires": { + "katex": "^0.12.0" + } + }, "@intervolga/optimize-cssnano-plugin": { "version": "1.0.6", "resolved": "https://registry.npm.taobao.org/@intervolga/optimize-cssnano-plugin/download/@intervolga/optimize-cssnano-plugin-1.0.6.tgz", diff --git a/hoj-vue/package.json b/hoj-vue/package.json index 0dab4e42..dc616bd4 100644 --- a/hoj-vue/package.json +++ b/hoj-vue/package.json @@ -7,6 +7,7 @@ "build": "vue-cli-service build" }, "dependencies": { + "@iktakahiro/markdown-it-katex": "^4.0.1", "axios": "^0.21.0", "browser-detect": "^0.2.28", "compression-webpack-plugin": "^5.0.1", @@ -16,7 +17,6 @@ "font-awesome": "^4.7.0", "highlight.js": "^10.3.2", "jquery": "^3.5.1", - "katex": "^0.12.0", "mavon-editor": "^2.9.1", "moment": "^2.29.1", "muse-ui": "^3.0.2", diff --git a/hoj-vue/src/components/admin/KatexEditor.vue b/hoj-vue/src/components/admin/KatexEditor.vue index b2cefb10..355465eb 100644 --- a/hoj-vue/src/components/admin/KatexEditor.vue +++ b/hoj-vue/src/components/admin/KatexEditor.vue @@ -1,45 +1,45 @@ - + diff --git a/hoj-vue/src/components/oj/comment/comment.vue b/hoj-vue/src/components/oj/comment/comment.vue index 2e6c9a72..887eb738 100644 --- a/hoj-vue/src/components/oj/comment/comment.vue +++ b/hoj-vue/src/components/oj/comment/comment.vue @@ -717,9 +717,8 @@ export default { }) .then(() => { let replyDeleteData = { - id: reply.id, did: this.did, - fromUid: reply.fromUid, + reply: reply, }; api.deleteReply(replyDeleteData).then((res) => { myMessage.success(res.data.msg); diff --git a/hoj-vue/src/main.js b/hoj-vue/src/main.js index 38e0a7b0..c2c685d5 100644 --- a/hoj-vue/src/main.js +++ b/hoj-vue/src/main.js @@ -10,6 +10,8 @@ import Message from 'vue-m-message' import 'vue-m-message/dist/index.css' import axios from 'axios' +import Md_Katex from '@iktakahiro/markdown-it-katex' + // 注释表示使用cdn引入 // import 'xe-utils' // import VXETable from 'vxe-table' @@ -81,7 +83,7 @@ Vue.use(SlideVerify) // 滑动验证码组件 Vue.prototype.$axios = axios -Vue.prototype.$markDown = mavonEditor.markdownIt +Vue.prototype.$markDown = mavonEditor.markdownIt.use(Md_Katex) // 挂载到vue Vue.config.productionTip = false new Vue({ diff --git a/hoj-vue/src/views/oj/Home.vue b/hoj-vue/src/views/oj/Home.vue index ceee1ab6..1784a9da 100644 --- a/hoj-vue/src/views/oj/Home.vue +++ b/hoj-vue/src/views/oj/Home.vue @@ -61,7 +61,6 @@
diff --git a/hoj-vue/src/views/oj/contest/ContestDetails.vue b/hoj-vue/src/views/oj/contest/ContestDetails.vue index 56475b28..37da1fac 100644 --- a/hoj-vue/src/views/oj/contest/ContestDetails.vue +++ b/hoj-vue/src/views/oj/contest/ContestDetails.vue @@ -100,7 +100,6 @@
diff --git a/hoj-vue/src/views/oj/discussion/discussion.vue b/hoj-vue/src/views/oj/discussion/discussion.vue index 0f3105d0..9f8df216 100644 --- a/hoj-vue/src/views/oj/discussion/discussion.vue +++ b/hoj-vue/src/views/oj/discussion/discussion.vue @@ -96,12 +96,7 @@
-
+
diff --git a/hoj-vue/vue.config.js b/hoj-vue/vue.config.js index 46fda183..e964157d 100644 --- a/hoj-vue/vue.config.js +++ b/hoj-vue/vue.config.js @@ -27,7 +27,7 @@ const cdn = { css: [ 'https://cdn.bootcdn.net/ajax/libs/element-ui/2.14.0/theme-chalk/index.min.css', "https://cdn.bootcdn.net/ajax/libs/github-markdown-css/4.0.0/github-markdown.min.css", - "https://cdn.jsdelivr.net/npm/vxe-table@2.9.26/lib/style.css" + "https://cdn.jsdelivr.net/npm/vxe-table@2.9.26/lib/style.css", ], // cdn的js链接 js: [