mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2025-03-02 10:57:32 +00:00
refactor(image link mixin): adds image link mixin
This commit is contained in:
parent
dfa4c6c083
commit
d2f1699a59
15
mixins/imageHelper.ts
Normal file
15
mixins/imageHelper.ts
Normal file
@ -0,0 +1,15 @@
|
||||
const imageHelper = {
|
||||
methods: {
|
||||
/**
|
||||
* returns a URL with the link to the image
|
||||
* @param id itemId to get image for
|
||||
* @param type type of image (primary/backdrop)
|
||||
* @returns URL of the link to the image
|
||||
*/
|
||||
getImageLink(id: string, type: string): string {
|
||||
return `${this.$axios.defaults.baseURL}/Items/${id}/Images/${type}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default imageHelper;
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-img :src="imageLink(item.Id, 'backdrop')"></v-img>
|
||||
<v-img :src="getImageLink(item.Id, 'backdrop')"></v-img>
|
||||
<h1>{{ item.Name }}</h1>
|
||||
<p>{{ item.Overview }}</p>
|
||||
<v-btn color="primary">Play {{ item.Type }}</v-btn>
|
||||
@ -10,8 +10,10 @@
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import imageHelper from '~/mixins/imageHelper';
|
||||
|
||||
export default Vue.extend({
|
||||
mixins: [imageHelper],
|
||||
data() {
|
||||
return {
|
||||
item: {}
|
||||
@ -27,12 +29,6 @@ export default Vue.extend({
|
||||
});
|
||||
|
||||
this.item = Item.data.Items[0];
|
||||
},
|
||||
methods: {
|
||||
imageLink(id: string, type: string) {
|
||||
const url = `${this.$axios.defaults.baseURL}/Items/${id}/Images/${type}`;
|
||||
return url;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user