From 3e8b5d36d3b87a3e8d4d29092b43303de7008c4b Mon Sep 17 00:00:00 2001 From: Himit_ZH <372347736@qq.com> Date: Mon, 27 Dec 2021 20:46:32 +0800 Subject: [PATCH] delete user upload md img --- .../file/MarkDownFileController.java | 2 + .../hcode/hoj/dao/xml/UserRecordMapper.xml | 6 +- hoj-vue/src/components/admin/Editor.vue | 57 ++++++++++++++++++- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/file/MarkDownFileController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/file/MarkDownFileController.java index a32218a4..a817fa78 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/file/MarkDownFileController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/file/MarkDownFileController.java @@ -41,6 +41,7 @@ public class MarkDownFileController { @RequestMapping(value = "/upload-md-img", method = RequestMethod.POST) @RequiresAuthentication @ResponseBody + @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR) public CommonResult uploadMDImg(@RequestParam("image") MultipartFile image, HttpServletRequest request) { if (image == null) { return CommonResult.errorResponse("上传的图片不能为空!"); @@ -90,6 +91,7 @@ public class MarkDownFileController { @RequestMapping(value = "/delete-md-img", method = RequestMethod.GET) @RequiresAuthentication @ResponseBody + @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR) public CommonResult deleteMDImg(@RequestParam("fileId") Long fileId, HttpServletRequest request) { // 获取当前登录用户 diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserRecordMapper.xml b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserRecordMapper.xml index 54a8aa5f..78ece253 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserRecordMapper.xml +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserRecordMapper.xml @@ -2,7 +2,7 @@ - SELECT ui.uuid AS uid, ui.nickname, ui.username, ui.signature, ui.avatar + SELECT ui.uuid AS uid, ui.nickname, ui.username, left(ui.signature,100) as signature, ui.avatar , ( SELECT COUNT(DISTINCT pid) FROM user_acproblem diff --git a/hoj-vue/src/components/admin/Editor.vue b/hoj-vue/src/components/admin/Editor.vue index b4007161..340aefcd 100644 --- a/hoj-vue/src/components/admin/Editor.vue +++ b/hoj-vue/src/components/admin/Editor.vue @@ -6,6 +6,7 @@ @imgDel="$imgDel" :ishljs="true" :autofocus="false" + :toolbars="toolbars" v-model="currentValue" codeStyle="arduino-light" > @@ -46,11 +47,54 @@ export default { return { currentValue: this.value, img_file: {}, + toolbars: { + bold: true, // 粗体 + italic: true, // 斜体 + header: true, // 标题 + underline: true, // 下划线 + strikethrough: true, // 中划线 + mark: true, // 标记 + superscript: true, // 上角标 + subscript: true, // 下角标 + quote: true, // 引用 + ol: true, // 有序列表 + ul: true, // 无序列表 + link: true, // 链接 + imagelink: false, // 图片链接 + code: true, // code + table: true, // 表格 + fullscreen: true, // 全屏编辑 + readmodel: true, // 沉浸式阅读 + htmlcode: true, // 展示html源码 + help: true, // 帮助 + /* 1.3.5 */ + undo: true, // 上一步 + redo: true, // 下一步 + trash: true, // 清空 + save: true, // 保存(触发events中的save事件) + /* 1.4.2 */ + navigation: true, // 导航目录 + /* 2.1.8 */ + alignleft: true, // 左对齐 + aligncenter: true, // 居中 + alignright: true, // 右对齐 + /* 2.2.1 */ + subfield: true, // 单双栏模式 + preview: true, // 预览 + }, }; }, + created() { + if (this.isAdminRole) { + this.toolbars.imagelink = true; + } + }, methods: { // 将图片上传到服务器,返回地址替换到md中 $imgAdd(pos, $file) { + if (!this.isAdminRole) { + return; + } var formdata = new FormData(); formdata.append('image', $file); //将下面上传接口替换为你自己的服务器接口 @@ -103,6 +147,9 @@ export default { }); }, }, + computed: { + ...mapGetters(['isAdminRole']), + }, watch: { value(val) { if (this.currentValue !== val) { @@ -117,9 +164,13 @@ export default { }); } }, - }, - computed: { - ...mapGetters(['isAdminRole']), + isAdminRole(val) { + if (!val) { + this.toolbars.imagelink = false; + } else { + this.toolbars.imagelink = true; + } + }, }, };