diff --git a/src/disqus.js b/src/disqus.js index 113435f..abe5972 100644 --- a/src/disqus.js +++ b/src/disqus.js @@ -177,8 +177,14 @@ * API URI: /3.0/posts/list.json?forum=[shortname]&thread=[thread id]&api_key=[apikey] */ - let getComment = () => { - let url = `${disqusjs.config.api}3.0/posts/list.json?forum=${disqusjs.config.shortname}&thread=${disqusjs.page.id}&api_key=${disqusjs.config.apikey}`; + let getComment = (cursor) => { + if (!cursor) { + cursor = ''; + } else { + cursor = `&cursor=${cursor}`; + } + + let url = `${disqusjs.config.api}3.0/posts/list.json?forum=${disqusjs.config.shortname}&thread=${disqusjs.page.id}${cursor}&api_key=${disqusjs.config.apikey}`; xhr.open('GET', url, true); xhr.timeout = 4000; xhr.send(); @@ -192,6 +198,11 @@ document.getElementById('dsqjs-no-comment').classList.remove('dsqjs-hide'); } + if (res.cursor.hasNext) { + document.getElementById('dsqjs-load-more').classList.remove('dsqjs-hide'); + document.getElementById('dsqjs-load-more').addEventListener('click', () => {getComment(res.cursor.next)}); + } + } else { loadError(); } @@ -270,6 +281,8 @@ s.nesting = 1; } + console.log(s); + return s; } @@ -355,14 +368,15 @@
这里冷冷清清的,一条评论都没有