jawil / GayHub

An awesome chrome extension for github :octocat:
MIT License
1.08k stars 95 forks source link

不能加载私有仓库的文件树 #37

Open rocka opened 7 years ago

rocka commented 7 years ago

因为私有仓库需要 access token 才能访问的到,所以会出现错误。

另外,buunguyen/octotree 这个插件,是可以通过配置 access token 来访问私有仓库的

控制台输出

GET https://api.github.com/repos/<user>/<repo>/git/trees/master?recursive=1 404 (Not Found)

Uncaught (in promise) TypeError: Cannot read property 'length' of undefined    sideBarHelp.js?1f7b:217
    at generateCurrentTreeDOM (sideBarHelp.js?1f7b:217)
    at initDOM (sideBarHelp.js?1f7b:91)
    at eval (sidebarNav.js?c5dc:34)
    at <anonymous>

generateCurrentTreeDOM | @ | sideBarHelp.js?1f7b:217
initDOM | @ | sideBarHelp.js?1f7b:91
(anonymous) | @ | sidebarNav.js?c5dc:34
Promise resolved (async) |   |  
(anonymous) | @ | sidebarNav.js?c5dc:32
module.exports | @ | sidebarNav.js?c5dc:40
(anonymous) | @ | index.js?1fdf:19
(anonymous) | @ | contentscript.js:409
__webpack_require__ | @ | contentscript.js:20
(anonymous) | @ | contentscript.js:63
(anonymous) | @ | contentscript.js:66

报错代码位置

/**
 * 递归生成当前文件树下面所有的DOM结构 
 * @param {*当前目录所有的文件} CurrentTreeFiles 
 * @param {*DOM的根节点} parent 
 * @param {*当前层级,点击一下递归再生成两层目录} cascad 
 * @param {*github接口返回的所有文件树} files 
 */

const generateCurrentTreeDOM = function(
  CurrentTreeFiles,
  parent,
  cascad,
  files
) {
  if (!CurrentTreeFiles.length) {  // <- 错误定位在这一行
    return;
  }

  /* 重新渲染Pjax */
  new Pjax({
    elements: "a[data-href],a[id],a[type],span.js-path-segment>a",
    selectors: [
      "#js-repo-pjax-container",
      ".context-loader-container",
      "[data-pjax-container]"
    ]
  });
jawil commented 7 years ago

收到,最近收到的bug会抽空一起解决

ZHENGGEGE commented 7 years ago

对对,之前装的的一个类似的插件也是不满足私有仓库,这个比之前装的更漂亮,能加载私有的就更好了