/*
 * @Author: your name
 * @Date: 2021-07-26 13:50:44
 * @LastEditTime: 2021-07-28 11:46:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /TracerMethodology_PC/src/utils.js
 */


//获取url参数
/**
 * 
 * @param {*} name 需要获取的query名
 * @returns 
 */


 import { useRequest,request } from 'umi';


const getQueryString = (name)=>{
    let reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    let r = window.location.search.substr(1).match(reg);
    console.log({r});
    if (r != null) {
        return decodeURIComponent(r[2]);
    };
    return null;
} 

/**
 * 
 * @param {Function} requestFunc request函数
 */
const CARequest = (url)=>{
      const { data, error, loading } = useRequest(() => {
        return request(url);
      });
      console.log({data, error, loading});
      
}

export  {
    getQueryString,
    CARequest
}