24 lines
599 B
TypeScript
24 lines
599 B
TypeScript
import { Message, MessageBox } from 'element-ui'
|
|
import { post } from './net'
|
|
import { trans } from './i18n'
|
|
|
|
export async function logout() {
|
|
try {
|
|
await MessageBox.confirm(trans('general.confirmLogout'), {
|
|
type: 'warning',
|
|
})
|
|
} catch {
|
|
return
|
|
}
|
|
|
|
const { message } = await post('/auth/logout')
|
|
setTimeout(() => (window.location.href = blessing.base_url), 1000)
|
|
Message.success(message)
|
|
}
|
|
|
|
const button = document.querySelector('#logout-button')
|
|
/* istanbul ignore next, not all pages contains this button. */
|
|
if (button) {
|
|
button.addEventListener('click', logout)
|
|
}
|