From 138c9868e8cd76adb49a02346102a16beb9a41eb Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 5 Sep 2020 13:04:59 +0900 Subject: [PATCH] wip --- src/client/components/avatar.vue | 1 + src/client/components/dialog.vue | 8 ++++---- src/client/pages/test.vue | 10 +++++++--- src/client/root.vue | 13 +++++-------- src/client/store.ts | 29 ++++++++++++++++++++++------- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/client/components/avatar.vue b/src/client/components/avatar.vue index 004231c163..79590e39f3 100644 --- a/src/client/components/avatar.vue +++ b/src/client/components/avatar.vue @@ -13,6 +13,7 @@ import { getStaticImageUrl } from '../scripts/get-static-image-url'; import { acct, userPage } from '../filters/user'; export default defineComponent({ + emits: ['click'], props: { user: { type: Object, diff --git a/src/client/components/dialog.vue b/src/client/components/dialog.vue index 5f7ca01a8c..c40f3bd0e7 100644 --- a/src/client/components/dialog.vue +++ b/src/client/components/dialog.vue @@ -148,7 +148,7 @@ export default defineComponent({ if (this.autoClose) { setTimeout(() => { - this.$emit('ok'); + this.$emit('done'); }, 1000); } @@ -167,19 +167,19 @@ export default defineComponent({ if (this.user) { const user = await this.$root.api('users/show', parseAcct(this.userInputValue)); if (user) { - this.$emit('ok', user); + this.$emit('done', { canceled: false, result: user }); } } else { const result = this.input ? this.inputValue : this.select ? this.selectedValue : true; - this.$emit('ok', result); + this.$emit('done', { canceled: false, result }); } }, cancel() { - this.$emit('cancel'); + this.$emit('done', { canceled: true }); }, onBgClick() { diff --git a/src/client/pages/test.vue b/src/client/pages/test.vue index 98d9492615..46d9dbbc68 100644 --- a/src/client/pages/test.vue +++ b/src/client/pages/test.vue @@ -10,6 +10,9 @@ Show +
+ Result: {{ dialogResult }} +
@@ -35,15 +38,16 @@ export default defineComponent({ data() { return { dialogTitle: 'Title', + dialogResult: null, faExclamationTriangle } }, methods: { - showDialog() { - this.$root.showDialog({ + async showDialog() { + this.dialogResult = await this.$store.dispatch('showDialog', { title: this.dialogTitle, - }) + }); } } }); diff --git a/src/client/root.vue b/src/client/root.vue index 694f99a73c..6c4bf23c05 100644 --- a/src/client/root.vue +++ b/src/client/root.vue @@ -2,7 +2,8 @@ - +