Files
ESP32_COMM/tools/css/components.css
T
小龙虾 a47a027178 feat(ota):实现ESP32和GD32的OTA上传流程
- 添加了upload-esp32.js用于处理ESP32的OTA上传,包括文件上传、SHA-256验证和设备重启。
- 引入了upload-gd32.js,用于触发GD32 OTA中继并跟踪中继进度。
- 针对OTA流程,增强了会话管理和错误处理能力。
- 通过在上传过程中显示吐司通知和进度更新,改进了用户反馈。
2026-07-15 12:12:19 +08:00

659 lines
19 KiB
CSS

/* === components.css — 上传/文件信息/进度/指标/堆概况/状态徽章/OTA流程/日志/Toast/Tooltip 等组件 === */
/* === UPLOAD ZONE === */
.upload-zone {
border: 2px dashed var(--border); border-radius: var(--radius);
padding: 28px 16px; text-align: center; cursor: pointer;
transition: border-color .2s, background .2s;
}
.upload-zone:hover,
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-dim); }
.upload-zone .upload-ico { font-size: 32px; margin-bottom: 10px; }
.upload-zone h4 { font-size: 14px; margin-bottom: 4px; }
.upload-zone p { font-size: 12px; color: var(--text-dim); }
.upload-zone-sm { padding: 16px 12px; }
.upload-zone-sm .upload-ico { font-size: 24px; margin-bottom: 6px; }
.upload-zone-sm h4 { font-size: 13px; }
/* === FILE INFO === */
.file-info {
display: none; margin-top: 12px;
background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 12px 14px;
}
.file-info.show { display: block; }
.file-info-row { display: flex; justify-content: space-between; align-items: center; }
.file-info-row + .file-info-row { margin-top: 10px; }
.file-info-grid {
display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px;
}
.file-meta-item {
background: var(--bg-card); padding: 8px 10px; border-radius: 6px;
font-size: 12px;
}
.file-meta-item span { color: var(--text-label); display: block; font-size: 10px; margin-bottom: 2px; }
.file-meta-item b { font-weight: 600; }
/* === PROGRESS === */
.progress-phase-row {
display: flex; align-items: center; gap: 0; margin-bottom: 14px;
flex-wrap: nowrap;
background: var(--bg-input);
border-radius: 20px;
padding: 4px;
border: 1px solid var(--border);
}
.pp-step {
flex: 1;
display: flex; align-items: center; justify-content: center; gap: 5px;
padding: 7px 10px; border-radius: 16px;
font-size: 12px; font-weight: 600; color: var(--text-dim);
background: transparent;
transition: all .25s ease; white-space: nowrap;
cursor: default;
}
.pp-ico { font-size: 13px; opacity: .45; transition: all .25s ease; }
.pp-txt { transition: color .25s ease; }
.pp-sep { display: none; }
/* Active step — highlighted capsule */
.pp-step.active {
color: #07121c;
background: var(--accent);
box-shadow: 0 0 10px var(--accent-dim);
}
.pp-step.active .pp-ico { opacity: 1; }
.pp-step.active .pp-txt { color: #07121c; }
/* Done step — green outlined capsule */
.pp-step.done {
color: var(--green);
background: rgba(34,197,94,.12);
}
.pp-step.done .pp-ico { opacity: 1; }
.pp-step.done .pp-txt::after {
content: ' ✓'; font-size: 10px;
}
.progress-wrap { margin-top: 0; display: none; }
.progress-wrap.show { display: block; }
.progress-track {
width: 100%; height: 10px; border-radius: 20px;
background: var(--bg-input); overflow: hidden;
box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
}
.progress-fill {
height: 100%; border-radius: 20px;
background: linear-gradient(90deg, #22d3ee, #06b6d4);
width: 0%; transition: width .3s ease;
position: relative;
box-shadow: 0 0 8px rgba(34,211,238,.3);
}
.progress-fill::after {
content: ""; position: absolute; inset: 0;
background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.3) 50%, transparent 100%);
animation: sweep 1.6s linear infinite;
}
.progress-fill.done {
background: linear-gradient(90deg, #22c55e, #16a34a);
box-shadow: 0 0 8px rgba(34,197,94,.3);
}
@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.progress-text {
display: flex; justify-content: space-between; margin-top: 7px;
font-size: 12px; color: var(--text-dim);
}
/* === BUTTON ROW === */
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1; }
/* === METRIC GRID === */
.metric-grid {
display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.metric {
background: var(--bg-elevated); border: 1px solid var(--border);
border-radius: var(--radius-sm); padding: 12px 14px;
}
.metric .k {
font-size: 10px; color: var(--text-label); text-transform: uppercase;
letter-spacing: .1em; margin-bottom: 4px;
}
.metric .v {
font-size: 20px; font-weight: 700; word-break: break-word;
}
.metric .v.highlight { color: var(--accent); }
.status-kv-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
}
.status-kv {
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 10px 12px;
}
.status-kv .k {
display: block;
font-size: 10px;
color: var(--text-label);
text-transform: uppercase;
letter-spacing: .08em;
margin-bottom: 4px;
}
.status-kv b {
display: block;
color: var(--text);
font-size: 13px;
font-weight: 700;
word-break: break-word;
font-family: var(--font-mono);
}
.status-section-title { margin-top: 14px; margin-bottom: 8px; font-size: 11px; color: var(--text-label); text-transform: uppercase; letter-spacing: .08em; }
/* ===== 堆概况 ===== */
.heap-group {
background: rgba(255,255,255,0.02);
border: 1px solid var(--border);
border-radius: 8px;
padding: 12px 14px;
margin-bottom: 10px;
}
.heap-group:last-child { margin-bottom: 0; }
.cpu-group { margin-bottom: 8px; }
.cpu-task-list {
margin-bottom: 12px;
}
.cpu-task-list .status-task {
background: rgba(255,255,255,0.025);
}
.cpu-fill {
background: linear-gradient(90deg, #38bdf8, #22c55e);
}
.heap-group-title {
font-size: 11px;
font-weight: 600;
color: var(--text-label);
text-transform: uppercase;
letter-spacing: 0.06em;
margin-bottom: 10px;
}
.heap-bar-row {
display: flex;
align-items: center;
gap: 10px;
}
.heap-bar-text {
font-size: 13px;
font-weight: 600;
white-space: nowrap;
min-width: 165px;
color: var(--text);
}
.heap-bar-track {
flex: 1;
height: 14px;
background: rgba(255,255,255,0.06);
border-radius: 7px;
overflow: hidden;
position: relative;
}
.heap-bar-fill {
display: block;
height: 100%;
border-radius: 7px;
background: linear-gradient(90deg, var(--accent), #5eead4);
transition: width .4s ease;
.heap-bar-fill.warn {
background: linear-gradient(90deg, #f59e0b, #d97706);
}
.heap-bar-fill.danger {
background: linear-gradient(90deg, #ef4444, #dc2626);
}
}
.heap-bar-pct {
font-size: 12px;
font-weight: 600;
min-width: 42px;
text-align: right;
font-variant-numeric: tabular-nums;
color: var(--text-dim);
}
.heap-detail-row {
display: flex;
gap: 16px;
font-size: 11px;
color: var(--text-dim);
margin-top: 6px;
padding-top: 6px;
border-top: 1px solid rgba(255,255,255,0.04);
flex-wrap: wrap;
}
.heap-detail-row span {
display: inline-flex;
align-items: center;
gap: 4px;
}
.heap-detail-row b {
color: var(--text);
font-weight: 500;
font-family: var(--font-mono);
font-size: 11px;
}
.status-task-list {
display: grid;
gap: 8px;
}
.status-task {
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 10px 12px;
}
.status-task-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 8px;
}
.status-task-name {
font-size: 12px;
font-weight: 700;
color: var(--text);
font-family: var(--font-mono);
}
.status-task-ratio {
font-size: 11px;
color: var(--text-dim);
font-family: var(--font-mono);
}
.status-task-bar {
width: 100%;
height: 8px;
border-radius: 999px;
background: var(--bg-input);
overflow: hidden;
margin-bottom: 8px;
}
.status-task-bar-fill {
height: 100%;
border-radius: 999px;
background: linear-gradient(90deg, #22d3ee, #06b6d4);
}
.status-task-bar-fill.warn {
background: linear-gradient(90deg, #f59e0b, #d97706);
}
.status-task-bar-fill.err {
background: linear-gradient(90deg, #ef4444, #dc2626);
}
.status-task-meta {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
}
.status-task-meta span {
display: block;
font-size: 10px;
color: var(--text-label);
text-transform: uppercase;
letter-spacing: .06em;
}
.status-task-meta b {
display: block;
margin-top: 2px;
color: var(--text);
font-size: 11px;
font-family: var(--font-mono);
}
.status-json {
margin-top: 0;
padding: 12px;
border-radius: var(--radius-sm);
border: 1px solid var(--border);
background: var(--bg-elevated);
color: var(--text-dim);
font-size: 11px;
line-height: 1.6;
max-height: 280px;
overflow: auto;
white-space: pre-wrap;
word-break: break-word;
font-family: var(--font-mono);
}
.status-empty {
padding: 12px;
border: 1px dashed var(--border);
border-radius: var(--radius-sm);
color: var(--text-dim);
font-size: 12px;
}
/* === PRIMARY STATUS BADGES (large) === */
.badge-grid {
display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.badge-stat {
background: var(--bg-elevated); border: 1px solid var(--border);
border-radius: var(--radius); padding: 14px 16px; text-align: center;
}
.badge-stat .v {
font-size: 22px; font-weight: 700;
}
.badge-stat .v.accent { color: var(--accent); }
.badge-stat .v.ok { color: var(--green); }
.badge-stat .v.warn { color: var(--amber); }
.badge-stat .v.err { color: var(--red); }
.badge-stat .k {
font-size: 10px; color: var(--text-label); text-transform: uppercase;
letter-spacing: .1em; margin-top: 2px;
}
/* === OTA STAGE FLOW === */
.stage-flow {
display: flex; align-items: flex-start; gap: 0; padding: 8px 0;
}
.stage-node {
flex: 1; display: flex; flex-direction: column; align-items: center;
gap: 6px; position: relative;
}
.stage-node:not(:last-child)::after {
content: ""; position: absolute; top: 18px; left: calc(50% + 18px);
width: calc(100% - 36px); height: 2px;
background: var(--border); transition: background .3s;
}
.stage-node.done:not(:last-child)::after,
.stage-node.live:not(:last-child)::after { background: var(--accent); }
.stage-dot {
width: 36px; height: 36px; border-radius: 50%;
background: var(--bg-input); border: 2px solid var(--border);
display: flex; align-items: center; justify-content: center;
font-size: 16px; z-index: 1; transition: all .3s;
}
.stage-node.live .stage-dot {
background: var(--accent); border-color: var(--accent); color: #07121c;
box-shadow: 0 0 12px var(--accent-dim);
}
.stage-node.done .stage-dot {
background: var(--green); border-color: var(--green); color: #fff;
}
.stage-node.err .stage-dot {
background: var(--red); border-color: var(--red); color: #fff;
}
.stage-label {
font-size: 11px; color: var(--text-label); text-align: center; line-height: 1.3;
}
.stage-detail {
font-size: 10px; color: var(--accent); text-align: center; line-height: 1.2;
margin-top: 2px; min-height: 14px;
font-family: var(--font-mono);
transition: color .3s;
}
.stage-node.live .stage-label,
.stage-node.done .stage-label,
.stage-node.err .stage-label { color: var(--text); }
.stage-node.live .stage-detail { color: var(--accent); }
.stage-node.done .stage-detail { color: var(--green); }
.stage-node.err .stage-detail { color: var(--red); }
/* Stage status bar */
.stage-status-bar {
display: flex; align-items: center; gap: 10px;
margin-top: 14px; padding: 10px 16px;
border-radius: 20px;
background: var(--bg-elevated); border: 1px solid var(--border);
font-size: 13px;
transition: all .3s;
}
.stage-status-bar .ssb-dot {
width: 8px; height: 8px; border-radius: 50%;
flex-shrink: 0;
background: var(--text-dim);
transition: all .3s;
}
.stage-status-bar .ssb-text {
color: var(--text-dim); font-size: 13px; font-weight: 500;
letter-spacing: .01em;
}
/* idle — muted, with subtle pulse */
.stage-status-bar .ssb-dot { animation: dotPulse 2.5s ease-in-out infinite; }
@keyframes dotPulse {
0%, 100% { opacity: .45; }
50% { opacity: .8; }
}
/* active — accent colored */
.stage-status-bar.active {
border-color: rgba(34,211,238,.25);
background: linear-gradient(135deg, rgba(34,211,238,.06), rgba(34,211,238,.02));
}
.stage-status-bar.active .ssb-dot {
background: var(--accent);
box-shadow: 0 0 6px var(--accent-dim);
animation: dotPulseLive 1.2s ease-in-out infinite;
}
.stage-status-bar.active .ssb-text { color: var(--accent); font-weight: 600; }
@keyframes dotPulseLive {
0%, 100% { opacity: .7; transform: scale(1); }
50% { opacity: 1; transform: scale(1.25); }
}
/* ok — green */
.stage-status-bar.ok {
border-color: rgba(34,197,94,.25);
background: linear-gradient(135deg, rgba(34,197,94,.06), rgba(34,197,94,.02));
}
.stage-status-bar.ok .ssb-dot {
background: var(--green);
box-shadow: 0 0 6px rgba(34,197,94,.3);
animation: none;
}
.stage-status-bar.ok .ssb-text { color: var(--green); font-weight: 600; }
/* err — red */
.stage-status-bar.err {
border-color: rgba(239,68,68,.25);
background: linear-gradient(135deg, rgba(239,68,68,.06), rgba(239,68,68,.02));
}
.stage-status-bar.err .ssb-dot {
background: var(--red);
box-shadow: 0 0 6px rgba(239,68,68,.3);
animation: none;
}
.stage-status-bar.err .ssb-text { color: var(--red); font-weight: 600; }
/* Stage verification info panel */
.stage-verify-info {
margin-top: 12px; padding: 12px 14px;
border-radius: var(--radius-sm);
background: var(--bg-elevated); border: 1px solid var(--border);
}
.svi-row {
display: flex; align-items: flex-start; gap: 12px;
padding: 6px 0; font-size: 12px;
border-bottom: 1px solid rgba(255,255,255,.03);
}
.svi-row:last-child { border-bottom: none; }
.svi-key {
color: var(--text-label); font-weight: 600;
text-transform: uppercase; letter-spacing: .06em; font-size: 10px;
min-width: 100px; flex-shrink: 0;
padding-top: 2px;
}
.svi-val {
color: var(--text-dim); font-family: var(--font-mono); font-size: 11px;
word-break: break-all;
}
.svi-val.ok { color: var(--green); font-weight: 600; }
.svi-val.err { color: var(--red); font-weight: 600; }
/* Stage result panel - 上位机确认 0x07/0x85 收尾 */
.stage-result {
margin-top: 12px; padding: 14px 16px;
border-radius: var(--radius-sm);
background: var(--bg-elevated); border: 1px solid var(--border);
display: flex; flex-direction: column; gap: 10px;
}
.stage-result.ok { border-color: rgba(34,197,94,.45); background: rgba(34,197,94,.08); }
.stage-result.err { border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.08); }
.stage-result .sr-head { display: flex; align-items: center; gap: 10px; }
.stage-result .sr-ico {
width: 32px; height: 32px; border-radius: 50%;
display: inline-flex; align-items: center; justify-content: center;
font-size: 18px; font-weight: 700; color: #07121c;
}
.stage-result.ok .sr-ico { background: var(--green); }
.stage-result.err .sr-ico { background: var(--red); }
.stage-result .sr-title { font-size: 16px; font-weight: 700; }
.stage-result.ok .sr-title { color: var(--green); }
.stage-result.err .sr-title { color: var(--red); }
.stage-result .sr-detail { font-size: 13px; color: var(--text); line-height: 1.5; }
.stage-result .sr-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* === LOG PANEL === */
.log-panel { display: flex; flex-direction: column; min-height: 380px; }
.log-panel .card-body { flex: 1; display: flex; flex-direction: column; padding: 0; }
.log-toolbar {
display: flex; align-items: center; justify-content: space-between;
padding: 10px 16px; border-bottom: 1px solid var(--border);
gap: 10px; flex-wrap: wrap;
}
.log-filters { display: flex; gap: 6px; }
.log-filter {
padding: 4px 10px; border-radius: 14px; font-size: 11px; font-weight: 500;
border: 1px solid var(--border); background: transparent; color: var(--text-dim);
cursor: pointer; transition: all .15s;
}
.log-filter.active { background: var(--accent); color: #07121c; border-color: var(--accent); }
.log-filter:hover:not(.active) { border-color: var(--text-dim); }
.log-scroll {
flex: 1; overflow-y: auto; padding: 12px 16px;
font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
max-height: 420px;
}
.log-scroll::-webkit-scrollbar { width: 5px; }
.log-scroll::-webkit-scrollbar-track { background: transparent; }
.log-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.log-line {
display: flex; gap: 8px; padding: 3px 0;
border-bottom: 1px solid rgba(255,255,255,.02);
}
.log-line .lt { color: var(--text-label); flex-shrink: 0; }
.log-line .lv {
font-weight: 600; min-width: 20px; flex-shrink: 0;
}
.log-line .lv.E { color: var(--red); }
.log-line .lv.W { color: var(--amber); }
.log-line .lv.I { color: var(--accent); }
.log-line .lv.D { color: var(--text-label); }
.log-line .lg { color: #a78bfa; flex-shrink: 0; }
.log-line .lm { color: var(--text); word-break: break-all; }
/* BLE log compat */
.log-line .t { color: var(--text-label); flex-shrink: 0; }
.log-line .tag { color: #a78bfa; flex-shrink: 0; }
.log-foot {
display: flex; justify-content: space-between; align-items: center;
padding: 8px 16px; border-top: 1px solid var(--border);
font-size: 11px; color: var(--text-label);
}
/* === TOAST === */
.toast {
position: fixed; top: 45%; left: 50%; transform: translateX(-50%) translateY(30px);
z-index: 9999;
display: flex; align-items: center; gap: 10px;
padding: 14px 24px; border-radius: 10px;
font-size: 14px; font-weight: 600; color: #fff; pointer-events: none;
opacity: 0;
transition: all .35s cubic-bezier(.4,0,.2,1);
box-shadow: 0 8px 32px rgba(0,0,0,.35);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.ok { background: #16a34a; }
.toast.err { background: #dc2626; }
.toast.warn { background: #d97706; }
.toast .toast-ico { font-size: 18px; }
/* === GRID ROWS === */
.row-2, .row-3, .row-4 { display: grid; gap: 10px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
.row-4 { grid-template-columns: repeat(4, 1fr); }
/* === SUB ACTIONS === */
.sub-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
/* === FOOTER NOTE === */
.footer-note { margin-top: 12px; font-size: 12px; line-height: 1.7; color: var(--text-dim); }
/* === CODE === */
code { color: #d3f9ff; font-family: var(--font-mono); }
/* === FILE INFO BORDER === */
.file-info { border: 1px solid var(--border); }
/* === PILL LIVE === */
.pill.live .indicator { background: var(--amber); animation: blink 1s infinite; }
/* ===== Header sub-row (设备名/设备ID) ===== */
.header-sub {
display: flex; gap: 12px;
margin-top: 0;
padding: 0;
}
.pill-val {
font-weight: 600;
color: var(--text);
}
/* ===== Custom Tooltip ===== */
.pill[data-tooltip] {
position: relative;
cursor: help;
}
.pill[data-tooltip]:hover::after {
content: attr(data-tooltip);
position: absolute;
top: calc(100% + 10px);
left: 50%;
transform: translateX(-50%);
background: #1a2432;
color: #e2e8f0;
font-size: 11px;
font-weight: 400;
font-family: "SF Mono","Fira Code","Cascadia Code","Consolas",monospace;
padding: 6px 12px;
border-radius: 6px;
border: 1px solid #2a3a4e;
box-shadow: 0 4px 16px rgba(0,0,0,.45);
white-space: nowrap;
z-index: 1000;
pointer-events: none;
animation: tooltipFadeIn .15s ease-out;
}
.pill[data-tooltip]:hover::before {
content: '';
position: absolute;
top: calc(100% + 4px);
left: 50%;
transform: translateX(-50%);
border: 6px solid transparent;
border-bottom-color: #2a3a4e;
z-index: 1001;
pointer-events: none;
animation: tooltipFadeIn .15s ease-out;
}
@keyframes tooltipFadeIn {
from { opacity: 0; transform: translateX(-50%) translateY(3px); }
to { opacity: 1; transform: translateX(-50%) translateY(0); }
}