import headlogo from '../image/header-logo.png'; import defaultImg from '../image/default.png'; import addIcon from '../image/addIcon.png'; import refreshIcon from '../image/refresh.png'; import plusIcon from '../image/plusIcon.png'; import clockIcon from '../image/clock.png'; import breakImg from '../image/breakImg.png'; import plusIcon_disabled from '../image/plusIcon_disabled.png'; import refresh_disabled from '../image/refresh_disabled.png'; import overPassIcon from '../image/overPassIcon.png' import homePage from '../image/homepage.png' const localHost = 'http://localhost:7788'; const devHost = 'http://test.mjitech.com'; const masterHost = 'http://www.mjitech.com'; /** * 获取新的图片链接 * @param path * @param host * @returns {*} */ const getNewPath = (path,host)=>{ return path.indexOf('http') < 0 ? host + path : path; }; /** * 获取新的规格的图片地址 * @param path * @param format * @returns {*} */ const getNewFormatPath = (path,format)=>{ let particial = path.split('.'); if(particial.length === 4){ particial[2] = particial[2] + '_' + format; return particial.join('.') } else { return path; } }; /** * 获取本地图片的新规格链接 * @param path * @param format * @returns {*} */ const getPic = (path,format)=>{ let newPath = getNewFormatPath(path,format); newPath = getNewPath(newPath,devHost); return newPath; }; const handleImgError = (ref)=>{ let src = ref.src; src = defaultImg return src; } const handleImgLoad = (ref)=>{ let width = ref.width; let height = ref.height; let style = {} if(width >= height){ style ={ width : "100%", height : "auto" } }else{ style ={ width : "auto", height : "100%" } } return style; } const localImg = {headlogo,defaultImg,addIcon,refreshIcon,plusIcon,clockIcon,breakImg,refresh_disabled,plusIcon_disabled,overPassIcon,homePage} module.exports = {localHost,devHost,masterHost,getPic,handleImgError,handleImgLoad,localImg};