/* * index.ts * Copyright (C) 2024 veypi * 2024-10-22 17:51 * Distributed under terms of the GPL license. */ import slide from './slide' import v from './v2dom' import logic from '../logic' import bus from '../bus' export default class { slide: slide frame: HTMLElement constructor() { this.slide = new slide() this.frame = v('voa', this.gen_avatar()) } mount(root: Element) { root.appendChild(this.frame) } gen_avatar() { let frame_user = v({ class: 'voa-on', vclass: [() => logic.ready ? 'voa-scale-in' : 'voa-scale-off'], inner: ``, onclick: () => { this.slide.show() // logic.logout() } }) let frame_login = v({ class: 'voa-off voa-hover-line-b', vclass: [() => !logic.ready ? 'voa-scale-in' : 'voa-scale-off'], inner: '登录', onclick: () => { console.log('click login') bus.emit('login') } }) return () => { if (logic.ready) { return frame_user } else { return frame_login } } } }