From 4f1981df03c32706eb91ff604b2436621a7dabba Mon Sep 17 00:00:00 2001 From: Xeltica <7106976+Xeltica@users.noreply.github.com> Date: Sat, 15 Feb 2020 01:33:09 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=89=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC=E3=81=8B=E3=82=89=E3=82=A2?= =?UTF-8?q?=E3=82=AB=E3=82=A6=E3=83=B3=E3=83=88=E3=82=92=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#5910?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * メニューからアカウントを作成できるようにした * i18n * Update signup.vue Co-authored-by: syuilo --- locales/ja-JP.yml | 1 + src/client/app.vue | 26 +++++++++++++++++---- src/client/components/signup-dialog.vue | 19 +++++++++++++-- src/client/components/signup.vue | 20 ++++++++++++++-- src/client/pages/index.welcome.entrance.vue | 4 +++- 5 files changed, 60 insertions(+), 10 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index f883e7263..0bdf32130 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -397,6 +397,7 @@ doing: "やっています" category: "カテゴリ" tags: "タグ" docSource: "このドキュメントのソース" +createAccount: "アカウントを作成" _ago: unknown: "謎" diff --git a/src/client/app.vue b/src/client/app.vue index 615f6b9cd..6a4acfe07 100644 --- a/src/client/app.vue +++ b/src/client/app.vue @@ -364,10 +364,15 @@ export default Vue.extend({ icon: faCog, }, null, { type: 'item', - text: this.$t('addAcount'), icon: faPlus, + text: this.$t('addAcount'), action: () => { this.addAcount() }, - }], ...accountItems], + }, { + type: 'item', + icon: faPlus, + text: this.$t('createAccount'), + action: () => { this.createAccount() }, + }, null, ...accountItems, ]], align: 'left', fixed: true, width: 240, @@ -507,9 +512,20 @@ export default Vue.extend({ }); }, - async switchAccount(account) { - const token = this.$store.state.device.accounts.find(x => x.id === account.id).token; - this.$root.api('i', {}, token).then(i => { + async createAccount() { + this.$root.new(await import('./components/signup-dialog.vue').then(m => m.default)).$once('signup', res => { + this.$store.dispatch('addAcount', res); + this.switchAccountWithToken(res.i); + }); + }, + + async switchAccount(account: any) { + const token = this.$store.state.device.accounts.find((x: any) => x.id === account.id).token; + this.switchAccountWithToken(token); + }, + + switchAccountWithToken(token: string) { + this.$root.api('i', {}, token).then((i: any) => { this.$store.dispatch('switchAccount', { ...i, token: token diff --git a/src/client/components/signup-dialog.vue b/src/client/components/signup-dialog.vue index 76421d44e..10cdf3a56 100644 --- a/src/client/components/signup-dialog.vue +++ b/src/client/components/signup-dialog.vue @@ -1,7 +1,7 @@ @@ -18,5 +18,20 @@ export default Vue.extend({ XSignup, XWindow, }, + + props: { + autoSet: { + type: Boolean, + required: false, + default: false, + } + }, + + methods: { + onSignup(res) { + this.$emit('signup', res); + this.$refs.window.close(); + } + } }); diff --git a/src/client/components/signup.vue b/src/client/components/signup.vue index b821af396..34765a7a2 100644 --- a/src/client/components/signup.vue +++ b/src/client/components/signup.vue @@ -84,6 +84,14 @@ export default Vue.extend({ } }, + props: { + autoSet: { + type: Boolean, + required: false, + default: false, + } + }, + computed: { meta() { return this.$store.state.instance.meta; @@ -97,6 +105,15 @@ export default Vue.extend({ } }, + created() { + if (this.autoSet) { + this.$once('signup', res => { + localStorage.setItem('i', res.i); + location.reload(); + }); + } + }, + mounted() { const head = document.getElementsByTagName('head')[0]; const script = document.createElement('script'); @@ -166,8 +183,7 @@ export default Vue.extend({ username: this.username, password: this.password }).then(res => { - localStorage.setItem('i', res.i); - location.href = '/'; + this.$emit('signup', res); }); }).catch(() => { this.submitting = false; diff --git a/src/client/pages/index.welcome.entrance.vue b/src/client/pages/index.welcome.entrance.vue index f63e0c2c2..a9343e87c 100644 --- a/src/client/pages/index.welcome.entrance.vue +++ b/src/client/pages/index.welcome.entrance.vue @@ -62,7 +62,9 @@ export default Vue.extend({ }, signup() { - this.$root.new(XSignupDialog); + this.$root.new(XSignupDialog, { + autoSet: true + }); } } });