import variables from '@/styles/element-variables.scss'
import defaultSettings from '@/settings'

// const { showSettings, tagsView, breadcrumb, fixedHeader, sidebarLogo } = defaultSettings
const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings

const state = {
  theme: variables.theme, // 主题
  showSettings: showSettings, // 是否显示设置按钮
  breadcrumb: true, // 是否显示面包屑
  tagsView: tagsView, // 是否显示tagsView
  fixedHeader: fixedHeader, // 是否固定面包屑
  sidebarLogo: sidebarLogo, // 是否显示logo
  bodyHeight: 400, // 内容高度
  amapSecurityCode: '182a2c5889f7fe6d90546d9b8f4781ad', // 安全密钥
  amapKey: 'e1733551f35b56f6d8e9c0a9d4c2523b' // 高德地图key
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    if (Object.prototype.hasOwnProperty.call(state, 'key')) {
      state[key] = value
    }
  },
  SET_BODY_HEIGHT: (state, height) => {
    state.bodyHeight = height
    console.log('bodyHeight', height)
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  },
  ChangeHeight({ commit }, height) {
    commit('SET_BODY_HEIGHT', height)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

