Merge pull request #675 from h3poteto/iss-625

closes #625 Add option to hide/show global header
This commit is contained in:
AkiraFukushima 2018-10-23 20:20:50 +09:00 committed by GitHub
commit 8823e05d02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 82 additions and 12 deletions

View File

@ -642,6 +642,30 @@ ipcMain.on('get-collapse', (event, _) => {
}) })
}) })
ipcMain.on('change-global-header', (event, value) => {
const preferences = new Preferences(preferencesDBPath)
preferences.update(
{
state: {
hideGlobalHeader: value
}
})
.then((conf) => {
event.sender.send('response-change-global-header', conf)
})
.catch(err => {
log.error(err)
})
})
ipcMain.on('get-global-header', (event, _) => {
const preferences = new Preferences(preferencesDBPath)
preferences.load()
.then((conf) => {
event.sender.send('response-get-global-header', conf.state.hideGlobalHeader)
})
})
ipcMain.on('change-language', (event, value) => { ipcMain.on('change-language', (event, value) => {
const preferences = new Preferences(preferencesDBPath) const preferences = new Preferences(preferencesDBPath)
preferences.update( preferences.update(

View File

@ -17,7 +17,8 @@ const Base = {
tootVisibility: Visibility.Public.value tootVisibility: Visibility.Public.value
}, },
state: { state: {
collapse: false collapse: false,
hideGlobalHeader: false
}, },
language: { language: {
language: Language.en.key language: Language.en.key

View File

@ -1,6 +1,7 @@
<template> <template>
<div id="global_header"> <div id="global_header">
<el-menu <el-menu
v-if="!hide"
:default-active="activeRoute()" :default-active="activeRoute()"
class="el-menu-vertical account-menu" class="el-menu-vertical account-menu"
:collapse="true" :collapse="true"
@ -19,10 +20,11 @@
<span slot="new">New</span> <span slot="new">New</span>
</el-menu-item> </el-menu-item>
</el-menu> </el-menu>
<div class="space"> <div :class="hide ? 'space no-global-header':'space with-global-header' ">
<router-view :key="$route.params.id"></router-view> <router-view :key="$route.params.id"></router-view>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
@ -31,8 +33,11 @@ import { mapState } from 'vuex'
export default { export default {
name: 'global-header', name: 'global-header',
computed: { computed: {
...mapState('GlobalHeader', {
accounts: state => state.accounts,
hide: state => state.hide
}),
...mapState({ ...mapState({
accounts: state => state.GlobalHeader.accounts,
themeColor: state => state.App.theme.global_header_color themeColor: state => state.App.theme.global_header_color
}) })
}, },
@ -90,8 +95,15 @@ export default {
} }
.space { .space {
margin-left: 65px;
height: 100%; height: 100%;
} }
.no-global-header {
margin-left: 0;
}
.with-global-header {
margin-left: 65px;
}
} }
</style> </style>

View File

@ -197,14 +197,13 @@ export default {
width: calc(100% - 245px); width: calc(100% - 245px);
position: fixed; position: fixed;
top: 0; top: 0;
left: 245px;
height: 48px; height: 48px;
border-bottom: solid 1px var(--theme-border-color); border-bottom: solid 1px var(--theme-border-color);
} }
} }
.page-narrow { .page-narrow {
margin-left: 76px; margin-left: 64px;
height: 100%; height: 100%;
box-sizing: border-box; box-sizing: border-box;
@ -212,7 +211,6 @@ export default {
width: calc(100% - 141px); width: calc(100% - 141px);
position: fixed; position: fixed;
top: 0; top: 0;
left: 141px;
height: 48px; height: 48px;
border-bottom: solid 1px var(--theme-border-color); border-bottom: solid 1px var(--theme-border-color);
} }

View File

@ -87,6 +87,12 @@
</el-menu-item> </el-menu-item>
</template> </template>
</el-menu> </el-menu>
<el-button v-if="hideGlobalHeader" class="global-header-control" type="text" @click="changeGlobalHeader(false)">
<icon name="caret-square-right"></icon>
</el-button>
<el-button v-else class="global-header-control" type="text" @click="changeGlobalHeader(true)">
<icon name="caret-square-left"></icon>
</el-button>
</div> </div>
</template> </template>
@ -103,7 +109,8 @@ export default {
unreadLocalTimeline: state => state.unreadLocalTimeline, unreadLocalTimeline: state => state.unreadLocalTimeline,
lists: state => state.lists, lists: state => state.lists,
tags: state => state.tags, tags: state => state.tags,
collapse: state => state.collapse collapse: state => state.collapse,
hideGlobalHeader: state => state.hideGlobalHeader
}), }),
...mapState({ ...mapState({
account: state => state.TimelineSpace.account, account: state => state.TimelineSpace.account,
@ -142,6 +149,9 @@ export default {
}, },
releaseCollapse () { releaseCollapse () {
this.$store.dispatch('TimelineSpace/SideMenu/changeCollapse', false) this.$store.dispatch('TimelineSpace/SideMenu/changeCollapse', false)
},
changeGlobalHeader (value) {
this.$store.dispatch('TimelineSpace/SideMenu/changeGlobalHeader', value)
} }
} }
} }
@ -153,7 +163,6 @@ export default {
background-color: var(--theme-side-menu-color); background-color: var(--theme-side-menu-color);
position: fixed; position: fixed;
top: 0; top: 0;
left: 65px;
width: 180px; width: 180px;
height: 70px; height: 70px;
font-size: 16px; font-size: 16px;
@ -215,7 +224,6 @@ export default {
.timeline-menu /deep/ { .timeline-menu /deep/ {
position: fixed; position: fixed;
top: 70px; top: 70px;
left: 65px;
height: calc(100% - 70px); height: calc(100% - 70px);
width: 180px; width: 180px;
border: none; border: none;
@ -257,5 +265,11 @@ export default {
margin-left: -8px; margin-left: -8px;
} }
} }
.global-header-control {
position: fixed;
bottom: 0;
color: #dcdfe6;
}
} }
</style> </style>

