fix getMXC add getMediaUrl / fix link color

dev
adb 4 years ago
parent 8a9b5a478b
commit dfaa87f5e7

@ -39,6 +39,9 @@ input:focus{
color: #000; color: #000;
background-color: #fff; background-color: #fff;
} }
a{
color: #00BCD4;
}
*{ *{
scrollbar-width: thin; scrollbar-width: thin;
scrollbar-color: #42b983 #2220; scrollbar-color: #42b983 #2220;

@ -1,11 +1,11 @@
<template> <template>
<img v-if="mxcURL" :src="getAvatarUrl(mxcURL)" class="userThumbnail image"/> <img v-if="mxcURL" :src="getPreviewUrl(mxcURL)" class="userThumbnail image"/>
<div v-else v-html="getJdenticon()" class="userThumbnail identicon"/> <div v-else v-html="getJdenticon()" class="userThumbnail identicon"/>
</template> </template>
<script> <script>
import {toSvg} from 'jdenticon'; import {toSvg} from 'jdenticon';
import {getAvatarUrl} from '@/lib/getMxc'; import {getPreviewUrl} from '@/lib/getMxc';
export default { export default {
name: 'userThumbnail.vue', name: 'userThumbnail.vue',
@ -24,7 +24,7 @@ export default {
getJdenticon(){ getJdenticon(){
return toSvg(this.fallback, this.getFontSize()*this.size); return toSvg(this.fallback, this.getFontSize()*this.size);
}, },
getAvatarUrl getPreviewUrl
}, },
data(){ data(){
return { return {

@ -19,8 +19,14 @@ export function getMxcFromRoomId(roomId){
return getMxcFromRoom(matrix.client.getRoom(roomId)); return getMxcFromRoom(matrix.client.getRoom(roomId));
} }
export function getAvatarUrl(mxcUrl, size = 64, resizeMethod = 'crop'){ export function getPreviewUrl(mxcUrl, size = 64, resizeMethod = 'crop'){
let mxc = parseMXC.parse(mxcUrl); let mxc = parseMXC.parse(mxcUrl);
return `${matrix.baseUrl}/_matrix/media/v1/thumbnail/${ return `${matrix.baseUrl}/_matrix/media/v1/thumbnail/${
mxc.homeserver}/${mxc.id}?width=${size}&height=${size}&method=${resizeMethod}`; mxc.homeserver}/${mxc.id}?width=${size}&height=${size}&method=${resizeMethod}`;
} }
export function getMediaUrl(mxcUrl){
let mxc = parseMXC.parse(mxcUrl);
return `${matrix.baseUrl}/_matrix/media/r0/download/${
mxc.homeserver}/${mxc.id}`;
}
Loading…
Cancel
Save