分离html并优化

This commit is contained in:
2025-07-09 17:29:39 +08:00
parent 62060e254e
commit 1f790a3ec3
17 changed files with 1020 additions and 1021 deletions

94
data/config.html Normal file
View File

@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>ESP32 WiFi 设置</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background-color: #f0f2f5;
display: flex;
flex-direction: column;
align-items: center;
padding: 40px;
}
h1 {
color: #333;
margin-bottom: 30px;
}
form {
background-color: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
width: 100%;
max-width: 400px;
}
label {
font-weight: 500;
display: block;
margin: 10px 0 5px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
input[type="submit"] {
width: 100%;
background-color: #1890ff;
color: white;
border: none;
padding: 12px;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
}
input[type="submit"]:hover {
background-color: #40a9ff;
}
</style>
<script>
async function saveWiFiSettings() {
const ssid = document.getElementById("ssid").value;
const password = document.getElementById("password").value;
try {
const response = await fetch("/saveWiFi", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: "ssid=" + encodeURIComponent(ssid) + "&password=" + encodeURIComponent(password)
});
const result = await response.json();
alert(result.message || "WiFi 设置保存成功!");
} catch (error) {
alert("保存失败,请重试。");
}
}
</script>
</head>
<body>
<h1>WiFi 设置</h1>
<form onsubmit="event.preventDefault(); saveWiFiSettings();">
<label for="ssid">SSID</label>
<input type="text" id="ssid" name="ssid" required />
<label for="password">密码</label>
<input type="password" id="password" name="password" required />
<input type="submit" value="保存设置" />
</form>
</body>
</html>