mirror of https://github.com/veypi/OneAuth.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
/*
|
|
* 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 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: `<img src="${logic.user.icon}" />`,
|
|
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|