// 环境配置相关
/**
 * 环境配置
 * env 环境变量字段
 * netConfig 网络配置
 * aliOSSConfig 阿里云配置
 * debounceConfig 防抖相关配置
 */
const envParam = {
  dev: 'development',
  test: 'testing',
  prod: 'production',
}

const env = envParam['test']

// 全局配置
const config = {
  // 网络全局配置
  netConfig: {
    development: {
      baseURL: 'http://127.0.0.1:8003/englishread-admin/appletApi',
    //   baseURL: 'http://h5.xzaiyp.top/englishread-admin/appletApi',
    },
    testing: {
      baseURL: 'https://www.multipleculture.com/englishread-admin/appletApi',
    },
    production: {
      baseURL: 'https://exhibit.augcl.com/exhibit-admin/exhibit',
    }
  },

  // 阿里云配置
  aliOSSConfig :{
    development: {
      aliOSS_accessKey: 'LTAI5tQzgwJQK7hd7zFKJbLm',
      aliOSS_secretKey: 'siB6FGNXDgSrLao5xvdNb4OCbQOt8d',
      aliOSS_bucketName: 'multipleculture',
      endpoint: 'oss-cn-beijing.aliyuncs.com',
      staticDomain: 'https://image.multipleculture.com/'
    },
    testing: {
      aliOSS_accessKey: 'LTAI5tQzgwJQK7hd7zFKJbLm',
      aliOSS_secretKey: 'siB6FGNXDgSrLao5xvdNb4OCbQOt8d',
      aliOSS_bucketName: 'multipleculture',
      endpoint: 'oss-cn-beijing.aliyuncs.com',
      staticDomain: 'https://image.multipleculture.com/'
    },
    production: {
      aliOSS_accessKey: 'LTAI5tRqoxbC9BKrWJduKDVT',
      aliOSS_secretKey: 's5ANiOq4kYpzuMLQhqPMYL4IybMR7L',
      aliOSS_bucketName: 'mulinyouni',
      endpoint: 'oss-cn-beijing.aliyuncs.com',
      staticDomain: 'https://image.mulinyouni.com/'
    },
  },

  // 防抖相关配置
  debounceConfig : {
    DEFAULT_DEBOUNCE_TIME: 0,
    DEFAULT_THROTTLE_TIME: 0,
    MAX_MAP_SIZE: 1000,
  }
}

// 全自动导入并生成平坦化结构
const finalConfig = Object.keys(config).reduce((finallyConfig, key) => {
  let tempConfig = {}
  if (key === 'netConfig' || key === 'aliOSSConfig') {

    tempConfig = config[key][env]
  }else {
    tempConfig = config[key]
  }
  return {
    ...finallyConfig,
    ...tempConfig,
  }
}, {})

export default finalConfig