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

const env = envParam['test']

// 全局配置
const config = {
  // 网络全局配置
  netConfig: {
    development: {
      baseURL: 'http://augcl.natapp1.cc/exhibit-admin/exhibit',
    },
    testing: {
      baseURL: 'https://exhibit.augcl.com/exhibit-admin/exhibit',
    },
    production: {
      baseURL: 'https://exhibit.augcl.com/exhibit-admin/exhibit',
    }
  },

  // 阿里云配置
  aliOSSConfig :{
    development: {
      aliOSS_accessKey: 'LTAI5tQSs47izVy8DLVdwUU9',
      aliOSS_secretKey: 'qHI7C3PaXYZySr84HTToviC71AYlFq',
      aliOSS_bucketName: 'hanhaiimage',
      endpoint: 'oss-cn-shenzhen.aliyuncs.com',
      staticDomain: 'https://image.hhlm1688.com/'
    },
    testing: {
      aliOSS_accessKey: 'LTAI5tQSs47izVy8DLVdwUU9',
      aliOSS_secretKey: 'qHI7C3PaXYZySr84HTToviC71AYlFq',
      aliOSS_bucketName: 'hanhaiimage',
      endpoint: 'oss-cn-shenzhen.aliyuncs.com',
      staticDomain: 'https://image.hhlm1688.com/'
    },
    production: {
      aliOSS_accessKey: 'LTAI5tQSs47izVy8DLVdwUU9',
      aliOSS_secretKey: 'qHI7C3PaXYZySr84HTToviC71AYlFq',
      aliOSS_bucketName: 'hanhaiimage',
      endpoint: 'oss-cn-shenzhen.aliyuncs.com',
      staticDomain: 'https://image.hhlm1688.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