提交 | 用户 | 时间
|
1ac2bc
|
1 |
<div class="lock-screen-wrapper"> |
懒 |
2 |
<div class="lock-screen-time"></div> |
|
3 |
<div class="lock-screen-date"></div> |
|
4 |
<div class="lock-screen-form"> |
|
5 |
<input placeholder="输入123456解锁" autocomplete="new-password" class="lock-screen-psw" maxlength="20" type="password" name="newpwd" id="newpwd"/> |
|
6 |
<i class="layui-icon layui-icon-right lock-screen-enter"></i> |
|
7 |
<br/> |
|
8 |
<div class="lock-screen-tip"></div> |
|
9 |
</div> |
|
10 |
<div class="lock-screen-tool"> |
|
11 |
<div class="lock-screen-tool-item"> |
|
12 |
<i class="layui-icon layui-icon-logout" data-confirm="false" id="logoutBtn"></i> |
|
13 |
<div class="lock-screen-tool-tip">退出登录</div> |
|
14 |
</div> |
|
15 |
</div> |
|
16 |
</div> |
|
17 |
|
|
18 |
<script> |
|
19 |
layui.use(['util', 'admin', 'ax'], function () { |
|
20 |
var $ = layui.jquery; |
|
21 |
var util = layui.util; |
|
22 |
var admin = layui.admin; |
|
23 |
var $ax = layui.ax; |
|
24 |
var rightPsw = 'e10adc3949ba59abbe56e057f20f883e'; // 正确密码的MD5密文 |
|
25 |
|
|
26 |
// 获取各个组件 |
|
27 |
var $form = $('.lock-screen-wrapper .lock-screen-form'); |
|
28 |
var $psw = $form.find('.lock-screen-psw'); |
|
29 |
var $tip = $form.find('.lock-screen-tip'); |
|
30 |
var $time = $('.lock-screen-wrapper .lock-screen-time'); |
|
31 |
var $date = $('.lock-screen-wrapper .lock-screen-date'); |
|
32 |
|
|
33 |
// 监听退出 |
|
34 |
$('#logoutBtn').click(function (e) { |
|
35 |
|
|
36 |
//解锁锁屏 |
|
37 |
admin.unlockScreen(); |
|
38 |
|
|
39 |
var ajax = new $ax(Feng.ctxPath + "/logout", function (data) { |
|
40 |
Feng.success("退出成功!"); |
|
41 |
location.replace(Feng.ctxPath + "/"); |
|
42 |
}, function (data) { |
|
43 |
layer.msg("退出失败!" + data.responseJSON.message, {icon: 5, anim: 6}); |
|
44 |
}); |
|
45 |
ajax.start(); |
|
46 |
}); |
|
47 |
|
|
48 |
// 监听enter键 |
|
49 |
$(window).keydown(function (event) { |
|
50 |
if (admin.isLockScreen) { |
|
51 |
if (event.keyCode === 13) { |
|
52 |
doVer(); |
|
53 |
} else if (event.keyCode === 8 && !$psw.val()) { |
|
54 |
restForm(); |
|
55 |
if (event.preventDefault) event.preventDefault(); |
|
56 |
if (event.returnValue) event.returnValue = false; |
|
57 |
} |
|
58 |
} |
|
59 |
}); |
|
60 |
|
|
61 |
// 监听输入 |
|
62 |
$psw.on('input', function () { |
|
63 |
var psw = $psw.val(); |
|
64 |
if (rightPsw === toMd5Hex(psw)) { |
|
65 |
restForm(); |
|
66 |
admin.unlockScreen(); |
|
67 |
} else if (psw) { |
|
68 |
$form.removeClass('show-back'); |
|
69 |
$tip.text(''); |
|
70 |
} else { |
|
71 |
$form.addClass('show-back'); |
|
72 |
} |
|
73 |
}); |
|
74 |
|
|
75 |
// 监听按钮点击 |
|
76 |
$form.find('.lock-screen-enter').click(function (e) { |
|
77 |
doVer(true); |
|
78 |
}); |
|
79 |
|
|
80 |
// 处理事件 |
|
81 |
function doVer(emptyRest) { |
|
82 |
if ($form.hasClass('show-psw')) { |
|
83 |
$psw.focus(); |
|
84 |
var psw = $psw.val(); |
|
85 |
if (!psw) { |
|
86 |
emptyRest ? restForm() : $tip.text('请输入解锁密码'); |
|
87 |
} else if (rightPsw === toMd5Hex(psw)) { |
|
88 |
restForm(); |
|
89 |
admin.unlockScreen(); |
|
90 |
} else { |
|
91 |
$psw.val(''); |
|
92 |
$tip.text('密码不正确'); |
|
93 |
$form.addClass('show-back'); |
|
94 |
} |
|
95 |
} else { |
|
96 |
$form.addClass('show-psw show-back'); |
|
97 |
$psw.focus(); |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
// 重置 |
|
102 |
function restForm() { |
|
103 |
$psw.blur(); |
|
104 |
$psw.val(''); |
|
105 |
$tip.text(''); |
|
106 |
$form.removeClass('show-psw show-back'); |
|
107 |
} |
|
108 |
|
|
109 |
// 时间、日期 |
|
110 |
function setDate() { |
|
111 |
var date = new Date(); |
|
112 |
$time.text(util.toDateString(date, 'HH:mm')); |
|
113 |
var weeks = ['日', '一', '二', '三', '四', '五', '六']; |
|
114 |
$date.text(util.toDateString(date, 'MM月dd日,星期') + weeks[date.getDay()]); |
|
115 |
} |
|
116 |
|
|
117 |
setDate(); |
|
118 |
|
|
119 |
setInterval(function () { |
|
120 |
if (admin.isLockScreen) setDate(); |
|
121 |
}, 1000); |
|
122 |
|
|
123 |
}); |
|
124 |
</script> |
|
125 |
|
|
126 |
<style> |
|
127 |
.lock-screen-wrapper { |
|
128 |
color: #ffffff; |
|
129 |
width: 100%; |
|
130 |
height: 100%; |
|
131 |
box-sizing: border-box; |
|
132 |
padding: 50px 60px 0 60px; |
|
133 |
background-color: #000000; |
|
134 |
background-image: url("${ctxPath}/assets/common/images/bg-screen.jpg"); |
|
135 |
background-repeat: no-repeat; |
|
136 |
background-size: cover; |
|
137 |
position: relative; |
|
138 |
} |
|
139 |
|
|
140 |
.lock-screen-time { |
|
141 |
font-size: 88px; |
|
142 |
} |
|
143 |
|
|
144 |
.lock-screen-date { |
|
145 |
font-size: 24px; |
|
146 |
padding: 0 0 0 13px; |
|
147 |
} |
|
148 |
|
|
149 |
.lock-screen-form { |
|
150 |
position: absolute; |
|
151 |
left: 0; |
|
152 |
right: 0; |
|
153 |
top: 65%; |
|
154 |
width: 100%; |
|
155 |
text-align: center; |
|
156 |
} |
|
157 |
|
|
158 |
.lock-screen-psw { |
|
159 |
color: #ffffff; |
|
160 |
font-size: 22px; |
|
161 |
width: 0; |
|
162 |
height: 0; |
|
163 |
line-height: 40px; |
|
164 |
border-radius: 40px; |
|
165 |
border: 2px solid transparent; |
|
166 |
background-color: transparent; |
|
167 |
box-sizing: border-box; |
|
168 |
vertical-align: middle; |
|
169 |
-webkit-transition: all .3s; |
|
170 |
transition: all .3s; |
|
171 |
text-align: center; |
|
172 |
} |
|
173 |
|
|
174 |
.lock-screen-psw::-webkit-input-placeholder { |
|
175 |
color: #F6F6F6; |
|
176 |
font-size: 16px; |
|
177 |
} |
|
178 |
|
|
179 |
.lock-screen-psw::-moz-placeholder { |
|
180 |
color: #F6F6F6; |
|
181 |
font-size: 16px; |
|
182 |
} |
|
183 |
|
|
184 |
.lock-screen-psw::-ms-input-placeholder { |
|
185 |
color: #F6F6F6; |
|
186 |
font-size: 16px; |
|
187 |
} |
|
188 |
|
|
189 |
.lock-screen-enter { |
|
190 |
width: 65px; |
|
191 |
height: 65px; |
|
192 |
line-height: 1; |
|
193 |
font-size: 28px; |
|
194 |
padding-top: 18px; |
|
195 |
border: 2px solid #ffffff; |
|
196 |
border-radius: 50%; |
|
197 |
text-align: center; |
|
198 |
display: inline-block; |
|
199 |
box-sizing: border-box; |
|
200 |
vertical-align: middle; |
|
201 |
transition: all .3s; |
|
202 |
cursor: pointer; |
|
203 |
} |
|
204 |
|
|
205 |
.lock-screen-enter:hover { |
|
206 |
background-color: rgba(255, 255, 255, .3); |
|
207 |
} |
|
208 |
|
|
209 |
.lock-screen-form.show-psw .lock-screen-psw { |
|
210 |
height: 40px; |
|
211 |
width: 180px; |
|
212 |
padding: 0 5px; |
|
213 |
margin-right: 10px; |
|
214 |
border-color: #ffffff; |
|
215 |
background-color: rgba(255, 255, 255, .3); |
|
216 |
} |
|
217 |
|
|
218 |
.lock-screen-form.show-psw .lock-screen-enter { |
|
219 |
width: 40px; |
|
220 |
height: 40px; |
|
221 |
font-size: 20px; |
|
222 |
padding-top: 8px; |
|
223 |
} |
|
224 |
|
|
225 |
.lock-screen-form.show-back .lock-screen-enter:before { |
|
226 |
content: "\e603"; |
|
227 |
} |
|
228 |
|
|
229 |
.lock-screen-tip { |
|
230 |
color: red; |
|
231 |
width: 230px; |
|
232 |
padding: 0 3px; |
|
233 |
font-size: 14px; |
|
234 |
text-align: left; |
|
235 |
box-sizing: border-box; |
|
236 |
display: none; |
|
237 |
} |
|
238 |
|
|
239 |
.lock-screen-form.show-psw .lock-screen-tip { |
|
240 |
display: inline-block; |
|
241 |
} |
|
242 |
|
|
243 |
.lock-screen-tool { |
|
244 |
width: 20px; |
|
245 |
position: absolute; |
|
246 |
right: 20px; |
|
247 |
bottom: 20px; |
|
248 |
} |
|
249 |
|
|
250 |
.lock-screen-tool .lock-screen-tool-item { |
|
251 |
position: relative; |
|
252 |
width: 20px; |
|
253 |
height: 20px; |
|
254 |
line-height: 20px; |
|
255 |
margin-top: 15px; |
|
256 |
cursor: pointer; |
|
257 |
} |
|
258 |
|
|
259 |
.lock-screen-tool .lock-screen-tool-item:hover .layui-icon { |
|
260 |
color: #ffffff; |
|
261 |
} |
|
262 |
|
|
263 |
.lock-screen-tool .layui-icon { |
|
264 |
font-size: 20px; |
|
265 |
} |
|
266 |
|
|
267 |
.lock-screen-tool .lock-screen-tool-item .lock-screen-tool-tip { |
|
268 |
position: absolute; |
|
269 |
top: 50%; |
|
270 |
right: 100%; |
|
271 |
height: 24px; |
|
272 |
line-height: 24px; |
|
273 |
width: 60px; |
|
274 |
width: max-content; |
|
275 |
text-align: center; |
|
276 |
margin-right: 10px; |
|
277 |
margin-top: -12px; |
|
278 |
font-size: 12px; |
|
279 |
padding: 0 8px; |
|
280 |
color: #eee; |
|
281 |
border-radius: 3px; |
|
282 |
background-color: rgba(255, 255, 255, .3); |
|
283 |
word-break: break-all; |
|
284 |
display: none; |
|
285 |
} |
|
286 |
|
|
287 |
.lock-screen-tool .lock-screen-tool-item:hover .lock-screen-tool-tip { |
|
288 |
display: inline-block; |
|
289 |
} |
|
290 |
|
|
291 |
.lock-screen-tool .lock-screen-tool-item .lock-screen-tool-tip:before { |
|
292 |
content: ""; |
|
293 |
border: 4px solid transparent; |
|
294 |
border-left-color: rgba(255, 255, 255, .3); |
|
295 |
position: absolute; |
|
296 |
right: -8px; |
|
297 |
top: 50%; |
|
298 |
margin-top: -4px; |
|
299 |
} |
|
300 |
</style> |
|
301 |
|
|
302 |
<script> |
|
303 |
/** MD5加密 */ |
|
304 |
function toMd5Hex(text) { |
|
305 |
var hexcase = 0; |
|
306 |
var chrsz = 8; |
|
307 |
|
|
308 |
function core_md5(x, len) { |
|
309 |
x[len >> 5] |= 0x80 << ((len) % 32); |
|
310 |
x[(((len + 64) >>> 9) << 4) + 14] = len; |
|
311 |
var a = 1732584193; |
|
312 |
var b = -271733879; |
|
313 |
var c = -1732584194; |
|
314 |
var d = 271733878; |
|
315 |
for (var i = 0; i < x.length; i += 16) { |
|
316 |
var olda = a; |
|
317 |
var oldb = b; |
|
318 |
var oldc = c; |
|
319 |
var oldd = d; |
|
320 |
a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936); |
|
321 |
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586); |
|
322 |
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819); |
|
323 |
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330); |
|
324 |
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897); |
|
325 |
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426); |
|
326 |
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341); |
|
327 |
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983); |
|
328 |
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416); |
|
329 |
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417); |
|
330 |
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063); |
|
331 |
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162); |
|
332 |
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682); |
|
333 |
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101); |
|
334 |
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290); |
|
335 |
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329); |
|
336 |
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510); |
|
337 |
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632); |
|
338 |
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713); |
|
339 |
b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302); |
|
340 |
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691); |
|
341 |
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083); |
|
342 |
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335); |
|
343 |
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848); |
|
344 |
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438); |
|
345 |
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690); |
|
346 |
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961); |
|
347 |
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501); |
|
348 |
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467); |
|
349 |
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784); |
|
350 |
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473); |
|
351 |
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734); |
|
352 |
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558); |
|
353 |
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463); |
|
354 |
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562); |
|
355 |
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556); |
|
356 |
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060); |
|
357 |
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353); |
|
358 |
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632); |
|
359 |
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640); |
|
360 |
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174); |
|
361 |
d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222); |
|
362 |
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979); |
|
363 |
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189); |
|
364 |
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487); |
|
365 |
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835); |
|
366 |
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520); |
|
367 |
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651); |
|
368 |
a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844); |
|
369 |
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415); |
|
370 |
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905); |
|
371 |
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055); |
|
372 |
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571); |
|
373 |
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606); |
|
374 |
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523); |
|
375 |
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799); |
|
376 |
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359); |
|
377 |
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744); |
|
378 |
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380); |
|
379 |
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649); |
|
380 |
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070); |
|
381 |
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379); |
|
382 |
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259); |
|
383 |
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551); |
|
384 |
a = safe_add(a, olda); |
|
385 |
b = safe_add(b, oldb); |
|
386 |
c = safe_add(c, oldc); |
|
387 |
d = safe_add(d, oldd); |
|
388 |
} |
|
389 |
return Array(a, b, c, d); |
|
390 |
} |
|
391 |
|
|
392 |
function md5_cmn(q, a, b, x, s, t) { |
|
393 |
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b); |
|
394 |
} |
|
395 |
|
|
396 |
function md5_ff(a, b, c, d, x, s, t) { |
|
397 |
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); |
|
398 |
} |
|
399 |
|
|
400 |
function md5_gg(a, b, c, d, x, s, t) { |
|
401 |
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); |
|
402 |
} |
|
403 |
|
|
404 |
function md5_hh(a, b, c, d, x, s, t) { |
|
405 |
return md5_cmn(b ^ c ^ d, a, b, x, s, t); |
|
406 |
} |
|
407 |
|
|
408 |
function md5_ii(a, b, c, d, x, s, t) { |
|
409 |
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); |
|
410 |
} |
|
411 |
|
|
412 |
function safe_add(x, y) { |
|
413 |
var lsw = (x & 0xFFFF) + (y & 0xFFFF); |
|
414 |
var msw = (x >> 16) + (y >> 16) + (lsw >> 16); |
|
415 |
return (msw << 16) | (lsw & 0xFFFF); |
|
416 |
} |
|
417 |
|
|
418 |
function bit_rol(num, cnt) { |
|
419 |
return (num << cnt) | (num >>> (32 - cnt)); |
|
420 |
} |
|
421 |
|
|
422 |
function str2binl(str) { |
|
423 |
var bin = Array(); |
|
424 |
var mask = (1 << chrsz) - 1; |
|
425 |
for (var i = 0; i < str.length * chrsz; i += chrsz) |
|
426 |
bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32); |
|
427 |
return bin; |
|
428 |
} |
|
429 |
|
|
430 |
function binl2hex(binarray) { |
|
431 |
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; |
|
432 |
var str = ""; |
|
433 |
for (var i = 0; i < binarray.length * 4; i++) { |
|
434 |
str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) + |
|
435 |
hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF); |
|
436 |
} |
|
437 |
return str; |
|
438 |
} |
|
439 |
|
|
440 |
return binl2hex(core_md5(str2binl(text), text.length * chrsz)); |
|
441 |
} |
|
442 |
</script> |