D0n9X1n / hexo-blog-encrypt

Yet, just another hexo plugin for security.
https://www.npmjs.com/package/hexo-blog-encrypt
MIT License
971 stars 101 forks source link

想请问一下 Callback 函数应该怎么写 #177

Closed greedymonkey closed 2 years ago

greedymonkey commented 2 years ago

Issue

虽然不知道可不可行,我想在文章解密后加载其他js文件来生成目录,但是我不太清楚具体的 Callback 函数应该怎么写

Expected Behavior

在文章解密后成功加载js文件并执行

Actual Behavior

加载失败或者没有执行加载的js,没有生成TOC

Steps to Reproduce the Problem

  1. _在自定义页面的MD文件最后通过js引入TOC 的js和CSS

  2. _ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.11.1/tocbot.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.11.1/tocbot.min.js"></script>

  3. _ 然后引入自定义的js文件,自定义js代码如下 let markbody = document.getElementById('hexo-blog-encrypt').firstChild;markbody.className="js-toc-content"; tocbot.init({ // Where to render the table of contents. tocSelector: '#toc', // Where to grab the headings to build the table of contents. contentSelector: '.js-toc-content', // Which headings to grab inside of the contentSelector element. headingSelector: 'h1, h2, h3, h4, h5, h6', // For headings inside relative or absolute positioned containers within content. hasInnerContainers: true,});

Specifications

主题用的是fluid,hexo和主题还有插件的版本在我测试的时候都是最新

另外似乎初始化的js中需要一个放生成TOC的div,我之前有尝试通过js创建一个并给他添加ID和class,但是在我想把他添加到一个指定位置的时候会报错,错误大概我猜测是由于加密解密造成的,例如我通过document.getElementsByTagName('main')[0]获取到第一个main标签(页面中有这个标签),并且用var声明一个变量 maintag等于他,然后再把我之前创建的div放到这个元素内但是在hexo g之后我在网页的控制台看到heb.js报错,错误大概是‘maint’ undefined这个样的,看起来像是我的变量不知道是什么原因被截断不完整了,所以才出现这个错误,我尝试修改变量名也不行,依旧会出现这个错误,想请教一下有没有什么解决办法,我应该怎么修改代码,谢谢

(The version of the project, operating system, hardware etc.)