代码小调整

master
toesbieya 6 years ago
parent 5a9dbfea0f
commit 3946f31952
  1. 2
      vue/src/asset/style/index.scss
  2. 2
      vue/src/layout/component/Header.vue
  3. 4
      vue/src/layout/index.vue
  4. 4
      vue/src/router/index.js
  5. 4
      vue/src/store/module/app.js
  6. 16
      vue/src/store/module/setting.js

@ -81,7 +81,7 @@ a:hover {
height: calc(100vh - #{$page-view-margin * 2}); height: calc(100vh - #{$page-view-margin * 2});
} }
.has-header { .has-nav {
.max-view-height { .max-view-height {
height: calc(100vh - #{$nav-height} - #{$page-view-margin * 2}); height: calc(100vh - #{$nav-height} - #{$page-view-margin * 2});
} }

@ -34,7 +34,7 @@ export default {
}, },
hideHeader(v) { hideHeader(v) {
this.$store.commit('app/hasHeader', !v) this.$store.commit('app/hasNav', !v)
v ? this.addEvent() : this.removeEvent() v ? this.addEvent() : this.removeEvent()
} }
}, },

@ -30,7 +30,7 @@ export default {
components: {VMain, VSidebar, VHeader}, components: {VMain, VSidebar, VHeader},
computed: { computed: {
...mapState('app', ['device', 'hasHeader']), ...mapState('app', ['device', 'hasNav']),
...mapState('setting', ['useTagsView', 'sidebarCollapse']), ...mapState('setting', ['useTagsView', 'sidebarCollapse']),
@ -38,7 +38,7 @@ export default {
return { return {
'el-container': true, 'el-container': true,
'main-container': true, 'main-container': true,
'has-header': this.hasHeader, 'has-nav': this.hasNav,
'has-tags-view': this.useTagsView 'has-tags-view': this.useTagsView
} }
}, },

@ -131,12 +131,12 @@ function iframeControl(to, from) {
if (from.meta.noCache || to.path === `/redirect${from.path}`) { if (from.meta.noCache || to.path === `/redirect${from.path}`) {
del = true del = true
} }
store.dispatch(`iframe/close`, {src: from.meta.iframe, del}) store.dispatch('iframe/close', {src: from.meta.iframe, del})
} }
//跳转至iframe页面时,打开iframe //跳转至iframe页面时,打开iframe
if (to.meta.iframe) { if (to.meta.iframe) {
store.dispatch(`iframe/open`, {src: to.meta.iframe}) store.dispatch('iframe/open', {src: to.meta.iframe})
} }
} }

@ -11,8 +11,8 @@ const state = {
//登陆页背景动画 //登陆页背景动画
loginBackgroundAnimation: 'sparkRain', loginBackgroundAnimation: 'sparkRain',
//右侧块是否含有头部,这里初始值是为了转为boolean类型 //右侧块是否含有导航栏,这里初始值是为了转为boolean类型
hasHeader: !!!localSettings.headerAutoHidden hasNav: !!!localSettings.headerAutoHidden
} }
const mutations = createMutations(state) const mutations = createMutations(state)

@ -5,8 +5,6 @@
import {isEmpty} from "@/util" import {isEmpty} from "@/util"
import {getLocalPersonalSettings, setLocalPersonalSettings} from "@/util/storage" import {getLocalPersonalSettings, setLocalPersonalSettings} from "@/util/storage"
const localSettings = getLocalPersonalSettings()
const state = { const state = {
//是否显示logo //是否显示logo
showLogo: true, showLogo: true,
@ -37,6 +35,7 @@ const state = {
} }
//state填入初始值 //state填入初始值
const localSettings = getLocalPersonalSettings()
Object.keys(state).forEach(key => { Object.keys(state).forEach(key => {
if (!isEmpty(localSettings[key])) state[key] = localSettings[key] if (!isEmpty(localSettings[key])) state[key] = localSettings[key]
}) })
@ -61,6 +60,13 @@ const mutations = {
} }
} }
export default {
namespaced: true,
state,
mutations
}
//每次修改个人设置时,同步到localStorage
function createMutations(state) { function createMutations(state) {
return Object.keys(state).reduce((mutations, key) => { return Object.keys(state).reduce((mutations, key) => {
mutations[key] = (ref, data) => { mutations[key] = (ref, data) => {
@ -70,9 +76,3 @@ function createMutations(state) {
return mutations return mutations
}, {}) }, {})
} }
export default {
namespaced: true,
state,
mutations
}

Loading…
Cancel
Save