fix: markDown部分图片不显示
This commit is contained in:
parent
146de7a88d
commit
ba501f32cb
|
@ -7,4 +7,5 @@ import lombok.Setter;
|
|||
@Setter
|
||||
public class MdUploadRequest {
|
||||
private String id;
|
||||
private String fileName;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue