| | |
| | | } |
| | | }, |
| | | computed: { |
| | | // blob 临时地址本身不带扩展名,待上传文件靠原始文件名判断类型 |
| | | currentFileName() { |
| | | return (this.currentFile && this.currentFile.fileName) || '' |
| | | }, |
| | | isImage() { |
| | | return /\.(jpg|jpeg|png|gif)$/i.test(this.fileUrl) |
| | | return /\.(jpg|jpeg|png|gif)$/i.test(this.fileUrl) || /\.(jpg|jpeg|png|gif)$/i.test(this.currentFileName) |
| | | }, |
| | | imgUrl() { |
| | | // 图片存在 /img 静态路径下,调用方传的可能是 /word 地址,这里统一换成 /img |
| | |
| | | } |
| | | }, |
| | | fileExt() { |
| | | const match = this.fileUrl.match(/\.([a-zA-Z0-9]+)$/) |
| | | const match = (this.currentFileName || this.fileUrl).match(/\.([a-zA-Z0-9]+)$/) |
| | | return match ? match[1].toUpperCase() : '未知' |
| | | }, |
| | | // 调用方传了 OnlyOffice 的配置才走文档服务,否则用浏览器内置阅读器 |