
import { ENV_CONFIG } from './enumerate.js'

function p_getElm(elmId) {
  return document.getElementById(elmId)
}


/**
 * 配置编译环境和线上环境之间的切换
 */
 function getTestEnv (ipAddress)  {
    let environments = ["localhost","dev", "uat","test1","10.177.10.231"];
    for (let i = 0; i < environments.length; i++) {
        if (ipAddress.indexOf(environments[i]) > -1) {
            return environments[i];
        }
    }
    return null;
};

// 根据不同环境，生成URL
function getConfigByEnvType(urlType) {
    if (process.client){
        console.log(window)
        let ipAddress = "https://" + window.location.host;
        let parm = null;
        let env = getTestEnv(ipAddress);
        if(env == 'localhost' || env == 'dev' || env == 'test1' || env == "10.177.10.231"){
            parm = 'test'
        }else{
            parm = 'prod'
        }
        	// console.log(parm)
        console.log(ENV_CONFIG[parm][urlType])
        return ENV_CONFIG[parm][urlType]
    }
    
}

