You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

44 lines
1.0 KiB

/**
* getUrlParameter
* @param {string} arg_key
* @returns {string | TRUE}
*/
export function getUrlParameter(arg_key) {
let searchStr = window.location.search.substring(1),
paramList = searchStr.split('&');
for (let i = 0; i < paramList.length; i++) {
let paramPair = paramList[i].split('=');
if (paramPair[0] === arg_key) {
return paramPair[1] === undefined
? true
: decodeURIComponent(paramPair[1]);
}
}
}
/**
* 深冻结函数
*/
export function deepFreeze(o) {
const oIsFunction = typeof o === 'function';
const hasOwnProp = Object.prototype.hasOwnProperty;
Object.getOwnPropertyNames(o).forEach(function(name) {
const prop = o[name];
if (
hasOwnProp.call(o, name) &&
(oIsFunction
? name !== 'caller' && name !== 'callee' && name !== 'arguments'
: true) &&
prop !== null &&
(typeof prop === 'object' || typeof prop === 'function') &&
!Object.isFrozen(prop)
) {
deepFreeze(prop);
}
});
return Object.freeze(o);
}