This commit is contained in:
j3d1 2023-12-13 02:00:59 +01:00
parent 0434961829
commit 4b11264dfe
3 changed files with 18 additions and 13 deletions

View file

@ -23,17 +23,21 @@ export default {
servers: []
}
},
methods: mapActions(['fetchImage']),
async mounted() {
try {
const response = await this.fetchImage(this.src);
const mime_type = response.headers.get("content-type");
const base64 = btoa(new Uint8Array(await response.arrayBuffer())
.reduce((data, byte) => data + String.fromCharCode(byte), ""));
this.image_data = "data:" + mime_type + ";base64," + base64;
} catch (e) {
console.log(e);
methods: {
...mapActions(['fetchImage']),
loadImage() {
this.fetchImage(this.src).then((response) => {
const mime_type = response.headers.get("content-type");
response.arrayBuffer().then((buf) => {
const base64 = btoa(new Uint8Array(buf)
.reduce((data, byte) => data + String.fromCharCode(byte), ""));
this.image_data = "data:" + mime_type + ";base64," + base64;
});
})
}
},
mounted() {
this.loadImage();
}
}
</script>

View file

@ -208,14 +208,15 @@ const store = new Vuex.Store({
await dispatch('loadTickets');
},
async fetchImage({state}, url) {
return await fetch(url, {headers: {'Authorization': `Token ${state.token}`}}).then(r => r.blob());
return await fetch(url, {headers: {'Authorization': `Token ${state.token}`}});
},
async loadEvents({commit}) {
const {data} = await axios.get('/2/events/');
commit('replaceEvents', data);
},
changeEvent({dispatch, getters}, eventName) {
changeEvent({dispatch, getters, commit}, eventName) {
router.push({path: `/${eventName.slug}/${getters.getActiveView}/`});
commit('replaceLoadedItems', []);
dispatch('loadEventItems');
},
changeView({getters}, link) {

View file

@ -44,7 +44,7 @@
v-slot="{ item }"
@itemActivated="openLightboxModalWith($event)"
>
<AuthenticatedImage
<AuthenticatedImage v-if="item.file"
:src="`/media/2/256/${item.file}/`"
class="card-img-top img-fluid"
/>