-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimecode2fa.html
More file actions
68 lines (53 loc) · 1.22 KB
/
Copy pathtimecode2fa.html
File metadata and controls
68 lines (53 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>动态码</title>
<style>
body{
margin:0;
height:100vh;
display:flex;
flex-direction:column;
justify-content:center;
align-items:center;
background:#111;
color:white;
font-family:Arial;
}
.code{
font-size:72px;
font-weight:bold;
letter-spacing:10px;
}
.time{
margin-top:20px;
opacity:0.7;
}
</style>
</head>
<body>
<div class="code" id="code">000000</div>
<div class="time" id="time"></div>
<script>
function generateCode() {
// 当前10分钟时间片
const timeSlice = Math.floor(Date.now() / 1000 / 600);
// 固定算法
let code = (timeSlice * 9301 + 49297) % 1000000;
// 补零
return code.toString().padStart(6, '0');
}
function update() {
document.getElementById("code").innerText = generateCode();
const now = new Date();
document.getElementById("time").innerText =
"当前时间:" + now.toLocaleString();
}
update();
// 每秒刷新一次显示
setInterval(update, 1000);
</script>
</body>
</html>