Skip to content

Commit 2307949

Browse files
authored
feat: 添加考试广播返回按钮
2 parents 7a2fbf0 + 9db25b5 commit 2307949

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

notification/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<link rel="stylesheet" href="styles/switch.css">
1818
</head>
1919
<body class="light-mode">
20+
<button id="return-btn" onclick="goBack()">返回</button>
2021
<div class="info-container">
2122
<div class="info-content" id="infoMessage"></div>
2223
</div>

notification/scripts/script.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,21 @@ function init() {
199199
window.onbeforeunload = function () {
200200
if (timer) clearTimeout(timer);
201201
};
202+
203+
function goBack() {
204+
window.history.back(); // 返回上一页
205+
}
206+
207+
// 监听主题切换
208+
document.getElementById('theme-toggle').addEventListener('change', function () {
209+
const body = document.body;
210+
if (this.checked) {
211+
body.classList.remove('light-mode');
212+
body.classList.add('dark-mode');
213+
} else {
214+
body.classList.remove('dark-mode');
215+
body.classList.add('light-mode');
216+
}
217+
});
218+
202219
init();

notification/styles/dark-mode.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,35 @@ body.dark-mode .action-btn {
104104
body.dark-mode .action-btn:hover {
105105
box-shadow: 0 6px 16px rgba(39, 174, 96, 0.35);
106106
}
107+
108+
#return-btn {
109+
position: absolute; /* 绝对定位 */
110+
top: 20px; /* 距离顶部 20px */
111+
left: 20px; /* 距离左侧 20px */
112+
background-color: #f5f7fa; /* 默认亮色模式背景颜色 */
113+
color: #333333; /* 默认亮色模式文字颜色 */
114+
border: 1px solid #cccccc; /* 默认亮色模式边框颜色 */
115+
border-radius: 16px; /* 按钮圆角大小 */
116+
padding: 10px 18px; /* 按钮内边距 */
117+
font-size: 14px; /* 按钮字体大小 */
118+
cursor: pointer; /* 鼠标悬停时显示为手型 */
119+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); /* 按钮阴影 */
120+
transition: background-color 0.3s ease, transform 0.3s ease; /* 背景颜色和缩放的过渡效果 */
121+
z-index: 1001; /* 按钮层级 */
122+
}
123+
124+
#return-btn:hover {
125+
background-color: #e0e4e8; /* 默认亮色模式悬停背景颜色 */
126+
transform: scale(1.05); /* 悬停时放大 5% */
127+
}
128+
129+
/* 暗色模式 */
130+
body.dark-mode #return-btn {
131+
background-color: #4a4f55; /* 更浅的暗色模式背景颜色 */
132+
color: #e0e0e0; /* 暗色模式文字颜色 */
133+
border: 1px solid #555555; /* 更浅的暗色模式边框颜色 */
134+
}
135+
136+
body.dark-mode #return-btn:hover {
137+
background-color: #3b4046; /* 更浅的暗色模式悬停背景颜色 */
138+
}

0 commit comments

Comments
 (0)