import { Vue, Prop, Component, Watch } from "vue-property-decorator"; import { IActiveTerminal } from "@/types"; import Thumbnail from "../../Thumbnail/index.vue"; import Icon from "../../Icon/index.vue"; import Overview from "../Overview/index.vue"; import Create from "../Create/index.vue"; @Component({ components: { Icon, Thumbnail, Overview, Create, }, }) export default class SwitchTerminal extends Vue { @Prop({ type: Boolean, default: false }) active!: boolean; @Prop({ type: String, required: true }) title!: string; @Prop({ type: String, required: true }) link!: string; @Prop({ type: String }) icon?: string; @Prop({ type: String }) img?: string; @Prop({ type: String }) activeTerminal?: IActiveTerminal; @Prop({ type: String }) alt?: string; @Prop({ type: Boolean, default: false }) isFocused?: boolean; terminalLogo = ""; currentLogo(t: any) { const img = new Image(); img.src = `${t}/128x128.png?d=404`; img.onload = () => { this.terminalLogo = `${t}/128x128.png?d=404`; }; img.onerror = () => { this.terminalLogo = ""; }; } async created() { await this.currentLogo(this.img); } @Watch('img') async onChangeImg(newImg) { await this.currentLogo(newImg) } }