mirror of https://github.com/halo-dev/halo-admin
refactor: layout setting drawer. (#113)
parent
aa49508cb2
commit
3221a4923b
|
@ -7,7 +7,7 @@
|
||||||
width="300"
|
width="300"
|
||||||
closable
|
closable
|
||||||
@close="onClose"
|
@close="onClose"
|
||||||
:visible="visible"
|
:visible="layoutSetting"
|
||||||
>
|
>
|
||||||
<div class="setting-drawer-index-content">
|
<div class="setting-drawer-index-content">
|
||||||
<div :style="{ marginBottom: '24px' }">
|
<div :style="{ marginBottom: '24px' }">
|
||||||
|
@ -194,6 +194,7 @@ import SettingItem from '@/components/SettingDrawer/SettingItem'
|
||||||
import config from '@/config/defaultSettings'
|
import config from '@/config/defaultSettings'
|
||||||
import { updateTheme, colorList } from './setting'
|
import { updateTheme, colorList } from './setting'
|
||||||
import { mixin, mixinDevice } from '@/utils/mixin'
|
import { mixin, mixinDevice } from '@/utils/mixin'
|
||||||
|
import { mapActions, mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -202,7 +203,6 @@ export default {
|
||||||
mixins: [mixin, mixinDevice],
|
mixins: [mixin, mixinDevice],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
|
||||||
colorList,
|
colorList,
|
||||||
baseConfig: Object.assign({}, config)
|
baseConfig: Object.assign({}, config)
|
||||||
}
|
}
|
||||||
|
@ -214,15 +214,13 @@ export default {
|
||||||
updateTheme(this.primaryColor)
|
updateTheme(this.primaryColor)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['layoutSetting'])
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showDrawer() {
|
...mapActions(['setSidebar', 'ToggleLayoutSetting']),
|
||||||
this.visible = true
|
|
||||||
},
|
|
||||||
onClose() {
|
onClose() {
|
||||||
this.visible = false
|
this.ToggleLayoutSetting(false)
|
||||||
},
|
|
||||||
toggle() {
|
|
||||||
this.visible = !this.visible
|
|
||||||
},
|
},
|
||||||
handleMenuTheme(theme) {
|
handleMenuTheme(theme) {
|
||||||
this.baseConfig.navTheme = theme
|
this.baseConfig.navTheme = theme
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="javascript:void(0)"
|
href="javascript:void(0)"
|
||||||
@click="showOptionModal"
|
@click="handleShowLayoutSetting"
|
||||||
>
|
>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
|
@ -60,34 +60,23 @@
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
<setting-drawer ref="drawer"></setting-drawer>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HeaderComment from './HeaderComment'
|
import HeaderComment from './HeaderComment'
|
||||||
import SettingDrawer from '@/components/SettingDrawer/SettingDrawer'
|
|
||||||
import { mapActions, mapGetters } from 'vuex'
|
import { mapActions, mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UserMenu',
|
name: 'UserMenu',
|
||||||
components: {
|
components: {
|
||||||
HeaderComment,
|
HeaderComment
|
||||||
SettingDrawer
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
optionVisible: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.optionVisible = this.$refs.drawer.visible
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['user', 'options'])
|
...mapGetters(['user', 'options'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['logout']),
|
...mapActions(['logout', 'ToggleLayoutSetting']),
|
||||||
handleLogout() {
|
handleLogout() {
|
||||||
const that = this
|
const that = this
|
||||||
|
|
||||||
|
@ -110,9 +99,8 @@ export default {
|
||||||
onCancel() {}
|
onCancel() {}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
showOptionModal() {
|
handleShowLayoutSetting() {
|
||||||
this.optionVisible = this.$refs.drawer.visible
|
this.ToggleLayoutSetting(true)
|
||||||
this.$refs.drawer.toggle()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@
|
||||||
<global-footer />
|
<global-footer />
|
||||||
</a-layout-footer>
|
</a-layout-footer>
|
||||||
</a-layout>
|
</a-layout>
|
||||||
|
|
||||||
|
<setting-drawer ref="drawer"></setting-drawer>
|
||||||
</a-layout>
|
</a-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -68,6 +70,7 @@ import RouteView from './RouteView'
|
||||||
import SideMenu from '@/components/Menu/SideMenu'
|
import SideMenu from '@/components/Menu/SideMenu'
|
||||||
import GlobalHeader from '@/components/GlobalHeader'
|
import GlobalHeader from '@/components/GlobalHeader'
|
||||||
import GlobalFooter from '@/components/GlobalFooter'
|
import GlobalFooter from '@/components/GlobalFooter'
|
||||||
|
import SettingDrawer from '@/components/SettingDrawer/SettingDrawer'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BasicLayout',
|
name: 'BasicLayout',
|
||||||
|
@ -76,7 +79,8 @@ export default {
|
||||||
RouteView,
|
RouteView,
|
||||||
SideMenu,
|
SideMenu,
|
||||||
GlobalHeader,
|
GlobalHeader,
|
||||||
GlobalFooter
|
GlobalFooter,
|
||||||
|
SettingDrawer
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,6 +2,7 @@ const getters = {
|
||||||
device: state => state.app.device,
|
device: state => state.app.device,
|
||||||
theme: state => state.app.theme,
|
theme: state => state.app.theme,
|
||||||
color: state => state.app.color,
|
color: state => state.app.color,
|
||||||
|
layoutSetting: state => state.app.layoutSetting,
|
||||||
token: state => state.user.token,
|
token: state => state.user.token,
|
||||||
user: state => state.user.user,
|
user: state => state.user.user,
|
||||||
addRouters: state => state.permission.addRouters,
|
addRouters: state => state.permission.addRouters,
|
||||||
|
|
|
@ -8,7 +8,8 @@ import {
|
||||||
DEFAULT_FIXED_SIDEMENU,
|
DEFAULT_FIXED_SIDEMENU,
|
||||||
DEFAULT_FIXED_HEADER_HIDDEN,
|
DEFAULT_FIXED_HEADER_HIDDEN,
|
||||||
DEFAULT_CONTENT_WIDTH_TYPE,
|
DEFAULT_CONTENT_WIDTH_TYPE,
|
||||||
API_URL
|
API_URL,
|
||||||
|
LAYOUT_SETTING
|
||||||
} from '@/store/mutation-types'
|
} from '@/store/mutation-types'
|
||||||
|
|
||||||
const app = {
|
const app = {
|
||||||
|
@ -22,7 +23,8 @@ const app = {
|
||||||
fixSiderbar: false,
|
fixSiderbar: false,
|
||||||
autoHideHeader: false,
|
autoHideHeader: false,
|
||||||
color: null,
|
color: null,
|
||||||
apiUrl: null
|
apiUrl: null,
|
||||||
|
layoutSetting: false
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
SET_API_URL: (state, apiUrl) => {
|
SET_API_URL: (state, apiUrl) => {
|
||||||
|
@ -72,6 +74,10 @@ const app = {
|
||||||
TOGGLE_COLOR: (state, color) => {
|
TOGGLE_COLOR: (state, color) => {
|
||||||
Vue.ls.set(DEFAULT_COLOR, color)
|
Vue.ls.set(DEFAULT_COLOR, color)
|
||||||
state.color = color
|
state.color = color
|
||||||
|
},
|
||||||
|
TOGGLE_LAYOUT_SETTING: (state, show) => {
|
||||||
|
Vue.ls.set(LAYOUT_SETTING, show)
|
||||||
|
state.layoutSetting = show
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -107,6 +113,9 @@ const app = {
|
||||||
},
|
},
|
||||||
ToggleColor({ commit }, color) {
|
ToggleColor({ commit }, color) {
|
||||||
commit('TOGGLE_COLOR', color)
|
commit('TOGGLE_COLOR', color)
|
||||||
|
},
|
||||||
|
ToggleLayoutSetting({ commit }, show) {
|
||||||
|
commit('TOGGLE_LAYOUT_SETTING', show)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ export const DEFAULT_CONTENT_WIDTH_TYPE = 'DEFAULT_CONTENT_WIDTH_TYPE'
|
||||||
export const USER = 'USER'
|
export const USER = 'USER'
|
||||||
export const API_URL = 'API_URL'
|
export const API_URL = 'API_URL'
|
||||||
export const OPTIONS = 'OPTIONS'
|
export const OPTIONS = 'OPTIONS'
|
||||||
|
export const LAYOUT_SETTING = 'LAYOUT_SETTING'
|
||||||
|
|
||||||
export const CONTENT_WIDTH_TYPE = {
|
export const CONTENT_WIDTH_TYPE = {
|
||||||
Fluid: 'Fluid',
|
Fluid: 'Fluid',
|
||||||
|
|
Loading…
Reference in New Issue