first
This commit is contained in:
parent
c7ba5418a2
commit
2ba6ac703f
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
dist
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
9
.idea/itEyes.iml
Normal file
9
.idea/itEyes.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/itEyes.iml" filepath="$PROJECT_DIR$/.idea/itEyes.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
17
app.py
Normal file
17
app.py
Normal file
@ -0,0 +1,17 @@
|
||||
import os
|
||||
import http.server
|
||||
import socketserver
|
||||
|
||||
# 设置要使用的端口
|
||||
PORT = 5000
|
||||
|
||||
# 设置要服务的目录
|
||||
os.chdir('.') # 替换为你想要服务的目录路径
|
||||
|
||||
# 定义请求处理程序
|
||||
Handler = http.server.SimpleHTTPRequestHandler
|
||||
|
||||
# 创建服务器
|
||||
with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
||||
print(f"Serving at port {PORT}")
|
||||
httpd.serve_forever()
|
BIN
assets/icon.ico
Normal file
BIN
assets/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 165 KiB |
159
gncs.html
Normal file
159
gncs.html
Normal file
@ -0,0 +1,159 @@
|
||||
<!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>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.container {
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 10px;
|
||||
width: 400px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.function-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 10px 0;
|
||||
padding: 10px;
|
||||
background-color: #f0f0f0;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.function-item span {
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
}
|
||||
.toggle-btn {
|
||||
width: 60px;
|
||||
height: 30px;
|
||||
background-color: #ccc;
|
||||
border-radius: 15px;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
.toggle-btn::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
.toggle-btn.active {
|
||||
background-color: #4caf50;
|
||||
}
|
||||
.toggle-btn.active::before {
|
||||
transform: translateX(30px);
|
||||
}
|
||||
|
||||
/* 导航栏样式 */
|
||||
.navbar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
background-color: #333;
|
||||
padding: 10px 0;
|
||||
}
|
||||
.navbar a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-size: 16px;
|
||||
}
|
||||
.navbar a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>功能测试页面</h2>
|
||||
|
||||
<div class="function-item">
|
||||
<span>摄像头</span>
|
||||
<div class="toggle-btn" id="camera-btn"></div>
|
||||
</div>
|
||||
|
||||
<div class="function-item">
|
||||
<span>人脸距离过近</span>
|
||||
<div class="toggle-btn" id="face-btn"></div>
|
||||
</div>
|
||||
|
||||
<div class="function-item">
|
||||
<span>屏幕锁定密码解锁</span>
|
||||
<div class="toggle-btn" id="unlock-btn"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- JavaScript -->
|
||||
<script>
|
||||
// 获取所有开关按钮
|
||||
const cameraBtn = document.getElementById('camera-btn');
|
||||
const faceBtn = document.getElementById('face-btn');
|
||||
const unlockBtn = document.getElementById('unlock-btn');
|
||||
|
||||
// 存储当前打开的测试按钮
|
||||
let activeButton = null;
|
||||
|
||||
// 切换开关按钮状态并控制逻辑
|
||||
function toggleButton(btn, testName) {
|
||||
if (btn === activeButton) {
|
||||
// 如果点击的是已经激活的按钮,则关闭它
|
||||
btn.classList.remove('active');
|
||||
activeButton = null;
|
||||
alert(`${testName} 停止`);
|
||||
} else {
|
||||
// 关闭当前已激活的按钮(如果有)
|
||||
if (activeButton) {
|
||||
activeButton.classList.remove('active');
|
||||
alert(`上一个测试已停止`);
|
||||
}
|
||||
// 激活新按钮
|
||||
btn.classList.add('active');
|
||||
activeButton = btn;
|
||||
alert(`${testName} 启动`);
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定点击事件
|
||||
cameraBtn.addEventListener('click', () => toggleButton(cameraBtn, '摄像头'));
|
||||
faceBtn.addEventListener('click', () => toggleButton(faceBtn, '人脸距离过近'));
|
||||
unlockBtn.addEventListener('click', () => toggleButton(unlockBtn, '屏幕锁定密码解锁'));
|
||||
</script>
|
||||
|
||||
<!-- 导航栏 -->
|
||||
<div class="navbar">
|
||||
<a href="index.html"><button id="home">启动首页</button></a>
|
||||
<a href="psw.html"><button id="unlock">解锁密码设置</button></a>
|
||||
<a href="gncs.html"><button id="test">功能测试</button></a>
|
||||
<a href="setting.html"><button id="settings">软件设置</button></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
238
index.html
Normal file
238
index.html
Normal file
@ -0,0 +1,238 @@
|
||||
<!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>
|
||||
/* 样式定义 */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 10px;
|
||||
width: 300px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.button-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
background-color: #333;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
.function-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.function-buttons button {
|
||||
width: 130px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
/* 开关容器的样式 */
|
||||
.switch-container {
|
||||
width: 100px;
|
||||
height: 50px;
|
||||
background-color: #ccc;
|
||||
border-radius: 25px;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
/* 开关按钮的样式 */
|
||||
.switch {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 5px;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
/* 开启状态的样式 */
|
||||
.switch.on {
|
||||
left: 55px;
|
||||
background-color: #4caf50; /* 绿色 */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- 开关按钮部分 -->
|
||||
<div class="switch-container" id="switch-container" style="margin-bottom: 20px;">
|
||||
<div class="switch" id="switch"></div>
|
||||
</div>
|
||||
|
||||
<!-- 功能按钮部分 -->
|
||||
<div class="container">
|
||||
<div class="function-buttons">
|
||||
<a href="index.html"><button id="home">启动首页</button></a>
|
||||
<a href="psw.html"><button id="unlock">解锁密码设置</button></a>
|
||||
<a href="gncs.html"><button id="test">功能测试</button></a>
|
||||
<a href="setting.html"><button id="settings">软件设置</button></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
socket = null
|
||||
// 开关按钮功能
|
||||
const switchButton = document.getElementById('switch');
|
||||
let isSwitchOn = false;
|
||||
|
||||
switchButton.addEventListener('click', function () {
|
||||
if (isSwitchOn) {
|
||||
const password = prompt("请输入密码以关闭开关:");
|
||||
if (password === currentPassword) {
|
||||
// socket.close(). then(() => {
|
||||
// switchButton.classList.remove('on')
|
||||
// alert('开关已关闭');
|
||||
// isSwitchOn = false;
|
||||
// socket = null
|
||||
// })
|
||||
switchButton.classList.remove('on')
|
||||
alert('开关已关闭');
|
||||
isSwitchOn = false;
|
||||
|
||||
} else {
|
||||
alert('密码错误!');
|
||||
}
|
||||
} else {
|
||||
//创建 WebSocket 连接
|
||||
socket = new WebSocket('ws://localhost:45601');
|
||||
|
||||
// 打开连接时触发
|
||||
socket.onopen = function(event) {
|
||||
console.log('WebSocketOn.');
|
||||
switchButton.classList.add('on');
|
||||
isSwitchOn = true;
|
||||
console.log(123)
|
||||
};
|
||||
|
||||
// 接收到消息时触发
|
||||
socket.onmessage = function(event) {
|
||||
console.log('收到消息:', event.data);
|
||||
|
||||
// 根据服务器的响应处理逻辑
|
||||
// 注意:服务器应该发送明确的消息格式以便客户端正确解析
|
||||
};
|
||||
|
||||
// 连接关闭时触发
|
||||
socket.onclose = function(event) {
|
||||
console.log('WebSocketClose.');
|
||||
};
|
||||
|
||||
// 连接出错时触发
|
||||
socket.onerror = function(error) {
|
||||
console.log('WebSocket Error:', error);
|
||||
};
|
||||
sendMessage({
|
||||
"ClientEvent":"open",
|
||||
"Content": null
|
||||
}).then(() => {
|
||||
switchButton.classList.add('on');
|
||||
isSwitchOn = true;
|
||||
console.log(123321)
|
||||
})
|
||||
switchButton.classList.add('on');
|
||||
isSwitchOn = true;
|
||||
console.log(123321)
|
||||
}
|
||||
});
|
||||
|
||||
function onMessage(data){
|
||||
switch (data.Event){
|
||||
case "near":
|
||||
if (nearTest){
|
||||
if (heavyAlert){
|
||||
//把强提醒函数写这
|
||||
}else{
|
||||
alert("用眼过近!")
|
||||
}
|
||||
}
|
||||
case "long":
|
||||
if (longTest){
|
||||
if (heavyAlert){
|
||||
//把强提醒函数写这
|
||||
fetch("http://localhost:45602/electronAlert", { method: 'POST' , body: "用眼过长!"})
|
||||
|
||||
}else{
|
||||
alert("用眼过长!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 向服务器发送消息
|
||||
function sendMessage(message) {
|
||||
if (socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(message);
|
||||
} else {
|
||||
console.log('WebSocket 连接未打开.');
|
||||
}
|
||||
}
|
||||
// 导航按钮逻辑
|
||||
const navButtons = document.querySelectorAll('.function-buttons a');
|
||||
|
||||
navButtons.forEach(button => {
|
||||
button.addEventListener('click', function (e) {
|
||||
if (isSwitchOn) {
|
||||
e.preventDefault(); // 阻止默认行为
|
||||
const password = prompt("请输入密码以进行页面跳转:");
|
||||
if (password === currentPassword) {
|
||||
// 关闭开关
|
||||
switchButton.classList.remove('on');
|
||||
alert('开关已关闭');
|
||||
isSwitchOn = false;
|
||||
|
||||
// 跳转到目标页面
|
||||
window.location.href = button.href;
|
||||
} else {
|
||||
alert('密码错误!');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
46
index.js
Normal file
46
index.js
Normal file
@ -0,0 +1,46 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
|
||||
const { spawn } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const flaskProcess = spawn('python', [path.join(__dirname, 'app.py')]);
|
||||
|
||||
flaskProcess.stdout.on('data', (data) => {
|
||||
console.log(`Flask: ${data}`);
|
||||
});
|
||||
|
||||
// 监听Node.js进程的关闭事件
|
||||
process.on('SIGINT', () => {
|
||||
console.log('Closing Node.js application and Python script...');
|
||||
|
||||
// 杀掉Python进程
|
||||
pythonProcess.kill('SIGINT');
|
||||
|
||||
// 完全退出Node.js应用
|
||||
process.exit();
|
||||
});
|
||||
|
||||
let mainWindow;
|
||||
|
||||
app.whenReady().then(() => {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
icon: path.join(__dirname, 'assets', 'icon.ico'),
|
||||
webPreferences: {
|
||||
nodeIntegration: false, // 禁用 Node 集成
|
||||
contextIsolation: true, // 启用上下文隔离
|
||||
},
|
||||
});
|
||||
|
||||
// 加载 HTTP 服务的 URL
|
||||
mainWindow.loadURL('http://127.0.0.1:5000/');
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null;
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit();
|
||||
});
|
2216
package-lock.json
generated
Normal file
2216
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
package.json
Normal file
17
package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "iteyes",
|
||||
"version": "1.0.0",
|
||||
"description": "A program that intelligently controls eye health",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "electron .",
|
||||
"package": "electron-packager . needle-server --platform=win32 --arch=x64 --out=./out --asar --app-version=1.0.0 --overwrite --ignore=node_modules --electron-version=$(npm list electron --depth=0 | jq -r '.dependencies.electron.version')"
|
||||
},
|
||||
"author": "宫瑞骏,张晓星",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"electron": "^33.0.1",
|
||||
"electron-packager": "^17.1.2"
|
||||
}
|
||||
}
|
20
package.sh
Normal file
20
package.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 要清理的临时目录路径
|
||||
TEMP_DIR="C:/Users/XINNIAN/AppData/Local/Temp/electron-packager"
|
||||
|
||||
# 检查临时目录是否存在,并清理其内容
|
||||
if [ -d "$TEMP_DIR" ]; then
|
||||
echo "正在清理临时目录: $TEMP_DIR"
|
||||
rm -rf "$TEMP_DIR"/*
|
||||
echo "临时目录清理完成!"
|
||||
else
|
||||
echo "临时目录不存在: $TEMP_DIR"
|
||||
fi
|
||||
|
||||
# 打包 Electron 应用
|
||||
echo "开始打包 Electron 应用..."
|
||||
npx electron-packager . iteyes --platform=win32 --arch=x64 --icon=assets/icon.ico --out=dist --overwrite
|
||||
|
||||
|
||||
echo "Electron 应用打包完成!"
|
151
psw.html
Normal file
151
psw.html
Normal file
@ -0,0 +1,151 @@
|
||||
<!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>
|
||||
/* 样式定义 */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.container {
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 10px;
|
||||
width: 300px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
h2 {
|
||||
text-align: center;
|
||||
}
|
||||
input[type="password"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.button-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
background-color: #333;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
.function-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.function-buttons button {
|
||||
width: 130px;
|
||||
margin: 10px;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>智眼-密码设置</h2>
|
||||
<label for="password">输入密码</label>
|
||||
<input type="password" id="password" oncopy="return false" oncut="return false" onpaste="return false" ondragstart="return false" ondrop="return false">
|
||||
|
||||
<div class="button-container">
|
||||
<button id="confirm" style="display: block;">确认</button>
|
||||
<button id="reset" style="display: none;">重置</button>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div id="reset-section" class="hidden">
|
||||
<label for="old-password">输入旧密码进行重置</label>
|
||||
<input type="password" id="old-password" oncopy="return false" oncut="return false" onpaste="return false" ondragstart="return false" ondrop="return false">
|
||||
<button id="confirm-reset">确认重置</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 功能按钮部分 -->
|
||||
<div class="container">
|
||||
<div class="function-buttons">
|
||||
<a href="index.html"><button id="home">启动首页</button></a>
|
||||
<a href="psw.html"><button id="unlock">解锁密码设置</button></a>
|
||||
<a href="gncs.html"><button id="test">功能测试</button></a>
|
||||
<a href="setting.html"><button id="settings">软件设置</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
currentPassword = '123';
|
||||
|
||||
// 当用户点击确认按钮时,保存密码并隐藏确认按钮
|
||||
document.getElementById('confirm').addEventListener('click', function() {
|
||||
const password = document.getElementById('password').value;
|
||||
if (password) {
|
||||
currentPassword = password;
|
||||
console.log(password)
|
||||
sendMessage({
|
||||
"ClientEvent": "SetPassword",
|
||||
"Content": {
|
||||
"Password": password
|
||||
}
|
||||
}).then(() => {
|
||||
alert('密码已设置');
|
||||
document.getElementById('password').setAttribute('disabled', true); // 禁用输入框
|
||||
document.getElementById('confirm').style.display = 'none'; // 隐藏确认按钮
|
||||
document.getElementById('reset').style.display = 'block'; // 显示重置按钮
|
||||
})
|
||||
|
||||
} else {
|
||||
alert('请输入密码');
|
||||
}
|
||||
});
|
||||
|
||||
// 当用户点击重置按钮时,显示输入旧密码的区域
|
||||
document.getElementById('reset').addEventListener('click', function() {
|
||||
document.getElementById('reset-section').classList.remove('hidden');
|
||||
});
|
||||
|
||||
// 确认重置密码
|
||||
document.getElementById('confirm-reset').addEventListener('click', function() {
|
||||
const oldPassword = document.getElementById('old-password').value;
|
||||
if (oldPassword === currentPassword) {
|
||||
currentPassword = ''; // 清空当前密码
|
||||
document.getElementById('password').value = ''; // 清空密码输入框
|
||||
document.getElementById('old-password').value = ''; // 清空旧密码输入框
|
||||
document.getElementById('password').removeAttribute('disabled'); // 重新启用密码输入框
|
||||
document.getElementById('confirm').style.display = 'block'; // 重新显示确认按钮
|
||||
document.getElementById('reset').style.display = 'none'; // 隐藏重置按钮
|
||||
document.getElementById('reset-section').classList.add('hidden'); // 隐藏重置部分
|
||||
alert('密码已重置');
|
||||
} else {
|
||||
alert('旧密码不正确');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
149
setting.html
Normal file
149
setting.html
Normal file
@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>智眼-软件设置</title>
|
||||
<script type="text/javascript">
|
||||
function password() {
|
||||
var testV = 1;
|
||||
var pass1 = prompt('请输入密码','');
|
||||
while (testV < 3) {
|
||||
if (!pass1)
|
||||
history.go(-1);
|
||||
if (pass1 == "123") {//初始密码123
|
||||
alert('密码正确');
|
||||
break;
|
||||
}
|
||||
testV+=1;
|
||||
var pass1 =
|
||||
prompt('密码错误!请重新输入:');
|
||||
}
|
||||
if (pass1!="password" & testV ==3)
|
||||
history.go(-1);
|
||||
return " ";
|
||||
}
|
||||
document.write(password());
|
||||
</script>
|
||||
<style>
|
||||
/* 样式定义 */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.container {
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 10px;
|
||||
width: 300px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
input[type="text"], input[type="number"], input[type="checkbox"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.button-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
background-color: #333;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
.function-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.function-buttons button {
|
||||
width: 130px;
|
||||
margin: 10px;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>时间限制设置</h2>
|
||||
<label for="time-limit">设置每天使用时间上限(分钟),填“0”则为不限制:</label>
|
||||
<input type="number" id="time-limit" min="0" max="7200">
|
||||
<div class="button-container">
|
||||
<button id="save-time-limit">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 导航栏部分 -->
|
||||
<div class="container">
|
||||
<div class="function-buttons">
|
||||
<a href="index.html"><button id="home">启动首页</button></a>
|
||||
<a href="psw.html"><button id="unlock">解锁密码设置</button></a>
|
||||
<a href="gncs.html"><button id="test">功能测试</button></a>
|
||||
<a href="setting.html"><button id="settings">软件设置</button></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 处理时间限制设置
|
||||
document.getElementById('save-time-limit').addEventListener('click', function() {
|
||||
const timeLimit = document.getElementById('time-limit').value;
|
||||
if (timeLimit > 0 && timeLimit <= 7200) {
|
||||
sendMessage({
|
||||
"ClientEvent": "SetLongTestTime",
|
||||
"Content": {
|
||||
"Time": timeLimit
|
||||
}
|
||||
}).then(() => {
|
||||
// 处理发送消息成功后的逻辑
|
||||
longTest = true
|
||||
alert(`已将每日使用时间上限设置为 ${timeLimit} 分钟`);
|
||||
})
|
||||
|
||||
}
|
||||
if (timeLimit > 7200) {
|
||||
alert('请输入有效的分钟数');
|
||||
}
|
||||
if (timeLimit < 0) {
|
||||
alert('请输入有效的分钟数');
|
||||
}
|
||||
if (timeLimit == 0) {
|
||||
longTest = false
|
||||
alert(`已取消时间限制`);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user