feat: Encrypt

This commit is contained in:
shenyu
2021-07-23 11:47:30 +08:00
parent 8b6074fef4
commit c24db5e371
19 changed files with 143 additions and 6 deletions

View File

@@ -40,10 +40,21 @@
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
<% } %> <%- partial('google-analytics') %> <%- partial('baidu-analytics')
%>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>
<!-- mermaid -->
<% if (theme.mermaid.enable) { %>
<script src="<%= theme.mermaid.cdn %>"></script>
<% } %>
<style>
.swal2-styled.swal2-confirm {
font-size: 1.6rem;
}
</style>
</head>
</html>
</html>

37
layout/_partial/lock.ejs Normal file
View File

@@ -0,0 +1,37 @@
<% if (theme.lock.enable){ %>
<script>
const password = "<%= theme.lock.password %>";
const lock_password = window.sessionStorage.getItem("lock_password");
console.log(password, lock_password);
if (lock_password !== password) {
Swal.fire({
title: "<%= __('lock.lock_info') %>",
input: "text",
inputAttributes: {
autocapitalize: "off",
},
showCancelButton: false,
showLoaderOnConfirm: true,
allowOutsideClick: false,
confirmButtonText: "<%= __('lock.confirm_text') %>",
}).then((result) => {
console.log(result);
if (result.isConfirmed) {
console.log(password);
if (result.value === password) {
window.sessionStorage.setItem("lock_password", result.value);
} else {
Swal.fire({
icon: "error",
title: "<%= __('lock.lock_error') %>",
confirmButtonText: "<%= __('lock.confirm_text') %>",
allowOutsideClick: false,
}).then(() => {
window.location.reload();
});
}
}
});
}
</script>
<% } %>