update 恢复文件预览权限验证,新增图片组件,从接口读取文件流
This commit is contained in:
35
Web/src/components/yoImage/index.js
Normal file
35
Web/src/components/yoImage/index.js
Normal 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 }} />
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user