import store from 'store';
import { getUrlParam, getFirstHost } from '@/cool/utils';

const env = process.env;

// 路由模式
const routerMode = 'hash';

// 图片host
const imgHostUrl = `${window.location.protocol}//img.${getFirstHost()}.com`;

// 请求地址
const baseUrl = (() => {
	let proxy = getUrlParam('proxy');
	console.log('proxy', proxy);

	if (proxy) {
		store.set('proxy', proxy);
	} else {
		proxy = store.get('proxy') || 'dev';
	}

	switch (env.NODE_ENV) {
		case 'development':
			return `/${proxy}`;
		case 'production':
			// return `http://api.b.huaml.com`;
			return `${window.location.protocol}//api.b.${getFirstHost()}.com`;
		default:
			return '';
	}
})();

// 阿里字体图标库 https://at.alicdn.com/t/**.css
const iconfontUrl = ``;

export { env, routerMode, baseUrl, iconfontUrl, imgHostUrl };
