Оптимизировал вёрстку web панели

This commit is contained in:
2026-09-28 23:49:32 +07:00
parent a034489e99
commit c8b39be5b4
8 changed files with 402 additions and 465 deletions
+127
View File
@@ -0,0 +1,127 @@
/* ==========================================
ОБЩИЕ СТИЛИ (ШРИФТЫ, БАЗОВЫЕ СЕЛЕКТОРЫ)
========================================== */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #121212; /* Глубокий черный фон */
color: #ffffff;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
}
h1 {
color: #ff6600;
margin: 0 0 30px 0;
text-transform: uppercase;
letter-spacing: 2px;
border-bottom: 2px solid #ff6600;
padding-bottom: 10px;
}
/* ==========================================
ШАПКА (TOP BAR) — ПРИСУТСТВУЕТ ВЕЗДЕ
========================================== */
.top-bar {
width: 100%;
background-color: #1a1a1a;
border-bottom: 2px solid #ff6600; /* Оранжевая полоса снизу */
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
position: sticky;
top: 0;
z-index: 1000;
}
.top-bar-container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
height: 60px;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-size: 20px;
font-weight: bold;
color: #ffffff;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 1px;
}
.logo span {
color: #ff6600;
}
.nav-links {
display: flex;
align-items: center;
gap: 20px;
}
.nav-link {
color: #e0e0e0;
text-decoration: none;
font-size: 15px;
transition: color 0.2s ease;
}
.nav-link:hover,
.nav-link.active {
color: #ff6600;
}
.nav-link.active {
font-weight: 600;
}
/* Общий контейнер контента */
.main-content {
width: 100%;
padding: 40px 20px;
box-sizing: border-box;
}
/* ==========================================
АДАПТИВНОСТЬ ДЛЯ ШАПКИ И БАЗОВЫХ ЭЛЕМЕНТОВ
========================================== */
@media (max-width: 768px) {
.top-bar-container {
height: auto;
padding: 12px 16px;
flex-direction: column;
align-items: flex-start;
gap: 12px;
}
.nav-links {
width: 100%;
justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
}
.main-content {
padding: 24px 14px;
}
h1 {
font-size: 24px;
letter-spacing: 1px;
}
}
/* --- СТИЛИ ДЛЯ ЧЕКБОКСА (CHECKBUTTON) --- */
.checkbox-group {
display: flex;
flex-direction: row;
align-items: center;
gap: 12px;
cursor: pointer;
user-select: none;
margin-bottom: 25px;
}
+4 -98
View File
@@ -1,67 +1,4 @@
/* Общие стили для страницы */ /* Кнопка настроек в шапке (уникальна для списка пользователей) */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #121212; /* Глубокий черный фон */
color: #ffffff;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
}
/* --- TOP BAR STYLE --- */
.top-bar {
width: 100%;
background-color: #1a1a1a; /* Темно-серый фон панели */
border-bottom: 2px solid #ff6600; /* Оранжевая полоса снизу */
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
position: sticky;
top: 0;
z-index: 1000;
}
.top-bar-container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
height: 60px;
display: flex;
justify-content: space-between;
align-items: center;
}
/* Логотип / Название проекта */
.logo {
font-size: 20px;
font-weight: bold;
color: #ffffff;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 1px;
}
.logo span {
color: #ff6600; /* Оранжевый акцент */
}
/* Навигация и кнопка настроек */
.nav-links {
display: flex;
align-items: center;
gap: 20px;
}
.nav-link {
color: #e0e0e0;
text-decoration: none;
font-size: 15px;
transition: color 0.2s ease;
}
.nav-link:hover {
color: #ff6600;
}
/* Кнопка настроек */
.settings-btn { .settings-btn {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -77,30 +14,22 @@
font-size: 14px; font-size: 14px;
transition: all 0.3s ease; transition: all 0.3s ease;
} }
.settings-btn:hover { .settings-btn:hover {
background-color: #ff6600; background-color: #ff6600;
color: #000000; color: #000000;
box-shadow: 0 0 10px rgba(255, 102, 0, 0.4); box-shadow: 0 0 10px rgba(255, 102, 0, 0.4);
} }
/* --- ОСНОВНОЙ КОНТЕНТ --- */ /* Специфичное выравнивание для страницы таблицы */
.main-content { .main-content {
width: 100%;
max-width: 940px; max-width: 940px;
padding: 40px 20px;
box-sizing: border-box;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
h1 { h1 {
color: #ff6600;
margin-bottom: 30px;
text-transform: uppercase;
letter-spacing: 2px;
border-bottom: 2px solid #ff6600;
padding-bottom: 10px;
align-self: flex-start; align-self: flex-start;
} }
@@ -151,36 +80,13 @@
transition: all 0.2s ease; transition: all 0.2s ease;
} }
/* Адаптивность элементов таблицы */
@media (max-width: 680px) { @media (max-width: 680px) {
.top-bar-container {
height: auto;
padding: 12px 16px;
flex-direction: column;
align-items: flex-start;
gap: 12px;
}
.nav-links {
width: 100%;
justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
}
.settings-btn { .settings-btn {
width: 100%; width: 100%;
justify-content: center; justify-content: center;
} }
.main-content {
padding: 24px 14px;
}
h1 {
font-size: 24px;
letter-spacing: 1px;
}
th, td { th, td {
padding: 10px 8px; padding: 10px 8px;
font-size: 12px; font-size: 12px;
+12 -15
View File
@@ -4,26 +4,23 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Панель управления — Список пользователей</title> <title>Панель управления — Список пользователей</title>
<link rel="stylesheet" href="/base.css">
<link rel="stylesheet" href="/root.css"> <link rel="stylesheet" href="/root.css">
<style>
/* Индивидуальное ограничение ширины для страницы таблицы */
.main-content { max-width: 940px; align-items: center; display: flex; flex-direction: column; }
h1 { align-self: flex-start; }
</style>
</head> </head>
<body> <body>
<header class="top-bar"> <header class="top-bar">
<div class="top-bar-container"> <div class="top-bar-container">
<a href="#" class="logo">Admin <span>Panel</span></a> <a href="#" class="logo">Admin <span>Panel</span></a>
<nav class="nav-links"> <nav class="nav-links">
<a href="#" class="nav-link">Главная</a> <a href="/#" class="nav-link">Главная</a>
<a href="#" class="nav-link">Пользователи</a> <a href="/#" class="nav-link active">Пользователи</a>
<!-- Кнопка перехода в настройки --> <a href="/settings#" id="go-to-settings" class="settings-btn">Настройки</a>
<a href="settings" class="settings-btn">
<!-- Иконка шестерёнки на чистом CSS -->
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align: middle;">
<circle cx="12" cy="12" r="3"></circle>
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path>
</svg>
Настройки
</a>
</nav> </nav>
</div> </div>
</header> </header>
@@ -32,7 +29,7 @@
<h1>Список пользователей</h1> <h1>Список пользователей</h1>
<div class="table-container"> <div class="table-container">
<table> <table id="users-table">
<thead> <thead>
<tr> <tr>
<th>IP</th> <th>IP</th>
@@ -46,5 +43,5 @@
</main> </main>
</body> </body>
<script src="/root.js"></script> <script src="root.js"></script>
</html> </html>
+7 -124
View File
@@ -1,75 +1,6 @@
/* Общие стили для страницы */ /* Специфичное ограничение ширины для карточек настроек */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #121212; /* Глубокий черный фон */
color: #ffffff;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
}
/* --- TOP BAR STYLE --- */
.top-bar {
width: 100%;
background-color: #1a1a1a;
border-bottom: 2px solid #ff6600; /* Оранжевая полоса снизу */
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
position: sticky;
top: 0;
z-index: 1000;
}
.top-bar-container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
height: 60px;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-size: 20px;
font-weight: bold;
color: #ffffff;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 1px;
}
.logo span {
color: #ff6600;
}
.nav-links {
display: flex;
align-items: center;
gap: 20px;
}
.nav-link {
color: #e0e0e0;
text-decoration: none;
font-size: 15px;
transition: color 0.2s ease;
}
.nav-link:hover {
color: #ff6600;
}
.nav-link.active {
color: #ff6600;
font-weight: 600;
}
/* --- ОСНОВНОЙ КОНТЕНТ --- */
.main-content { .main-content {
width: 100%; max-width: 700px;
max-width: 700px; /* Немного расширили для двух карточек */
padding: 40px 20px;
box-sizing: border-box;
} }
/* Ссылка назад к списку */ /* Ссылка назад к списку */
@@ -83,19 +14,11 @@
margin-bottom: 20px; margin-bottom: 20px;
transition: color 0.2s ease; transition: color 0.2s ease;
} }
.back-link:hover { .back-link:hover {
color: #ff6600; color: #ff6600;
} }
h1 {
color: #ff6600;
margin: 0 0 30px 0;
text-transform: uppercase;
letter-spacing: 2px;
border-bottom: 2px solid #ff6600;
padding-bottom: 10px;
}
/* Сетка для блоков настроек */ /* Сетка для блоков настроек */
.settings-grid { .settings-grid {
display: flex; display: flex;
@@ -103,9 +26,9 @@
gap: 30px; gap: 30px;
} }
/* --- СТИЛИ КАРТОЧКИ --- */ /* Карточка настроек */
.settings-card { .settings-card {
background-color: #1a1a1a; /* Темный фон карточки */ background-color: #1a1a1a;
border-radius: 8px; border-radius: 8px;
padding: 30px; padding: 30px;
box-shadow: 0 4px 15px rgba(255, 102, 0, 0.05); box-shadow: 0 4px 15px rgba(255, 102, 0, 0.05);
@@ -135,7 +58,7 @@
font-weight: 500; font-weight: 500;
} }
/* Поля ввода (универсальный стиль) */ /* Поля ввода */
input[type="text"], input[type="text"],
input[type="password"] { input[type="password"] {
width: 100%; width: 100%;
@@ -150,24 +73,12 @@
transition: all 0.3s ease; transition: all 0.3s ease;
} }
/* Состояние фокуса */
input[type="text"]:focus, input[type="text"]:focus,
input[type="password"]:focus { input[type="password"]:focus {
border-color: #ff6600; border-color: #ff6600;
box-shadow: 0 0 8px rgba(255, 102, 0, 0.2); box-shadow: 0 0 8px rgba(255, 102, 0, 0.2);
} }
/* --- СТИЛИ ДЛЯ ЧЕКБОКСА (CHECKBUTTON) --- */
.checkbox-group {
flex-direction: row;
align-items: center;
gap: 12px;
cursor: pointer;
user-select: none;
margin-bottom: 25px;
}
/* Скрываем дефолтный чекбокс, чтобы сделать красивый кастомный */
.checkbox-group input[type="checkbox"] { .checkbox-group input[type="checkbox"] {
position: absolute; position: absolute;
opacity: 0; opacity: 0;
@@ -176,7 +87,6 @@
width: 0; width: 0;
} }
/* Наш кастомный чекбокс */
.checkmark { .checkmark {
height: 20px; height: 20px;
width: 20px; width: 20px;
@@ -188,18 +98,15 @@
transition: all 0.2s ease; transition: all 0.2s ease;
} }
/* Эффект при наведении */
.checkbox-group:hover input[type="checkbox"] ~ .checkmark { .checkbox-group:hover input[type="checkbox"] ~ .checkmark {
border-color: #ff6600; border-color: #ff6600;
} }
/* Когда чекбокс активен (выбран) */
.checkbox-group input[type="checkbox"]:checked ~ .checkmark { .checkbox-group input[type="checkbox"]:checked ~ .checkmark {
background-color: #ff6600; background-color: #ff6600;
border-color: #ff6600; border-color: #ff6600;
} }
/* Стрелочка внутри чекбокса */
.checkmark:after { .checkmark:after {
content: ""; content: "";
position: absolute; position: absolute;
@@ -213,7 +120,6 @@
transform: rotate(45deg); transform: rotate(45deg);
} }
/* Показываем стрелочку при выборе */
.checkbox-group input[type="checkbox"]:checked ~ .checkmark:after { .checkbox-group input[type="checkbox"]:checked ~ .checkmark:after {
display: block; display: block;
} }
@@ -247,31 +153,8 @@
box-shadow: 0 4px 12px rgba(255, 102, 0, 0.3); box-shadow: 0 4px 12px rgba(255, 102, 0, 0.3);
} }
/* Адаптивность для карточек и инпутов */
@media (max-width: 768px) { @media (max-width: 768px) {
.top-bar-container {
height: auto;
padding: 12px 16px;
flex-direction: column;
align-items: flex-start;
gap: 12px;
}
.nav-links {
width: 100%;
justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
}
.main-content {
padding: 24px 14px;
}
h1 {
font-size: 24px;
letter-spacing: 1px;
}
.settings-card { .settings-card {
padding: 20px 16px; padding: 20px 16px;
} }
+1
View File
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Панель управления — Настройки сети</title> <title>Панель управления — Настройки сети</title>
<link rel="stylesheet" href="/base.css">
<link rel="stylesheet" href="/settings.css"> <link rel="stylesheet" href="/settings.css">
</head> </head>
<body> <body>
+1 -1
View File
@@ -72,7 +72,7 @@ async function set_conn_out()
async function init() async function init()
{ {
try { try {
const res = await fetch("h/settings/is_conn_out", { const res = await fetch("/settings/is_conn_out", {
method: "GET" method: "GET"
}); });
+21
View File
@@ -9,6 +9,24 @@ extern "C" {
#include "user_interface.h" #include "user_interface.h"
} }
void WebServer::css_base()
{
if (web_server.authenticate(settings_.getAdminLogin().c_str(), settings_.getAdminPass().c_str()) == false)
{
web_server.requestAuthentication();
return;
}
File css = LittleFS.open("/base.css", "r");
if (!css)
{
web_server.send(404);
return;
}
web_server.streamFile(css, "text/css");
css.close();
}
void WebServer::root_call() void WebServer::root_call()
{ {
if (web_server.authenticate(settings_.getAdminLogin().c_str(), settings_.getAdminPass().c_str()) == false) if (web_server.authenticate(settings_.getAdminLogin().c_str(), settings_.getAdminPass().c_str()) == false)
@@ -302,6 +320,9 @@ settings_(settings)
web_server.on("/", [this](){ web_server.on("/", [this](){
root_call(); root_call();
}); });
web_server.on("/base.css", [this](){
css_base();
});
web_server.on("/root.js", [this](){ web_server.on("/root.js", [this](){
js_root_call(); js_root_call();
}); });
+2
View File
@@ -8,6 +8,8 @@ class WebServer
ESP8266WebServer web_server; ESP8266WebServer web_server;
Settings& settings_; Settings& settings_;
void css_base();
void root_call(); void root_call();
void js_root_call(); void js_root_call();
void css_root_call(); void css_root_call();