refactor: update EmbedVideo to receive other media
This commit is contained in:
@@ -12,7 +12,9 @@ export default {
|
||||
name: 'EmbedVideo',
|
||||
|
||||
props: {
|
||||
src: { type: String, required: true }
|
||||
src: { type: String, required: true },
|
||||
type: { type: String, required: true },
|
||||
full: { type: Boolean, default: false }
|
||||
},
|
||||
|
||||
data () {
|
||||
@@ -54,22 +56,23 @@ export default {
|
||||
|
||||
item () {
|
||||
const embed = this.embed
|
||||
let src = this.src
|
||||
const attrs = this.type === 'iframe' ? { allowfullscreen: true } : { controls: true }
|
||||
|
||||
if (this.full && this.type === 'iframe') {
|
||||
attrs.width = '100%'
|
||||
attrs.height = '100%'
|
||||
}
|
||||
|
||||
if (embed) {
|
||||
const query = Object.entries(embed.params).map(entry => entry.join('=')).join('&')
|
||||
const and = embed.url.indexOf('?') >= 0 ? '&' : '?'
|
||||
return {
|
||||
type: 'iframe',
|
||||
src: this.src.replace(embed.reg, embed.url) + and + query,
|
||||
attrs: { allowfullscreen: true }
|
||||
src = this.src.replace(embed.reg, embed.url)
|
||||
if (!this.full) {
|
||||
src += embed.url.indexOf('?') >= 0 ? '&' : '?' + query
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'video',
|
||||
src: this.src,
|
||||
attrs: { controls: true }
|
||||
}
|
||||
return { type: this.type, src, attrs }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user