fix: markDown部分图片不显示
This commit is contained in:
parent
146de7a88d
commit
ba501f32cb
|
@ -7,4 +7,5 @@ import lombok.Setter;
|
||||||
@Setter
|
@Setter
|
||||||
public class MdUploadRequest {
|
public class MdUploadRequest {
|
||||||
private String id;
|
private String id;
|
||||||
|
private String fileName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -18,14 +20,20 @@ import java.util.Date;
|
||||||
public class ResourceService {
|
public class ResourceService {
|
||||||
|
|
||||||
public void mdUpload(MdUploadRequest request, MultipartFile file) {
|
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) {
|
public ResponseEntity<FileSystemResource> getMdImage(String name) {
|
||||||
File file = new File(FileUtils.MD_IMAGE_DIR + "/" + name);
|
File file = new File(FileUtils.MD_IMAGE_DIR + "/" + name);
|
||||||
HttpHeaders headers = new HttpHeaders();
|
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("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("Pragma", "no-cache");
|
||||||
headers.add("Expires", "0");
|
headers.add("Expires", "0");
|
||||||
headers.add("Last-Modified", new Date().toString());
|
headers.add("Last-Modified", new Date().toString());
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<el-form-item :label="'Jira ' + $t('organization.integration.account')" prop="account">
|
<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-input v-model="data.jiraAccount" :placeholder="$t('organization.integration.input_api_account')"/>
|
||||||
</el-form-item>
|
</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"
|
<el-input v-model="data.jiraPassword" auto-complete="new-password"
|
||||||
:placeholder="$t('organization.integration.input_api_password')" show-password/>
|
:placeholder="$t('organization.integration.input_api_password')" show-password/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<el-form-item :label="$t('organization.integration.account')" prop="account">
|
<el-form-item :label="$t('organization.integration.account')" prop="account">
|
||||||
<el-input v-model="form.account" :placeholder="$t('organization.integration.input_api_account')"/>
|
<el-input v-model="form.account" :placeholder="$t('organization.integration.input_api_account')"/>
|
||||||
</el-form-item>
|
</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"
|
<el-input v-model="form.password" auto-complete="new-password" v-if="showInput"
|
||||||
:placeholder="$t('organization.integration.input_api_password')" show-password/>
|
:placeholder="$t('organization.integration.input_api_password')" show-password/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
|
@ -107,9 +107,11 @@ export default {
|
||||||
};
|
};
|
||||||
file.prefix = param.id;
|
file.prefix = param.id;
|
||||||
this.result.loading = true;
|
this.result.loading = true;
|
||||||
|
// 带括号和空格,可能无法展示
|
||||||
|
param.fileName = file.name.replace("(", "").replace(")", "").replace(" ", "");
|
||||||
this.$fileUpload('/resource/md/upload', file, null, param, () => {
|
this.$fileUpload('/resource/md/upload', file, null, 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 + '_' + file.name);
|
this.$refs.md.$img2Url(pos, '/resource/md/get/' + param.id + '_' + param.fileName);
|
||||||
this.result.loading = false;
|
this.result.loading = false;
|
||||||
});
|
});
|
||||||
this.$emit('imgAdd', file);
|
this.$emit('imgAdd', file);
|
||||||
|
|
Loading…
Reference in New Issue