Commit 795fb51d authored by zhuyangbin's avatar zhuyangbin

图片支持heic

parent ad7a7b13
...@@ -110,7 +110,7 @@ const UploadCom = (props) => { ...@@ -110,7 +110,7 @@ const UploadCom = (props) => {
const obj = checkoutFileType(file.name); const obj = checkoutFileType(file.name);
const typeArr = file.name.match(/\.[a-zA-Z0-9]+$/); const typeArr = file.name.match(/\.[a-zA-Z0-9]+$/);
const type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : ''; const type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : '';
if (!['png', 'gif', 'bmp', 'jpg', 'jpeg'].includes(type)) { if (!['png', 'gif', 'bmp', 'jpg', 'jpeg', 'heic'].includes(type)) {
res(obj.thumbUrl); res(obj.thumbUrl);
} }
}); });
......
...@@ -10,14 +10,12 @@ export default class uploadDetail extends React.Component { ...@@ -10,14 +10,12 @@ export default class uploadDetail extends React.Component {
}; };
onPreview = (url:string, name:string) => { onPreview = (url:string, name:string) => {
console.log('name: ', name);
console.log('url: ', url);
const nameTypeArr = name.match(/\.[a-zA-Z0-9]+$/); const nameTypeArr = name.match(/\.[a-zA-Z0-9]+$/);
const urlTypeArr = url.match(/\.[a-zA-Z0-9]+$/); const urlTypeArr = url.match(/\.[a-zA-Z0-9]+$/);
const typeArr = nameTypeArr || urlTypeArr; const typeArr = nameTypeArr || urlTypeArr;
let type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : ''; let type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : '';
type = type.toLowerCase(); type = type.toLowerCase();
if (['png', 'gif', 'bmp', 'jpg', 'jpeg'].includes(type)) { if (['png', 'gif', 'bmp', 'jpg', 'jpeg', 'heic'].includes(type)) {
this.setState({ showDialog: true, type: 'image', url }); this.setState({ showDialog: true, type: 'image', url });
} else if (['doc', 'docx', 'document', 'xls', 'xlsx', 'ppt', 'pptx'].includes(type)) { } else if (['doc', 'docx', 'document', 'xls', 'xlsx', 'ppt', 'pptx'].includes(type)) {
this.setState({ showDialog: true, type: 'office', url }); this.setState({ showDialog: true, type: 'office', url });
......
...@@ -4,7 +4,7 @@ export const checkoutFileType = (url = '') => { ...@@ -4,7 +4,7 @@ export const checkoutFileType = (url = '') => {
const typeArr = url.match(/\.[a-zA-Z0-9]+$/); const typeArr = url.match(/\.[a-zA-Z0-9]+$/);
let type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : ''; let type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : '';
type = type.toLowerCase(); type = type.toLowerCase();
if (type === 'png' || type === 'jpg' || type === 'gif' || type === 'bmp' || type === 'jpeg') { if (type === 'png' || type === 'jpg' || type === 'gif' || type === 'bmp' || type === 'jpeg' || type === 'heic') {
return { thumbUrl: `${url}?imageView2/1/w/120/h/120`, fileType: type }; return { thumbUrl: `${url}?imageView2/1/w/120/h/120`, fileType: type };
} }
return fileType[type] ? fileType[type] : fileType.other; return fileType[type] ? fileType[type] : fileType.other;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment