From 79633150238cced1fe17819c43b78eead0ce030b Mon Sep 17 00:00:00 2001 From: axolotle Date: Tue, 24 Sep 2024 18:41:51 +0200 Subject: [PATCH] refactor: update EmbedVideo to receive other media --- src/components/globals/EmbedVideo.vue | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/components/globals/EmbedVideo.vue b/src/components/globals/EmbedVideo.vue index 35a7fb0..a2f5ec0 100644 --- a/src/components/globals/EmbedVideo.vue +++ b/src/components/globals/EmbedVideo.vue @@ -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 } } } }