diff --git a/layout/_partials/plugins/encrypt.ejs b/layout/_partials/plugins/encrypt.ejs new file mode 100644 index 00000000..14a18edb --- /dev/null +++ b/layout/_partials/plugins/encrypt.ejs @@ -0,0 +1,18 @@ +<% +import_script(` + +`) +%> diff --git a/layout/post.ejs b/layout/post.ejs index d2aa6f61..8ffa9a42 100644 --- a/layout/post.ejs +++ b/layout/post.ejs @@ -35,18 +35,25 @@ page.banner_mask_alpha = page.banner_mask_alpha || theme.post.banner_mask_alpha <% } %>

<% } %> -
+ <% if (page.encrypt === true) { %> <%- inject_point('postMarkdownBegin') %> <%- page.content %> + <%- partial('_partials/plugins/encrypt') %> <%- inject_point('postMarkdownEnd') %> -
+ <% } else { %> +
+ <%- inject_point('postMarkdownBegin') %> + <%- page.content %> + <%- inject_point('postMarkdownEnd') %> +
+ <% } %>
<%- inject_point('postMetaBottom') %> <%- inject_point('postCopyright') %> - <% if(theme.post.prev_next.enable && !page.hide) { %> + <% if (theme.post.prev_next.enable && !page.hide) { %>
<% const prev = prev_post(page) %> diff --git a/source/js/utils.js b/source/js/utils.js index 86f34612..8ca61403 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -174,7 +174,19 @@ Fluid.utils = { } var colorCast = (0.213 * rgbArr[0]) + (0.715 * rgbArr[1]) + (0.072 * rgbArr[2]); return colorCast === 0 || colorCast > 255 / 2 ? 1 : -1; - } + }, + + retry(handler, interval, times) { + if (times <= 0) { + return; + } + var next = function() { + if (--times >= 0 && !handler()) { + setTimeout(next, interval); + } + }; + setTimeout(next, interval); + }, };