This commit is contained in:
syuilo
2020-09-05 11:14:42 +09:00
parent 190486d841
commit c399e3151e
73 changed files with 329 additions and 254 deletions

View File

@@ -60,7 +60,7 @@ export default defineComponent({
methods: {
async setAntenna() {
const antennas = await this.$root.api('antennas/list');
const { canceled, result: antenna } = await this.$root.dialog({
const { canceled, result: antenna } = await this.$root.showDialog({
title: this.$t('selectAntenna'),
type: null,
select: {

View File

@@ -137,7 +137,7 @@ export default defineComponent({
icon: faPencilAlt,
text: this.$t('rename'),
action: () => {
this.$root.dialog({
this.$root.showDialog({
title: this.$t('rename'),
input: {
default: this.column.name,

View File

@@ -60,7 +60,7 @@ export default defineComponent({
methods: {
async setList() {
const lists = await this.$root.api('users/lists/list');
const { canceled, result: list } = await this.$root.dialog({
const { canceled, result: list } = await this.$root.showDialog({
title: this.$t('selectList'),
type: null,
select: {

View File

@@ -78,7 +78,7 @@ export default defineComponent({
methods: {
async setType() {
const { canceled, result: src } = await this.$root.dialog({
const { canceled, result: src } = await this.$root.showDialog({
title: this.$t('timeline'),
type: null,
select: {

View File

@@ -1,10 +1,10 @@
<template>
<div class="mk-dialog" :class="{ iconOnly }">
<div class="mk-dialog" :class="{ iconOnly }" :style="{ pointerEvents: closing ? 'none' : 'auto' }">
<transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear>
<div class="bg _modalBg" ref="bg" @click="onBgClick" v-if="show"></div>
<div class="bg _modalBg" @click="onBgClick" v-if="!closing" :style="{ pointerEvents: closing ? 'none' : 'auto' }"></div>
</transition>
<transition :name="$store.state.device.animation ? 'dialog' : ''" appear @after-leave="() => { destroyDom(); }">
<div class="main" ref="main" v-if="show">
<transition :name="$store.state.device.animation ? 'dialog' : ''" appear @after-leave="$emit('closed')">
<div class="main" v-if="!closing" :style="{ pointerEvents: closing ? 'none' : 'auto' }">
<template v-if="type == 'signin'">
<mk-signin/>
</template>
@@ -114,12 +114,15 @@ export default defineComponent({
autoClose: {
type: Boolean,
default: false
}
},
closing: {
type: Boolean,
default: false
},
},
data() {
return {
show: true,
inputValue: this.input && this.input.default ? this.input.default : null,
userInputValue: null,
selectedValue: this.select ? this.select.default ? this.select.default : this.select.items ? this.select.items[0].value : this.select.groupedItems[0].items[0].value : null,
@@ -137,7 +140,7 @@ export default defineComponent({
this.canOk = false;
});
}
}
},
},
mounted() {
@@ -145,7 +148,7 @@ export default defineComponent({
if (this.autoClose) {
setTimeout(() => {
this.close();
this.$emit('ok');
}, 1000);
}
@@ -165,7 +168,6 @@ export default defineComponent({
const user = await this.$root.api('users/show', parseAcct(this.userInputValue));
if (user) {
this.$emit('ok', user);
this.close();
}
} else {
const result =
@@ -173,21 +175,11 @@ export default defineComponent({
this.select ? this.selectedValue :
true;
this.$emit('ok', result);
this.close();
}
},
cancel() {
this.$emit('cancel');
this.close();
},
close() {
if (!this.show) return;
this.show = false;
this.$el.style.pointerEvents = 'none';
(this.$refs.bg as any).style.pointerEvents = 'none';
(this.$refs.main as any).style.pointerEvents = 'none';
},
onBgClick() {

View File

@@ -128,7 +128,7 @@ export default defineComponent({
},
rename() {
this.$root.dialog({
this.$root.showDialog({
title: this.$t('renameFile'),
input: {
placeholder: this.$t('inputNewFileName'),
@@ -153,7 +153,7 @@ export default defineComponent({
copyUrl() {
copyToClipboard(this.file.url);
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
@@ -172,7 +172,7 @@ export default defineComponent({
},
async deleteFile() {
const { canceled } = await this.$root.dialog({
const { canceled } = await this.$root.showDialog({
type: 'warning',
text: this.$t('driveFileDeleteConfirm', { name: this.file.name }),
showCancelButton: true

View File

@@ -149,13 +149,13 @@ export default defineComponent({
}).catch(err => {
switch (err) {
case 'detected-circular-definition':
this.$root.dialog({
this.$root.showDialog({
title: this.$t('unableToProcess'),
text: this.$t('circularReferenceFolder')
});
break;
default:
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('error')
});
@@ -189,7 +189,7 @@ export default defineComponent({
},
rename() {
this.$root.dialog({
this.$root.showDialog({
title: this.$t('renameFolder'),
input: {
placeholder: this.$t('inputNewFolderName'),
@@ -217,14 +217,14 @@ export default defineComponent({
}).catch(err => {
switch(err.id) {
case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
this.$root.dialog({
this.$root.showDialog({
type: 'error',
title: this.$t('unableToDelete'),
text: this.$t('hasChildFilesOrFolders')
});
break;
default:
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('unableToDelete')
});

View File

@@ -282,13 +282,13 @@ export default defineComponent({
}).catch(err => {
switch (err) {
case 'detected-circular-definition':
this.$root.dialog({
this.$root.showDialog({
title: this.$t('unableToProcess'),
text: this.$t('circularReferenceFolder')
});
break;
default:
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('error')
});
@@ -303,7 +303,7 @@ export default defineComponent({
},
urlUpload() {
this.$root.dialog({
this.$root.showDialog({
title: this.$t('uploadFromUrl'),
input: {
placeholder: this.$t('uploadFromUrlDescription')
@@ -315,7 +315,7 @@ export default defineComponent({
folderId: this.folder ? this.folder.id : undefined
});
this.$root.dialog({
this.$root.showDialog({
title: this.$t('uploadFromUrlRequested'),
text: this.$t('uploadFromUrlMayTakeTime')
});
@@ -323,7 +323,7 @@ export default defineComponent({
},
createFolder() {
this.$root.dialog({
this.$root.showDialog({
title: this.$t('createFolder'),
input: {
placeholder: this.$t('folderName')
@@ -340,7 +340,7 @@ export default defineComponent({
},
renameFolder(folder) {
this.$root.dialog({
this.$root.showDialog({
title: this.$t('renameFolder'),
input: {
placeholder: this.$t('inputNewFolderName'),
@@ -367,14 +367,14 @@ export default defineComponent({
}).catch(err => {
switch(err.id) {
case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
this.$root.dialog({
this.$root.showDialog({
type: 'error',
title: this.$t('unableToDelete'),
text: this.$t('hasChildFilesOrFolders')
});
break;
default:
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('unableToDelete')
});

View File

@@ -91,7 +91,7 @@ export default defineComponent({
try {
if (this.isFollowing) {
const { canceled } = await this.$root.dialog({
const { canceled } = await this.$root.showDialog({
type: 'warning',
text: this.$t('unfollowConfirm', { name: this.user.name || this.user.username }),
showCancelButton: true

View File

@@ -519,7 +519,7 @@ export default defineComponent({
this.$root.api('notes/favorites/create', {
noteId: this.appearNote.id
}).then(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
@@ -527,7 +527,7 @@ export default defineComponent({
},
del() {
this.$root.dialog({
this.$root.showDialog({
type: 'warning',
text: this.$t('noteDeleteConfirm'),
showCancelButton: true
@@ -541,7 +541,7 @@ export default defineComponent({
},
delEdit() {
this.$root.dialog({
this.$root.showDialog({
type: 'warning',
text: this.$t('deleteAndEditConfirm'),
showCancelButton: true
@@ -560,7 +560,7 @@ export default defineComponent({
this.$root.api(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
noteId: this.appearNote.id
}).then(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
@@ -571,7 +571,7 @@ export default defineComponent({
this.$root.api(watch ? 'notes/watching/create' : 'notes/watching/delete', {
noteId: this.appearNote.id
}).then(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
@@ -716,7 +716,7 @@ export default defineComponent({
copyContent() {
copyToClipboard(this.appearNote.text);
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
@@ -724,7 +724,7 @@ export default defineComponent({
copyLink() {
copyToClipboard(`${url}/notes/${this.appearNote.id}`);
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
@@ -734,13 +734,13 @@ export default defineComponent({
this.$root.api(pin ? 'i/pin' : 'i/unpin', {
noteId: this.appearNote.id
}).then(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
}).catch(e => {
if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('pinLimitExceeded')
});
@@ -749,7 +749,7 @@ export default defineComponent({
},
async promote() {
const { canceled, result: days } = await this.$root.dialog({
const { canceled, result: days } = await this.$root.showDialog({
title: this.$t('numberOfDays'),
input: { type: 'number' }
});
@@ -760,12 +760,12 @@ export default defineComponent({
noteId: this.appearNote.id,
expiresAt: Date.now() + (86400000 * days)
}).then(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
}).catch(e => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: e
});

View File

@@ -134,7 +134,7 @@ export default defineComponent({
acceptGroupInvitation() {
this.groupInviteDone = true;
this.$root.api('users/groups/invitations/accept', { invitationId: this.notification.invitation.id });
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});

View File

@@ -24,7 +24,7 @@ export default defineComponent({
click() {
if (this.value.action === 'dialog') {
this.hpml.eval();
this.$root.dialog({
this.$root.showDialog({
text: this.hpml.interpolate(this.value.content)
});
} else if (this.value.action === 'resetRandom') {
@@ -39,7 +39,7 @@ export default defineComponent({
} : {})
});
this.$root.dialog({
this.$root.showDialog({
type: 'success',
text: this.hpml.interpolate(this.value.message)
});

View File

@@ -44,7 +44,7 @@ export default defineComponent({
methods: {
upload() {
return new Promise((ok) => {
const dialog = this.$root.dialog({
const dialog = this.$root.showDialog({
type: 'waiting',
text: this.$t('uploading') + '...',
showOkButton: false,
@@ -80,7 +80,7 @@ export default defineComponent({
fileIds: file ? [file.id] : undefined,
}).then(() => {
this.posted = true;
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});

View File

@@ -49,7 +49,7 @@ export default defineComponent({
ast = parse(this.page.script);
} catch (e) {
console.error(e);
/*this.$root.dialog({
/*this.$root.showDialog({
type: 'error',
text: 'Syntax error :('
});*/
@@ -59,7 +59,7 @@ export default defineComponent({
this.hpml.eval();
}).catch(e => {
console.error(e);
/*this.$root.dialog({
/*this.$root.showDialog({
type: 'error',
text: e
});*/

View File

@@ -62,7 +62,7 @@ export default defineComponent({
});
},
async rename(file) {
const { canceled, result } = await this.$root.dialog({
const { canceled, result } = await this.$root.showDialog({
title: this.$t('enterFileName'),
input: {
default: file.name

View File

@@ -469,7 +469,7 @@ export default defineComponent({
if (!this.renote && !this.quoteId && paste.startsWith(url + '/notes/')) {
e.preventDefault();
this.$root.dialog({
this.$root.showDialog({
type: 'info',
text: this.$t('quoteQuestion'),
showCancelButton: true

View File

@@ -127,7 +127,7 @@ export default defineComponent({
search() {
if (this.searching) return;
this.$root.dialog({
this.$root.showDialog({
title: this.$t('search'),
input: true
}).then(async ({ canceled, result: query }) => {
@@ -277,7 +277,7 @@ export default defineComponent({
async addAcount() {
this.$root.new(await import('./signin-dialog.vue')).$once('login', res => {
this.$store.dispatch('addAcount', res);
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
@@ -297,7 +297,7 @@ export default defineComponent({
},
switchAccountWithToken(token: string) {
this.$root.dialog({
this.$root.showDialog({
type: 'waiting',
iconOnly: true
});

View File

@@ -145,7 +145,7 @@ export default defineComponent({
this.$emit('login', res);
}).catch(err => {
if (err === null) return;
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('signinFailed')
});
@@ -166,7 +166,7 @@ export default defineComponent({
this.challengeData = res;
return this.queryKey();
}).catch(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('signinFailed')
});
@@ -186,7 +186,7 @@ export default defineComponent({
}).then(res => {
this.$emit('login', res);
}).catch(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('loginFailed')
});

View File

@@ -193,7 +193,7 @@ export default defineComponent({
this.$refs.hcaptcha?.reset?.();
this.$refs.recaptcha?.reset?.();
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('error')
});

View File

@@ -206,11 +206,12 @@ export default defineComponent({
});
});
this.$on('keydown', (e: KeyboardEvent) => {
// TODO: vue3
/*this.$on('keydown', (e: KeyboardEvent) => {
if (e.code == 'Enter') {
this.$emit('enter');
}
});
});*/
},
methods: {
focus() {

View File

@@ -100,13 +100,13 @@ export default defineComponent({
const t = this.$t('selectList'); // なぜか後で参照すると null になるので最初にメモリに確保しておく
const lists = await this.$root.api('users/lists/list');
if (lists.length === 0) {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('youHaveNoLists')
});
return;
}
const { canceled, result: listId } = await this.$root.dialog({
const { canceled, result: listId } = await this.$root.showDialog({
type: null,
title: t,
select: {
@@ -121,12 +121,12 @@ export default defineComponent({
listId: listId,
userId: this.user.id
}).then(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
}).catch(e => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: e
});
@@ -136,13 +136,13 @@ export default defineComponent({
async inviteGroup() {
const groups = await this.$root.api('users/groups/owned');
if (groups.length === 0) {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: this.$t('youHaveNoGroups')
});
return;
}
const { canceled, result: groupId } = await this.$root.dialog({
const { canceled, result: groupId } = await this.$root.showDialog({
type: null,
title: this.$t('group'),
select: {
@@ -157,12 +157,12 @@ export default defineComponent({
groupId: groupId,
userId: this.user.id
}).then(() => {
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
}).catch(e => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: e
});
@@ -174,12 +174,12 @@ export default defineComponent({
userId: this.user.id
}).then(() => {
this.user.isMuted = !this.user.isMuted;
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
}, e => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: e
});
@@ -193,12 +193,12 @@ export default defineComponent({
userId: this.user.id
}).then(() => {
this.user.isBlocking = !this.user.isBlocking;
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
}, e => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: e
});
@@ -212,12 +212,12 @@ export default defineComponent({
userId: this.user.id
}).then(() => {
this.user.isSilenced = !this.user.isSilenced;
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
}, e => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: e
});
@@ -231,12 +231,12 @@ export default defineComponent({
userId: this.user.id
}).then(() => {
this.user.isSuspended = !this.user.isSuspended;
this.$root.dialog({
this.$root.showDialog({
type: 'success',
iconOnly: true, autoClose: true
});
}, e => {
this.$root.dialog({
this.$root.showDialog({
type: 'error',
text: e
});
@@ -244,7 +244,7 @@ export default defineComponent({
},
async getConfirmed(text: string): Promise<Boolean> {
const confirm = await this.$root.dialog({
const confirm = await this.$root.showDialog({
type: 'warning',
showCancelButton: true,
title: 'confirm',