Spaces:
Running
Running
Download template/index.html from bevisssssss/driver: direct link, hf CLI and curl.
- Browser
- Download file 48.2 kB
-
https://huggingface.co/spaces/bevisssssss/driver/resolve/main/template/index.html
- Command line
-
hf download hf://spaces/bevisssssss/driver/template/index.html
-
curl -L -o index.html https://huggingface.co/spaces/bevisssssss/driver/resolve/main/template/index.html
48.2 kB
<!DOCTYPE html>
<html lang="zh-CN" data-theme="cool">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>驱动下载中心</title>
<style>
/* ════════════════════════════════════════
Design System — Theme Variables
════════════════════════════════════════ */
:root {
/* Cool theme (default) */
--bg-page: #f0f4f8;
--bg-card: #ffffff;
--bg-elevated: #ffffff;
--bg-subtle: #f8fafc;
--text-primary: #0f172a;
--text-secondary: #475569;
--text-muted: #94a3b8;
--border-light: #e2e8f0;
--border-subtle: #f1f5f9;
--shadow-card: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
--shadow-hover: 0 10px 30px -5px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
--shadow-panel: 0 4px 6px -1px rgba(0,0,0,.03);
--header-start: #0b1426;
--header-mid: #14203a;
--header-end: #0b1426;
--header-text: #f1f5f9;
--header-sub: #64748b;
--header-accent-glow-1: rgba(59,130,246,.08);
--header-accent-glow-2: rgba(139,92,246,.08);
--pill-bg: #f1f5f9;
--pill-text: #475569;
--pill-hover: #e2e8f0;
--tag-bg: #f1f5f9;
--tag-text: #64748b;
--section-divider: #e2e8f0;
--filter-bar-bg: rgba(255,255,255,.85);
--filter-bar-border: #e2e8f0;
--accent-cool: #3b82f6;
--os-android: #16a34a;
--os-windows: #2563eb;
--os-linux: #d97706;
--spinner-track: #e2e8f0;
--spinner-accent: #0f172a;
--bg-pattern: rgba(59,130,246,.015);
}
[data-theme="warm"] {
--bg-page: #fef7ee;
--bg-card: #ffffff;
--bg-elevated: #ffffff;
--bg-subtle: #fffbeb;
--text-primary: #1c1917;
--text-secondary: #57534e;
--text-muted: #a8a29e;
--border-light: #e7e5e4;
--border-subtle: #f5f5f4;
--shadow-card: 0 1px 3px rgba(120,80,40,.04), 0 1px 2px rgba(120,80,40,.06);
--shadow-hover: 0 10px 30px -5px rgba(120,80,40,.1), 0 4px 6px -2px rgba(120,80,40,.05);
--shadow-panel: 0 4px 6px -1px rgba(120,80,40,.03);
--header-start: #1c130d;
--header-mid: #2d1f14;
--header-end: #1c130d;
--header-text: #fefce8;
--header-sub: #a8a29e;
--header-accent-glow-1: rgba(245,158,11,.07);
--header-accent-glow-2: rgba(239,68,68,.06);
--pill-bg: #fef3c7;
--pill-text: #92400e;
--pill-hover: #fde68a;
--tag-bg: #fef3c7;
--tag-text: #b45309;
--section-divider: #e7e5e4;
--filter-bar-bg: rgba(255,252,245,.88);
--filter-bar-border: #e7e5e4;
--accent-cool: #d97706;
--os-android: #16a34a;
--os-windows: #2563eb;
--os-linux: #dc2626;
--spinner-track: #e7e5e4;
--spinner-accent: #1c1917;
--bg-pattern: rgba(245,158,11,.015);
}
/* ── Reset & Base ── */
* { margin:0; padding:0; box-sizing:border-box; }
body {
font-family:"PingFang SC","Microsoft YaHei","Noto Sans SC","Helvetica Neue",sans-serif;
background:var(--bg-page); color:var(--text-primary); min-height:100vh;
transition:background .4s ease,color .3s ease;
}
/* subtle grid pattern */
body::before {
content:''; position:fixed; inset:0; z-index:-1;
background-image:
linear-gradient(var(--bg-pattern) 1px, transparent 1px),
linear-gradient(90deg, var(--bg-pattern) 1px, transparent 1px);
background-size:60px 60px;
}
/* ── Theme Toggle ── */
.theme-toggle {
position:fixed; top:20px; right:20px; z-index:100;
width:44px; height:44px; border-radius:50%;
border:2px solid var(--border-light); background:var(--bg-card);
cursor:pointer; font-size:20px; display:flex; align-items:center; justify-content:center;
transition:all .3s cubic-bezier(.4,0,.2,1);
box-shadow:0 2px 12px rgba(0,0,0,.08);
backdrop-filter:blur(8px);
}
.theme-toggle:hover { transform:scale(1.1); box-shadow:0 4px 20px rgba(0,0,0,.12); }
/* ── Header ── */
.header {
background:linear-gradient(135deg,var(--header-start) 0%,var(--header-mid) 50%,var(--header-end) 100%);
color:var(--header-text); padding:36px 0 30px; text-align:center; position:relative; overflow:hidden;
transition:background .4s ease;
}
.header::before {
content:''; position:absolute; top:-50%; left:-50%; width:200%; height:200%;
background:
radial-gradient(ellipse at 30% 50%,var(--header-accent-glow-1) 0%,transparent 60%),
radial-gradient(ellipse at 70% 50%,var(--header-accent-glow-2) 0%,transparent 60%);
}
.header::after {
content:''; position:absolute; bottom:0; left:0; right:0; height:1px;
background:linear-gradient(90deg,transparent,rgba(255,255,255,.08),transparent);
}
.header-content { position:relative; z-index:1; }
.header h1 {
font-size:30px; font-weight:800; letter-spacing:3px;
background:linear-gradient(135deg,#f8fafc,#cbd5e1);
-webkit-background-clip:text; -webkit-text-fill-color:transparent;
background-clip:text;
}
[data-theme="warm"] .header h1 {
background:linear-gradient(135deg,#fefce8,#fcd34d);
-webkit-background-clip:text; -webkit-text-fill-color:transparent;
background-clip:text;
}
.header .sub { font-size:14px; color:var(--header-sub); margin-top:8px; letter-spacing:1px; }
.header .admin-link {
position:absolute; top:16px; left:20px; z-index:2;
display:flex; align-items:center; gap:6px;
color:var(--header-sub); font-size:12px; letter-spacing:.5px;
text-decoration:none; padding:6px 14px;
border:1px solid rgba(255,255,255,.1); border-radius:20px;
transition:all .25s;
}
.header .admin-link:hover {
color:var(--header-text); border-color:rgba(255,255,255,.25);
background:rgba(255,255,255,.05);
}
/* ── Stats bar ── */
.stats-bar {
display:flex; justify-content:center; gap:28px; margin-top:22px; flex-wrap:wrap;
}
.stat-item { text-align:center; position:relative; }
.stat-item + .stat-item::before {
content:''; position:absolute; left:-14px; top:50%; transform:translateY(-50%);
width:1px; height:24px; background:rgba(255,255,255,.06);
}
.stat-num { font-size:24px; font-weight:800; color:var(--header-text); letter-spacing:-.5px; }
.stat-label { font-size:11px; color:var(--header-sub); margin-top:1px; letter-spacing:.5px; }
/* ── Filter pills ── */
.filter-wrap {
background:var(--filter-bar-bg); padding:0 24px; position:sticky; top:0; z-index:50;
backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
border-bottom:1px solid var(--filter-bar-border); transition:all .4s ease;
}
.filter-scroll {
max-width:960px; margin:0 auto; display:flex; gap:6px;
padding:14px 0 10px; overflow-x:auto; -webkit-overflow-scrolling:touch;
}
.filter-scroll::-webkit-scrollbar { height:0; }
.os-filter-scroll {
max-width:960px; margin:0 auto; display:flex; gap:6px;
padding:6px 0 14px; overflow-x:auto; -webkit-overflow-scrolling:touch;
border-top:1px solid var(--border-subtle);
}
.os-filter-scroll::-webkit-scrollbar { height:0; }
.pill {
display:flex; align-items:center; gap:8px; padding:10px 22px 10px 16px;
border-radius:28px; border:none; cursor:pointer; font-size:14px; font-weight:500;
white-space:nowrap; transition:all .25s cubic-bezier(.4,0,.2,1);
background:var(--pill-bg); color:var(--pill-text);
}
.pill:hover { background:var(--pill-hover); transform:translateY(-1px); }
.pill.active { color:#fff; box-shadow:0 4px 14px rgba(0,0,0,.15); transform:translateY(-1px); }
.pill .dot { width:10px; height:10px; border-radius:50%; display:inline-block; flex-shrink:0; }
.os-pill {
display:flex; align-items:center; gap:6px; padding:7px 18px 7px 14px;
border-radius:20px; border:none; cursor:pointer; font-size:13px; font-weight:500;
white-space:nowrap; transition:all .25s cubic-bezier(.4,0,.2,1);
background:transparent; color:var(--text-muted);
}
.os-pill:hover { color:var(--text-secondary); background:var(--bg-subtle); }
.os-pill.active { color:#fff; font-weight:600; box-shadow:0 2px 10px rgba(0,0,0,.1); }
.os-pill.active svg { fill:#fff !important; }
.os-pill .dot { width:9px; height:9px; border-radius:50%; display:inline-block; flex-shrink:0; }
/* ── Device grid ── */
.container { max-width:1200px; margin:0 auto; padding:32px 24px 80px; }
.section-title {
font-size:14px; font-weight:600; padding-bottom:12px; margin-bottom:20px;
display:flex; align-items:center; gap:10px; letter-spacing:1px; text-transform:uppercase;
border-bottom:2px solid var(--section-divider); transition:border-color .3s ease;
}
.section-title .count {
font-size:11px; font-weight:500; padding:1px 10px; border-radius:8px;
background:var(--tag-bg); color:var(--tag-text); transition:all .3s ease;
}
.grid {
display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr));
gap:18px; margin-bottom:48px;
}
/* ── Device card ── */
.card {
background:var(--bg-card); border-radius:14px; overflow:hidden; cursor:pointer;
border:1px solid var(--border-light); box-shadow:var(--shadow-card);
transition:all .3s cubic-bezier(.4,0,.2,1); position:relative;
}
.card::before {
content:''; position:absolute; top:0; left:0; right:0; height:3px;
background:linear-gradient(90deg,var(--accent-cool),transparent); opacity:0;
transition:opacity .3s ease;
}
.card:hover::before { opacity:1; }
.card:hover {
box-shadow:var(--shadow-hover); transform:translateY(-3px);
border-color:color-mix(in srgb,var(--accent-cool) 20%,var(--border-light));
}
.card-top {
padding:22px; display:flex; align-items:center; gap:16px;
border-bottom:1px solid var(--border-subtle); transition:border-color .3s ease;
}
.card-icon {
width:48px; height:48px; border-radius:12px; display:flex; align-items:center;
justify-content:center; font-size:22px; flex-shrink:0;
position:relative; overflow:hidden;
}
.card-icon::after {
content:''; position:absolute; top:-50%; right:-50%; width:80%; height:80%;
background:linear-gradient(135deg,rgba(255,255,255,.2),transparent);
border-radius:50%;
}
.card-name { font-size:16px; font-weight:600; }
.card-desc { font-size:12px; color:var(--text-muted); margin-top:3px; line-height:1.4; }
.card-tag {
margin-left:auto; font-size:11px; padding:4px 12px; border-radius:8px;
background:var(--tag-bg); color:var(--tag-text); flex-shrink:0; font-weight:500;
transition:all .3s ease;
}
/* ── OS panel ── */
.os-panel { display:none; }
.os-panel.open { display:block; animation:slideDown .25s cubic-bezier(.4,0,.2,1); }
@keyframes slideDown {
from { opacity:0; transform:translateY(-6px) scaleY(.98); }
to { opacity:1; transform:translateY(0) scaleY(1); }
}
.os-row {
border-bottom:1px solid var(--border-subtle); transition:all .3s ease;
}
.os-row:last-child { border-bottom:none; }
.os-header {
display:flex; align-items:center; gap:10px; padding:14px 22px; cursor:pointer;
font-size:14px; transition:background .2s ease;
}
.os-header:hover { background:var(--bg-subtle); }
.os-dot { width:9px; height:9px; border-radius:50%; flex-shrink:0; }
.dl-list { display:none; }
.dl-list.open { display:block; animation:slideUp .2s cubic-bezier(.4,0,.2,1); }
@keyframes slideUp {
from { opacity:0; transform:translateY(-3px); }
to { opacity:1; transform:translateY(0); }
}
.dl-item {
display:flex; align-items:center; gap:14px; padding:11px 22px 11px 50px;
border-top:1px solid var(--border-subtle); transition:background .2s ease;
}
.dl-item:hover { background:var(--bg-subtle); }
.dl-icon { font-size:15px; width:22px; text-align:center; flex-shrink:0; }
.dl-info { flex:1; min-width:0; }
.dl-title { font-size:13px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dl-meta { font-size:11px; color:var(--text-muted); margin-top:2px; }
.dl-btn {
display:inline-flex; align-items:center; gap:6px; padding:6px 16px;
border-radius:8px; text-decoration:none; font-size:12px; font-weight:600;
flex-shrink:0; transition:all .2s cubic-bezier(.4,0,.2,1); color:#fff;
letter-spacing:.5px; position:relative; overflow:hidden;
}
.dl-btn::after {
content:''; position:absolute; inset:0;
background:linear-gradient(135deg,rgba(255,255,255,.15),transparent 50%);
}
.dl-btn:hover {
filter:brightness(1.12); transform:translateY(-2px);
box-shadow:0 4px 12px rgba(0,0,0,.15);
}
.dl-btn:active { transform:translateY(0); }
/* ── Empty ── */
.empty { text-align:center; padding:80px 20px; color:var(--text-muted); grid-column:1/-1; }
.empty .big-icon { font-size:52px; margin-bottom:16px; opacity:.6; }
.empty p { font-size:14px; }
/* ── Loading ── */
#loading { text-align:center; padding:100px 0; }
.spinner {
width:40px; height:40px; border:3px solid var(--spinner-track);
border-top-color:var(--spinner-accent); border-radius:50%;
display:inline-block; animation:spin .6s linear infinite;
transition:border-color .3s ease;
}
@keyframes spin { to { transform:rotate(360deg); } }
.loading-text { color:var(--text-muted); font-size:13px; margin-top:12px; transition:color .3s ease; }
/* ── Announcement Banner ── */
.announce-banner { max-width:960px; margin:12px auto 0; padding:0 24px; }
.announce-item { display:flex; align-items:flex-start; gap:10px; padding:12px 16px; margin-bottom:8px; border-radius:10px; font-size:13px; line-height:1.6; }
.announce-item.公告 { background:#eff6ff; border:1px solid #bfdbfe; color:#1e40af; }
.announce-item.更新日志 { background:#f0fdf4; border:1px solid #bbf7d0; color:#166534; }
.announce-item.重要通知 { background:#fef2f2; border:1px solid #fecaca; color:#991b1b; }
[data-theme="warm"] .announce-item.公告 { background:#fefce8; border:1px solid #fde68a; color:#92400e; }
[data-theme="warm"] .announce-item.更新日志 { background:#fffbeb; border:1px solid #fed7aa; color:#9a3412; }
[data-theme="warm"] .announce-item.重要通知 { background:#fef2f2; border:1px solid #fecaca; color:#991b1b; }
.announce-item .kind { font-weight:700; white-space:nowrap; }
.announce-item .title { font-weight:600; }
.announce-item .content { color:inherit; opacity:.85; }
/* ════════════════════════════════════════
SN Lookup Section
════════════════════════════════════════ */
.sn-lookup-wrap {
max-width:960px; margin:0 auto; padding:0 24px;
}
.sn-lookup-card {
background:var(--bg-card); border-radius:14px;
border:1px solid var(--border-light); box-shadow:var(--shadow-card);
margin-bottom:24px; overflow:hidden;
transition:border-color .3s ease;
}
.sn-lookup-card:focus-within {
border-color:var(--accent-cool);
box-shadow:0 0 0 3px color-mix(in srgb, var(--accent-cool) 15%, transparent), var(--shadow-card);
}
.sn-lookup-header {
display:flex; align-items:center; gap:10px;
padding:14px 22px; font-size:14px; font-weight:600;
border-bottom:1px solid var(--border-subtle);
color:var(--text-primary); letter-spacing:.3px;
}
.sn-lookup-header .icon { font-size:18px; }
.sn-lookup-header .sub {
font-size:12px; font-weight:400; color:var(--text-muted); margin-left:auto;
}
.sn-lookup-body { padding:16px 22px 20px; }
.sn-input-group { display:flex; gap:10px; }
.sn-input {
flex:1; padding:10px 16px; border-radius:10px; border:1.5px solid var(--border-light);
background:var(--bg-subtle); color:var(--text-primary);
font-size:14px; font-family:inherit; outline:none;
transition:all .25s cubic-bezier(.4,0,.2,1);
}
.sn-input::placeholder { color:var(--text-muted); }
.sn-input:focus {
border-color:var(--accent-cool);
background:var(--bg-card);
box-shadow:0 0 0 3px color-mix(in srgb, var(--accent-cool) 12%, transparent);
}
.sn-btn {
display:inline-flex; align-items:center; gap:6px; padding:10px 24px;
border-radius:10px; border:none; cursor:pointer;
font-size:14px; font-weight:600; font-family:inherit; letter-spacing:.5px;
background:var(--accent-cool); color:#fff; white-space:nowrap;
transition:all .25s cubic-bezier(.4,0,.2,1);
position:relative; overflow:hidden;
}
.sn-btn::after {
content:''; position:absolute; inset:0;
background:linear-gradient(135deg,rgba(255,255,255,.15),transparent 50%);
}
.sn-btn:hover { filter:brightness(1.1); transform:translateY(-1px); box-shadow:0 4px 14px rgba(0,0,0,.15); }
.sn-btn:active { transform:translateY(0); }
.sn-btn:disabled { opacity:.5; cursor:not-allowed; transform:none; filter:none; }
.sn-btn.loading { position:relative; color:transparent; }
.sn-btn.loading::before {
content:''; position:absolute; left:50%; top:50%; width:18px; height:18px;
margin:-9px 0 0 -9px;
border:2px solid rgba(255,255,255,.3); border-top-color:#fff; border-radius:50%;
animation:spin .6s linear infinite; z-index:1;
}
/* ── SN Result ── */
.sn-result { display:none; margin-top:16px; }
.sn-result.open { display:block; animation:slideDown .25s cubic-bezier(.4,0,.2,1); }
.sn-result-card { border-radius:12px; border:1px solid var(--border-light); overflow:hidden; }
.sn-result-card.success { border-color:#bbf7d0; }
.sn-result-card.error { border-color:#fecaca; }
.sn-result-header {
display:flex; align-items:center; gap:10px;
padding:12px 18px; font-size:13px;
}
.sn-result-card.success .sn-result-header { background:#f0fdf4; color:#166534; }
.sn-result-card.error .sn-result-header { background:#fef2f2; color:#991b1b; }
.sn-result-body { padding:14px 18px 16px; }
.sn-info-grid { display:grid; grid-template-columns:auto 1fr; gap:6px 14px; font-size:13px; }
.sn-info-label { color:var(--text-muted); white-space:nowrap; }
.sn-info-value { color:var(--text-primary); font-weight:500; word-break:break-all; }
.sn-downloads-title {
font-size:13px; font-weight:600; color:var(--text-primary);
margin-top:14px; padding-top:14px;
border-top:1px solid var(--border-subtle);
display:flex; align-items:center; gap:6px;
}
.sn-dl-item {
display:flex; align-items:center; gap:12px;
padding:10px 0; border-bottom:1px solid var(--border-subtle);
}
.sn-dl-item:last-child { border-bottom:none; padding-bottom:0; }
.sn-dl-icon { font-size:16px; width:20px; text-align:center; flex-shrink:0; }
.sn-dl-info { flex:1; min-width:0; }
.sn-dl-name { font-size:13px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sn-dl-size { font-size:11px; color:var(--text-muted); margin-top:1px; }
.sn-dl-btn {
display:inline-flex; align-items:center; gap:5px; padding:6px 14px;
border-radius:8px; text-decoration:none; font-size:12px; font-weight:600;
flex-shrink:0; color:#fff; transition:all .2s;
position:relative; overflow:hidden;
}
.sn-dl-btn::after {
content:''; position:absolute; inset:0;
background:linear-gradient(135deg,rgba(255,255,255,.15),transparent 50%);
}
.sn-dl-btn:hover { filter:brightness(1.1); transform:translateY(-1px); box-shadow:0 4px 12px rgba(0,0,0,.15); }
/* ── Responsive ── */
/* ── SN Query Progress ── */
.sn-progress {
padding: 36px 24px 40px; text-align: center;
background: var(--bg-card); border-radius: 12px;
border: 1px solid var(--border-light);
}
.sn-progress-bar-wrap {
height: 6px; background: var(--bg-subtle); border-radius: 3px;
overflow: hidden; margin-bottom: 18px; max-width: 320px; margin-left: auto; margin-right: auto;
}
.sn-progress-bar {
height: 100%; border-radius: 3px;
background: linear-gradient(90deg, #3b82f6, #8b5cf6, #6366f1, #3b82f6);
background-size: 300% 100%;
transition: width .45s cubic-bezier(.4,0,.2,1);
animation: progressShimmer 2s ease infinite;
}
@keyframes progressShimmer {
0% { background-position: 300% 0; }
100% { background-position: -300% 0; }
}
.sn-progress-text {
font-size: 14px; color: var(--text-secondary);
display: flex; align-items: center; justify-content: center; gap: 10px;
}
.sn-progress-dot {
width: 8px; height: 8px; border-radius: 50%;
background: #3b82f6; display: inline-block; flex-shrink: 0;
animation: progressPulse 1.2s ease-in-out infinite;
}
@keyframes progressPulse {
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: .35; transform: scale(.7); }
}
@media(max-width:640px) {
.header { padding:28px 0 24px; }
.header h1 { font-size:24px; }
.theme-toggle { top:14px; right:14px; width:38px; height:38px; font-size:16px; }
.stats-bar { gap:16px; }
.stat-num { font-size:20px; }
.stat-item + .stat-item::before { display:none; }
.grid { grid-template-columns:1fr; gap:14px; }
.container { padding:20px 16px 60px; }
.filter-wrap { padding:0 16px; }
.card-top { padding:18px; }
.os-header { padding:12px 18px; }
.dl-item { padding:10px 18px 10px 40px; }
.sn-progress { padding: 28px 16px 32px; }
.sn-progress-bar-wrap { max-width: 240px; }
}
}
</style>
</head>
<body>
<!-- Theme Toggle -->
<button class="theme-toggle" id="themeToggle" onclick="toggleTheme()" title="切换冷暖色调">❄️</button>
<!-- Header -->
<div class="header">
<div class="header-content">
<h1>驱动下载中心</h1>
<div class="sub">系统固件 · 驱动程序 · 工具软件 · 技术文档</div>
<a class="admin-link" href="admin.html">管理后台 →</a>
<div class="stats-bar" id="statsBar"></div>
<div class="announce-banner" id="announceBanner"></div>
</div>
</div>
<!-- Filter -->
<div class="filter-wrap">
<div class="filter-scroll" id="filterBar"></div>
<div class="os-filter-scroll" id="osFilterBar"></div>
</div>
<!-- SN Lookup -->
<div class="sn-lookup-wrap">
<div class="sn-lookup-card">
<div class="sn-lookup-header">
<span class="icon">🔍</span>
<span>SN 查询</span>
<span class="sub">输入设备序列号,一键获取固件下载链接</span>
</div>
<div class="sn-lookup-body">
<div class="sn-input-group">
<input type="text" class="sn-input" id="snInput"
placeholder="输入 SN,如 M1TA688A0NXA25M0356"
onkeydown="if(event.key==='Enter') snSearch()">
<button class="sn-btn" id="snSearchBtn" onclick="snSearch()">查 询</button>
</div>
<div class="sn-result" id="snResult"></div>
</div>
</div>
</div>
<!-- Main -->
<div id="loading"><div class="spinner"></div><div class="loading-text">加载中...</div></div>
<div class="container" id="appContainer" style="display:none"></div>
<script>
const CATEGORIES = [
{ key:'all', label:'全部', icon:'📋', color:'', type:'all' },
{ key:'handheld', label:'手持机', icon:'📱', color:'#3b82f6', type:'device' },
{ key:'tablet', label:'平板', icon:'📟', color:'#8b5cf6', type:'device' },
{ key:'notebook', label:'笔记本', icon:'💻', color:'#10b981', type:'device' },
{ key:'industrial', label:'工控', icon:'⚙️', color:'#f59e0b', type:'device' },
{ key:'vehicle', label:'车载', icon:'🚗', color:'#ef4444', type:'device' },
{ key:'tools', label:'工具软件', icon:'🛠️', color:'#06b6d4', type:'device' },
{ key:'docs', label:'技术文档', icon:'📄', color:'#8b5cf6', type:'device' },
];
const OS_COLORS = { android:'#16a34a', windows:'#2563eb', linux:'#d97706' };
const OS_NAMES = { android:'Android', windows:'Windows', linux:'Linux' };
const FILE_ICONS = { firmware:'⚙️', driver:'🔌', tool:'🛠️', document:'📄' };
const FILE_NAMES = { firmware:'固件', driver:'驱动', tool:'工具', document:'文档' };
const OS_FILTERS = [
{ key:'all', label:'全部系统', icon:'💿', color:'' },
{ key:'android', label:'Android', icon:'<svg viewBox="0 0 128 128" width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g><g><path fill="#8BC34A" d="M112.368,40.466c-4.222,0-7.64,3.326-7.64,7.428 v31.797c0,4.102,3.418,7.428,7.64,7.428c4.214,0,7.632-3.326,7.632-7.428V47.894C120,43.793,116.582,40.466,112.368,40.466z M15.64,40.466c-4.222,0-7.64,3.326-7.64,7.428v31.797c0,4.102,3.418,7.428,7.64,7.428c4.214,0,7.632-3.326,7.632-7.428V47.894 C23.272,43.793,19.854,40.466,15.64,40.466z M28.917,40.466h-0.549v54.503c0,4.327,3.611,7.85,8.065,7.85h5.815 c-0.201,0.655-0.309,1.34-0.309,2.062v15.692c0,4.102,3.426,7.428,7.64,7.428c4.214,0,7.64-3.326,7.64-7.428V104.88 c0-0.722-0.116-1.407-0.309-2.062h14.182c-0.193,0.655-0.302,1.34-0.302,2.062v15.692c0,4.102,3.418,7.428,7.632,7.428 c4.222,0,7.648-3.326,7.648-7.428V104.88c0-0.722-0.116-1.407-0.317-2.062h5.823c4.454,0,8.057-3.522,8.057-7.85V40.466H28.917z M81.53,10.716l1.423-2.092l1.423-2.062l3.17-4.636c0.394-0.572,0.232-1.34-0.356-1.716c-0.58-0.384-1.376-0.226-1.755,0.346 l-4.841,7.052L79.141,9.73C74.54,7.992,69.413,7.021,64,7.021c-5.405,0-10.54,0.971-15.141,2.709l-1.446-2.122l-1.431-2.085 l-3.402-4.967c-0.394-0.572-1.183-0.722-1.771-0.346c-0.58,0.376-0.742,1.144-0.356,1.716l3.17,4.636l1.423,2.062l1.431,2.092 c-10.803,4.899-18.11,14.179-18.11,24.798h71.264C99.632,24.895,92.325,15.616,81.53,10.716z M48.728,25.602 c-2.111,0-3.82-1.663-3.82-3.718c0-2.055,1.709-3.71,3.82-3.71s3.82,1.656,3.82,3.71C52.548,23.939,50.839,25.602,48.728,25.602z M79.272,25.602c-2.111,0-3.82-1.663-3.82-3.718c0-2.055,1.709-3.71,3.82-3.71c2.111,0,3.82,1.656,3.82,3.71 C83.092,23.939,81.383,25.602,79.272,25.602z"/></g></g></svg>', color:'#16a34a' },
{ key:'windows', label:'Windows', icon:'<svg viewBox="0 0 512 512" width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g><path fill="#00ACEE" d="M495.3,133.7c0,35.5-0.1,71,0.1,106.4c0,4.8-1.2,6.8-6,6.2c-0.8-0.1-1.7,0-2.5,0 c-61.6,0.3-123.2,0.6-184.9,1c-20.1,0.1-40.3,0.3-60.4,0.7c-4.9,0.1-6.6-1.3-6.6-6.5c0.2-59.3,0.2-118.6,0-177.9 c0-5.1,1.1-7.2,6.7-7.8c22.5-2.7,44.8-5.9,67.2-9c31-4.4,61.9-9,92.8-13.4c29.5-4.2,59-8.1,88.5-12.3c4.7-0.7,5.2,1.3,5.2,5.2 C495.3,62,495.3,97.9,495.3,133.7z"/><path fill="#35ABD5" d="M213.1,154.4c0,29.3,0,58.7,0,88c0,6.4,0,6.4-6.6,6.4c-12.2,0.1-24.3,0.1-36.5,0.2 c-48.8,0.3-97.6,0.6-146.4,1c-7.1,0-7.1,0.1-7.1-6.9c0-49.8,0-99.6,0-149.5c0-6.9,0.1-6.6,6.9-7.6c17.6-2.4,35.2-5.1,52.8-7.6 c13.5-1.9,27.1-3.5,40.6-5.3c27.2-3.7,54.4-7.6,81.5-11.4c3.9-0.6,7.8-1.7,11.8-1.7c2.1,0,3.1,0.7,3,2.9c-0.1,1.7,0,3.3,0,5 C213.1,96.7,213.1,125.5,213.1,154.4z M210,153.8c0-28.6-0.1-57.3,0.1-85.9c0-4.2-1.5-5.1-5.2-4.9c-3.1,0.2-5.5,2-8.6,2.2 c-6.6,0.4-13.1,1.6-19.7,2.5c-12.9,1.8-25.9,3.4-38.7,5.4c-7.8,1.2-15.9,1.1-23.4,4.2c-1.3,0.5-2.6,0.9-3.9,0.4 c-4.2-1.7-8.5-0.2-12.2,0.7c-9.4,2.4-19.1,3-28.7,4.3c-8,1.1-16,2.7-24.1,3c-6.8,0.2-12.9,3.7-19.9,3.4c-6-0.3-6.8,0.8-6.8,7 c0,48,0,95.9,0,143.9c0,6.5,0.7,7,7.2,7.1c31.9,0.5,63.9-1.5,95.8-1.1c26.6,0.3,53.3,0.1,79.9,0c7.7,0,8.1-0.3,8.1-8.3 C210,209.7,210,181.8,210,153.8z"/><path fill="#35ABD5" d="M213.1,365.3c0,29.5-0.1,59,0.1,88.5c0,4.5-0.9,6.1-5.7,5.3c-14.4-2.3-28.9-4.3-43.4-6.3 c-15-2.1-30-3.8-45-6c-21.2-3-42.4-6.3-63.7-9.3c-11.2-1.6-22.4-3.2-33.6-4.4c-4-0.4-5.4-1.7-5.4-5.8c0.1-50.8,0.1-101.6,0-152.5 c0-4.3,1.1-6.3,5.7-5.5c2.1,0.3,4.3,0.1,6.5,0.1c59.8,0.3,119.6,0.7,179.4,0.9c4.3,0,5.3,1.4,5.2,5.4 C213,305.6,213.1,335.4,213.1,365.3z M210,365.4c0-28-0.2-56,0.1-83.9c0.1-7.3-3.2-8.4-8.6-8.4c-8.2,0-16.3,0.4-24.6,0.2 c-36.6-1-73.2,0.7-109.8-1.1c-13.8-0.7-27.6-0.1-41.5-0.1c-6.1,0-6.8,0.8-6.8,7c0,48.1,0,96.3,0,144.4c0,6.5,1,7.1,7.4,7.7 c9.9,0.9,19.8,1.7,29.5,3.6c12.2,2.3,24.5,3.6,36.8,5.3c6.4,0.9,13,1.1,19.1,2.6c8.7,2,17.5,2.6,26.2,4c9.5,1.6,19.3,2.8,29,3.8 c12.4,1.4,24.9,2.8,37.2,5.5c4,0.9,5.9-0.3,5.9-5.1C209.9,422.3,210,393.8,210,365.4z"/><path fill="#35ABD5" d="M495.7,385.7c0,35.3,0,70.6,0,106c0,7.7,0,7.8-7.9,6.7c-18.8-2.7-37.5-5.5-56.3-8.1 c-25.9-3.6-51.8-7-77.6-10.7c-24.5-3.4-49.1-6.9-73.6-10.6c-13.6-2.1-27.4-3.2-41-5.7c-4.3-0.8-4.4-2.7-4.4-5.9c0-32.5,0-65,0-97.5 c0-27.7,0-55.3,0-83c0-6.1,0.2-6.5,6.6-6.4c83.1,1.4,166.2,1.4,249.3,1.8c4.2,0,4.9,1.7,4.9,5.3 C495.7,313.7,495.7,349.7,495.7,385.7C495.7,385.7,495.7,385.7,495.7,385.7z M494,384.7c0-27.3,0-54.7,0-82c0-7.8,0-15.7,0-23.5 c0-2,0.4-4.1-2.7-4.3c-3.5-0.2-6.9-0.8-10.4-0.9c-34.8-0.6-69.6,0-104.4-0.8c-44.1-1-88.3-0.3-132.5-0.3c-7,0-7,0-7,6.8 c0,55.3,0,110.6,0,166c0,4,0.1,8,0,12c-0.1,3,1.2,4,4.2,4.2c4.8,0.3,9.5,1.4,14.3,1.5c8.3,0.2,16.2,3.1,24.6,3.5 c8.1,0.4,16.1,1.5,24.1,2.5c9.5,1.3,18.9,4,28.4,4.1c10.7,0.1,20.9,3.4,31.5,4c9.9,0.6,19.6,2.9,29.4,4.3 c11.6,1.6,23.3,2.8,34.9,4.7c9,1.5,18,2.2,27,3.4c9.4,1.3,18.6,3.5,28.1,3c0.7,0,1.5,0.7,2.2,1c5.8,2.5,8.3,0.9,8.3-5.5 C494,454,494,419.4,494,384.7z"/><path fill="#00ACEE" d="M210,153.8c0,28,0,56,0,83.9c0,8-0.3,8.3-8.1,8.3c-26.6,0-53.3,0.3-79.9,0c-32-0.4-63.9,1.5-95.8,1.1 c-6.5-0.1-7.2-0.7-7.2-7.1c0-48,0-95.9,0-143.9c0-6.2,0.8-7.3,6.8-7c6.9,0.4,13.1-3.2,19.9-3.4c8.1-0.2,16.1-1.9,24.1-3 c9.5-1.3,19.2-1.8,28.7-4.3c3.7-1,8-2.4,12.2-0.7c1.3,0.5,2.6,0.1,3.9-0.4c7.5-3.1,15.6-3,23.4-4.2c12.9-2,25.8-3.7,38.7-5.4 c6.5-0.9,13.1-2.1,19.7-2.5c3.1-0.2,5.6-2,8.6-2.2c3.8-0.2,5.2,0.8,5.2,4.9C210,96.5,210,125.1,210,153.8z"/><path fill="#00ACEE" d="M210,365.4c0,28.5-0.1,57,0.1,85.4c0,4.8-1.9,6-5.9,5.1c-12.3-2.7-24.8-4.2-37.2-5.5 c-9.7-1.1-19.5-2.3-29-3.8c-8.7-1.4-17.5-2-26.2-4c-6.1-1.4-12.7-1.7-19.1-2.6c-12.3-1.7-24.6-3-36.8-5.3 c-9.7-1.9-19.6-2.7-29.5-3.6c-6.5-0.6-7.4-1.1-7.4-7.7c0-48.1,0-96.3,0-144.4c0-6.3,0.7-7,6.8-7c13.8,0,27.7-0.6,41.5,0.1 c36.6,1.8,73.2,0,109.8,1.1c8.2,0.2,16.4-0.1,24.6-0.2c5.4,0,8.7,1.1,8.6,8.4C209.8,309.4,210,337.4,210,365.4z"/><path fill="#00ACEE" d="M494,384.7c0,34.7,0,69.3,0,104c0,6.4-2.5,8-8.3,5.5c-0.8-0.3-1.5-1-2.2-1c-9.5,0.5-18.8-1.7-28.1-3 c-9-1.2-18-1.9-27-3.4c-11.6-2-23.3-3.1-34.9-4.7c-9.8-1.4-19.6-3.7-29.4-4.3c-10.6-0.7-20.7-3.9-31.5-4 c-9.5-0.1-18.9-2.8-28.4-4.1c-8-1.1-16.1-2.1-24.1-2.5c-8.3-0.4-16.2-3.3-24.6-3.5c-4.8-0.1-9.5-1.2-14.3-1.5 c-2.9-0.2-4.2-1.3-4.2-4.2c0.1-4,0-8,0-12c0-55.3,0-110.6,0-166c0-6.8,0-6.8,7-6.8c44.2,0,88.3-0.7,132.5,0.3 c34.8,0.8,69.6,0.2,104.4,0.8c3.5,0.1,6.9,0.7,10.4,0.9c3.1,0.1,2.7,2.3,2.7,4.3c0,7.8,0,15.7,0,23.5 C494,330.1,494,357.4,494,384.7z"/></g></svg>', color:'#2563eb' },
{ key:'linux', label:'Linux', icon:'🐧', color:'#d97706' },
];
let tree = [], currentFilter = 'all', currentOSFilter = 'all';
function cat(key) { return CATEGORIES.find(c => c.key === key); }
// ── Stats ──
function updateStats(devices) {
const bar = document.getElementById('statsBar');
bar.innerHTML = CATEGORIES.filter(c => c.type === 'device').map(c => {
const n = devices.filter(d => d.device_type === c.key).length;
return `<div class="stat-item"><div class="stat-num">${n}</div><div class="stat-label">${c.label}</div></div>`;
}).join('');
}
// ── Filter bar ──
function renderFilter() {
document.getElementById('filterBar').innerHTML = CATEGORIES.map(c => {
const isActive = c.key === currentFilter;
let btnStyle = '';
let dotStyle = `background:${c.color}`;
if (isActive) {
if (c.key === 'all') {
btnStyle = 'background:var(--text-primary);color:#fff';
} else {
btnStyle = `background:${c.color};color:#fff`;
dotStyle = 'background:#fff';
}
}
return `<button class="pill ${isActive?'active':''}" onclick="setFilter('${c.key}')"
${btnStyle ? `style="${btnStyle}"` : ''}>
${c.key==='all' ? '' : `<span class="dot" style="${dotStyle}"></span>`}
${c.icon} ${c.label}
</button>`;
}).join('');
}
function setFilter(key) {
currentFilter = key; renderFilter(); render();
}
function setOSFilter(key) {
currentOSFilter = key; renderOSFilter(); render();
}
// ── OS Filter bar ──
function renderOSFilter() {
document.getElementById('osFilterBar').innerHTML = OS_FILTERS.map(c => {
const isActive = c.key === currentOSFilter;
let btnStyle = '';
let dotStyle = c.color ? `background:${c.color}` : '';
if (isActive) {
if (c.key === 'all') {
btnStyle = 'background:var(--text-primary);color:#fff';
} else {
btnStyle = `background:${c.color};color:#fff`;
dotStyle = 'background:#fff';
}
}
return `<button class="os-pill ${isActive?'active':''}" onclick="setOSFilter('${c.key}')"
${btnStyle ? `style="${btnStyle}"` : ''}>
${c.color ? `<span class="dot" style="${dotStyle}"></span>` : ''}
${c.icon} ${c.label}
</button>`;
}).join('');
}
// ── Load ──
async function load() {
try {
const r = await fetch('/api/drivers/devices/tree');
const data = await r.json();
tree = data.tree || [];
updateStats(tree);
renderFilter();
renderOSFilter();
document.getElementById('loading').style.display = 'none';
document.getElementById('appContainer').style.display = 'block';
render();
loadAnnouncements();
logVisit();
} catch(e) {
document.getElementById('loading').innerHTML = '<div style="color:#94a3b8;padding:60px"><div style="font-size:40px;margin-bottom:12px">⚠️</div><p>服务器连接失败</p></div>';
}
}
// ── Render ──
function render() {
const con = document.getElementById('appContainer');
let filtered = currentFilter === 'all' ? tree : tree.filter(d => d.device_type === currentFilter);
// Apply OS filter: filter each device's os_versions
if (currentOSFilter !== 'all') {
filtered = filtered.map(d => {
const match = (d.os_versions || []).filter(os => os.os_type === currentOSFilter);
return { ...d, os_versions: match };
});
// Remove devices with no matching OS versions
filtered = filtered.filter(d => d.os_versions && d.os_versions.length > 0);
}
if (filtered.length === 0) {
con.innerHTML = `<div class="empty"><div class="big-icon">📦</div><p>暂无设备</p></div>`;
return;
}
const groups = {};
for (const d of filtered) {
const c = cat(d.device_type);
const key = c ? c.label : d.device_type;
if (!groups[key]) groups[key] = [];
groups[key].push(d);
}
let html = '';
for (const [type, devices] of Object.entries(groups)) {
const c = cat(devices[0].device_type);
const accent = c ? c.color : '#64748b';
html += `<div class="section-title" style="color:${accent};border-bottom:2px solid ${accent}">
${c?c.icon:'📋'} ${type} <span class="count">${devices.length}</span>
</div><div class="grid">`;
for (const d of devices) {
const totalDls = d.os_versions?.reduce((s,o) => s + (o.downloads?.length||0), 0) || 0;
html += `<div class="card" onclick="toggleOS(${d.id})">
<div class="card-top">
<div class="card-icon" style="background:${accent}15;color:${accent}">${c?c.icon:'📋'}</div>
<div>
<div class="card-name">${d.name}</div>
${d.description ? `<div class="card-desc">${d.description}</div>` : ''}
</div>
<div class="card-tag">${totalDls} 项</div>
</div>
<div class="os-panel" id="osPanel${d.id}">
${d.os_versions?.length ? d.os_versions.map(os => `
<div class="os-row">
<div class="os-header" onclick="event.stopPropagation();toggleDL(${os.id})">
<span class="os-dot" style="background:${OS_COLORS[os.os_type]||'#94a3b8'}"></span>
<span>${OS_NAMES[os.os_type]||os.os_type}</span>
<span style="font-size:13px;font-weight:500;color:var(--text-primary)">${os.version_name}</span>
<span style="font-size:12px;color:var(--text-muted);margin-left:auto">${os.downloads?.length||0} 个文件</span>
</div>
<div class="dl-list" id="dlList${os.id}">
${os.downloads?.length ? os.downloads.map(dl => `
<div class="dl-item">
<span class="dl-icon">${FILE_ICONS[dl.file_type]||'📎'}</span>
<div class="dl-info">
<div class="dl-title">${dl.title}</div>
<div class="dl-meta">${FILE_NAMES[dl.file_type]||dl.file_type}${dl.file_size ? ' · '+dl.file_size : ''}</div>
</div>
<a class="dl-btn" style="background:${accent}" href="${dl.mega_link}" target="_blank" rel="noopener" onclick="event.stopPropagation();trackDownload(${dl.id},'${escAttr(dl.title)}','${dl.file_type}','${escAttr(d.name)}','${dl.os_type||''}')">下载</a>
</div>
`).join('') : '<div style="padding:10px 20px 10px 48px;color:#94a3b8;font-size:13px;">暂无下载项</div>'}
</div>
</div>
`).join('') : '<div style="padding:14px 20px;color:#94a3b8;font-size:13px;">暂无系统版本</div>'}
</div>
</div>`;
}
html += '</div>';
}
con.innerHTML = html;
}
// ── Theme Toggle ──
function toggleTheme() {
const html = document.documentElement;
const btn = document.getElementById('themeToggle');
if (html.getAttribute('data-theme') === 'warm') {
html.setAttribute('data-theme', 'cool');
btn.textContent = '❄️';
btn.title = '切换暖色调';
} else {
html.setAttribute('data-theme', 'warm');
btn.textContent = '☀️';
btn.title = '切换冷色调';
}
localStorage.setItem('drivers_theme', html.getAttribute('data-theme'));
}
// Apply saved theme on load
(function() {
const saved = localStorage.getItem('drivers_theme');
if (saved) {
document.documentElement.setAttribute('data-theme', saved);
document.getElementById('themeToggle').textContent = saved === 'warm' ? '☀️' : '❄️';
}
})();
// ── Toggle ──
function toggleOS(id) {
const p = document.getElementById('osPanel'+id);
document.querySelectorAll('.os-panel.open').forEach(el => { if (el !== p) el.classList.remove('open'); });
p?.classList.toggle('open');
}
function toggleDL(id) {
document.getElementById('dlList'+id)?.classList.toggle('open');
}
// ── Announcements ──
async function loadAnnouncements() {
try {
const r = await fetch('/api/drivers/announcements/active');
const data = await r.json();
const list = data.announcements || [];
const el = document.getElementById('announceBanner');
if (!list.length) { el.innerHTML = ''; return; }
el.innerHTML = list.map(a => `
<div class="announce-item ${a.kind||'公告'}">
<span class="kind">[${a.kind||'公告'}]</span>
${a.title ? `<span class="title">${esc(a.title)}:</span>` : ''}
<span class="content">${esc(a.content)}</span>
</div>
`).join('');
} catch(e) { /* silent */ }
}
// ── Visit tracking ──
async function logVisit() {
try {
await fetch('/api/drivers/visit', { method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({ path:location.pathname })
});
} catch(e) { /* silent */ }
}
// ── Download click tracking ──
async function trackDownload(dlId, title, fileType, deviceName, osName) {
try {
await fetch('/api/drivers/download-click', { method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({ download_id:dlId, title, file_type:fileType, device_name:deviceName, os_name:osName })
});
} catch(e) { /* silent */ }
}
function esc(s) { if (!s) return ''; const d=document.createElement('div'); d.textContent=s; return d.innerHTML; }
function escAttr(s) { if (!s) return ''; return esc(s).replace(/"/g,'"').replace(/'/g,'''); }
// ── SN Lookup ──
const OS_ICONS = { android:'⭐', windows:'💠', linux:'🐧' };
function formatSize(bytes) {
if (!bytes || bytes <= 0) return '';
if (bytes < 1024) return bytes + ' B';
if (bytes < 1024*1024) return (bytes/1024).toFixed(1) + ' KB';
if (bytes < 1024*1024*1024) return (bytes/1024/1024).toFixed(1) + ' MB';
return (bytes/1024/1024/1024).toFixed(2) + ' GB';
}
// ── Progress UI ──
function buildProgressUI(pct, msg) {
const width = Math.max(pct, 3);
return `<div class="sn-progress">
<div class="sn-progress-bar-wrap">
<div class="sn-progress-bar" style="width:${width}%"></div>
</div>
<div class="sn-progress-text">
<span class="sn-progress-dot"></span>
${esc(msg)}
</div>
</div>`;
}
function updateProgressUI(pct, msg) {
const bar = document.querySelector('.sn-progress-bar');
const text = document.querySelector('.sn-progress-text');
if (bar) bar.style.width = Math.max(pct, 3) + '%';
if (text) text.innerHTML = `<span class="sn-progress-dot"></span> ${esc(msg)}`;
}
function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
// ── Build result HTML from data ──
function buildResultHTML(data) {
const osTypeLower = (data.os_type||'').toLowerCase();
const isWindows = osTypeLower.includes('windows');
const osIcon = OS_ICONS[osTypeLower.replace(/[\d]/g,'')] || '💿';
let osListHtml = '';
if (data.os_versions && data.os_versions.length > 0) {
osListHtml = data.os_versions.map(ov => {
const srcLabel = ov.source === 'ASD_OS' ? '客制化系统' : '中性系统';
const compLabel = ov.component === 'scd' ? 'SCD' : ov.component === 'rcd' ? 'RCD' : '';
const compBadge = compLabel
? `<span style="display:inline-block;padding:1px 6px;border-radius:3px;font-size:10px;font-weight:700;margin-right:4px;background:#e0e7ff;color:#4338ca">${compLabel}</span>`
: '';
return `<div style="font-size:12px;line-height:1.5">
<span style="display:inline-block;padding:1px 8px;border-radius:4px;font-size:11px;font-weight:600;margin-right:6px;background:${ov.source==='ASD_OS'?'#dbeafe':'#f1f5f9'};color:${ov.source==='ASD_OS'?'#1d4ed8':'#64748b'}">${srcLabel}</span>
${compBadge}
<span>${esc(ov.os_version)}</span>
</div>`;
}).join('');
}
let html = `<div class="sn-result-card success">
<div class="sn-result-header">✅ 查询成功</div>
<div class="sn-result-body">
<div class="sn-info-grid">
<span class="sn-info-label">SN</span>
<span class="sn-info-value">${esc(data.sn)}</span>
${data.model ? `<span class="sn-info-label">设备型号</span>
<span class="sn-info-value">${esc(data.model)}</span>` : ''}
${data.os_type ? `<span class="sn-info-label">系统类型</span>
<span class="sn-info-value">${osIcon} ${esc(data.os_type)}</span>` : ''}
<span class="sn-info-label">OS 版本</span>
<span class="sn-info-value">${osListHtml || esc(data.os_version)}</span>`;
if (isWindows) {
if (data.bios_version) {
html += `<span class="sn-info-label">BIOS 版本</span>
<span class="sn-info-value" style="font-family:monospace;font-size:12px">${esc(data.bios_version)}</span>`;
}
if (data.ec_version) {
html += `<span class="sn-info-label">EC 版本</span>
<span class="sn-info-value" style="font-family:monospace;font-size:12px">${esc(data.ec_version)}</span>`;
}
}
html += `</div>`; // close sn-info-grid
if (data.downloads && data.downloads.length > 0) {
if (isWindows && data.windows_components) {
const groups = { scd: [], rcd: [], bios: [], ec: [] };
data.downloads.forEach(dl => {
const c = dl.component || 'os';
if (groups[c]) groups[c].push(dl);
else { groups.os = groups.os || []; groups.os.push(dl); }
});
const compMeta = {
scd: { label: 'OS 系统 (SCD)', icon: '💿', color: '#2563eb' },
rcd: { label: 'OS 系统 (RCD)', icon: '💿', color: '#2563eb' },
bios: { label: 'BIOS 固件', icon: '⚡', color: '#d97706' },
ec: { label: 'EC 固件', icon: '🔌', color: '#059669' },
};
for (const [key, items] of Object.entries(groups)) {
if (!items.length) continue;
const meta = compMeta[key] || { label: '文件', icon: '📦', color: '#64748b' };
html += `<div class="sn-downloads-title">${meta.icon} ${meta.label}(${items.length} 项)</div>`;
items.forEach(dl => {
const srcLabel = dl.source === 'ASD_OS' ? '客制化' : dl.source === 'MID_OSVERSION' ? '中性' : dl.source === 'BIOS' ? 'BIOS' : dl.source === 'EC' ? 'EC' : '';
const srcBadge = srcLabel
? `<span style="display:inline-block;padding:0 6px;border-radius:3px;font-size:10px;font-weight:600;margin-left:6px;background:#f1f5f9;color:#64748b">${srcLabel}</span>`
: '';
html += `<div class="sn-dl-item">
<span class="sn-dl-icon">${meta.icon}</span>
<div class="sn-dl-info">
<div class="sn-dl-name">${esc(dl.name)}${srcBadge}</div>
<div class="sn-dl-size">${formatSize(dl.size)}</div>
</div>
${dl.link
? `<a class="sn-dl-btn" style="background:${meta.color}" href="${escAttr(dl.link)}" target="_blank" rel="noopener">下载</a>`
: `<span style="font-size:11px;color:var(--text-muted);flex-shrink:0">链接不可用</span>`
}
</div>`;
});
}
} else {
html += `<div class="sn-downloads-title">📥 下载文件(${data.downloads.length} 项)</div>`;
data.downloads.forEach(dl => {
const accent = '#3b82f6';
const srcLabel = dl.source === 'ASD_OS' ? '客制化' : dl.source === 'MID_OSVERSION' ? '中性' : '';
const srcBadge = srcLabel
? `<span style="display:inline-block;padding:0 6px;border-radius:3px;font-size:10px;font-weight:600;margin-left:6px;background:${dl.source==='ASD_OS'?'#dbeafe':'#f1f5f9'};color:${dl.source==='ASD_OS'?'#1d4ed8':'#64748b'}">${srcLabel}</span>`
: '';
html += `<div class="sn-dl-item">
<span class="sn-dl-icon">📦</span>
<div class="sn-dl-info">
<div class="sn-dl-name">${esc(dl.name)}${srcBadge}</div>
<div class="sn-dl-size">${formatSize(dl.size)}</div>
</div>
${dl.link
? `<a class="sn-dl-btn" style="background:${accent}" href="${escAttr(dl.link)}" target="_blank" rel="noopener">下载</a>`
: `<span style="font-size:11px;color:var(--text-muted);flex-shrink:0">链接不可用</span>`
}
</div>`;
});
}
} else {
html += `<div style="margin-top:12px;padding:12px;border-radius:8px;background:var(--bg-subtle);color:var(--text-muted);font-size:13px;text-align:center">
⚠️ 未找到匹配的固件文件下载链接
</div>`;
}
html += `</div></div>`;
return html;
}
async function snSearch() {
const input = document.getElementById('snInput');
const btn = document.getElementById('snSearchBtn');
const result = document.getElementById('snResult');
const sn = input.value.trim();
if (!sn) { input.focus(); return; }
btn.disabled = true;
btn.classList.add('loading');
btn.textContent = '查询中';
result.className = 'sn-result';
result.innerHTML = buildProgressUI(0, '正在启动查询...');
result.className = 'sn-result open';
let pollActive = true;
try {
const taskResp = await fetch('/api/drivers/sn-lookup', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ sn }),
});
const ct = taskResp.headers.get('content-type') || '';
if (!ct.includes('application/json')) {
const text = await taskResp.text();
throw new Error(text.slice(0, 200));
}
const taskData = await taskResp.json();
const taskId = taskData.task_id;
if (!taskId) throw new Error('未获取到任务 ID');
while (pollActive) {
await sleep(800);
const statusResp = await fetch(`/api/drivers/sn-lookup/status/${taskId}`);
if (!statusResp.ok) {
const errText = await statusResp.text();
throw new Error(errText.slice(0, 200));
}
const status = await statusResp.json();
updateProgressUI(status.progress, status.message);
if (status.status === 'done') {
pollActive = false;
if (status.result) {
result.innerHTML = buildResultHTML(status.result);
} else {
showSnResult('error', '⚠️', status.error || '查询完成但无结果');
}
} else if (status.status === 'error') {
pollActive = false;
showSnResult('error', '⚠️', status.error || '查询失败');
}
}
} catch(e) {
pollActive = false;
showSnResult('error', '⚠️', '查询失败:' + e.message);
} finally {
btn.disabled = false;
btn.classList.remove('loading');
btn.textContent = '查 询';
}
}
function showSnResult(type, icon, msg) {
const result = document.getElementById('snResult');
result.innerHTML = `<div class="sn-result-card ${type}">
<div class="sn-result-header">${icon} ${esc(msg)}</div>
</div>`;
result.className = 'sn-result open';
}
load();
</script>
</body>
</html>
<html lang="zh-CN" data-theme="cool">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>驱动下载中心</title>
<style>
/* ════════════════════════════════════════
Design System — Theme Variables
════════════════════════════════════════ */
:root {
/* Cool theme (default) */
--bg-page: #f0f4f8;
--bg-card: #ffffff;
--bg-elevated: #ffffff;
--bg-subtle: #f8fafc;
--text-primary: #0f172a;
--text-secondary: #475569;
--text-muted: #94a3b8;
--border-light: #e2e8f0;
--border-subtle: #f1f5f9;
--shadow-card: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
--shadow-hover: 0 10px 30px -5px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
--shadow-panel: 0 4px 6px -1px rgba(0,0,0,.03);
--header-start: #0b1426;
--header-mid: #14203a;
--header-end: #0b1426;
--header-text: #f1f5f9;
--header-sub: #64748b;
--header-accent-glow-1: rgba(59,130,246,.08);
--header-accent-glow-2: rgba(139,92,246,.08);
--pill-bg: #f1f5f9;
--pill-text: #475569;
--pill-hover: #e2e8f0;
--tag-bg: #f1f5f9;
--tag-text: #64748b;
--section-divider: #e2e8f0;
--filter-bar-bg: rgba(255,255,255,.85);
--filter-bar-border: #e2e8f0;
--accent-cool: #3b82f6;
--os-android: #16a34a;
--os-windows: #2563eb;
--os-linux: #d97706;
--spinner-track: #e2e8f0;
--spinner-accent: #0f172a;
--bg-pattern: rgba(59,130,246,.015);
}
[data-theme="warm"] {
--bg-page: #fef7ee;
--bg-card: #ffffff;
--bg-elevated: #ffffff;
--bg-subtle: #fffbeb;
--text-primary: #1c1917;
--text-secondary: #57534e;
--text-muted: #a8a29e;
--border-light: #e7e5e4;
--border-subtle: #f5f5f4;
--shadow-card: 0 1px 3px rgba(120,80,40,.04), 0 1px 2px rgba(120,80,40,.06);
--shadow-hover: 0 10px 30px -5px rgba(120,80,40,.1), 0 4px 6px -2px rgba(120,80,40,.05);
--shadow-panel: 0 4px 6px -1px rgba(120,80,40,.03);
--header-start: #1c130d;
--header-mid: #2d1f14;
--header-end: #1c130d;
--header-text: #fefce8;
--header-sub: #a8a29e;
--header-accent-glow-1: rgba(245,158,11,.07);
--header-accent-glow-2: rgba(239,68,68,.06);
--pill-bg: #fef3c7;
--pill-text: #92400e;
--pill-hover: #fde68a;
--tag-bg: #fef3c7;
--tag-text: #b45309;
--section-divider: #e7e5e4;
--filter-bar-bg: rgba(255,252,245,.88);
--filter-bar-border: #e7e5e4;
--accent-cool: #d97706;
--os-android: #16a34a;
--os-windows: #2563eb;
--os-linux: #dc2626;
--spinner-track: #e7e5e4;
--spinner-accent: #1c1917;
--bg-pattern: rgba(245,158,11,.015);
}
/* ── Reset & Base ── */
* { margin:0; padding:0; box-sizing:border-box; }
body {
font-family:"PingFang SC","Microsoft YaHei","Noto Sans SC","Helvetica Neue",sans-serif;
background:var(--bg-page); color:var(--text-primary); min-height:100vh;
transition:background .4s ease,color .3s ease;
}
/* subtle grid pattern */
body::before {
content:''; position:fixed; inset:0; z-index:-1;
background-image:
linear-gradient(var(--bg-pattern) 1px, transparent 1px),
linear-gradient(90deg, var(--bg-pattern) 1px, transparent 1px);
background-size:60px 60px;