fix: markdown图片名是中文的无法显示

This commit is contained in:
chenjianxing 2022-01-12 16:44:57 +08:00 committed by song-tianyang
parent 15b143228f
commit ff0124d74f
4 changed files with 8 additions and 8 deletions

View File

@ -15,7 +15,7 @@ public class ShiroUtils {
public static void loadBaseFilterChain(Map<String, String> filterChainDefinitionMap) { public static void loadBaseFilterChain(Map<String, String> filterChainDefinitionMap) {
filterChainDefinitionMap.put("/resource/md/get/*", "anon"); filterChainDefinitionMap.put("/resource/md/get", "anon");
filterChainDefinitionMap.put("/*.worker.js", "anon"); filterChainDefinitionMap.put("/*.worker.js", "anon");
filterChainDefinitionMap.put("/login", "anon"); filterChainDefinitionMap.put("/login", "anon");
filterChainDefinitionMap.put("/signin", "anon"); filterChainDefinitionMap.put("/signin", "anon");
@ -78,7 +78,6 @@ public class ShiroUtils {
filterChainDefinitionMap.put("/language", "apikey, authc");// 跳转到 /language 不用校验 csrf filterChainDefinitionMap.put("/language", "apikey, authc");// 跳转到 /language 不用校验 csrf
filterChainDefinitionMap.put("/test/case/file/preview/**", "apikey, authc"); // 预览测试用例附件 不用校验 csrf filterChainDefinitionMap.put("/test/case/file/preview/**", "apikey, authc"); // 预览测试用例附件 不用校验 csrf
filterChainDefinitionMap.put("/mock", "apikey, authc"); // 跳转到 /mock接口 不用校验 csrf filterChainDefinitionMap.put("/mock", "apikey, authc"); // 跳转到 /mock接口 不用校验 csrf
filterChainDefinitionMap.put("/resource/md/get/**", "apikey, authc");
} }
public static Cookie getSessionIdCookie() { public static Cookie getSessionIdCookie() {

View File

@ -20,8 +20,8 @@ public class ResourceController {
resourceService.mdUpload(request, file); resourceService.mdUpload(request, file);
} }
@GetMapping(value = "/md/get/{fileName}") @GetMapping(value = "/md/get")
public ResponseEntity<FileSystemResource> getFile(@PathVariable("fileName") String fileName) { public ResponseEntity<FileSystemResource> getFile(@RequestParam ("fileName") String fileName) {
return resourceService.getMdImage(fileName); return resourceService.getMdImage(fileName);
} }

View File

@ -154,7 +154,8 @@ export default {
this.result.loading = true; this.result.loading = true;
uploadMarkDownImg(file, (response, param) => { uploadMarkDownImg(file, (response, param) => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.$refs.md.$img2Url(pos, '/resource/md/get/' + param.id + '_' + param.fileName); let url = '/resource/md/get?fileName=' + param.id + '_' + encodeURIComponent(param.fileName);
this.$refs.md.$img2Url(pos, url);
this.result.loading = false; this.result.loading = false;
}); });
this.$emit('imgAdd', file); this.$emit('imgAdd', file);

View File

@ -168,9 +168,9 @@ export default {
let returnFlag = false; let returnFlag = false;
if (param) { if (param) {
let message = param + ""; let message = param + "";
let matchIndex = message.indexOf("](/resource/md/get/"); let matchIndex = message.indexOf("](/resource/md/get");
if (matchIndex > 0) { if (matchIndex > 0) {
let messageSplitArr = message.split("](/resource/md/get/"); let messageSplitArr = message.split("](/resource/md/get");
for (let itemIndex = 0; itemIndex < messageSplitArr.length; itemIndex++) { for (let itemIndex = 0; itemIndex < messageSplitArr.length; itemIndex++) {
let itemStr = messageSplitArr[itemIndex]; let itemStr = messageSplitArr[itemIndex];
let picNameIndex = itemStr.indexOf("!["); let picNameIndex = itemStr.indexOf("![");
@ -183,7 +183,7 @@ export default {
this.imgNameList.push(itemStrArr); this.imgNameList.push(itemStrArr);
} }
let imgUrl = "/resource/md/get/" + itemStrArr; let imgUrl = "/resource/md/get" + itemStrArr;
this.src = imgUrl; this.src = imgUrl;
if (this.srcList.indexOf(itemStrArr) < 0) { if (this.srcList.indexOf(itemStrArr) < 0) {
this.srcList.push(imgUrl); this.srcList.push(imgUrl);