import store from '@/store'
import storage from 'store'
import {
  ACCESS_TOKEN,
  TOGGLE_CONTENT_WIDTH,
  TOGGLE_HEADER_STYLE,
  TOGGLE_FIXED_HEADER,
  TOGGLE_FIXED_SIDEBAR,
  TOGGLE_HIDE_HEADER,
  TOGGLE_LAYOUT,
  TOGGLE_NAV_THEME,
  TOGGLE_WEAK,
  TOGGLE_PRIMARY_COLOR,
  TOGGLE_MULTI_TAB,
  TOGGLE_LANAGUAGE,
  TOGGLE_ZOOM
} from '@/store/mutation-types'
import defaultSettings from '@/config/defaultSettings'

export default function Initializer() {
  store.commit(TOGGLE_LAYOUT, storage.get(TOGGLE_LAYOUT, defaultSettings.layout))
  store.commit(TOGGLE_HEADER_STYLE, storage.get(TOGGLE_HEADER_STYLE, defaultSettings.headerStyle))
  store.commit(TOGGLE_FIXED_HEADER, storage.get(TOGGLE_FIXED_HEADER, defaultSettings.fixedHeader))
  store.commit(TOGGLE_FIXED_SIDEBAR, storage.get(TOGGLE_FIXED_SIDEBAR, defaultSettings.fixSiderbar))
  store.commit(TOGGLE_CONTENT_WIDTH, storage.get(TOGGLE_CONTENT_WIDTH, defaultSettings.contentWidth))
  store.commit(TOGGLE_HIDE_HEADER, storage.get(TOGGLE_HIDE_HEADER, defaultSettings.autoHideHeader))
  store.commit(TOGGLE_NAV_THEME, storage.get(TOGGLE_NAV_THEME, defaultSettings.navTheme))
  store.commit(TOGGLE_WEAK, storage.get(TOGGLE_WEAK, defaultSettings.colorWeak))
  store.commit(TOGGLE_PRIMARY_COLOR, storage.get(TOGGLE_PRIMARY_COLOR, defaultSettings.primaryColor))
  store.commit(TOGGLE_MULTI_TAB, storage.get(TOGGLE_MULTI_TAB, defaultSettings.multiTab))
  store.commit(TOGGLE_ZOOM, storage.get(TOGGLE_ZOOM, defaultSettings.zoom))

  //store.commit('SET_TOKEN', storage.get(ACCESS_TOKEN))
  store.commit('SET_TOKEN', storage.get(ACCESS_TOKEN))

  //设置语言 移到获取userinfo逻辑中
  store.dispatch("setLangFromMem", storage.get(TOGGLE_LANAGUAGE, defaultSettings.lang))
  // last step
}
