fix bug
This commit is contained in:
parent
3e40500a49
commit
6e4e8a44de
|
@ -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<Reply>().eq("comment_id", comment.getId()));
|
||||
|
||||
// 删除该数据 包括关联外键的reply表数据
|
||||
boolean isDeleteComment = commentService.remove(new UpdateWrapper<Comment>().eq("id", comment.getId()));
|
||||
|
||||
// 同时需要删除该评论的回复表数据
|
||||
|
@ -168,7 +171,7 @@ public class CommentController {
|
|||
if (comment.getDid() != null) {
|
||||
UpdateWrapper<Discussion> 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, "删除成功");
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
<template>
|
||||
<el-form>
|
||||
<el-form-item label="Input">
|
||||
<el-input type="textarea" v-model="input" @change="changeInput" @keyup.enter.native="changeInput"></el-input>
|
||||
<el-input
|
||||
type="textarea"
|
||||
v-model="input"
|
||||
@change="changeInput"
|
||||
@keyup.enter.native="changeInput"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="Output">
|
||||
</el-form-item>
|
||||
<el-form-item label="Output"> </el-form-item>
|
||||
<div v-html="text"></div>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import katex from 'katex'
|
||||
export default {
|
||||
name: '',
|
||||
data () {
|
||||
return {
|
||||
input: 'c = \\pm\\sqrt{a^2 + b^2}',
|
||||
text: ''
|
||||
export default {
|
||||
name: '',
|
||||
data() {
|
||||
return {
|
||||
input: '$c = \\pm\\sqrt{a^2 + b^2}$',
|
||||
text: '',
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.text = this.renderTex(this.input);
|
||||
},
|
||||
methods: {
|
||||
renderTex(data) {
|
||||
return this.$markDown.render(data);
|
||||
},
|
||||
changeInput() {
|
||||
try {
|
||||
this.text = this.renderTex(this.input);
|
||||
} catch (e) {
|
||||
this.text =
|
||||
'<p style="text-align: center"><span style="color:red">Error Input</span></p>';
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.text = this.renderTex(this.input)
|
||||
},
|
||||
methods: {
|
||||
renderTex (data) {
|
||||
return katex.renderToString(data, {
|
||||
displayMode: true,
|
||||
throwOnError: false
|
||||
})
|
||||
},
|
||||
changeInput () {
|
||||
try {
|
||||
this.text = this.renderTex(this.input)
|
||||
} catch (e) {
|
||||
this.text = '<p style="text-align: center"><span style="color:red">Error Input</span></p>'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
<div class="contest-description">
|
||||
<blockquote
|
||||
v-html="contest.description"
|
||||
v-katex
|
||||
v-highlight
|
||||
class="markdown-body"
|
||||
></blockquote>
|
||||
|
|
|
@ -100,7 +100,6 @@
|
|||
<el-card class="box-card">
|
||||
<div
|
||||
v-html="descriptionHtml"
|
||||
v-katex
|
||||
v-highlight
|
||||
class="markdown-body"
|
||||
></div>
|
||||
|
|
|
@ -96,12 +96,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="body-article">
|
||||
<div
|
||||
class="markdown-body"
|
||||
v-html="contentHtml"
|
||||
v-katex
|
||||
v-highlight
|
||||
></div>
|
||||
<div class="markdown-body" v-html="contentHtml" v-highlight></div>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog
|
||||
|
@ -325,6 +320,8 @@ export default {
|
|||
contentHtml() {
|
||||
if (this.discussion.content) {
|
||||
return this.$markDown.render(this.discussion.content);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -110,7 +110,6 @@
|
|||
<div
|
||||
class="markdown-body"
|
||||
v-html="contentHtml"
|
||||
v-katex
|
||||
v-highlight
|
||||
v-if="contentHtml"
|
||||
></div>
|
||||
|
|
|
@ -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: [
|
||||
|
|
Loading…
Reference in New Issue