You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
1.8 KiB

import defaultSettings from '@/settings'
const { sideTheme, showSettings, tagsView, fixedHeader, sidebarLogo, dynamicTitle, fontSize } = defaultSettings
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
const isPrototypeLayout = storageSetting.layoutVersion === 'prototype-v1'
const state = {
title: '',
theme: isPrototypeLayout ? (storageSetting.theme || '#1890ff') : '#1890ff',
// Old saved settings belong to the former top-navigation layout. Start the
// new left-menu layout with the light theme, then persist later selections.
sideTheme: isPrototypeLayout ? (storageSetting.sideTheme || sideTheme) : sideTheme,
showSettings: showSettings,
// The project now uses a fixed left navigation layout. Ignore the old
// persisted TopNav value so existing users are switched to the new layout.
topNav: false,
tagsView: isPrototypeLayout && storageSetting.tagsView !== undefined ? storageSetting.tagsView : tagsView,
fixedHeader: isPrototypeLayout && storageSetting.fixedHeader !== undefined ? storageSetting.fixedHeader : fixedHeader,
sidebarLogo: isPrototypeLayout && storageSetting.sidebarLogo !== undefined ? storageSetting.sidebarLogo : sidebarLogo,
dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle,
fontSize: isPrototypeLayout && storageSetting.fontSize !== undefined ? storageSetting.fontSize : fontSize
}
const mutations = {
CHANGE_SETTING: (state, { key, value }) => {
if (state.hasOwnProperty(key)) {
state[key] = value
}
}
}
const actions = {
// 修改布局设置
changeSetting({ commit }, data) {
commit('CHANGE_SETTING', data)
},
// 设置网页标题
setTitle({ commit }, title) {
state.title = title
}
}
export default {
namespaced: true,
state,
mutations,
actions
}