import { setStore, getStore, removeStore } from '@/util/store' import website from '@/config/website' const common = { state: { language: getStore({name: 'language'}) || 'zh-CN', isCollapse: false, isFullScren: false, isMenu: true, isShade: false, screen: -1, isLock: getStore({name: 'isLock'}) || false, showTag: true, showDebug: true, showCollapse: true, showSearch: true, showLock: true, showFullScren: true, showTheme: true, showMenu: true, showColor: true, colorName: getStore({name: 'colorName'}) || '#409EFF', themeName: getStore({name: 'themeName'}) || 'theme-default', lockPasswd: getStore({name: 'lockPasswd'}) || '', website: website, }, mutations: { SET_LANGUAGE: (state: { language: any }, language: any) => { state.language = language setStore({ name: 'language', content: state.language }) }, SET_SHADE: (state: { isShade: any }, active: any) => { state.isShade = active; }, SET_COLLAPSE: (state: { isCollapse: boolean }) => { state.isCollapse = !state.isCollapse; }, SET_FULLSCREN: (state: { isFullScren: boolean }) => { state.isFullScren = !state.isFullScren; }, SET_IS_MENU: (state: { isMenu: any }, menu: any) => { state.isMenu = menu; }, SET_LOCK: (state: any) => { state.isLock = true; setStore({ name: 'isLock', content: state.isLock, type: 'session' }) }, SET_SCREEN: (state: { screen: any }, screen: any) => { state.screen = screen; }, SET_COLOR_NAME: (state: { colorName: any }, colorName: any) => { state.colorName = colorName; setStore({ name: 'colorName', content: state.colorName, }) }, SET_THEME_NAME: (state: { themeName: any }, themeName: any) => { state.themeName = themeName; setStore({ name: 'themeName', content: state.themeName, }) }, SET_LOCK_PASSWD: (state: { lockPasswd: any }, lockPasswd: any) => { state.lockPasswd = lockPasswd; setStore({ name: 'lockPasswd', content: state.lockPasswd, type: 'session' }) }, CLEAR_LOCK: (state: { isLock: boolean; lockPasswd: string }) => { state.isLock = false; state.lockPasswd = ''; removeStore({ name: 'lockPasswd', type: 'session' }); removeStore({ name: 'isLock', type: 'session' }); }, } } export default common