| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 | var novapath = function (tab,type) {  var path = tab.pagePath;  // 外部应用,检测Scheme:https:// http:// wxapp://  if(path.indexOf("http")!=-1){    switch (type) {      case "module":        return "h5view"        break;      case "path":        return path        break;      default:        break;    }    return false  }  if(path.indexOf("wxapp")!=-1){  }  // 内部应用,截取path第一位为module,后续为路径,?为参数  // var plist = path.split("/")  var rpath = path.split("?")[0]  var paramstr = path.split("?")[1]  if(type=="module"){    return "comp"  }  if(type=="path"){    return rpath  }  if(type=="tag"){ // 如:"/nova-zhiliang/pages/my/index" 转为组件名 "nova-zhiliang-pages-my-index"    var tag = rpath.split("/").slice(1).join("-");        return tag  }  if(type=="params"){    if(paramstr){      return params2Json(paramstr)    }else{      return {}    }  }  return false}  var params2Json = function(paramstr){      var obj = {}, pairs = paramstr.split('&'), d = decodeURIComponent, name, value;      pairs.forEach(function (pair) {        pair = pair.split('=');        name = d(pair[0]);        value = d(pair[1]);        obj[name] = value;      });      return obj;  };   var isDiypage = function (path){    return path  }  var imageExtensions = ['.mp4', '.mov', '.m4v', '.3gp','.avi','.m3u8','.webm'];  function isVideo(url) {    var ext = url.slice(url.lastIndexOf('.')).toLowerCase();    return imageExtensions.indexOf(ext) > -1;  }  module.exports = {    novapath: novapath,    isDiypage: isDiypage,    isVideo:isVideo  }
 |