-
Notifications
You must be signed in to change notification settings - Fork 0
/
break.html
66 lines (59 loc) · 1.46 KB
/
break.html
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
<!DOCTYPE html>
<html>
<head>
<title>Break Time</title>
<style>
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.9);
color: white;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
.title {
font-size: 48px;
margin-bottom: 30px;
font-weight: 300;
}
.countdown {
font-size: 72px;
margin-bottom: 30px;
font-weight: 200;
}
.message {
font-size: 24px;
opacity: 0.8;
font-weight: 300;
}
</style>
</head>
<body>
<div class="title">Time for a Break!</div>
<div class="countdown">10</div>
<div class="message">Your computer will sleep in a moment...</div>
<script>
let countdown = 10;
const countdownElement = document.querySelector('.countdown');
const timer = setInterval(() => {
countdown--;
countdownElement.textContent = countdown;
if (countdown <= 0) {
clearInterval(timer);
}
}, 1000);
document.addEventListener('keydown', async (event) => {
if (event.code === 'Space') {
clearInterval(timer);
await window.electron.cancelBreak(); // 调用cancelBreak
window.close();
}
});
</script>
</body>
</html>