
/////这里集成一些只有web环境才会用到的方法,链接参数,cookie参数等等


let urlParams: { [key: string]: string | true };
/**
 * 获取链接参数
 * @param key
 */
export function getUrlParams(key: string): string | true {
    if (urlParams) return urlParams[key];
    urlParams = {};
    let search = window.location.search;
    try {
        search = top.location.search;  //尝试获取顶层的链接
    } catch (e) {
    }
    //获取链接参数
    for (let item of search.replace('?', '').split('&')) {
        let arr = item.split('=');
        urlParams[arr[0]] = arr.length === 1 ? true : decodeURIComponent(arr[1]);
    }
    return urlParams[key];
}
