export function genKey() {
    // const t  = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
    const t = 'xxxxxxxx'
    return t.replace(/[xy]/g, function (c) {
      const r = Math.random() * 16 | 0
      const v = c === 'x' ? r : (r & 0x3 | 0x8)
      return v.toString(16)
    })
  }
  
  export function getKey(route, keyName) {
    return `${route.name || route.path}?${route.query[keyName]}`
  }
  
  export function matches(pattern, name) {
    if (Array.isArray(pattern)) {
      return pattern.indexOf(name) > -1
    } else if (typeof pattern === 'string') {
      return pattern.split(',').indexOf(name) > -1
    } else if (isRegExp(pattern)) {
      return pattern.test(name)
    }
    return false
  }
  
  export function isObjEqual(obj1, obj2) {
    if (obj1 === obj2) {
      return true
    }
    else {
      const keys1 = Object.getOwnPropertyNames(obj1)
      const keys2 = Object.getOwnPropertyNames(obj2)
      if (keys1.length !== keys2.length) {
        return false
      }
      for (const key of keys1) {
        if (obj1[key] !== obj2[key]) {
          return false
        }
      }
      return true
    }
  }
  let imgUrlDomain = process.env.VUE_APP_IMAGE_SERVER
 /*
  * 获取图片路径方法修改
  */
 export function getImgUrl(str,defalutImg){
     if(typeof str != 'string'){
         return defalutImg||"";
     }
     if(str.length == 0){
         return defalutImg||"";
     }else{
         if(str.indexOf("../")>-1){
             //访问本地路径
             return defalutImg||str;
         }else if((str.indexOf("http://")>-1) || (str.indexOf("https://")>-1)){
             return str;
         }else{
             //服务器上的图片路径
             return imgUrlDomain + str;
         }
     }
 }