refactor(client): refactor dialog functions to improve type inference

This commit is contained in:
syuilo
2021-11-18 18:45:58 +09:00
parent 63415f1074
commit ea9aeef9d8
84 changed files with 415 additions and 460 deletions

View File

@ -101,10 +101,9 @@ export default defineComponent({
},
remove(ad) {
os.dialog({
os.confirm({
type: 'warning',
text: this.$t('removeAreYouSure', { x: ad.url }),
showCancelButton: true
}).then(({ canceled }) => {
if (canceled) return;
this.ads = this.ads.filter(x => x != ad);

View File

@ -76,10 +76,9 @@ export default defineComponent({
},
remove(announcement) {
os.dialog({
os.confirm({
type: 'warning',
text: this.$t('removeAreYouSure', { x: announcement.title }),
showCancelButton: true
}).then(({ canceled }) => {
if (canceled) return;
this.announcements = this.announcements.filter(x => x != announcement);
@ -90,24 +89,24 @@ export default defineComponent({
save(announcement) {
if (announcement.id == null) {
os.api('admin/announcements/create', announcement).then(() => {
os.dialog({
os.alert({
type: 'success',
text: this.$ts.saved
});
}).catch(e => {
os.dialog({
os.alert({
type: 'error',
text: e
});
});
} else {
os.api('admin/announcements/update', announcement).then(() => {
os.dialog({
os.alert({
type: 'success',
text: this.$ts.saved
});
}).catch(e => {
os.dialog({
os.alert({
type: 'error',
text: e
});

View File

@ -96,11 +96,10 @@ export default defineComponent({
},
async testEmail() {
const { canceled, result: destination } = await os.dialog({
const { canceled, result: destination } = await os.inputText({
title: this.$ts.destination,
input: {
placeholder: this.$instance.maintainerEmail
}
type: 'email',
placeholder: this.$instance.maintainerEmail
});
if (canceled) return;
os.apiWithDialog('admin/send-email', {

View File

@ -89,10 +89,9 @@ export default defineComponent({
},
async del() {
const { canceled } = await os.dialog({
const { canceled } = await os.confirm({
type: 'warning',
text: this.$t('removeAreYouSure', { x: this.emoji.name }),
showCancelButton: true
});
if (canceled) return;

View File

@ -86,10 +86,9 @@ export default defineComponent({
},
async del() {
const { canceled } = await os.dialog({
const { canceled } = await os.confirm({
type: 'warning',
text: this.$t('removeAreYouSure', { x: this.file.name }),
showCancelButton: true
});
if (canceled) return;

View File

@ -124,10 +124,9 @@ export default defineComponent({
methods: {
clear() {
os.dialog({
os.confirm({
type: 'warning',
text: this.$ts.clearCachedFilesConfirm,
showCancelButton: true
}).then(({ canceled }) => {
if (canceled) return;
@ -146,7 +145,7 @@ export default defineComponent({
this.show(file);
}).catch(e => {
if (e.code === 'NO_SUCH_FILE') {
os.dialog({
os.alert({
type: 'error',
text: this.$ts.notFound
});

View File

@ -281,12 +281,12 @@ export default defineComponent({
const invite = () => {
os.api('admin/invite').then(x => {
os.dialog({
os.alert({
type: 'info',
text: x.code
});
}).catch(e => {
os.dialog({
os.alert({
type: 'error',
text: e
});

View File

@ -57,11 +57,10 @@ export default defineComponent({
methods: {
clear() {
os.dialog({
os.confirm({
type: 'warning',
title: this.$ts.clearQueueConfirmTitle,
text: this.$ts.clearQueueConfirmText,
showCancelButton: true
}).then(({ canceled }) => {
if (canceled) return;

View File

@ -53,11 +53,10 @@ export default defineComponent({
methods: {
async addRelay() {
const { canceled, result: inbox } = await os.dialog({
const { canceled, result: inbox } = await os.inputText({
title: this.$ts.addRelay,
input: {
placeholder: this.$ts.inboxUrl
}
type: 'url',
placeholder: this.$ts.inboxUrl
});
if (canceled) return;
os.api('admin/relays/add', {
@ -65,7 +64,7 @@ export default defineComponent({
}).then((relay: any) => {
this.refresh();
}).catch((e: any) => {
os.dialog({
os.alert({
type: 'error',
text: e.message || e
});
@ -78,7 +77,7 @@ export default defineComponent({
}).then(() => {
this.refresh();
}).catch((e: any) => {
os.dialog({
os.alert({
type: 'error',
text: e.message || e
});

View File

@ -150,15 +150,14 @@ export default defineComponent({
},
async addUser() {
const { canceled: canceled1, result: username } = await os.dialog({
const { canceled: canceled1, result: username } = await os.inputText({
title: this.$ts.username,
input: true
});
if (canceled1) return;
const { canceled: canceled2, result: password } = await os.dialog({
const { canceled: canceled2, result: password } = await os.inputText({
title: this.$ts.password,
input: { type: 'password' }
type: 'password'
});
if (canceled2) return;