stash
This commit is contained in:
parent
0434961829
commit
4b11264dfe
3 changed files with 18 additions and 13 deletions
|
@ -23,17 +23,21 @@ export default {
|
|||
servers: []
|
||||
}
|
||||
},
|
||||
methods: mapActions(['fetchImage']),
|
||||
async mounted() {
|
||||
try {
|
||||
const response = await this.fetchImage(this.src);
|
||||
methods: {
|
||||
...mapActions(['fetchImage']),
|
||||
loadImage() {
|
||||
this.fetchImage(this.src).then((response) => {
|
||||
const mime_type = response.headers.get("content-type");
|
||||
const base64 = btoa(new Uint8Array(await response.arrayBuffer())
|
||||
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;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadImage();
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -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) {
|
||||
|
|
|
@ -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"
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue