From 6136f6f33a70459d3e52b4273f57628376dd15a9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 21 Jun 2019 13:06:47 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=87=E3=83=83=E3=82=AD=E3=81=AE=E7=8A=B6?= =?UTF-8?q?=E6=85=8B=E3=82=92=E5=90=8C=E6=9C=9F=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 1 + .../views/components/settings/settings.vue | 6 ++++ .../app/common/views/deck/deck.column.vue | 3 +- src/client/app/common/views/deck/deck.vue | 29 +++++++++++++++---- src/client/app/store.ts | 17 ++++++++++- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index bdf8c24ce..47e1d4d93 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -284,6 +284,7 @@ common: load-remote-media: "リモートサーバーのメディアを表示する" sync: "同期" home-profile: "ホームのプロファイル" + deck-profile: "デッキのプロファイル" search: "検索" delete: "削除" diff --git a/src/client/app/common/views/components/settings/settings.vue b/src/client/app/common/views/components/settings/settings.vue index 1c02bdee8..094791a15 100644 --- a/src/client/app/common/views/components/settings/settings.vue +++ b/src/client/app/common/views/components/settings/settings.vue @@ -135,6 +135,7 @@
{{ $t('@._settings.sync') }}
{{ $t('@._settings.home-profile') }} {{ $t('@._settings.home-profile') }} + {{ $t('@._settings.deck-profile') }}
@@ -516,6 +517,11 @@ export default Vue.extend({ get() { return this.$store.state.device.mobileHomeProfile; }, set(value) { this.$store.commit('device/set', { key: 'mobileHomeProfile', value }); } }, + + deckProfile: { + get() { return this.$store.state.device.deckProfile; }, + set(value) { this.$store.commit('device/set', { key: 'deckProfile', value }); } + }, }, created() { this.$root.getMeta().then(meta => { diff --git a/src/client/app/common/views/deck/deck.column.vue b/src/client/app/common/views/deck/deck.column.vue index eaa344d36..b09fdfbfe 100644 --- a/src/client/app/common/views/deck/deck.column.vue +++ b/src/client/app/common/views/deck/deck.column.vue @@ -146,7 +146,8 @@ export default Vue.extend({ toggleActive() { if (!this.isStacked) return; - const vms = this.$store.state.device.deck.layout.find(ids => ids.indexOf(this.column.id) != -1).map(id => this.getColumnVm(id)); + const deck = this.$store.state.device.deckProfile ? this.$store.state.settings.deckProfiles[this.$store.state.device.deckProfile] : this.$store.state.device.deck; + const vms = deck.layout.find(ids => ids.indexOf(this.column.id) != -1).map(id => this.getColumnVm(id)); if (this.active && countIf(vm => vm.$el.classList.contains('active'), vms) == 1) return; this.active = !this.active; }, diff --git a/src/client/app/common/views/deck/deck.vue b/src/client/app/common/views/deck/deck.vue index b46f2167a..e07e504ed 100644 --- a/src/client/app/common/views/deck/deck.vue +++ b/src/client/app/common/views/deck/deck.vue @@ -25,20 +25,29 @@ import * as uuid from 'uuid'; export default Vue.extend({ i18n: i18n('deck'), + components: { XColumnCore }, computed: { + deck() { + if (this.$store.state.device.deckProfile) { + return this.$store.state.settings.deckProfiles[this.$store.state.device.deckProfile] || this.$store.state.device.deck; + } else { + return this.$store.state.device.deck; + } + }, + columns(): any[] { - if (this.$store.state.device.deck == null) return []; - return this.$store.state.device.deck.columns; + if (this.deck == null) return []; + return this.deck.columns; }, layout(): any[] { - if (this.$store.state.device.deck == null) return []; - if (this.$store.state.device.deck.layout == null) return this.$store.state.device.deck.columns.map(c => [c.id]); - return this.$store.state.device.deck.layout; + if (this.deck == null) return []; + if (this.deck.layout == null) return this.deck.columns.map(c => [c.id]); + return this.deck.layout; }, style(): any { @@ -75,7 +84,7 @@ export default Vue.extend({ }, created() { - if (this.$store.state.device.deck == null) { + if (this.deck == null) { const deck = { columns: [/*{ type: 'widgets', @@ -106,6 +115,14 @@ export default Vue.extend({ value: deck }); } + + if (this.$store.state.device.deckProfile) { + this.$watch('$store.state.device.deck', () => { + this.$store.dispatch('settings/updateDeckProfile'); + }, { + deep: true + }); + } }, mounted() { diff --git a/src/client/app/store.ts b/src/client/app/store.ts index 7b56628b3..4a6e1a610 100644 --- a/src/client/app/store.ts +++ b/src/client/app/store.ts @@ -36,6 +36,7 @@ const defaultSettings = { disableAnimatedMfm: false, homeProfiles: {}, mobileHomeProfiles: {}, + deckProfiles: {}, }; const defaultDeviceSettings = { @@ -44,6 +45,7 @@ const defaultDeviceSettings = { mobileHomeProfile: null, mobileHome: [], deck: null, + deckProfile: null, deckMode: false, deckColumnAlign: 'center', deckColumnWidth: 'normal', @@ -390,7 +392,20 @@ export default (os: MiOS) => new Vuex.Store({ name: 'mobileHomeProfiles', value: profiles }); - } + }, + + updateDeckProfile(ctx) { + const profiles = ctx.state.deckProfiles; + profiles[ctx.rootState.device.deckProfile] = ctx.rootState.device.deck; + ctx.commit('set', { + key: 'deckProfiles', + value: profiles + }); + os.api('i/update-client-setting', { + name: 'deckProfiles', + value: profiles + }); + }, } } }