JO
2024-08-13 bf781fe79d3f2babeeaa9dd55e5f4a5da04e9977
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* global NexT, CONFIG */
 
document.addEventListener('page:loaded', () => {
  const { appid, appkey } = CONFIG.changyan;
  const mainJs = 'https://cy-cdn.kuaizhan.com/upload/changyan.js';
  const countJs = `https://cy-cdn.kuaizhan.com/upload/plugins/plugins.list.count.js?clientId=${appid}`;
 
  // Get the number of comments
  setTimeout(() => {
    return NexT.utils.getScript(countJs, {
      attributes: {
        async: true,
        id   : 'cy_cmt_num'
      }
    });
  }, 0);
 
  // When scroll to comment section
  if (CONFIG.page.comments && !CONFIG.page.isHome) {
    NexT.utils.loadComments('#SOHUCS')
      .then(() => {
        return NexT.utils.getScript(mainJs, {
          attributes: {
            async: true
          }
        });
      })
      .then(() => {
        window.changyan.api.config({
          appid,
          conf: appkey
        });
      })
      .catch(error => {
        // eslint-disable-next-line no-console
        console.error('Failed to load Changyan', error);
      });
  }
});