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

bug反馈 #123

Closed jerryc127 closed 4 years ago

jerryc127 commented 4 years ago

Issue

Expected Behavior

Actual Behavior

Steps to Reproduce the Problem

  1. _
  2. _
  3. _

Specifications

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

hexo 4.0.0 hexo-blog-encrypt 3.0.4

输入正确的密码后,会跳出一个提示框显示密码错误,点击确定后,博文能正常解锁显示。 2

提个建议

hexo.extend.filter.register('after_post_render', (data) => {})

这个可以减低优先度,不然博文提前加密,导致后续的js无法运作。。 可以参考 https://hexo.io/zh-tw/api/filter.html

D0n9X1n commented 4 years ago

弹窗的时候, 能提供下 console 中的信息吗?

jerryc127 commented 4 years ago

image

D0n9X1n commented 4 years ago

尴尬.... 更新到 v3.0.5 试试.

目前暂定 priority 1000 吧.

jerryc127 commented 4 years ago

解决了 callback这个怎么用 因为有些function需要解密后再调用一次

D0n9X1n commented 4 years ago

callback 目前还不支持, 这段时间会考虑重新实现, 之前版本的解决方案不太成功.

临时的解决办法的话, 可以添加到 node_modules/hexo-blog-encrypt/lib/blog-encrypt.js line 207 行.

https://github.com/MikeCoder/hexo-blog-encrypt/blob/0d33386b7affae0a8c00a2ab12c777e897591fa1/lib/blog-encrypt.js#L207

image
jerryc127 commented 4 years ago

有个问题 不知道为什么解密后,文章内的一下click会无法促发..

刷新页面,自动读取cookies解密。。点击正常触发

D0n9X1n commented 4 years ago

不是很明白这个问题描述,是解密之后,单击解密文章中的某一个按钮不能刷新? 如果是这样的话有可能是有函数钩子没挂上,保存密码的方式话,可能赶上了挂钩子的函数。

jerryc127 commented 4 years ago

我文章有個代碼框 有個按鈕可以展開/關閉代碼框 但是點擊按鈕沒有效果。。 (沒有報錯,按道理應該會觸發js)

D0n9X1n commented 4 years ago

能提供一段能复现的去敏博文内容吗?我明天看看是什么原因。

jerryc127 commented 4 years ago

https://demo.jerryc.me/posts/89757140/

密碼 123

D0n9X1n commented 4 years ago

比较简单的办法是在主题的 main.js 里面 248 行代码改成:

  /**
   * 代碼收縮
   */
// $('.code-area-wrap .code-expand').on('click', function () { 修改成如下
$(document).on('click', '.code-area-wrap .code-expand', function() {
    var $figure = $(this).parent().next()
    if ($(this).hasClass('code-closed')) {
      $figure.slideDown(300)
      $(this).removeClass('code-closed');
    } else {
      $figure.slideUp(300)
      $(this).addClass('code-closed');
    }
});

本质上还是解密时新添加的 dom 元素没有被添加事件监听. 解密之后保留密码, 因为博客中加密的 js 先于 main.js 执行, 导致 main.js 添加监听器的时候博客内容已经解密所以顺利挂上了监听器.

理论上, 如果 main.js 里面还有 on(event, function()) 这种写法, 都会存在这个问题...