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.
OneAuth/oaer/lib/components/index.ts

51 lines
1.1 KiB
TypeScript

1 month ago
/*
* 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'
4 weeks ago
import bus from '../bus'
export default class {
1 month ago
slide: slide
frame: HTMLElement
constructor() {
1 month ago
this.slide = new slide()
this.frame = v('voa', this.gen_avatar())
}
mount(root: Element) {
root.appendChild(this.frame)
1 month ago
}
gen_avatar() {
let frame_user = v({
class: 'voa-on',
vclass: [() => logic.ready ? 'voa-scale-in' : 'voa-scale-off'],
inner: `<img src="${logic.user.icon}" />`,
1 month ago
onclick: () => {
this.slide.show()
// logic.logout()
1 month ago
}
})
let frame_login = v({
class: 'voa-off voa-hover-line-b',
vclass: [() => !logic.ready ? 'voa-scale-in' : 'voa-scale-off'],
inner: '登录',
1 month ago
onclick: () => {
console.log('click login')
4 weeks ago
bus.emit('login')
1 month ago
}
})
return () => {
if (logic.ready) {
return frame_user
} else {
return frame_login
}
1 month ago
}
}
}