update 恢复文件预览权限验证,新增图片组件,从接口读取文件流

This commit is contained in:
2021-04-26 11:14:20 +08:00
parent f6258537c2
commit 0849fe5fe2
7 changed files with 129 additions and 12 deletions

View File

@@ -0,0 +1,35 @@
import { ArrayBufferToBase64 } from '@/util/file'
export default {
props: {
type: {
type: String,
default: 'image'
},
id: {
type: [String, Number],
require: true
}
},
data() {
return {
src: ''
}
},
created() {
if (this.id) {
this.$api.sysFileInfoPreview({ id: this.id }).then(async ({ data }) => {
const base64 = await ArrayBufferToBase64(data)
this.src = base64
})
}
},
render() {
return this.type == 'avatar' ?
<a-avatar src={this.src} {...{ props: this.$attrs }} />
:
<img src={this.src} {...{ props: this.$attrs }} />
},
}