Use vite as bundler
This commit is contained in:
parent
16dc5df9e5
commit
b6f7f75fdd
44 changed files with 4308 additions and 15961 deletions
56
src/components/AuthedImage.vue
Normal file
56
src/components/AuthedImage.vue
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<template>
|
||||
<img v-if="imageSrc" :src="imageSrc" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
|
||||
export default {
|
||||
name: "AuthedImage",
|
||||
props: {
|
||||
src: {
|
||||
type: String,
|
||||
default: function () {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
if (this.src) {
|
||||
console.error("GOT URL", this.src);
|
||||
if (this.$matrix.useAuthedMedia) {
|
||||
axios
|
||||
.get(this.src, { responseType: "blob", headers: {
|
||||
Authorization: `Bearer ${this.$matrix.matrixClient.getAccessToken()}`,
|
||||
}})
|
||||
.then((response) => {
|
||||
this.imageSrc = URL.createObjectURL(response.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("Download error: ", err);
|
||||
});
|
||||
} else {
|
||||
this.imageSrc = this.src;
|
||||
}
|
||||
}
|
||||
},
|
||||
destroyed() {
|
||||
if (this.imageSrc && this.src != this.imageSrc) {
|
||||
const url = this.imageSrc;
|
||||
this.imageSrc = null;
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
imageSrc: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import "@/assets/css/chat.scss";
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue