* Update avatar.vue

* Update avatar.vue

* Update avatar.vue
This commit is contained in:
Acid Chicken (硫酸鶏) 2020-07-24 16:58:26 +00:00 committed by GitHub
parent e6c7461757
commit 60e121e222

View File

@ -40,7 +40,23 @@ export default Vue.extend({
: this.user.avatarUrl;
},
},
watch: {
'user.avatarBlurhash'() {
this.$el.style.color = this.getBlurhashAvgColor(this.user.avatarBlurhash);
}
},
mounted() {
this.$el.style.color = this.getBlurhashAvgColor(this.user.avatarBlurhash);
},
methods: {
getBlurhashAvgColor(s) {
return typeof s == 'string'
? '#' + [...s.slice(2, 6)]
.map(x => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~'.indexOf(x))
.reduce((a, c) => a * 83 + c, 0)
.toString(16)
: undefined;
},
onClick(e) {
this.$emit('click', e);
}