import setting from '@/mixins/theme.js'
// 定义所需的 mutations
const mutations = {
  SET_THEME: (state, color) => {
    //		console.log(state,color);
    state.theme = color;
  },
  /* 是否有数据报表权限 */
  SET_DATA_AUTH(state, bool) {
    state.dataAuth = bool;
  },

  SET_COLLAPSE(state,bool) {
    state.isCollapse = bool;
  },
  //面包屑的二级动态name
  SET_TITLE(state,str) {
    state.breadSelfName = str;
  },

  //设置动态的外部链接
  SET_DYNAMIC_LINK(state,obj) {
    let filterObj = {};
    obj.forEach(item => {
        if(!filterObj[item.ConfKey]) {
          filterObj[item.ConfKey] = item.ConfVal;
        }
    });
    /*
        [
            {
                "ConfKey": "ReportViewUrl", //研报预览分享链接
                "ConfVal": "http://testetareport.hzinsights.com"
            },
            {
                "ConfKey": "ChartViewUrl", //研报插入图表&表格外联
                "ConfVal": "https://charttest.hzinsights.com"
            },
            {
                "ConfKey": "ObjectStorageClient", //文件上传、存储 oss/minio
                "ConfVal": "minio"
            },
            {
                "ConfKey": "ApprovalFlow", //接口权限：是否走审批流 
                "ConfVal": "" //0否 1研报2智能研报 3全选
            }
        ]
     */
    localStorage.setItem('dynamicOutLinks',JSON.stringify(filterObj))
    state.dynamicOutLinks = filterObj; 
    setting.dynamicOutLinks = state.dynamicOutLinks;

  },
  SET_PAGE_EVENT_LISTENER:(state,flag)=>{
    state.hasDoPageListening = flag
  },
  SET_ETRIAL(state,flag){
    state.hasTrialUserPermisson = flag
  },
  //设置商家code
  SET_BUSINESS_CODE(state,code) {
    state.businessCode = code || ""
  }
};

export default mutations;
