Add missing logout

This commit is contained in:
Pig Fang 2018-08-12 09:31:50 +08:00
parent 0889276494
commit 4470b7ba9c
2 changed files with 26 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import './i18n';
import './net';
import './layout';
import './logout';

View File

@ -0,0 +1,25 @@
import { post } from './net';
import { swal } from './notify';
import { trans } from './i18n';
export async function logout() {
const { dismiss } = await swal({
text: trans('general.confirmLogout'),
type: 'warning',
showCancelButton: true,
confirmButtonText: trans('general.confirm'),
cancelButtonText: trans('general.cancel')
});
if (dismiss) {
return;
}
const { msg } = await post('/auth/logout');
setTimeout(() => window.location = blessing.base_url, 1000);
swal({
type: 'success',
html: msg
});
}
$('#logout-button').click(logout);