Files
EAP_Interface_html/.preview/dfu_upgrade/option_1_fluid_studio.html
T
zhy200308 221fa34250 feat(ui): 交付手环升级(DFU固件升级)方案5落地物料并严格统一1:1双栏等比占比
1. 【手环升级 / DFU固件升级】:根据用户选定方案5(Master-Detail Inset Pro)完成6件套标准物料全量交付:
   - 左右两大板块严格统一为 1:1 双栏等比均衡占比,与【手环配置】板块占比完全一致;
   - 视觉体系严格对齐全局主色蓝规范 #2563EB(深色 #1D4ED8、浅底 #EFF6FF、高亮 #1E40AF);
   - 左侧布局:待升级手环硬件状态卡片(采用方案5 Inset 经典属性胶囊条:手环 ID/当前版本/剩余电量 + 取消升级暖黄按钮)与固件包版本源;
   - 右侧布局:升级进度条、毫秒级百分比读数、传输速率与极客暗晶升级日志控制台 Terminal;
   - 弹窗交互:居中底部抽拉式 Sheet(560px 宽度自适应居中),配备顶部阻尼把手、左上角动态雷达声呐动效与 BLE 协议胶囊标签;
   - 交互闭环:支持手环信道建立、固件下发传输、校验重启与安全取消全流程;
   - Chrome Headless 自动渲染生成官方 image.png 交付图。
2. 更新 README.md 项目进度(已完成 6/11 页面)。
2026-08-17 17:36:00 +08:00

