export function getUrlParams(url: string): Record<string, string> {
  const theRequest: Record<string, string> = {};
  if(url.indexOf("#") != -1){
	  const str=url.split("#")[1];
	  const strs=str.split("&");
	  for (let i = 0; i < strs.length; i++) {
	  	theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1] ?? "");
	  }
  }else if(url.indexOf("?") != -1){
	  const str=url.split("?")[1];
	  const strs=str.split("&");
	  for (let i = 0; i < strs.length; i++) {
	  	theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1] ?? "");
	  }
  }
  return theRequest;
}

/**
 * 将对象参数转换为URL查询字符串格式
 * @param {Object} args - 参数对象
 * @returns {String} 返回key=value&格式的查询字符串
 */
export function objectToUrlParams(args: Record<string, unknown> | null | undefined): string {
  if (!args || typeof args !== 'object') {
    return '';
  }
  
  const params: string[] = [];
  for (const key in args) {
    if (Object.prototype.hasOwnProperty.call(args, key) && args[key] !== undefined && args[key] !== null) {
      params.push(`${key}=${args[key]}`);
    }
  }
  
  return params.length > 0 ? params.join('&') : '';
}