View File

@ -5,7 +5,8 @@ const GlobalHeader = {
namespaced: true, namespaced: true,
state: { state: {
accounts: [], accounts: [],
changing: false changing: false,
hide: false
}, },
mutations: { mutations: {
updateAccounts (state, accounts) { updateAccounts (state, accounts) {
@ -13,6 +14,9 @@ const GlobalHeader = {
}, },
updateChanging (state, value) { updateChanging (state, value) {
state.changing = value state.changing = value
},
changeHide (state, value) {
state.hide = value
} }
}, },
actions: { actions: {
@ -62,6 +66,12 @@ const GlobalHeader = {
async removeShortcutEvents () { async removeShortcutEvents () {
ipcRenderer.removeAllListeners('change-account') ipcRenderer.removeAllListeners('change-account')
return 'removeShortcutEvents' return 'removeShortcutEvents'
},
reloadHide ({ commit }) {
ipcRenderer.send('get-global-header')
ipcRenderer.once('response-get-global-header', (event, value) => {
commit('changeHide', value)
})
} }
} }
} }

View File

@ -9,7 +9,8 @@ const SideMenu = {
unreadLocalTimeline: false, unreadLocalTimeline: false,
lists: [], lists: [],
tags: [], tags: [],
collapse: false collapse: false,
hideGlobalHeader: false
}, },
mutations: { mutations: {
changeUnreadHomeTimeline (state, value) { changeUnreadHomeTimeline (state, value) {
@ -29,6 +30,9 @@ const SideMenu = {
}, },
updateTags (state, tags) { updateTags (state, tags) {
state.tags = tags state.tags = tags
},
changeGlobalHeader (state, hide) {
state.hideGlobalHeader = hide
} }
}, },
actions: { actions: {
@ -53,6 +57,13 @@ const SideMenu = {
commit('changeCollapse', value) commit('changeCollapse', value)
ipcRenderer.send('change-collapse', value) ipcRenderer.send('change-collapse', value)
}, },
changeGlobalHeader ({ commit, dispatch }, value) {
commit('changeGlobalHeader', value)
ipcRenderer.send('change-global-header', value)
ipcRenderer.once('response-change-global-header', (event, _) => {
dispatch('GlobalHeader/reloadHide', {}, { root: true })
})
},
readCollapse ({ commit }) { readCollapse ({ commit }) {
ipcRenderer.send('get-collapse') ipcRenderer.send('get-collapse')
ipcRenderer.once('response-get-collapse', (event, value) => { ipcRenderer.once('response-get-collapse', (event, value) => {