fix: markDown部分图片不显示

This commit is contained in:
chenjianxing 2021-11-24 14:21:21 +08:00 committed by jianxing
parent 146de7a88d
commit ba501f32cb
5 changed files with 16 additions and 5 deletions

View File

@ -7,4 +7,5 @@ import lombok.Setter;
@Setter
public class MdUploadRequest {
private String id;
private String fileName;
}

View File

@ -11,6 +11,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Date;
@Service
@ -18,14 +20,20 @@ import java.util.Date;
public class ResourceService {
public void mdUpload(MdUploadRequest request, MultipartFile file) {
FileUtils.uploadFile(file, FileUtils.MD_IMAGE_DIR, request.getId() + "_" + file.getOriginalFilename());
FileUtils.uploadFile(file, FileUtils.MD_IMAGE_DIR, request.getId() + "_" + request.getFileName());
}
public ResponseEntity<FileSystemResource> getMdImage(String name) {
File file = new File(FileUtils.MD_IMAGE_DIR + "/" + name);
HttpHeaders headers = new HttpHeaders();
String fileName = "";
try {
fileName = URLEncoder.encode(file.getName(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
headers.add("Content-Disposition", "attachment; filename=" + file.getName());
headers.add("Content-Disposition", "attachment; filename=" + fileName);
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
headers.add("Last-Modified", new Date().toString());

View File

@ -6,7 +6,7 @@
<el-form-item :label="'Jira ' + $t('organization.integration.account')" prop="account">
<el-input v-model="data.jiraAccount" :placeholder="$t('organization.integration.input_api_account')"/>
</el-form-item>
<el-form-item :label="'Jira ' + $t('organization.integration.password')" prop="password">
<el-form-item label="Token" prop="password">
<el-input v-model="data.jiraPassword" auto-complete="new-password"
:placeholder="$t('organization.integration.input_api_password')" show-password/>
</el-form-item>

View File

@ -6,7 +6,7 @@
<el-form-item :label="$t('organization.integration.account')" prop="account">
<el-input v-model="form.account" :placeholder="$t('organization.integration.input_api_account')"/>
</el-form-item>
<el-form-item :label="$t('organization.integration.password')" prop="password">
<el-form-item label="Token" prop="password">
<el-input v-model="form.password" auto-complete="new-password" v-if="showInput"
:placeholder="$t('organization.integration.input_api_password')" show-password/>
</el-form-item>

View File

@ -107,9 +107,11 @@ export default {
};
file.prefix = param.id;
this.result.loading = true;
//
param.fileName = file.name.replace("(", "").replace(")", "").replace(" ", "");
this.$fileUpload('/resource/md/upload', file, null, param, () => {
this.$success(this.$t('commons.save_success'));
this.$refs.md.$img2Url(pos, '/resource/md/get/' + param.id + '_' + file.name);
this.$refs.md.$img2Url(pos, '/resource/md/get/' + param.id + '_' + param.fileName);
this.result.loading = false;
});
this.$emit('imgAdd', file);