-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
希望加个文章加密功能 #63
Comments
试一下这个 #30 (comment) |
emmm...原答案的链接进不去了,密码验证的函数实在是不好找😭 |
hexo-blog-encrypt/index.js#L94, 94, 95, 96 三行代码删掉,在 layout.ejs 的 <%- css('css/blog-encrypt') %>
<%- js('lib/crypto-js') %>
<%- js('lib/blog-encrypt') %> |
补充修改 hexo-blog-encrypt1.hexo-blog-encrypt/index.js#L94, line 94, 95, 96 删掉,新增一行代码(与主题的目录解析有冲突,所以禁用目录),修改一行代码: data.content = data.template;
- data.content += `<script src="${hexo.config.root}lib/crypto-js.js"></script>`;
- data.content += `<script src="${hexo.config.root}lib/blog-encrypt.js"></script>`;
- data.content += `<link href="${hexo.config.root}css/blog-encrypt.css" rel="stylesheet" type="text/css">`;
+ delete data.toc;
data.more = data.abstract;
data.excerpt = data.more;
}
return data;
-});
+}, 11); 2.hexo-blog-encrypt/template.html#L1, line1 删掉 - <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 3.hexo-blog-encrypt/lib/blog-encrypt.js#L113 line113 以下代码按如下修改: // Since you decided to use jQuery.
-$(document).ready(
- function () {
-
- console.log('Registering Enter for decrypt.');
- document.getElementById('pass').onkeypress = function (keyPressEvent) {
-
- if (keyPressEvent.keyCode === 13) {
-
- decryptAES();
-
- }
-
- };
-
- }
-);
+$(document).on('keypress', '#pass', function (keyPressEvent) {
+ if (keyPressEvent.keyCode === 13)
+ decryptAES();
+}) 修改主题 layout/index.ejs+<%- js("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js") %>
+<%- js("lib/crypto-js") %>
+<%- js("lib/blog-encrypt") %>
+<%- css("css/blog-encrypt") %>
</head> 最后先执行 如果还不行,打开 chrome 控制台,看下是不是有个 callback 什么鬼的报错了,hexo-blog-encrypt/lib/blog-encrypt.js#L33 删掉下面那行...... // Use jquery to load some js code
try {
$('#encrypt-blog').html(content);
- {callback}
} catch(e) { |
因为这款主题不支持Hexo-blog-encrypt 这款插件!
>_<The text was updated successfully, but these errors were encountered: