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

@ -61,7 +61,7 @@ export default defineComponent({
userId: this.user.id, userId: this.user.id,
comment: this.comment, comment: this.comment,
}, undefined, res => { }, undefined, res => {
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts.abuseReported text: this.$ts.abuseReported
}); });

View file

@ -138,13 +138,11 @@ export default defineComponent({
}, },
rename() { rename() {
os.dialog({ os.inputText({
title: this.$ts.renameFile, title: this.$ts.renameFile,
input: { placeholder: this.$ts.inputNewFileName,
placeholder: this.$ts.inputNewFileName, default: this.file.name,
default: this.file.name, allowEmpty: false
allowEmpty: false
}
}).then(({ canceled, result: name }) => { }).then(({ canceled, result: name }) => {
if (canceled) return; if (canceled) return;
os.api('drive/files/update', { os.api('drive/files/update', {
@ -191,10 +189,9 @@ export default defineComponent({
}, },
async deleteFile() { async deleteFile() {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$t('driveFileDeleteConfirm', { name: this.file.name }), text: this.$t('driveFileDeleteConfirm', { name: this.file.name }),
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -151,13 +151,13 @@ export default defineComponent({
}).catch(err => { }).catch(err => {
switch (err) { switch (err) {
case 'detected-circular-definition': case 'detected-circular-definition':
os.dialog({ os.alert({
title: this.$ts.unableToProcess, title: this.$ts.unableToProcess,
text: this.$ts.circularReferenceFolder text: this.$ts.circularReferenceFolder
}); });
break; break;
default: default:
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.somethingHappened text: this.$ts.somethingHappened
}); });
@ -191,12 +191,10 @@ export default defineComponent({
}, },
rename() { rename() {
os.dialog({ os.inputText({
title: this.$ts.renameFolder, title: this.$ts.renameFolder,
input: { placeholder: this.$ts.inputNewFolderName,
placeholder: this.$ts.inputNewFolderName, default: this.folder.name
default: this.folder.name
}
}).then(({ canceled, result: name }) => { }).then(({ canceled, result: name }) => {
if (canceled) return; if (canceled) return;
os.api('drive/folders/update', { os.api('drive/folders/update', {
@ -216,14 +214,14 @@ export default defineComponent({
}).catch(err => { }).catch(err => {
switch(err.id) { switch(err.id) {
case 'b0fc8a17-963c-405d-bfbc-859a487295e1': case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
os.dialog({ os.alert({
type: 'error', type: 'error',
title: this.$ts.unableToDelete, title: this.$ts.unableToDelete,
text: this.$ts.hasChildFilesOrFolders text: this.$ts.hasChildFilesOrFolders
}); });
break; break;
default: default:
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.unableToDelete text: this.$ts.unableToDelete
}); });

View file

@ -274,13 +274,13 @@ export default defineComponent({
}).catch(err => { }).catch(err => {
switch (err) { switch (err) {
case 'detected-circular-definition': case 'detected-circular-definition':
os.dialog({ os.alert({
title: this.$ts.unableToProcess, title: this.$ts.unableToProcess,
text: this.$ts.circularReferenceFolder text: this.$ts.circularReferenceFolder
}); });
break; break;
default: default:
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.somethingHappened text: this.$ts.somethingHappened
}); });
@ -295,11 +295,10 @@ export default defineComponent({
}, },
urlUpload() { urlUpload() {
os.dialog({ os.inputText({
title: this.$ts.uploadFromUrl, title: this.$ts.uploadFromUrl,
input: { type: 'url',
placeholder: this.$ts.uploadFromUrlDescription placeholder: this.$ts.uploadFromUrlDescription
}
}).then(({ canceled, result: url }) => { }).then(({ canceled, result: url }) => {
if (canceled) return; if (canceled) return;
os.api('drive/files/upload-from-url', { os.api('drive/files/upload-from-url', {
@ -307,7 +306,7 @@ export default defineComponent({
folderId: this.folder ? this.folder.id : undefined folderId: this.folder ? this.folder.id : undefined
}); });
os.dialog({ os.alert({
title: this.$ts.uploadFromUrlRequested, title: this.$ts.uploadFromUrlRequested,
text: this.$ts.uploadFromUrlMayTakeTime text: this.$ts.uploadFromUrlMayTakeTime
}); });
@ -315,11 +314,9 @@ export default defineComponent({
}, },
createFolder() { createFolder() {
os.dialog({ os.inputText({
title: this.$ts.createFolder, title: this.$ts.createFolder,
input: { placeholder: this.$ts.folderName
placeholder: this.$ts.folderName
}
}).then(({ canceled, result: name }) => { }).then(({ canceled, result: name }) => {
if (canceled) return; if (canceled) return;
os.api('drive/folders/create', { os.api('drive/folders/create', {
@ -332,12 +329,10 @@ export default defineComponent({
}, },
renameFolder(folder) { renameFolder(folder) {
os.dialog({ os.inputText({
title: this.$ts.renameFolder, title: this.$ts.renameFolder,
input: { placeholder: this.$ts.inputNewFolderName,
placeholder: this.$ts.inputNewFolderName, default: folder.name
default: folder.name
}
}).then(({ canceled, result: name }) => { }).then(({ canceled, result: name }) => {
if (canceled) return; if (canceled) return;
os.api('drive/folders/update', { os.api('drive/folders/update', {
@ -359,14 +354,14 @@ export default defineComponent({
}).catch(err => { }).catch(err => {
switch(err.id) { switch(err.id) {
case 'b0fc8a17-963c-405d-bfbc-859a487295e1': case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
os.dialog({ os.alert({
type: 'error', type: 'error',
title: this.$ts.unableToDelete, title: this.$ts.unableToDelete,
text: this.$ts.hasChildFilesOrFolders text: this.$ts.hasChildFilesOrFolders
}); });
break; break;
default: default:
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.unableToDelete text: this.$ts.unableToDelete
}); });

View file

@ -94,10 +94,9 @@ export default defineComponent({
try { try {
if (this.isFollowing) { if (this.isFollowing) {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$t('unfollowConfirm', { name: this.user.name || this.user.username }), text: this.$t('unfollowConfirm', { name: this.user.name || this.user.username }),
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -456,18 +456,18 @@ export default defineComponent({
os.apiWithDialog('notes/create', { os.apiWithDialog('notes/create', {
renoteId: this.appearNote.id renoteId: this.appearNote.id
}, undefined, (res: any) => { }, undefined, (res: any) => {
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts.renoted, text: this.$ts.renoted,
}); });
}, (e: Error) => { }, (e: Error) => {
if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') { if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantRenote, text: this.$ts.cantRenote,
}); });
} else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') { } else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantReRenote, text: this.$ts.cantReRenote,
}); });
@ -508,18 +508,18 @@ export default defineComponent({
os.apiWithDialog('notes/favorites/create', { os.apiWithDialog('notes/favorites/create', {
noteId: this.appearNote.id noteId: this.appearNote.id
}, undefined, (res: any) => { }, undefined, (res: any) => {
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts.favorited, text: this.$ts.favorited,
}); });
}, (e: Error) => { }, (e: Error) => {
if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') { if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.alreadyFavorited, text: this.$ts.alreadyFavorited,
}); });
} else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') { } else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantFavorite, text: this.$ts.cantFavorite,
}); });
@ -528,10 +528,9 @@ export default defineComponent({
}, },
del() { del() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.noteDeleteConfirm, text: this.$ts.noteDeleteConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
@ -542,10 +541,9 @@ export default defineComponent({
}, },
delEdit() { delEdit() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.deleteAndEditConfirm, text: this.$ts.deleteAndEditConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
@ -781,7 +779,7 @@ export default defineComponent({
noteId: this.appearNote.id noteId: this.appearNote.id
}, undefined, null, e => { }, undefined, null, e => {
if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') { if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.pinLimitExceeded text: this.$ts.pinLimitExceeded
}); });
@ -828,9 +826,8 @@ export default defineComponent({
}, },
async promote() { async promote() {
const { canceled, result: days } = await os.dialog({ const { canceled, result: days } = await os.inputNumber({
title: this.$ts.numberOfDays, title: this.$ts.numberOfDays,
input: { type: 'number' }
}); });
if (canceled) return; if (canceled) return;

View file

@ -432,18 +432,18 @@ export default defineComponent({
os.apiWithDialog('notes/create', { os.apiWithDialog('notes/create', {
renoteId: this.appearNote.id renoteId: this.appearNote.id
}, undefined, (res: any) => { }, undefined, (res: any) => {
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts.renoted, text: this.$ts.renoted,
}); });
}, (e: Error) => { }, (e: Error) => {
if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') { if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantRenote, text: this.$ts.cantRenote,
}); });
} else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') { } else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantReRenote, text: this.$ts.cantReRenote,
}); });
@ -484,18 +484,18 @@ export default defineComponent({
os.apiWithDialog('notes/favorites/create', { os.apiWithDialog('notes/favorites/create', {
noteId: this.appearNote.id noteId: this.appearNote.id
}, undefined, (res: any) => { }, undefined, (res: any) => {
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts.favorited, text: this.$ts.favorited,
}); });
}, (e: Error) => { }, (e: Error) => {
if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') { if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.alreadyFavorited, text: this.$ts.alreadyFavorited,
}); });
} else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') { } else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantFavorite, text: this.$ts.cantFavorite,
}); });
@ -504,10 +504,9 @@ export default defineComponent({
}, },
del() { del() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.noteDeleteConfirm, text: this.$ts.noteDeleteConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
@ -518,10 +517,9 @@ export default defineComponent({
}, },
delEdit() { delEdit() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.deleteAndEditConfirm, text: this.$ts.deleteAndEditConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
@ -757,7 +755,7 @@ export default defineComponent({
noteId: this.appearNote.id noteId: this.appearNote.id
}, undefined, null, e => { }, undefined, null, e => {
if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') { if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.pinLimitExceeded text: this.$ts.pinLimitExceeded
}); });
@ -804,9 +802,8 @@ export default defineComponent({
}, },
async promote() { async promote() {
const { canceled, result: days } = await os.dialog({ const { canceled, result: days } = await os.inputNumber({
title: this.$ts.numberOfDays, title: this.$ts.numberOfDays,
input: { type: 'number' }
}); });
if (canceled) return; if (canceled) return;

View file

@ -29,7 +29,7 @@ export default defineComponent({
click() { click() {
if (this.block.action === 'dialog') { if (this.block.action === 'dialog') {
this.hpml.eval(); this.hpml.eval();
os.dialog({ os.alert({
text: this.hpml.interpolate(this.block.content) text: this.hpml.interpolate(this.block.content)
}); });
} else if (this.block.action === 'resetRandom') { } else if (this.block.action === 'resetRandom') {
@ -44,7 +44,7 @@ export default defineComponent({
} : {}) } : {})
}); });
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.hpml.interpolate(this.block.message) text: this.hpml.interpolate(this.block.message)
}); });

View file

@ -40,7 +40,7 @@ export default defineComponent({
ast = parse(props.page.script); ast = parse(props.page.script);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
/*os.dialog({ /*os.alert({
type: 'error', type: 'error',
text: 'Syntax error :(' text: 'Syntax error :('
});*/ });*/
@ -50,7 +50,7 @@ export default defineComponent({
hpml.eval(); hpml.eval();
}).catch(e => { }).catch(e => {
console.error(e); console.error(e);
/*os.dialog({ /*os.alert({
type: 'error', type: 'error',
text: e text: e
});*/ });*/

View file

@ -73,11 +73,9 @@ export default defineComponent({
}); });
}, },
async rename(file) { async rename(file) {
const { canceled, result } = await os.dialog({ const { canceled, result } = await os.inputText({
title: this.$ts.enterFileName, title: this.$ts.enterFileName,
input: { default: file.name,
default: file.name
},
allowEmpty: false allowEmpty: false
}); });
if (canceled) return; if (canceled) return;

View file

@ -554,10 +554,9 @@ export default defineComponent({
if (!this.renote && !this.quoteId && paste.startsWith(url + '/notes/')) { if (!this.renote && !this.quoteId && paste.startsWith(url + '/notes/')) {
e.preventDefault(); e.preventDefault();
os.dialog({ os.confirm({
type: 'info', type: 'info',
text: this.$ts.quoteQuestion, text: this.$ts.quoteQuestion,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) { if (canceled) {
insertTextAtCursor(this.$refs.text, paste); insertTextAtCursor(this.$refs.text, paste);
@ -676,7 +675,7 @@ export default defineComponent({
}); });
}).catch(err => { }).catch(err => {
this.posting = false; this.posting = false;
os.dialog({ os.alert({
type: 'error', type: 'error',
text: err.message + '\n' + (err as any).id, text: err.message + '\n' + (err as any).id,
}); });

View file

@ -57,7 +57,7 @@ export default defineComponent({
methods: { methods: {
async openDialog() { async openDialog() {
os.dialog({ os.alert({
type: 'warning', type: 'warning',
title: 'Oh my Aichan', title: 'Oh my Aichan',
text: 'Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', text: 'Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',

View file

@ -150,7 +150,7 @@ export default defineComponent({
return this.onLogin(res); return this.onLogin(res);
}).catch(err => { }).catch(err => {
if (err === null) return; if (err === null) return;
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.signinFailed text: this.$ts.signinFailed
}); });
@ -190,7 +190,7 @@ export default defineComponent({
loginFailed(err) { loginFailed(err) {
switch (err.id) { switch (err.id) {
case '6cc579cc-885d-43d8-95c2-b8c7fc963280': { case '6cc579cc-885d-43d8-95c2-b8c7fc963280': {
os.dialog({ os.alert({
type: 'error', type: 'error',
title: this.$ts.loginFailed, title: this.$ts.loginFailed,
text: this.$ts.noSuchUser text: this.$ts.noSuchUser
@ -202,7 +202,7 @@ export default defineComponent({
break; break;
} }
default: { default: {
os.dialog({ os.alert({
type: 'error', type: 'error',
title: this.$ts.loginFailed, title: this.$ts.loginFailed,
text: JSON.stringify(err) text: JSON.stringify(err)

View file

@ -220,7 +220,7 @@ export default defineComponent({
'g-recaptcha-response': this.reCaptchaResponse, 'g-recaptcha-response': this.reCaptchaResponse,
}).then(() => { }).then(() => {
if (this.meta.emailRequiredForSignup) { if (this.meta.emailRequiredForSignup) {
os.dialog({ os.alert({
type: 'success', type: 'success',
title: this.$ts._signup.almostThere, title: this.$ts._signup.almostThere,
text: this.$t('_signup.emailSent', { email: this.email }), text: this.$t('_signup.emailSent', { email: this.email }),
@ -243,7 +243,7 @@ export default defineComponent({
this.$refs.hcaptcha?.reset?.(); this.$refs.hcaptcha?.reset?.();
this.$refs.recaptcha?.reset?.(); this.$refs.recaptcha?.reset?.();
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.somethingHappened text: this.$ts.somethingHappened
}); });

View file

@ -214,13 +214,141 @@ export function modalPageWindow(path: string) {
}, {}, 'closed'); }, {}, 'closed');
} }
export function dialog(props: { export function alert(props: {
type: 'error' | 'info' | 'success' | 'warning' | 'waiting'; type?: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question';
title?: string | null; title?: string | null;
text?: string | null; text?: string | null;
}) { }): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(import('@/components/dialog.vue'), props, { popup(import('@/components/dialog.vue'), props, {
done: result => {
resolve();
},
}, 'closed');
});
}
export function confirm(props: {
type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question';
title?: string | null;
text?: string | null;
}): Promise<{ canceled: boolean }> {
return new Promise((resolve, reject) => {
popup(import('@/components/dialog.vue'), {
...props,
showCancelButton: true,
}, {
done: result => {
resolve(result ? result : { canceled: true });
},
}, 'closed');
});
}
export function inputText(props: {
type?: 'text' | 'email' | 'password' | 'url';
title?: string | null;
text?: string | null;
placeholder?: string | null;
default?: string | null;
}): Promise<{ canceled: true; result: undefined; } | {
canceled: false; result: string;
}> {
return new Promise((resolve, reject) => {
popup(import('@/components/dialog.vue'), {
title: props.title,
text: props.text,
input: {
type: props.type,
placeholder: props.placeholder,
default: props.default,
}
}, {
done: result => {
resolve(result ? result : { canceled: true });
},
}, 'closed');
});
}
export function inputNumber(props: {
title?: string | null;
text?: string | null;
placeholder?: string | null;
default?: number | null;
}): Promise<{ canceled: true; result: undefined; } | {
canceled: false; result: number;
}> {
return new Promise((resolve, reject) => {
popup(import('@/components/dialog.vue'), {
title: props.title,
text: props.text,
input: {
type: 'number',
placeholder: props.placeholder,
default: props.default,
}
}, {
done: result => {
resolve(result ? result : { canceled: true });
},
}, 'closed');
});
}
export function inputDate(props: {
title?: string | null;
text?: string | null;
placeholder?: string | null;
default?: Date | null;
}): Promise<{ canceled: true; result: undefined; } | {
canceled: false; result: Date;
}> {
return new Promise((resolve, reject) => {
popup(import('@/components/dialog.vue'), {
title: props.title,
text: props.text,
input: {
type: 'date',
placeholder: props.placeholder,
default: props.default,
}
}, {
done: result => {
resolve(result ? { result: new Date(result.result), canceled: false } : { canceled: true });
},
}, 'closed');
});
}
export function select(props: {
title?: string | null;
text?: string | null;
default?: string | null;
items?: {
value: string;
text: string;
}[];
groupedItems?: {
label: string;
items: {
value: string;
text: string;
}[];
}[];
}): Promise<{ canceled: true; result: undefined; } | {
canceled: false; result: string;
}> {
return new Promise((resolve, reject) => {
popup(import('@/components/dialog.vue'), {
title: props.title,
text: props.text,
select: {
items: props.items,
groupedItems: props.groupedItems,
default: props.default,
}
}, {
done: result => { done: result => {
resolve(result ? result : { canceled: true }); resolve(result ? result : { canceled: true });
}, },

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -175,10 +175,9 @@ export default defineComponent({
}, },
async confirm(): Promise<boolean> { async confirm(): Promise<boolean> {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.leaveConfirm, text: this.$ts.leaveConfirm,
showCancelButton: true
}); });
return !canceled; return !canceled;
}, },
@ -192,9 +191,8 @@ export default defineComponent({
}, },
async del(i: number) { async del(i: number) {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
showCancelButton: true,
text: this.$t('_theme.deleteConstantConfirm', { const: this.theme[i][0] }), text: this.$t('_theme.deleteConstantConfirm', { const: this.theme[i][0] }),
}); });
if (canceled) return; if (canceled) return;
@ -202,9 +200,8 @@ export default defineComponent({
}, },
async addConst() { async addConst() {
const { canceled, result } = await os.dialog({ const { canceled, result } = await os.inputText({
title: this.$ts._theme.inputConstantName, title: this.$ts._theme.inputConstantName,
input: true
}); });
if (canceled) return; if (canceled) return;
this.theme.push([ '$' + result, '#000000']); this.theme.push([ '$' + result, '#000000']);
@ -213,7 +210,7 @@ export default defineComponent({
save() { save() {
const theme = convertToMisskeyTheme(this.theme, this.name, this.description, this.author, this.baseTheme); const theme = convertToMisskeyTheme(this.theme, this.name, this.description, this.author, this.baseTheme);
addTheme(theme); addTheme(theme);
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$t('_theme.installed', { name: theme.name }) text: this.$t('_theme.installed', { name: theme.name })
}); });
@ -225,7 +222,7 @@ export default defineComponent({
try { try {
applyTheme(theme, false); applyTheme(theme, false);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e.message text: e.message
}); });
@ -246,7 +243,7 @@ export default defineComponent({
this.theme = convertToViewModel(theme); this.theme = convertToViewModel(theme);
this.themeToImport = ''; this.themeToImport = '';
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e.message text: e.message
}); });

View file

@ -93,15 +93,12 @@ export default defineComponent({
}, },
async timetravel() { async timetravel() {
const { canceled, result: date } = await os.dialog({ const { canceled, result: date } = await os.inputDate({
title: this.$ts.date, title: this.$ts.date,
input: {
type: 'date'
}
}); });
if (canceled) return; if (canceled) return;
this.$refs.tl.timetravel(new Date(date)); this.$refs.tl.timetravel(date);
}, },
settings() { settings() {

View file

@ -114,10 +114,9 @@ export default defineComponent({
text: this.$ts.delete, text: this.$ts.delete,
danger: true, danger: true,
action: async () => { action: async () => {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$t('deleteAreYouSure', { x: this.clip.name }), text: this.$t('deleteAreYouSure', { x: this.clip.name }),
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -25,7 +25,7 @@ export default defineComponent({
} else if (res.type === 'Note') { } else if (res.type === 'Note') {
this.$router.push(`/notes/${res.object.id}`); this.$router.push(`/notes/${res.object.id}`);
} else { } else {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: 'Not a user' text: 'Not a user'
}).then(() => { }).then(() => {
@ -45,10 +45,9 @@ export default defineComponent({
methods: { methods: {
async follow(user) { async follow(user) {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'question', type: 'question',
text: this.$t('followConfirm', { name: user.name || user.username }), text: this.$t('followConfirm', { name: user.name || user.username }),
showCancelButton: true
}); });
if (canceled) { if (canceled) {

View file

@ -126,10 +126,9 @@ export default defineComponent({
}, },
async del() { async del() {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.deleteConfirm, text: this.$ts.deleteConfirm,
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
await os.apiWithDialog('gallery/posts/delete', { await os.apiWithDialog('gallery/posts/delete', {

View file

@ -148,9 +148,8 @@ export default defineComponent({
}, },
async unlike() { async unlike() {
const confirm = await os.dialog({ const confirm = await os.confirm({
type: 'warning', type: 'warning',
showCancelButton: true,
text: this.$ts.unlikeConfirm, text: this.$ts.unlikeConfirm,
}); });
if (confirm.canceled) return; if (confirm.canceled) return;

View file

@ -140,22 +140,18 @@ export default defineComponent({
const groups1 = await os.api('users/groups/owned'); const groups1 = await os.api('users/groups/owned');
const groups2 = await os.api('users/groups/joined'); const groups2 = await os.api('users/groups/joined');
if (groups1.length === 0 && groups2.length === 0) { if (groups1.length === 0 && groups2.length === 0) {
os.dialog({ os.alert({
type: 'warning', type: 'warning',
title: this.$ts.youHaveNoGroups, title: this.$ts.youHaveNoGroups,
text: this.$ts.joinOrCreateGroup, text: this.$ts.joinOrCreateGroup,
}); });
return; return;
} }
const { canceled, result: group } = await os.dialog({ const { canceled, result: group } = await os.select({
type: null,
title: this.$ts.group, title: this.$ts.group,
select: { items: groups1.concat(groups2).map(group => ({
items: groups1.concat(groups2).map(group => ({ value: group, text: group.name
value: group, text: group.name }))
}))
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
this.$router.push(`/my/messaging/group/${group.id}`); this.$router.push(`/my/messaging/group/${group.id}`);

View file

@ -95,20 +95,11 @@ export default defineComponent({
const lio = file.name.lastIndexOf('.'); const lio = file.name.lastIndexOf('.');
const ext = lio >= 0 ? file.name.slice(lio) : ''; const ext = lio >= 0 ? file.name.slice(lio) : '';
const formatted = `${formatTimeString(new Date(file.lastModified), this.$store.state.pastedFileName).replace(/{{number}}/g, '1')}${ext}`; const formatted = `${formatTimeString(new Date(file.lastModified), this.$store.state.pastedFileName).replace(/{{number}}/g, '1')}${ext}`;
const name = this.$store.state.pasteDialog if (formatted) this.upload(file, formatted);
? await os.dialog({
title: this.$ts.enterFileName,
input: {
default: formatted
},
allowEmpty: false
}).then(({ canceled, result }) => canceled ? false : result)
: formatted;
if (name) this.upload(file, name);
} }
} else { } else {
if (items[0].kind == 'file') { if (items[0].kind == 'file') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.onlyOneFileCanBeAttached text: this.$ts.onlyOneFileCanBeAttached
}); });
@ -133,7 +124,7 @@ export default defineComponent({
return; return;
} else if (e.dataTransfer.files.length > 1) { } else if (e.dataTransfer.files.length > 1) {
e.preventDefault(); e.preventDefault();
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.onlyOneFileCanBeAttached text: this.$ts.onlyOneFileCanBeAttached
}); });

View file

@ -182,7 +182,7 @@ const Component = defineComponent({
this.form.upload(e.dataTransfer.files[0]); this.form.upload(e.dataTransfer.files[0]);
return; return;
} else if (e.dataTransfer.files.length > 1) { } else if (e.dataTransfer.files.length > 1) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.onlyOneFileCanBeAttached text: this.$ts.onlyOneFileCanBeAttached
}); });

View file

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

View file

@ -106,11 +106,9 @@ export default defineComponent({
}, },
async renameGroup() { async renameGroup() {
const { canceled, result: name } = await os.dialog({ const { canceled, result: name } = await os.inputText({
title: this.$ts.groupName, title: this.$ts.groupName,
input: { default: this.group.name
default: this.group.name
}
}); });
if (canceled) return; if (canceled) return;
@ -132,10 +130,9 @@ export default defineComponent({
}, },
async deleteGroup() { async deleteGroup() {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$t('removeAreYouSure', { x: this.group.name }), text: this.$t('removeAreYouSure', { x: this.group.name }),
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -88,9 +88,8 @@ export default defineComponent({
methods: { methods: {
async create() { async create() {
const { canceled, result: name } = await os.dialog({ const { canceled, result: name } = await os.inputText({
title: this.$ts.groupName, title: this.$ts.groupName,
input: true
}); });
if (canceled) return; if (canceled) return;
await os.api('users/groups/create', { name: name }); await os.api('users/groups/create', { name: name });

View file

@ -46,9 +46,8 @@ export default defineComponent({
methods: { methods: {
async create() { async create() {
const { canceled, result: name } = await os.dialog({ const { canceled, result: name } = await os.inputText({
title: this.$ts.enterListName, title: this.$ts.enterListName,
input: true
}); });
if (canceled) return; if (canceled) return;
await os.api('users/lists/create', { name: name }); await os.api('users/lists/create', { name: name });

View file

@ -100,11 +100,9 @@ export default defineComponent({
}, },
async renameList() { async renameList() {
const { canceled, result: name } = await os.dialog({ const { canceled, result: name } = await os.inputText({
title: this.$ts.enterListName, title: this.$ts.enterListName,
input: { default: this.list.name
default: this.list.name
}
}); });
if (canceled) return; if (canceled) return;
@ -117,10 +115,9 @@ export default defineComponent({
}, },
async deleteList() { async deleteList() {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$t('removeAreYouSure', { x: this.list.name }), text: this.$t('removeAreYouSure', { x: this.list.name }),
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -60,13 +60,9 @@ export default defineComponent({
methods: { methods: {
async add() { async add() {
const { canceled, result: type } = await os.dialog({ const { canceled, result: type } = await os.select({
type: null,
title: this.$ts._pages.chooseBlock, title: this.$ts._pages.chooseBlock,
select: { groupedItems: this.getPageBlockList()
groupedItems: this.getPageBlockList()
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -57,26 +57,18 @@ export default defineComponent({
methods: { methods: {
async rename() { async rename() {
const { canceled, result: title } = await os.dialog({ const { canceled, result: title } = await os.inputText({
title: 'Enter title', title: 'Enter title',
input: { default: this.value.title
type: 'text',
default: this.value.title
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
this.value.title = title; this.value.title = title;
}, },
async add() { async add() {
const { canceled, result: type } = await os.dialog({ const { canceled, result: type } = await os.select({
type: null,
title: this.$ts._pages.chooseBlock, title: this.$ts._pages.chooseBlock,
select: { groupedItems: this.getPageBlockList()
groupedItems: this.getPageBlockList()
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -212,13 +212,9 @@ export default defineComponent({
methods: { methods: {
async changeType() { async changeType() {
const { canceled, result: type } = await os.dialog({ const { canceled, result: type } = await os.select({
type: null,
title: this.$ts._pages.selectType, title: this.$ts._pages.selectType,
select: { groupedItems: this.getScriptBlockList(this.getExpectedType ? this.getExpectedType() : null)
groupedItems: this.getScriptBlockList(this.getExpectedType ? this.getExpectedType() : null)
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
this.modelValue.type = type; this.modelValue.type = type;

View file

@ -272,14 +272,14 @@ export default defineComponent({
const onError = err => { const onError = err => {
if (err.id == '3d81ceae-475f-4600-b2a8-2bc116157532') { if (err.id == '3d81ceae-475f-4600-b2a8-2bc116157532') {
if (err.info.param == 'name') { if (err.info.param == 'name') {
os.dialog({ os.alert({
type: 'error', type: 'error',
title: this.$ts._pages.invalidNameTitle, title: this.$ts._pages.invalidNameTitle,
text: this.$ts._pages.invalidNameText text: this.$ts._pages.invalidNameText
}); });
} }
} else if (err.code == 'NAME_ALREADY_EXISTS') { } else if (err.code == 'NAME_ALREADY_EXISTS') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts._pages.nameAlreadyExists text: this.$ts._pages.nameAlreadyExists
}); });
@ -291,7 +291,7 @@ export default defineComponent({
os.api('pages/update', options) os.api('pages/update', options)
.then(page => { .then(page => {
this.currentName = this.name.trim(); this.currentName = this.name.trim();
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts._pages.updated text: this.$ts._pages.updated
}); });
@ -301,7 +301,7 @@ export default defineComponent({
.then(page => { .then(page => {
this.pageId = page.id; this.pageId = page.id;
this.currentName = this.name.trim(); this.currentName = this.name.trim();
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts._pages.created text: this.$ts._pages.created
}); });
@ -311,16 +311,15 @@ export default defineComponent({
}, },
del() { del() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$t('removeAreYouSure', { x: this.title.trim() }), text: this.$t('removeAreYouSure', { x: this.title.trim() }),
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
os.api('pages/delete', { os.api('pages/delete', {
pageId: this.pageId, pageId: this.pageId,
}).then(() => { }).then(() => {
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts._pages.deleted text: this.$ts._pages.deleted
}); });
@ -335,7 +334,7 @@ export default defineComponent({
os.api('pages/create', this.getSaveOptions()).then(page => { os.api('pages/create', this.getSaveOptions()).then(page => {
this.pageId = page.id; this.pageId = page.id;
this.currentName = this.name.trim(); this.currentName = this.name.trim();
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts._pages.created text: this.$ts._pages.created
}); });
@ -344,13 +343,10 @@ export default defineComponent({
}, },
async add() { async add() {
const { canceled, result: type } = await os.dialog({ const { canceled, result: type } = await os.select({
type: null, type: null,
title: this.$ts._pages.chooseBlock, title: this.$ts._pages.chooseBlock,
select: { groupedItems: this.getPageBlockList()
groupedItems: this.getPageBlockList()
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
@ -359,19 +355,15 @@ export default defineComponent({
}, },
async addVariable() { async addVariable() {
let { canceled, result: name } = await os.dialog({ let { canceled, result: name } = await os.inputText({
title: this.$ts._pages.enterVariableName, title: this.$ts._pages.enterVariableName,
input: {
type: 'text',
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
name = name.trim(); name = name.trim();
if (this.hpml.isUsedName(name)) { if (this.hpml.isUsedName(name)) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts._pages.variableNameIsAlreadyUsed text: this.$ts._pages.variableNameIsAlreadyUsed
}); });

View file

@ -168,9 +168,8 @@ export default defineComponent({
}, },
async unlike() { async unlike() {
const confirm = await os.dialog({ const confirm = await os.confirm({
type: 'warning', type: 'warning',
showCancelButton: true,
text: this.$ts.unlikeConfirm, text: this.$ts.unlikeConfirm,
}); });
if (confirm.canceled) return; if (confirm.canceled) return;

View file

@ -137,10 +137,9 @@ export default defineComponent({
beforeRouteLeave(to, from, next) { beforeRouteLeave(to, from, next) {
if (this.changed) { if (this.changed) {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.leaveConfirm, text: this.$ts.leaveConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) { if (canceled) {
next(false); next(false);
@ -167,15 +166,11 @@ export default defineComponent({
}, },
async add() { async add() {
const { canceled, result: id } = await os.dialog({ const { canceled, result: id } = await os.select({
type: null,
title: this.$ts._rooms.addFurniture, title: this.$ts._rooms.addFurniture,
select: { items: storeItems.map(item => ({
items: storeItems.map(item => ({ value: item.id, text: this.$t('_rooms._furnitures.' + item.id)
value: item.id, text: this.$t('_rooms._furnitures.' + item.id) }))
}))
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
room.addFurniture(id); room.addFurniture(id);
@ -196,7 +191,7 @@ export default defineComponent({
this.changed = false; this.changed = false;
os.success(); os.success();
}).catch((e: any) => { }).catch((e: any) => {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e.message text: e.message
}); });
@ -204,10 +199,9 @@ export default defineComponent({
}, },
clear() { clear() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts._rooms.clearConfirm, text: this.$ts._rooms.clearConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
room.removeAllFurnitures(); room.removeAllFurnitures();

View file

@ -74,9 +74,8 @@ export default defineComponent({
}), { }), {
in: (q) => { in: (q) => {
return new Promise(ok => { return new Promise(ok => {
os.dialog({ os.inputText({
title: q, title: q,
input: {}
}).then(({ canceled, result: a }) => { }).then(({ canceled, result: a }) => {
ok(a); ok(a);
}); });
@ -105,7 +104,7 @@ export default defineComponent({
try { try {
ast = parse(this.code); ast = parse(this.code);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: 'Syntax error :(' text: 'Syntax error :('
}); });
@ -114,7 +113,7 @@ export default defineComponent({
try { try {
await aiscript.exec(ast); await aiscript.exec(ast);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e text: e
}); });

View file

@ -105,11 +105,9 @@ export default defineComponent({
methods: { methods: {
register() { register() {
os.dialog({ os.inputText({
title: this.$ts.password, title: this.$ts.password,
input: { type: 'password'
type: 'password'
}
}).then(({ canceled, result: password }) => { }).then(({ canceled, result: password }) => {
if (canceled) return; if (canceled) return;
os.api('i/2fa/register', { os.api('i/2fa/register', {
@ -121,11 +119,9 @@ export default defineComponent({
}, },
unregister() { unregister() {
os.dialog({ os.inputText({
title: this.$ts.password, title: this.$ts.password,
input: { type: 'password'
type: 'password'
}
}).then(({ canceled, result: password }) => { }).then(({ canceled, result: password }) => {
if (canceled) return; if (canceled) return;
os.api('i/2fa/unregister', { os.api('i/2fa/unregister', {
@ -147,7 +143,7 @@ export default defineComponent({
os.success(); os.success();
this.$i.twoFactorEnabled = true; this.$i.twoFactorEnabled = true;
}).catch(e => { }).catch(e => {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e text: e
}); });
@ -171,11 +167,9 @@ export default defineComponent({
}, },
unregisterKey(key) { unregisterKey(key) {
os.dialog({ os.inputText({
title: this.$ts.password, title: this.$ts.password,
input: { type: 'password'
type: 'password'
}
}).then(({ canceled, result: password }) => { }).then(({ canceled, result: password }) => {
if (canceled) return; if (canceled) return;
return os.api('i/2fa/remove-key', { return os.api('i/2fa/remove-key', {
@ -191,11 +185,9 @@ export default defineComponent({
}, },
addSecurityKey() { addSecurityKey() {
os.dialog({ os.inputText({
title: this.$ts.password, title: this.$ts.password,
input: { type: 'password'
type: 'password'
}
}).then(({ canceled, result: password }) => { }).then(({ canceled, result: password }) => {
if (canceled) return; if (canceled) return;
os.api('i/2fa/register-key', { os.api('i/2fa/register-key', {

View file

@ -52,7 +52,7 @@ export default defineComponent({
permission: permissions, permission: permissions,
}); });
os.dialog({ os.alert({
type: 'success', type: 'success',
title: this.$ts.token, title: this.$ts.token,
text: token text: token

View file

@ -59,10 +59,9 @@ export default defineComponent({
async apply() { async apply() {
localStorage.setItem('customCss', this.localCustomCss); localStorage.setItem('customCss', this.localCustomCss);
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'info', type: 'info',
text: this.$ts.reloadToApplySetting, text: this.$ts.reloadToApplySetting,
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -75,10 +75,9 @@ export default defineComponent({
watch: { watch: {
async navWindow() { async navWindow() {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'info', type: 'info',
text: this.$ts.reloadToApplySetting, text: this.$ts.reloadToApplySetting,
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
@ -92,11 +91,9 @@ export default defineComponent({
methods: { methods: {
async setProfile() { async setProfile() {
const { canceled, result: name } = await os.dialog({ const { canceled, result: name } = await os.inputText({
title: this.$ts._deck.profile, title: this.$ts._deck.profile,
input: { allowEmpty: false
allowEmpty: false
}
}); });
if (canceled) return; if (canceled) return;
this.profile = name; this.profile = name;

View file

@ -46,19 +46,16 @@ export default defineComponent({
methods: { methods: {
async deleteAccount() { async deleteAccount() {
{ {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.deleteAccountConfirm, text: this.$ts.deleteAccountConfirm,
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
} }
const { canceled, result: password } = await os.dialog({ const { canceled, result: password } = await os.inputText({
title: this.$ts.password, title: this.$ts.password,
input: { type: 'password'
type: 'password'
}
}); });
if (canceled) return; if (canceled) return;
@ -66,7 +63,7 @@ export default defineComponent({
password: password password: password
}); });
await os.dialog({ await os.alert({
title: this.$ts._accountDelete.started, title: this.$ts._accountDelete.started,
}); });

View file

@ -52,11 +52,9 @@ export default defineComponent({
methods: { methods: {
save() { save() {
os.dialog({ os.inputText({
title: this.$ts.password, title: this.$ts.password,
input: { type: 'password'
type: 'password'
}
}).then(({ canceled, result: password }) => { }).then(({ canceled, result: password }) => {
if (canceled) return; if (canceled) return;
os.apiWithDialog('i/update-email', { os.apiWithDialog('i/update-email', {

View file

@ -209,10 +209,9 @@ export default defineComponent({
methods: { methods: {
async reloadAsk() { async reloadAsk() {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'info', type: 'info',
text: this.$ts.reloadToApplySetting, text: this.$ts.reloadToApplySetting,
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -67,12 +67,12 @@ export default defineComponent({
target === 'muting' ? 'i/export-mute' : target === 'muting' ? 'i/export-mute' :
null, {}) null, {})
.then(() => { .then(() => {
os.dialog({ os.alert({
type: 'info', type: 'info',
text: this.$ts.exportRequested text: this.$ts.exportRequested
}); });
}).catch((e: any) => { }).catch((e: any) => {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e.message text: e.message
}); });
@ -90,12 +90,12 @@ export default defineComponent({
null, { null, {
fileId: file.id fileId: file.id
}).then(() => { }).then(() => {
os.dialog({ os.alert({
type: 'info', type: 'info',
text: this.$ts.importRequested text: this.$ts.importRequested
}); });
}).catch((e: any) => { }).catch((e: any) => {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e.message text: e.message
}); });

View file

@ -76,17 +76,13 @@ export default defineComponent({
methods: { methods: {
async addItem() { async addItem() {
const menu = Object.keys(this.menuDef).filter(k => !this.$store.state.menu.includes(k)); const menu = Object.keys(this.menuDef).filter(k => !this.$store.state.menu.includes(k));
const { canceled, result: item } = await os.dialog({ const { canceled, result: item } = await os.select({
type: null,
title: this.$ts.addItem, title: this.$ts.addItem,
select: { items: [...menu.map(k => ({
items: [...menu.map(k => ({ value: k, text: this.$ts[this.menuDef[k].title]
value: k, text: this.$ts[this.menuDef[k].title] })), ...[{
})), ...[{ value: '-', text: this.$ts.divider
value: '-', text: this.$ts.divider }]]
}]]
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
this.items = [...this.splited, item].join('\n'); this.items = [...this.splited, item].join('\n');
@ -103,7 +99,7 @@ export default defineComponent({
}, },
async reloadAsk() { async reloadAsk() {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'info', type: 'info',
text: this.$ts.reloadToApplySetting, text: this.$ts.reloadToApplySetting,
showCancelButton: true showCancelButton: true

View file

@ -76,7 +76,7 @@ export default defineComponent({
try { try {
ast = parse(this.code); ast = parse(this.code);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: 'Syntax error :(' text: 'Syntax error :('
}); });
@ -84,7 +84,7 @@ export default defineComponent({
} }
const meta = AiScript.collectMetadata(ast); const meta = AiScript.collectMetadata(ast);
if (meta == null) { if (meta == null) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: 'No metadata found :(' text: 'No metadata found :('
}); });
@ -92,7 +92,7 @@ export default defineComponent({
} }
const data = meta.get(null); const data = meta.get(null);
if (data == null) { if (data == null) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: 'No metadata found :(' text: 'No metadata found :('
}); });
@ -100,7 +100,7 @@ export default defineComponent({
} }
const { name, version, author, description, permissions, config } = data; const { name, version, author, description, permissions, config } = data;
if (name == null || version == null || author == null) { if (name == null || version == null || author == null) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: 'Required property not found :(' text: 'Required property not found :('
}); });

View file

@ -221,7 +221,7 @@ export default defineComponent({
}).then(i => { }).then(i => {
os.success(); os.success();
}).catch(err => { }).catch(err => {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: err.id text: err.id
}); });

View file

@ -111,10 +111,9 @@ export default defineComponent({
}, },
async setDefault() { async setDefault() {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.resetAreYouSure, text: this.$ts.resetAreYouSure,
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -110,17 +110,16 @@ export default defineComponent({
try { try {
JSON5.parse(this.valueForEditor); JSON5.parse(this.valueForEditor);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.invalidValue text: this.$ts.invalidValue
}); });
return; return;
} }
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.saveConfirm, text: this.$ts.saveConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
os.apiWithDialog('i/registry/set', { os.apiWithDialog('i/registry/set', {
@ -132,10 +131,9 @@ export default defineComponent({
}, },
del() { del() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.deleteConfirm, text: this.$ts.deleteConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
os.apiWithDialog('i/registry/remove', { os.apiWithDialog('i/registry/remove', {

View file

@ -64,32 +64,26 @@ export default defineComponent({
methods: { methods: {
async change() { async change() {
const { canceled: canceled1, result: currentPassword } = await os.dialog({ const { canceled: canceled1, result: currentPassword } = await os.inputText({
title: this.$ts.currentPassword, title: this.$ts.currentPassword,
input: { type: 'password'
type: 'password'
}
}); });
if (canceled1) return; if (canceled1) return;
const { canceled: canceled2, result: newPassword } = await os.dialog({ const { canceled: canceled2, result: newPassword } = await os.inputText({
title: this.$ts.newPassword, title: this.$ts.newPassword,
input: { type: 'password'
type: 'password'
}
}); });
if (canceled2) return; if (canceled2) return;
const { canceled: canceled3, result: newPassword2 } = await os.dialog({ const { canceled: canceled3, result: newPassword2 } = await os.inputText({
title: this.$ts.newPasswordRetype, title: this.$ts.newPasswordRetype,
input: { type: 'password'
type: 'password'
}
}); });
if (canceled3) return; if (canceled3) return;
if (newPassword !== newPassword2) { if (newPassword !== newPassword2) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.retypedNotMatch text: this.$ts.retypedNotMatch
}); });
@ -103,11 +97,9 @@ export default defineComponent({
}, },
regenerateToken() { regenerateToken() {
os.dialog({ os.inputText({
title: this.$ts.password, title: this.$ts.password,
input: { type: 'password'
type: 'password'
}
}).then(({ canceled, result: password }) => { }).then(({ canceled, result: password }) => {
if (canceled) return; if (canceled) return;
os.api('i/regenerate_token', { os.api('i/regenerate_token', {

View file

@ -62,21 +62,21 @@ export default defineComponent({
try { try {
theme = JSON5.parse(code); theme = JSON5.parse(code);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts._theme.invalid text: this.$ts._theme.invalid
}); });
return false; return false;
} }
if (!validateTheme(theme)) { if (!validateTheme(theme)) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts._theme.invalid text: this.$ts._theme.invalid
}); });
return false; return false;
} }
if (getThemes().some(t => t.id === theme.id)) { if (getThemes().some(t => t.id === theme.id)) {
os.dialog({ os.alert({
type: 'info', type: 'info',
text: this.$ts._theme.alreadyInstalled text: this.$ts._theme.alreadyInstalled
}); });
@ -95,7 +95,7 @@ export default defineComponent({
const theme = this.parseThemeCode(code); const theme = this.parseThemeCode(code);
if (!theme) return; if (!theme) return;
await addTheme(theme); await addTheme(theme);
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$t('_theme.installed', { name: theme.name }) text: this.$t('_theme.installed', { name: theme.name })
}); });

View file

@ -154,7 +154,7 @@ export default defineComponent({
} }
//#endregion //#endregion
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
title: e.message, title: e.message,
text: e.name text: e.name

View file

@ -202,6 +202,7 @@ export default defineComponent({
methods: { methods: {
async showDialog() { async showDialog() {
this.dialogResult = null; this.dialogResult = null;
/*
this.dialogResult = await os.dialog({ this.dialogResult = await os.dialog({
type: this.dialogType, type: this.dialogType,
title: this.dialogTitle, title: this.dialogTitle,
@ -209,7 +210,7 @@ export default defineComponent({
showCancelButton: this.dialogCancel, showCancelButton: this.dialogCancel,
cancelableByBgClick: this.dialogCancelByBgClick, cancelableByBgClick: this.dialogCancelByBgClick,
input: this.dialogInput ? {} : null input: this.dialogInput ? {} : null
}); });*/
}, },
async form() { async form() {

View file

@ -155,10 +155,9 @@ export default defineComponent({
}, },
async leaveConfirm(): Promise<boolean> { async leaveConfirm(): Promise<boolean> {
const { canceled } = await os.dialog({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.leaveConfirm, text: this.$ts.leaveConfirm,
showCancelButton: true
}); });
return !canceled; return !canceled;
}, },
@ -205,7 +204,7 @@ export default defineComponent({
try { try {
parsed = JSON5.parse(this.themeCode); parsed = JSON5.parse(this.themeCode);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts._theme.invalid text: this.$ts._theme.invalid
}); });
@ -216,11 +215,9 @@ export default defineComponent({
}, },
async saveAs() { async saveAs() {
const { canceled, result: name } = await os.dialog({ const { canceled, result: name } = await os.inputText({
title: this.$ts.name, title: this.$ts.name,
input: { allowEmpty: false
allowEmpty: false
}
}); });
if (canceled) return; if (canceled) return;
@ -236,7 +233,7 @@ export default defineComponent({
ColdDeviceStorage.set('lightTheme', this.theme); ColdDeviceStorage.set('lightTheme', this.theme);
} }
this.changed = false; this.changed = false;
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$t('_theme.installed', { name: this.theme.name }) text: this.$t('_theme.installed', { name: this.theme.name })
}); });

View file

@ -171,15 +171,12 @@ export default defineComponent({
}, },
async timetravel() { async timetravel() {
const { canceled, result: date } = await os.dialog({ const { canceled, result: date } = await os.inputDate({
title: this.$ts.date, title: this.$ts.date,
input: {
type: 'date'
}
}); });
if (canceled) return; if (canceled) return;
this.$refs.tl.timetravel(new Date(date)); this.$refs.tl.timetravel(date);
}, },
focus() { focus() {

View file

@ -171,16 +171,15 @@ export default defineComponent({
userId: this.user.id, userId: this.user.id,
}); });
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$t('newPasswordIs', { password }) text: this.$t('newPasswordIs', { password })
}); });
}, },
async toggleSilence(v) { async toggleSilence(v) {
const confirm = await os.dialog({ const confirm = await os.confirm({
type: 'warning', type: 'warning',
showCancelButton: true,
text: v ? this.$ts.silenceConfirm : this.$ts.unsilenceConfirm, text: v ? this.$ts.silenceConfirm : this.$ts.unsilenceConfirm,
}); });
if (confirm.canceled) { if (confirm.canceled) {
@ -192,9 +191,8 @@ export default defineComponent({
}, },
async toggleSuspend(v) { async toggleSuspend(v) {
const confirm = await os.dialog({ const confirm = await os.confirm({
type: 'warning', type: 'warning',
showCancelButton: true,
text: v ? this.$ts.suspendConfirm : this.$ts.unsuspendConfirm, text: v ? this.$ts.suspendConfirm : this.$ts.unsuspendConfirm,
}); });
if (confirm.canceled) { if (confirm.canceled) {
@ -211,9 +209,8 @@ export default defineComponent({
}, },
async deleteAllFiles() { async deleteAllFiles() {
const confirm = await os.dialog({ const confirm = await os.confirm({
type: 'warning', type: 'warning',
showCancelButton: true,
text: this.$ts.deleteAllFilesConfirm, text: this.$ts.deleteAllFilesConfirm,
}); });
if (confirm.canceled) return; if (confirm.canceled) return;
@ -222,7 +219,7 @@ export default defineComponent({
os.success(); os.success();
}; };
await process().catch(e => { await process().catch(e => {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e.toString() text: e.toString()
}); });

View file

@ -97,15 +97,12 @@ export default defineComponent({
}, },
async timetravel() { async timetravel() {
const { canceled, result: date } = await os.dialog({ const { canceled, result: date } = await os.inputDate({
title: this.$ts.date, title: this.$ts.date,
input: {
type: 'date'
}
}); });
if (canceled) return; if (canceled) return;
this.$refs.tl.timetravel(new Date(date)); this.$refs.tl.timetravel(date);
}, },
focus() { focus() {

View file

@ -57,7 +57,7 @@ export default defineComponent({
}).catch(() => { }).catch(() => {
this.submitting = false; this.submitting = false;
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.somethingHappened text: this.$ts.somethingHappened
}); });

View file

@ -9,16 +9,15 @@ export function createAiScriptEnv(opts) {
USER_NAME: $i ? values.STR($i.name) : values.NULL, USER_NAME: $i ? values.STR($i.name) : values.NULL,
USER_USERNAME: $i ? values.STR($i.username) : values.NULL, USER_USERNAME: $i ? values.STR($i.username) : values.NULL,
'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => { 'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => {
await os.dialog({ await os.alert({
type: type ? type.value : 'info', type: type ? type.value : 'info',
title: title.value, title: title.value,
text: text.value, text: text.value,
}); });
}), }),
'Mk:confirm': values.FN_NATIVE(async ([title, text, type]) => { 'Mk:confirm': values.FN_NATIVE(async ([title, text, type]) => {
const confirm = await os.dialog({ const confirm = await os.confirm({
type: type ? type.value : 'question', type: type ? type.value : 'question',
showCancelButton: true,
title: title.value, title: title.value,
text: text.value, text: text.value,
}); });

View file

@ -14,21 +14,17 @@ export function getUserMenu(user) {
const t = i18n.locale.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく const t = i18n.locale.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく
const lists = await os.api('users/lists/list'); const lists = await os.api('users/lists/list');
if (lists.length === 0) { if (lists.length === 0) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: i18n.locale.youHaveNoLists text: i18n.locale.youHaveNoLists
}); });
return; return;
} }
const { canceled, result: listId } = await os.dialog({ const { canceled, result: listId } = await os.select({
type: null,
title: t, title: t,
select: { items: lists.map(list => ({
items: lists.map(list => ({ value: list.id, text: list.name
value: list.id, text: list.name }))
}))
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
os.apiWithDialog('users/lists/push', { os.apiWithDialog('users/lists/push', {
@ -40,21 +36,17 @@ export function getUserMenu(user) {
async function inviteGroup() { async function inviteGroup() {
const groups = await os.api('users/groups/owned'); const groups = await os.api('users/groups/owned');
if (groups.length === 0) { if (groups.length === 0) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: i18n.locale.youHaveNoGroups text: i18n.locale.youHaveNoGroups
}); });
return; return;
} }
const { canceled, result: groupId } = await os.dialog({ const { canceled, result: groupId } = await os.select({
type: null,
title: i18n.locale.group, title: i18n.locale.group,
select: { items: groups.map(group => ({
items: groups.map(group => ({ value: group.id, text: group.name
value: group.id, text: group.name }))
}))
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
os.apiWithDialog('users/groups/invite', { os.apiWithDialog('users/groups/invite', {
@ -108,9 +100,8 @@ export function getUserMenu(user) {
} }
async function getConfirmed(text: string): Promise<boolean> { async function getConfirmed(text: string): Promise<boolean> {
const confirm = await os.dialog({ const confirm = await os.confirm({
type: 'warning', type: 'warning',
showCancelButton: true,
title: 'confirm', title: 'confirm',
text, text,
}); });

View file

@ -39,9 +39,8 @@ export class Hpml {
}), ...initAiLib(this)}, { }), ...initAiLib(this)}, {
in: (q) => { in: (q) => {
return new Promise(ok => { return new Promise(ok => {
os.dialog({ os.inputText({
title: q, title: q,
input: {}
}).then(({ canceled, result: a }) => { }).then(({ canceled, result: a }) => {
ok(a); ok(a);
}); });

View file

@ -3,9 +3,8 @@ import { i18n } from '@/i18n';
import * as os from '@/os'; import * as os from '@/os';
export async function lookupUser() { export async function lookupUser() {
const { canceled, result } = await os.dialog({ const { canceled, result } = await os.inputText({
title: i18n.locale.usernameOrUserId, title: i18n.locale.usernameOrUserId,
input: true
}); });
if (canceled) return; if (canceled) return;
@ -18,7 +17,7 @@ export async function lookupUser() {
let _notFound = false; let _notFound = false;
const notFound = () => { const notFound = () => {
if (_notFound) { if (_notFound) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: i18n.locale.noSuchUser text: i18n.locale.noSuchUser
}); });

View file

@ -3,9 +3,8 @@ import { i18n } from '@/i18n';
import { router } from '@/router'; import { router } from '@/router';
export async function search() { export async function search() {
const { canceled, result: query } = await os.dialog({ const { canceled, result: query } = await os.inputText({
title: i18n.locale.search, title: i18n.locale.search,
input: true
}); });
if (canceled || query == null || query === '') return; if (canceled || query == null || query === '') return;
@ -35,7 +34,7 @@ export async function search() {
// TODO // TODO
//v.$root.$emit('warp', date); //v.$root.$emit('warp', date);
os.dialog({ os.alert({
icon: 'fas fa-history', icon: 'fas fa-history',
iconOnly: true, autoClose: true iconOnly: true, autoClose: true
}); });

View file

@ -14,7 +14,7 @@ export function selectFile(src: any, label: string | null, multiple = false) {
Promise.all(promises).then(driveFiles => { Promise.all(promises).then(driveFiles => {
res(multiple ? driveFiles : driveFiles[0]); res(multiple ? driveFiles : driveFiles[0]);
}).catch(e => { }).catch(e => {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e text: e
}); });
@ -38,11 +38,10 @@ export function selectFile(src: any, label: string | null, multiple = false) {
}; };
const chooseFileFromUrl = () => { const chooseFileFromUrl = () => {
os.dialog({ os.inputText({
title: i18n.locale.uploadFromUrl, title: i18n.locale.uploadFromUrl,
input: { type: 'url',
placeholder: i18n.locale.uploadFromUrlDescription placeholder: i18n.locale.uploadFromUrlDescription
}
}).then(({ canceled, result: url }) => { }).then(({ canceled, result: url }) => {
if (canceled) return; if (canceled) return;
@ -62,7 +61,7 @@ export function selectFile(src: any, label: string | null, multiple = false) {
marker marker
}); });
os.dialog({ os.alert({
title: i18n.locale.uploadFromUrlRequested, title: i18n.locale.uploadFromUrlRequested,
text: i18n.locale.uploadFromUrlMayTakeTime text: i18n.locale.uploadFromUrlMayTakeTime
}); });

View file

@ -2,7 +2,7 @@ import * as os from '@/os';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
export function showSuspendedDialog() { export function showSuspendedDialog() {
return os.dialog({ return os.alert({
type: 'error', type: 'error',
title: i18n.locale.yourAccountSuspendedTitle, title: i18n.locale.yourAccountSuspendedTitle,
text: i18n.locale.yourAccountSuspendedDescription text: i18n.locale.yourAccountSuspendedDescription

View file

@ -459,18 +459,18 @@ export default defineComponent({
os.apiWithDialog('notes/create', { os.apiWithDialog('notes/create', {
renoteId: this.appearNote.id renoteId: this.appearNote.id
}, undefined, (res: any) => { }, undefined, (res: any) => {
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts.renoted, text: this.$ts.renoted,
}); });
}, (e: Error) => { }, (e: Error) => {
if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') { if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantRenote, text: this.$ts.cantRenote,
}); });
} else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') { } else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantReRenote, text: this.$ts.cantReRenote,
}); });
@ -513,18 +513,18 @@ export default defineComponent({
os.apiWithDialog('notes/favorites/create', { os.apiWithDialog('notes/favorites/create', {
noteId: this.appearNote.id noteId: this.appearNote.id
}, undefined, (res: any) => { }, undefined, (res: any) => {
os.dialog({ os.alert({
type: 'success', type: 'success',
text: this.$ts.favorited, text: this.$ts.favorited,
}); });
}, (e: Error) => { }, (e: Error) => {
if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') { if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.alreadyFavorited, text: this.$ts.alreadyFavorited,
}); });
} else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') { } else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.cantFavorite, text: this.$ts.cantFavorite,
}); });
@ -533,10 +533,9 @@ export default defineComponent({
}, },
del() { del() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.noteDeleteConfirm, text: this.$ts.noteDeleteConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
@ -547,10 +546,9 @@ export default defineComponent({
}, },
delEdit() { delEdit() {
os.dialog({ os.confirm({
type: 'warning', type: 'warning',
text: this.$ts.deleteAndEditConfirm, text: this.$ts.deleteAndEditConfirm,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
@ -770,7 +768,7 @@ export default defineComponent({
noteId: this.appearNote.id noteId: this.appearNote.id
}, undefined, null, e => { }, undefined, null, e => {
if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') { if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: this.$ts.pinLimitExceeded text: this.$ts.pinLimitExceeded
}); });
@ -817,9 +815,8 @@ export default defineComponent({
}, },
async promote() { async promote() {
const { canceled, result: days } = await os.dialog({ const { canceled, result: days } = await os.inputNumber({
title: this.$ts.numberOfDays, title: this.$ts.numberOfDays,
input: { type: 'number' }
}); });
if (canceled) return; if (canceled) return;

View file

@ -155,9 +155,8 @@ export default defineComponent({
}, },
async inChannelSearch() { async inChannelSearch() {
const { canceled, result: query } = await os.dialog({ const { canceled, result: query } = await os.inputText({
title: this.$ts.inChannelSearch, title: this.$ts.inChannelSearch,
input: true
}); });
if (canceled || query == null || query === '') return; if (canceled || query == null || query === '') return;
router.push(`/search?q=${encodeURIComponent(query)}&channel=${this.channelId}`); router.push(`/search?q=${encodeURIComponent(query)}&channel=${this.channelId}`);

View file

@ -450,10 +450,9 @@ export default defineComponent({
if (!this.renote && !this.quoteId && paste.startsWith(url + '/notes/')) { if (!this.renote && !this.quoteId && paste.startsWith(url + '/notes/')) {
e.preventDefault(); e.preventDefault();
os.dialog({ os.confirm({
type: 'info', type: 'info',
text: this.$ts.quoteQuestion, text: this.$ts.quoteQuestion,
showCancelButton: true
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) { if (canceled) {
insertTextAtCursor(this.$refs.text, paste); insertTextAtCursor(this.$refs.text, paste);
@ -567,7 +566,7 @@ export default defineComponent({
}); });
}).catch(err => { }).catch(err => {
this.posting = false; this.posting = false;
os.dialog({ os.alert({
type: 'error', type: 'error',
text: err.message + '\n' + (err as any).id, text: err.message + '\n' + (err as any).id,
}); });

View file

@ -118,15 +118,11 @@ export default defineComponent({
'direct', 'direct',
]; ];
const { canceled, result: column } = await os.dialog({ const { canceled, result: column } = await os.select({
title: this.$ts._deck.addColumn, title: this.$ts._deck.addColumn,
type: null, items: columns.map(column => ({
select: { value: column, text: this.$t('_deck._columns.' + column)
items: columns.map(column => ({ }))
value: column, text: this.$t('_deck._columns.' + column)
}))
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;

View file

@ -52,16 +52,12 @@ export default defineComponent({
methods: { methods: {
async setAntenna() { async setAntenna() {
const antennas = await os.api('antennas/list'); const antennas = await os.api('antennas/list');
const { canceled, result: antenna } = await os.dialog({ const { canceled, result: antenna } = await os.select({
title: this.$ts.selectAntenna, title: this.$ts.selectAntenna,
type: null, items: antennas.map(x => ({
select: { value: x, text: x.name
items: antennas.map(x => ({ })),
value: x, text: x.name
})),
default: this.column.antennaId default: this.column.antennaId
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
updateColumn(this.column.id, { updateColumn(this.column.id, {

View file

@ -52,16 +52,12 @@ export default defineComponent({
methods: { methods: {
async setList() { async setList() {
const lists = await os.api('users/lists/list'); const lists = await os.api('users/lists/list');
const { canceled, result: list } = await os.dialog({ const { canceled, result: list } = await os.select({
title: this.$ts.selectList, title: this.$ts.selectList,
type: null, items: lists.map(x => ({
select: { value: x, text: x.name
items: lists.map(x => ({ })),
value: x, text: x.name default: this.column.listId
})),
default: this.column.listId
},
showCancelButton: true
}); });
if (canceled) return; if (canceled) return;
updateColumn(this.column.id, { updateColumn(this.column.id, {

View file

@ -69,20 +69,17 @@ export default defineComponent({
methods: { methods: {
async setType() { async setType() {
const { canceled, result: src } = await os.dialog({ const { canceled, result: src } = await os.select({
title: this.$ts.timeline, title: this.$ts.timeline,
type: null, items: [{
select: { value: 'home', text: this.$ts._timelines.home
items: [{ }, {
value: 'home', text: this.$ts._timelines.home value: 'local', text: this.$ts._timelines.local
}, { }, {
value: 'local', text: this.$ts._timelines.local value: 'social', text: this.$ts._timelines.social
}, { }, {
value: 'social', text: this.$ts._timelines.social value: 'global', text: this.$ts._timelines.global
}, { }]
value: 'global', text: this.$ts._timelines.global
}]
},
}); });
if (canceled) { if (canceled) {
if (this.column.tl == null) { if (this.column.tl == null) {

View file

@ -57,9 +57,8 @@ export default defineComponent({
}), { }), {
in: (q) => { in: (q) => {
return new Promise(ok => { return new Promise(ok => {
os.dialog({ os.inputText({
title: q, title: q,
input: {}
}).then(({ canceled, result: a }) => { }).then(({ canceled, result: a }) => {
ok(a); ok(a);
}); });
@ -88,7 +87,7 @@ export default defineComponent({
try { try {
ast = parse(this.props.script); ast = parse(this.props.script);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: 'Syntax error :(' text: 'Syntax error :('
}); });
@ -97,7 +96,7 @@ export default defineComponent({
try { try {
await aiscript.exec(ast); await aiscript.exec(ast);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e text: e
}); });

View file

@ -50,9 +50,8 @@ export default defineComponent({
}), { }), {
in: (q) => { in: (q) => {
return new Promise(ok => { return new Promise(ok => {
os.dialog({ os.inputText({
title: q, title: q,
input: {}
}).then(({ canceled, result: a }) => { }).then(({ canceled, result: a }) => {
ok(a); ok(a);
}); });
@ -70,7 +69,7 @@ export default defineComponent({
try { try {
ast = parse(this.props.script); ast = parse(this.props.script);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: 'Syntax error :(' text: 'Syntax error :('
}); });
@ -79,7 +78,7 @@ export default defineComponent({
try { try {
await aiscript.exec(ast); await aiscript.exec(ast);
} catch (e) { } catch (e) {
os.dialog({ os.alert({
type: 'error', type: 'error',
text: e text: e
}); });