mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-06 12:52:44 +02:00
use async / await.
This commit is contained in:
parent
aae55ea585
commit
b808530f0c
7 changed files with 96 additions and 99 deletions
|
@ -143,23 +143,27 @@
|
|||
return this.$accessor.client.about_page
|
||||
}
|
||||
|
||||
async Load() {
|
||||
this.loading = true
|
||||
|
||||
try {
|
||||
const res = await this.$http.get<string>('https://raw.githubusercontent.com/m1k1o/neko/dev/README.md')
|
||||
const res2 = await this.$http.post('https://api.github.com/markdown', {
|
||||
text: res.data,
|
||||
mode: 'gfm',
|
||||
context: 'github/gollum',
|
||||
})
|
||||
this.$accessor.client.setAbout(res2.data)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
mounted() {
|
||||
if (this.about === '') {
|
||||
this.loading = true
|
||||
this.$http
|
||||
.get<string>('https://raw.githubusercontent.com/m1k1o/neko/dev/README.md')
|
||||
.then((res) => {
|
||||
return this.$http.post('https://api.github.com/markdown', {
|
||||
text: res.data,
|
||||
mode: 'gfm',
|
||||
context: 'github/gollum',
|
||||
})
|
||||
})
|
||||
.then((res) => {
|
||||
this.$accessor.client.setAbout(res.data)
|
||||
this.loading = false
|
||||
})
|
||||
.catch((err) => console.error(err))
|
||||
this.Load()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -204,23 +204,23 @@
|
|||
}
|
||||
}
|
||||
|
||||
async login() {
|
||||
login() {
|
||||
let password = this.password
|
||||
if (this.autoPassword !== null) {
|
||||
password = this.autoPassword
|
||||
}
|
||||
|
||||
try {
|
||||
await this.$accessor.login({ displayname: this.displayname, password })
|
||||
|
||||
this.autoPassword = null
|
||||
} catch (err) {
|
||||
if (this.displayname == '') {
|
||||
this.$swal({
|
||||
title: this.$t('connect.error') as string,
|
||||
text: err.message,
|
||||
text: 'Display Name cannot be empty.' as string, // TODO: Add to i18n.
|
||||
icon: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.$accessor.login({ displayname: this.displayname, password })
|
||||
this.autoPassword = null
|
||||
}
|
||||
|
||||
about() {
|
||||
|
|
|
@ -165,64 +165,64 @@
|
|||
this.context.open(event, data)
|
||||
}
|
||||
|
||||
kick(member: Member) {
|
||||
this.$swal({
|
||||
async kick(member: Member) {
|
||||
const value = await this.$swal({
|
||||
title: this.$t('context.confirm.kick_title', { name: member.displayname }) as string,
|
||||
text: this.$t('context.confirm.kick_text', { name: member.displayname }) as string,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: this.$t('context.confirm.button_yes') as string,
|
||||
cancelButtonText: this.$t('context.confirm.button_cancel') as string,
|
||||
}).then(({ value }) => {
|
||||
if (value) {
|
||||
this.$accessor.user.kick(member)
|
||||
}
|
||||
})
|
||||
|
||||
if (value) {
|
||||
this.$accessor.user.kick(member)
|
||||
}
|
||||
}
|
||||
|
||||
ban(member: Member) {
|
||||
this.$swal({
|
||||
async ban(member: Member) {
|
||||
const value = await this.$swal({
|
||||
title: this.$t('context.confirm.ban_title', { name: member.displayname }) as string,
|
||||
text: this.$t('context.confirm.ban_text', { name: member.displayname }) as string,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: this.$t('context.confirm.button_yes') as string,
|
||||
cancelButtonText: this.$t('context.confirm.button_cancel') as string,
|
||||
}).then(({ value }) => {
|
||||
if (value) {
|
||||
this.$accessor.user.ban(member)
|
||||
}
|
||||
})
|
||||
|
||||
if (value) {
|
||||
this.$accessor.user.ban(member)
|
||||
}
|
||||
}
|
||||
|
||||
mute(member: Member) {
|
||||
this.$swal({
|
||||
async mute(member: Member) {
|
||||
const value = await this.$swal({
|
||||
title: this.$t('context.confirm.mute_title', { name: member.displayname }) as string,
|
||||
text: this.$t('context.confirm.mute_text', { name: member.displayname }) as string,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: this.$t('context.confirm.button_yes') as string,
|
||||
cancelButtonText: this.$t('context.confirm.button_cancel') as string,
|
||||
}).then(({ value }) => {
|
||||
if (value) {
|
||||
this.$accessor.user.mute(member)
|
||||
}
|
||||
})
|
||||
|
||||
if (value) {
|
||||
this.$accessor.user.mute(member)
|
||||
}
|
||||
}
|
||||
|
||||
unmute(member: Member) {
|
||||
this.$swal({
|
||||
async unmute(member: Member) {
|
||||
const value = await this.$swal({
|
||||
title: this.$t('context.confirm.unmute_title', { name: member.displayname }) as string,
|
||||
text: this.$t('context.confirm.unmute_text', { name: member.displayname }) as string,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: this.$t('context.confirm.button_yes') as string,
|
||||
cancelButtonText: this.$t('context.confirm.button_cancel') as string,
|
||||
}).then(({ value }) => {
|
||||
if (value) {
|
||||
this.$accessor.user.unmute(member)
|
||||
}
|
||||
})
|
||||
|
||||
if (value) {
|
||||
this.$accessor.user.unmute(member)
|
||||
}
|
||||
}
|
||||
|
||||
adminRelease(member: Member) {
|
||||
|
|
|
@ -482,18 +482,14 @@
|
|||
return key
|
||||
}
|
||||
|
||||
play() {
|
||||
async play() {
|
||||
if (!this._video.paused || !this.playable) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
this._video
|
||||
.play()
|
||||
.then(() => {
|
||||
this.onResise()
|
||||
})
|
||||
.catch((err) => this.$log.error)
|
||||
await this._video.play()
|
||||
this.onResise()
|
||||
} catch (err) {
|
||||
this.$log.error(err)
|
||||
}
|
||||
|
@ -569,21 +565,21 @@
|
|||
this.onResise()
|
||||
}
|
||||
|
||||
onFocus() {
|
||||
async onFocus() {
|
||||
if (!document.hasFocus() || !this.$accessor.active) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.hosting && this.clipboard_read_available) {
|
||||
navigator.clipboard
|
||||
.readText()
|
||||
.then((text) => {
|
||||
if (this.clipboard !== text) {
|
||||
this.$accessor.remote.setClipboard(text)
|
||||
this.$accessor.remote.sendClipboard(text)
|
||||
}
|
||||
})
|
||||
.catch(this.$log.error)
|
||||
try {
|
||||
const text = await navigator.clipboard.readText()
|
||||
if (this.clipboard !== text) {
|
||||
this.$accessor.remote.setClipboard(text)
|
||||
this.$accessor.remote.sendClipboard(text)
|
||||
}
|
||||
} catch (err) {
|
||||
this.$log.error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue