fchat-rising/bbcode/IconView.vue

81 lines
1.7 KiB
Vue
Raw Normal View History

2020-10-31 22:21:40 +00:00
<template>
<a
:href="`${Utils.siteDomain}c/${character}`"
target="_blank"
@mouseover.prevent="show()"
@mouseenter.prevent="show()"
@mouseleave.prevent="dismiss()"
2021-03-25 21:54:10 +00:00
@click.middle.prevent.stop="toggleStickyness()"
2020-10-31 22:21:40 +00:00
@click.right.passive="dismiss(true)"
@click.left.passive="dismiss(true)"
2024-01-27 03:45:59 +00:00
><img :src="getAvatarUrl()" class="character-avatar icon" :title="character" :alt="character" v-once></a>
2020-10-31 22:21:40 +00:00
</template>
<script lang="ts">
import {Component, Hook, Prop} from '@f-list/vue-ts';
import Vue from 'vue';
import { EventBus } from '../chat/preview/event-bus';
import * as Utils from '../site/utils';
2024-01-27 03:45:59 +00:00
import { characterImage } from '../chat/common';
2020-10-31 22:21:40 +00:00
@Component
export default class IconView extends Vue {
Utils = Utils;
@Prop({required: true})
readonly character!: string;
@Hook('mounted')
mounted(): void {
// do nothing
}
@Hook('beforeDestroy')
beforeDestroy(): void {
this.dismiss();
}
@Hook('deactivated')
deactivate(): void {
this.dismiss();
}
getCharacterUrl(): string {
return `flist-character://${this.character}`;
}
2024-01-27 03:45:59 +00:00
getAvatarUrl(): string {
return characterImage(this.character);
}
2020-10-31 22:21:40 +00:00
dismiss(force: boolean = false): void {
// if (!this.preview) {
// return;
// }
EventBus.$emit('imagepreview-dismiss', {url: this.getCharacterUrl(), force});
}
show(): void {
// if (!this.preview) {
// return;
// }
EventBus.$emit('imagepreview-show', {url: this.getCharacterUrl()});
}
toggleStickyness(): void {
// if (!this.preview) {
// return;
// }
EventBus.$emit('imagepreview-toggle-stickyness', {url: this.getCharacterUrl()});
}
}
</script>