|
|
|
/*
|
|
|
|
* index.ts
|
|
|
|
* Copyright (C) 2024 veypi <i@veypi.com>
|
|
|
|
* 2024-10-22 17:51
|
|
|
|
* Distributed under terms of the GPL license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import slide from './slide'
|
|
|
|
import v from './v2dom'
|
|
|
|
import bus from '../bus'
|
|
|
|
export default class {
|
|
|
|
slide: slide
|
|
|
|
frame: HTMLElement
|
|
|
|
frame_login?: HTMLElement
|
|
|
|
frame_user?: HTMLElement
|
|
|
|
constructor(frame: HTMLElement) {
|
|
|
|
this.frame = frame
|
|
|
|
this.frame.classList.add('voa')
|
|
|
|
this.slide = new slide()
|
|
|
|
this.mount_user()
|
|
|
|
bus.on('logout', () => {
|
|
|
|
this.mount_login()
|
|
|
|
this.slide.hide()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
mount_login() {
|
|
|
|
this.frame_login = v({
|
|
|
|
class: 'voa-off voa-hover-line-b voa-scale-in',
|
|
|
|
innerHtml: '登录',
|
|
|
|
onclick: () => {
|
|
|
|
console.log('click login')
|
|
|
|
this.frame_login?.classList.add('voa-scale-off')
|
|
|
|
this.mount_user()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if (this.frame_user) {
|
|
|
|
this.frame.removeChild(this.frame_user)
|
|
|
|
}
|
|
|
|
this.frame.appendChild(this.frame_login)
|
|
|
|
}
|
|
|
|
mount_user() {
|
|
|
|
let icon = 'https://public.veypi.com/img/avatar/0001.jpg'
|
|
|
|
this.frame_user = v({
|
|
|
|
class: 'voa-on voa-scale-in',
|
|
|
|
innerHtml: `
|
|
|
|
<img src="${icon}" />
|
|
|
|
`,
|
|
|
|
onclick: () => {
|
|
|
|
this.slide.show()
|
|
|
|
// this.mount_login()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if (this.frame_login) {
|
|
|
|
this.frame.removeChild(this.frame_login)
|
|
|
|
}
|
|
|
|
this.frame.appendChild(this.frame_user)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|