760 lines
24 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>方案 1:Fluid Studio 现代流体工控仪表盘 (与手环配置同系统一)</title>
<style>
:root {
--color-primary: #2563EB;
--color-primary-dark: #1D4ED8;
--color-on-primary-container: #1E40AF;
--color-primary-light: #EFF6FF;
--color-primary-container: #EFF6FF;
--color-primary-border: #DBEAFE;
--color-primary-glow: rgba(37, 99, 235, 0.25);
--color-primary-gradient: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
--bg: #EEF2F6;
--surface: #FFFFFF;
--surface-sub: #F8FAFC;
--text-main: #0F172A;
--text-sub: #64748B;
--text-dim: #94A3B8;
--divider: #E2E8F0;
--danger: #EF4444;
--danger-light: #FEF2F2;
--warning: #F59E0B;
--warning-light: #FEF3C7;
--warning-border: #FDE68A;
--warning-text: #D97706;
--success: #10B981;
--success-light: #ECFDF5;
--terminal-bg: #0F172A;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Segoe UI", Roboto, sans-serif;
background: var(--bg);
color: var(--text-main);
min-height: 100vh;
padding: clamp(16px, 2.5vw, 32px);
display: flex;
flex-direction: column;
-webkit-font-smoothing: antialiased;
}
.device-wrapper {
width: 100%;
max-width: min(100%, 1160px);
margin: 0 auto;
background: var(--surface);
border-radius: 20px;
border: 1px solid var(--divider);
box-shadow: 0 16px 40px -10px rgba(15, 23, 42, 0.08);
overflow: hidden;
position: relative;
min-height: 640px;
display: flex;
flex-direction: column;
}
/* 1. AppBar 统一全局规范 */
.appbar {
height: 60px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
border-bottom: 1px solid var(--divider);
background: var(--surface);
flex-shrink: 0;
}
.appbar-left { display: flex; align-items: center; }
.appbar-nav, .appbar-more {
width: 40px;
height: 40px;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
background: transparent;
border: none;
transition: all 0.15s ease;
}
.appbar-nav:hover, .appbar-more:hover {
background: rgba(15, 23, 42, 0.06);
transform: scale(0.96);
}
.appbar-nav svg, .appbar-more svg { width: 22px; height: 22px; fill: var(--text-main); }
.appbar-title { font-size: 19px; font-weight: 700; margin-left: 10px; }
/* 2. 主体流体双栏仪表盘 */
.main-dashboard {
padding: clamp(20px, 2.5vw, 30px);
display: grid;
grid-template-columns: 1fr 1.15fr;
gap: clamp(16px, 2vw, 24px);
background: #F8FAFC;
flex: 1;
overflow-y: auto;
max-height: calc(100vh - 120px);
}
.dash-column {
display: flex;
flex-direction: column;
gap: 18px;
}
.card-box {
background: var(--surface);
border: 1.5px solid var(--divider);
border-radius: 16px;
padding: 22px;
display: flex;
flex-direction: column;
gap: 16px;
box-shadow: 0 4px 16px rgba(15, 23, 42, 0.03);
transition: all 0.2s ease;
}
.card-box:hover { box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05); }
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid var(--divider);
padding-bottom: 12px;
}
.card-title {
font-size: 16px;
font-weight: 700;
color: var(--color-primary);
display: flex;
align-items: center;
gap: 8px;
}
.conn-badge {
font-size: 12px;
font-weight: 700;
padding: 3px 9px;
border-radius: 100px;
background: #F1F5F9;
color: var(--text-sub);
}
.conn-badge.online { background: var(--success-light); color: var(--success); }
/* 2.1 手环升级目标设备卡片 */
.device-profile-box {
display: flex;
align-items: center;
gap: 16px;
}
.device-art-icon {
width: 64px;
height: 64px;
border-radius: 14px;
background: var(--color-primary-light);
border: 1.5px solid var(--color-primary-border);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.device-art-icon svg { width: 34px; height: 34px; fill: var(--color-primary); }
.device-props-grid {
flex: 1;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.prop-item {
background: #F8FAFC;
border: 1px solid var(--divider);
border-radius: 8px;
padding: 8px 12px;
}
.prop-k { font-size: 11px; color: var(--text-sub); }
.prop-v { font-size: 13.5px; font-weight: 700; color: var(--text-main); font-family: ui-monospace, monospace; margin-top: 2px; }
.btn-cancel-upgrade {
background: var(--warning-light);
color: var(--warning-text);
border: 1px solid var(--warning-border);
padding: 8px 18px;
border-radius: 8px;
font-size: 13px;
font-weight: 700;
cursor: pointer;
transition: all 0.15s ease;
align-self: flex-end;
}
.btn-cancel-upgrade:hover { background: #FDE68A; }
/* 2.2 固件包信息卡片 */
.firmware-meta-card {
background: #F8FAFC;
border: 1px solid var(--divider);
border-radius: 12px;
padding: 14px 16px;
display: flex;
flex-direction: column;
gap: 6px;
}
.fw-name-text {
font-size: 13.5px;
font-weight: 700;
color: var(--text-main);
font-family: ui-monospace, monospace;
word-break: break-all;
}
.fw-source-tag {
font-size: 12px;
font-weight: 700;
color: var(--color-primary);
}
.fw-action-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.btn-fw-action {
background: #FFFFFF;
border: 1.5px solid var(--divider);
border-radius: 10px;
padding: 10px 12px;
font-size: 13px;
font-weight: 700;
color: var(--color-primary);
cursor: pointer;
transition: all 0.15s ease;
text-align: center;
}
.btn-fw-action:hover {
border-color: var(--color-primary);
background: var(--color-primary-light);
}
/* 2.3 升级进度与控制台 */
.progress-track-box {
display: flex;
flex-direction: column;
gap: 8px;
background: #F8FAFC;
border: 1px solid var(--divider);
border-radius: 12px;
padding: 14px 16px;
}
.progress-info-row {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 13px;
font-weight: 700;
}
.progress-bar-bg {
width: 100%;
height: 10px;
background: #E2E8F0;
border-radius: 100px;
overflow: hidden;
}
.progress-bar-fill {
width: 0%;
height: 100%;
background: var(--color-primary-gradient);
border-radius: 100px;
transition: width 0.3s ease;
}
.btn-start-upgrade {
width: 100%;
background: var(--color-primary-gradient);
color: white;
border: none;
padding: 13px;
border-radius: 12px;
font-size: 15px;
font-weight: 700;
cursor: pointer;
box-shadow: 0 4px 16px var(--color-primary-glow);
transition: all 0.2s ease;
}
.btn-start-upgrade:hover {
transform: translateY(-1px);
box-shadow: 0 6px 20px var(--color-primary-glow);
}
.terminal-hud {
background: var(--terminal-bg);
border-radius: 12px;
border: 1px solid #334155;
padding: 12px 14px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11.5px;
color: #94A3B8;
height: 140px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 4px;
flex: 1;
}
.term-line { line-height: 1.5; }
.term-line.info { color: #38BDF8; }
.term-line.success { color: #4ADE80; }
.term-line.warn { color: #FBBF24; }
/* 3. 右下角悬浮蓝牙按钮 (FAB) */
.bluetooth-fab {
position: absolute;
bottom: 24px;
right: 24px;
width: 52px;
height: 52px;
border-radius: 16px;
background: var(--surface);
border: 1.5px solid var(--divider);
box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
z-index: 50;
}
.bluetooth-fab:hover {
transform: scale(1.08) translateY(-2px);
border-color: var(--color-primary);
box-shadow: 0 14px 30px var(--color-primary-glow);
}
.bluetooth-fab svg { width: 24px; height: 24px; fill: var(--color-primary); }
/* 4. 居中底部抽拉式 Sheet */
.bottom-sheet-mask {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(15, 23, 42, 0.45);
backdrop-filter: blur(4px);
z-index: 100;
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
}
.bottom-sheet-mask.open { opacity: 1; pointer-events: auto; }
.bottom-sheet {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%) translateY(100%);
width: min(92%, 560px);
background: var(--surface);
border-radius: 24px 24px 0 0;
border: 1.5px solid var(--divider);
border-bottom: none;
box-shadow: 0 -16px 45px rgba(15, 23, 42, 0.2);
transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
display: flex;
flex-direction: column;
max-height: 490px;
z-index: 101;
}
.bottom-sheet-mask.open .bottom-sheet { transform: translateX(-50%) translateY(0); }
.sheet-handle-bar {
width: 44px;
height: 5px;
border-radius: 10px;
background: #CBD5E1;
margin: 10px auto 4px;
cursor: grab;
}
.sheet-head {
padding: 12px 24px 14px;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid var(--divider);
}
.sheet-title-box { display: flex; align-items: center; gap: 10px; }
.radar-scanner {
position: relative;
width: 34px;
height: 34px;
border-radius: 50%;
background: var(--color-primary-light);
display: flex;
align-items: center;
justify-content: center;
}
.radar-ring {
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
border: 2px solid var(--color-primary);
animation: radarWave 1.8s infinite ease-out;
}
@keyframes radarWave {
0% { transform: scale(0.6); opacity: 1; }
100% { transform: scale(1.6); opacity: 0; }
}
.radar-scanner svg { width: 18px; height: 18px; fill: var(--color-primary); z-index: 2; }
.sheet-close-btn {
width: 32px; height: 32px; border-radius: 50%; border: none; background: #F1F5F9;
cursor: pointer; display: flex; align-items: center; justify-content: center;
color: var(--text-sub); font-size: 16px; font-weight: 700; transition: all 0.15s;
}
.sheet-close-btn:hover { background: #E2E8F0; color: var(--text-main); }
.sheet-chips-line {
padding: 10px 24px;
background: #F8FAFC;
display: flex;
gap: 8px;
border-bottom: 1px solid var(--divider);
overflow-x: auto;
}
.filter-chip {
padding: 5px 14px;
border-radius: 100px;
font-size: 12px;
font-weight: 600;
border: 1px solid var(--divider);
background: white;
cursor: pointer;
white-space: nowrap;
transition: all 0.15s ease;
}
.filter-chip.active {
background: var(--color-primary-light);
color: var(--color-primary);
border-color: var(--color-primary-border);
}
.sheet-device-list {
padding: 14px 24px;
display: flex;
flex-direction: column;
gap: 10px;
overflow-y: auto;
max-height: 220px;
}
.device-item-card {
border: 1.5px solid var(--divider);
border-radius: 14px;
padding: 12px 16px;
display: flex;
align-items: center;
justify-content: space-between;
background: white;
transition: all 0.15s ease;
cursor: pointer;
}
.device-item-card:hover {
border-color: var(--color-primary);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}
.dev-badge-ble-right {
background: var(--color-primary-light);
color: var(--color-primary);
font-size: 12px;
font-weight: 800;
padding: 4px 10px;
border-radius: 6px;
border: 1px solid var(--color-primary-border);
letter-spacing: 0.5px;
}
.sheet-foot {
padding: 14px 24px 20px;
border-top: 1px solid var(--divider);
background: #F8FAFC;
}
.btn-pause-scan {
width: 100%;
background: #DCFCE7;
color: #15803D;
border: 1px solid #BBF7D0;
padding: 10px;
border-radius: 12px;
font-size: 13.5px;
font-weight: 700;
cursor: pointer;
transition: all 0.15s;
}
</style>
</head>
<body>
<div class="device-wrapper">
<header class="appbar">
<div class="appbar-left">
<button class="appbar-nav" title="返回"><svg viewBox="0 0 24 24"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg></button>
<h1 class="appbar-title">手环升级</h1>
</div>
<button class="appbar-more"><svg viewBox="0 0 24 24"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/></svg></button>
</header>
<main class="main-dashboard">
<div class="dash-column">
<section class="card-box">
<div class="card-header">
<span class="card-title">待升级手环状态</span>
<span class="conn-badge" id="targetConnBadge">状态:未连接</span>
</div>
<div class="device-profile-box">
<div class="device-art-icon">
<svg viewBox="0 0 24 24"><path d="M15 1H9c-.55 0-1 .45-1 1v2.17C5.84 5.38 4 7.97 4 11v2c0 3.03 1.84 5.62 4 6.83V22c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.17c2.16-1.21 4-3.8 4-6.83v-2c0-3.03-1.84-5.62-4-6.83V2c0-.55-.45-1-1-1zm-3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"/></svg>
</div>
<div class="device-props-grid">
<div class="prop-item"><div class="prop-k">ID:</div><div class="prop-v" id="devIdVal">未连接</div></div>
<div class="prop-item"><div class="prop-k">版本:</div><div class="prop-v" id="devVerVal">未知</div></div>
<div class="prop-item" style="grid-column: span 2;"><div class="prop-k">电量:</div><div class="prop-v" id="devBatVal">未知</div></div>
</div>
</div>
<button class="btn-cancel-upgrade" onclick="cancelUpgrade()">取消升级</button>
</section>
<section class="card-box">
<div class="card-header">
<span class="card-title">固件包与版本源</span>
</div>
<div class="firmware-meta-card">
<div class="fw-name-text" id="fwFileName">SC106_FW1.00.0036_HW0.1_20260720_DFU.zip (内置 v1.00.0036)</div>
<div class="fw-source-tag">固件来源: 内置 (优先)</div>
</div>
<div class="fw-action-grid">
<button class="btn-fw-action" onclick="checkServerFw()">检查服务端版本</button>
<button class="btn-fw-action" onclick="useBuiltinFw()">使用内置固件</button>
</div>
</section>
</div>
<div class="dash-column">
<section class="card-box" style="flex: 1;">
<div class="card-header">
<span class="card-title">升级进度与控制</span>
<span id="stageBadge" style="font-size: 12px; font-weight: 700; color: var(--color-primary);">等待就绪</span>
</div>
<div class="progress-track-box">
<div class="progress-info-row">
<span>升级进度</span>
<span id="progressPercent" style="color: var(--color-primary);">0%</span>
</div>
<div class="progress-bar-bg">
<div class="progress-bar-fill" id="progressBar"></div>
</div>
<div style="font-size: 12px; color: var(--text-sub); display: flex; justify-content: space-between;">
<span id="progressStatus">状态: 待开始</span>
<span id="speedTxt">传输速率: -- KB/s</span>
</div>
</div>
<button class="btn-start-upgrade" id="btnStartDfu" onclick="startDfuProcess()">开始升级</button>
<div style="display: flex; flex-direction: column; gap: 6px; flex: 1; margin-top: 4px;">
<span style="font-size: 13px; font-weight: 700; color: var(--text-main);">升级日志控制台</span>
<div class="terminal-hud" id="dfuTerminal">
<div class="term-line info">[DFU-Core] 固件升级引导服务已就绪...</div>
<div class="term-line">等待配对手环并下发 DFU 引导指令...</div>
</div>
</div>
</section>
</div>
</main>
<button class="bluetooth-fab" onclick="openBottomSheet()" title="扫描并选择待升级手环">
<svg viewBox="0 0 24 24"><path d="M17.71 7.71L12 2h-1v7.59L6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 11 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 5.83l1.88 1.88L13 9.59V5.83zm1.88 10.46L13 18.17v-3.76l1.88 1.88z"/></svg>
</button>
<div class="bottom-sheet-mask" id="sheetMask" onclick="if(event.target===this) closeBottomSheet()">
<div class="bottom-sheet">
<div class="sheet-handle-bar"></div>
<div class="sheet-head">
<div class="sheet-title-box">
<div class="radar-scanner">
<div class="radar-ring"></div>
<svg viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg>
</div>
<h2 style="font-size: 16px; font-weight: 700;">选择设备</h2>
</div>
<button class="sheet-close-btn" onclick="closeBottomSheet()">✕</button>
</div>
<div class="sheet-chips-line">
<span class="filter-chip active" onclick="toggleChip(this)">✓ 扫描顺序</span>
<span class="filter-chip" onclick="toggleChip(this)">名称</span>
<span class="filter-chip" onclick="toggleChip(this)">信号强度</span>
<span class="filter-chip" onclick="toggleChip(this)">类型</span>
</div>
<div class="sheet-device-list">
<div class="device-item-card" onclick="connectTarget('CL831-62200026', 'v1.00.0035', '88%')">
<div>
<div style="font-weight: 700; font-size: 14.5px; font-family: monospace;">CL831-62200026</div>
<div style="font-size: 11.5px; color: var(--text-sub); margin-top: 3px;">D9:24:0F:1C:55:FA · 信号: -89 dBm</div>
</div>
<span class="dev-badge-ble-right">BLE</span>
</div>
<div class="device-item-card" onclick="connectTarget('CL831-2200006', 'v1.00.0032', '95%')">
<div>
<div style="font-weight: 700; font-size: 14.5px; font-family: monospace;">CL831-2200006</div>
<div style="font-size: 11.5px; color: var(--text-sub); margin-top: 3px;">DF:16:BC:22:2E:5B · 信号: -98 dBm</div>
</div>
<span class="dev-badge-ble-right">BLE</span>
</div>
</div>
<div class="sheet-foot">
<button class="btn-pause-scan" id="btnScan" onclick="toggleScan()">暂停扫描</button>
</div>
</div>
</div>
</div>
<script>
let isConnected = false;
let isUpgrading = false;
let upgradeTimer = null;
function appendLog(t, type = '') {
const b = document.getElementById('dfuTerminal');
const d = document.createElement('div');
d.className = `term-line ${type}`;
d.innerText = `[${new Date().toTimeString().split(' ')[0]}] ${t}`;
b.appendChild(d);
b.scrollTop = b.scrollHeight;
}
function openBottomSheet() {
document.getElementById('sheetMask').classList.add('open');
appendLog("展开【选择设备】面板,正在侦听周围待升级 BLE 广播...", "info");
}
function closeBottomSheet() {
document.getElementById('sheetMask').classList.remove('open');
}
function toggleChip(el) {
document.querySelectorAll('.filter-chip').forEach(c => {
c.classList.remove('active');
c.innerText = c.innerText.replace('✓ ', '');
});
el.classList.add('active');
el.innerText = '✓ ' + el.innerText;
appendLog(`切换设备扫描排序: ${el.innerText}`, "info");
}
function connectTarget(name, ver, bat) {
closeBottomSheet();
appendLog(`正在连接待升级手环 [${name}]...`, "info");
setTimeout(() => {
isConnected = true;
document.getElementById('devIdVal').innerText = name;
document.getElementById('devVerVal').innerText = ver;
document.getElementById('devBatVal').innerText = bat;
document.getElementById('targetConnBadge').innerText = "状态:已就绪";
document.getElementById('targetConnBadge').classList.add('online');
document.getElementById('stageBadge').innerText = "可开始升级";
appendLog(`已成功与 [${name}] 建立 DFU 控制信道,当前版本: ${ver},电量充足 (${bat})。`, "success");
}, 600);
}
function startDfuProcess() {
if (!isConnected) {
alert("请先点击右下角蓝牙按钮选择待升级手环!");
openBottomSheet();
return;
}
if (isUpgrading) return;
isUpgrading = true;
let progress = 0;
document.getElementById('btnStartDfu').disabled = true;
document.getElementById('btnStartDfu').innerText = "正在传输固件...";
document.getElementById('progressStatus').innerText = "状态: 固件分包传输中 (GATT Write No Response)";
document.getElementById('stageBadge').innerText = "传输中 (0%)";
appendLog("启动 DFU 传输协议,握手 Secure Bootloader 校验公钥...", "info");
upgradeTimer = setInterval(() => {
progress += Math.floor(Math.random() * 8) + 5;
if (progress > 100) progress = 100;
document.getElementById('progressBar').style.width = progress + '%';
document.getElementById('progressPercent').innerText = progress + '%';
document.getElementById('stageBadge').innerText = `传输中 (${progress}%)`;
document.getElementById('speedTxt').innerText = `传输速率: ${(Math.random()*4 + 18).toFixed(1)} KB/s`;
if (progress >= 100) {
clearInterval(upgradeTimer);
document.getElementById('progressStatus').innerText = "状态: CRC 校验成功,手环正在重启应用新固件...";
document.getElementById('stageBadge').innerText = "升级完成";
document.getElementById('devVerVal').innerText = "v1.00.0036 (已最新)";
document.getElementById('btnStartDfu').innerText = "升级完成";
appendLog("固件数据包 100% 写入完成,CRC32 校验通过!手环正在重启生效...", "success");
setTimeout(() => {
alert("手环固件升级成功!新版本已生效。");
document.getElementById('btnStartDfu').disabled = false;
document.getElementById('btnStartDfu').innerText = "开始升级";
isUpgrading = false;
}, 1000);
}
}, 400);
}
function cancelUpgrade() {
if (isUpgrading) {
clearInterval(upgradeTimer);
isUpgrading = false;
document.getElementById('btnStartDfu').disabled = false;
document.getElementById('btnStartDfu').innerText = "开始升级";
document.getElementById('progressBar').style.width = '0%';
document.getElementById('progressPercent').innerText = '0%';
document.getElementById('progressStatus').innerText = "状态: 升级已取消";
document.getElementById('stageBadge').innerText = "已中断";
appendLog("用户手动触发 [取消升级],已终止固件传输。", "warn");
alert("已取消手环固件升级。");
} else {
appendLog("当前未处于升级传输过程中。", "info");
}
}
function checkServerFw() {
appendLog("正在请求服务端云端固件库 API...", "info");
setTimeout(() => {
appendLog("检查完成:当前内置固件 v1.00.0036 已为官方最新稳定版。", "success");
alert("服务端版本检查:当前内置固件已是最新版!");
}, 800);
}
function useBuiltinFw() {
appendLog("已切换为本地内置固件源:SC106_FW1.00.0036_HW0.1_20260720_DFU.zip", "info");
alert("已切换并锁定为本地内置固件!");
}
function toggleScan() {
const b = document.getElementById('btnScan');
if (b.innerText === "暂停扫描") {
b.innerText = "继续扫描";
b.style.background = "#FEF3C7";
b.style.color = "#D97706";
appendLog("已暂停 BLE 设备广播扫描。", "warn");
} else {
b.innerText = "暂停扫描";
b.style.background = "#DCFCE7";
b.style.color = "#15803D";
appendLog("已恢复 BLE 广播扫描...", "info");
}
}
</script>
</body>
</html>