This commit is contained in:
syuilo 2020-09-21 10:09:17 +09:00
parent 5ed0e0e43c
commit c4a83a563d
5 changed files with 30 additions and 27 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<x-window ref="window" :width="400" :height="450" :no-padding="true" @closed="() => { $emit('closed'); destroyDom(); }" :with-ok-button="true" :ok-button-disabled="false" @ok="ok()"> <x-window :width="400" :height="450" :no-padding="true" @close="$emit('done')" :with-ok-button="true" :ok-button-disabled="false" @ok="ok()">
<template #header>{{ $t('notificationSetting') }}</template> <template #header>{{ $t('notificationSetting') }}</template>
<div class="vv94n3oa"> <div class="vv94n3oa">
<div v-if="showGlobalToggle"> <div v-if="showGlobalToggle">
@ -49,6 +49,8 @@ export default defineComponent({
} }
}, },
emits: ['done'],
data() { data() {
return { return {
typesMap: {} as Record<typeof notificationTypes[number], boolean>, typesMap: {} as Record<typeof notificationTypes[number], boolean>,
@ -70,8 +72,7 @@ export default defineComponent({
const includingTypes = this.useGlobalSetting ? null : (Object.keys(this.typesMap) as typeof notificationTypes[number][]) const includingTypes = this.useGlobalSetting ? null : (Object.keys(this.typesMap) as typeof notificationTypes[number][])
.filter(type => this.typesMap[type]); .filter(type => this.typesMap[type]);
this.$emit('ok', { includingTypes }); this.$emit('done', { includingTypes });
this.$refs.window.close();
}, },
disableAll() { disableAll() {

View File

@ -1,5 +1,5 @@
<template> <template>
<x-window ref="window" @closed="() => { $emit('closed'); destroyDom(); }"> <x-window @close="$emit('done')">
<template #header>{{ $t('login') }}</template> <template #header>{{ $t('login') }}</template>
<mk-signin :auto-set="autoSet" @login="onLogin"/> <mk-signin :auto-set="autoSet" @login="onLogin"/>
</x-window> </x-window>
@ -25,10 +25,11 @@ export default defineComponent({
} }
}, },
emits: ['done'],
methods: { methods: {
onLogin(res) { onLogin(res) {
this.$emit('login', res); this.$emit('done', res);
this.$refs.window.close();
} }
} }
}); });

View File

@ -72,6 +72,8 @@ export default defineComponent({
} }
}, },
emits: ['login'],
data() { data() {
return { return {
signing: false, signing: false,
@ -95,15 +97,6 @@ export default defineComponent({
}, },
}, },
created() {
if (this.autoSet) {
this.$once('login', res => {
localStorage.setItem('i', res.i);
location.reload();
});
}
},
methods: { methods: {
onUsernameChange() { onUsernameChange() {
os.api('users/show', { os.api('users/show', {
@ -115,6 +108,13 @@ export default defineComponent({
}); });
}, },
onLogin(res) {
if (this.autoSet) {
localStorage.setItem('i', res.i);
location.reload();
}
},
queryKey() { queryKey() {
this.queryingKey = true; this.queryingKey = true;
return navigator.credentials.get({ return navigator.credentials.get({
@ -144,6 +144,7 @@ export default defineComponent({
}); });
}).then(res => { }).then(res => {
this.$emit('login', res); this.$emit('login', res);
this.onLogin(res);
}).catch(err => { }).catch(err => {
if (err === null) return; if (err === null) return;
os.dialog({ os.dialog({
@ -186,6 +187,7 @@ export default defineComponent({
token: this.user && this.user.twoFactorEnabled ? this.token : undefined token: this.user && this.user.twoFactorEnabled ? this.token : undefined
}).then(res => { }).then(res => {
this.$emit('login', res); this.$emit('login', res);
this.onLogin(res);
}).catch(() => { }).catch(() => {
os.dialog({ os.dialog({
type: 'error', type: 'error',

View File

@ -1,5 +1,5 @@
<template> <template>
<x-window ref="window" :width="366" :height="506" @closed="() => { $emit('closed'); destroyDom(); }"> <x-window :width="366" :height="506" @close="$emit('done')">
<template #header>{{ $t('signup') }}</template> <template #header>{{ $t('signup') }}</template>
<x-signup :auto-set="autoSet" @signup="onSignup"/> <x-signup :auto-set="autoSet" @signup="onSignup"/>
</x-window> </x-window>
@ -25,10 +25,11 @@ export default defineComponent({
} }
}, },
emits: ['done'],
methods: { methods: {
onSignup(res) { onSignup(res) {
this.$emit('signup', res); this.$emit('done', res);
this.$refs.window.close();
} }
} }
}); });

View File

@ -75,6 +75,8 @@ export default defineComponent({
} }
}, },
emits: ['signup'],
data() { data() {
return { return {
host: toUnicode(host), host: toUnicode(host),
@ -115,15 +117,6 @@ export default defineComponent({
} }
}, },
created() {
if (this.autoSet) {
this.$once('signup', res => {
localStorage.setItem('i', res.i);
location.reload();
});
}
},
methods: { methods: {
onChangeUsername() { onChangeUsername() {
if (this.username == '') { if (this.username == '') {
@ -188,6 +181,11 @@ export default defineComponent({
password: this.password password: this.password
}).then(res => { }).then(res => {
this.$emit('signup', res); this.$emit('signup', res);
if (this.autoSet) {
localStorage.setItem('i', res.i);
location.reload();
}
}); });
}).catch(() => { }).catch(() => {
this.submitting = false; this.submitting = false;