添加 sys.html

这个提交包含在:
2026-08-22 02:18:14 +08:00
父节点 caad5678cb
当前提交 80b94f9cd9
+438
查看文件
@@ -0,0 +1,438 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>系统侦探 - OS Detective</title>
<style>
:root{--bg:#0f172a;--card:#1e293b;--accent:#38bdf8;--accent2:#a78bfa;--success:#34d399;--danger:#f87171;--warning:#fbbf24;--text:#f1f5f9;--muted:#94a3b8}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Segoe UI','Microsoft YaHei',system-ui,sans-serif;background:var(--bg);color:var(--text);min-height:100vh;display:flex;justify-content:center;align-items:flex-start;padding:40px 16px}
.container{max-width:720px;width:100%}
h1{text-align:center;margin-bottom:4px;font-size:1.8rem}
.subtitle{text-align:center;color:var(--muted);font-size:.95rem;margin-bottom:24px}
.mode-select{display:flex;gap:12px;justify-content:center;margin-bottom:24px;flex-wrap:wrap}
.mode-btn{padding:12px 28px;border-radius:12px;border:2px solid var(--accent);background:transparent;color:var(--accent);font-weight:600;cursor:pointer;transition:all .2s;font-size:1rem}
.mode-btn:hover,.mode-btn.active{background:var(--accent);color:var(--bg)}
.game-area{display:none}
.game-area.active{display:block;animation:fadeIn .4s ease}
@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
.progress-bar{height:6px;background:#334155;border-radius:3px;margin-bottom:16px;overflow:hidden}
.progress-fill{height:100%;background:linear-gradient(90deg,var(--accent),var(--accent2));border-radius:3px;transition:width .4s ease}
.question-box{background:var(--card);padding:20px;border-radius:12px;margin-bottom:16px;border-left:4px solid var(--accent)}
.question-text{font-size:1.1rem;font-weight:600;margin-bottom:12px}
.options{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.opt-btn{padding:14px;border-radius:10px;border:1px solid #334155;background:#0f172a;color:var(--text);cursor:pointer;transition:all .15s;font-size:.95rem;text-align:left}
.opt-btn:hover{border-color:var(--accent);background:#1e293b;transform:translateY(-1px)}
.history{margin-top:16px}
.history-title{font-size:.85rem;color:var(--muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:1px}
.history-item{display:flex;align-items:center;gap:8px;padding:8px 12px;background:var(--card);border-radius:8px;margin-bottom:6px;font-size:.9rem}
.history-item .q{color:var(--muted)}
.history-item .a{color:var(--accent);font-weight:600}
.result-box{text-align:center;padding:32px;background:var(--card);border-radius:16px;display:none}
.result-box.active{display:block;animation:popIn .5s ease}
@keyframes popIn{0%{transform:scale(.8);opacity:0}100%{transform:scale(1);opacity:1}}
.result-icon{font-size:4rem;margin-bottom:12px}
.result-name{font-size:1.5rem;font-weight:700;margin-bottom:8px}
.result-desc{color:var(--muted);margin-bottom:20px;line-height:1.6}
.restart-btn{padding:12px 32px;border-radius:12px;border:none;background:linear-gradient(135deg,var(--accent),var(--accent2));color:#fff;font-weight:700;font-size:1rem;cursor:pointer;transition:transform .2s}
.restart-btn:hover{transform:scale(1.05)}
.stats{display:flex;justify-content:center;gap:24px;margin-bottom:16px;font-size:.9rem;color:var(--muted);flex-wrap:wrap}
.stat span{color:var(--text);font-weight:700}
.remaining-hint{text-align:center;color:var(--muted);font-size:.85rem;margin-top:8px}
.badge{display:inline-block;padding:2px 10px;border-radius:20px;font-size:.75rem;font-weight:700;margin-left:8px}
.badge-easy{background:var(--success);color:#064e3b}
.badge-normal{background:var(--warning);color:#78350f}
.badge-hard{background:var(--danger);color:#7f1d1d}
.ai-ask-box{background:linear-gradient(135deg,#1e293b,#0f172a);border:1px solid var(--accent2);border-radius:12px;padding:16px;margin-bottom:16px}
.ai-ask-title{color:var(--accent2);font-weight:700;margin-bottom:8px;display:flex;align-items:center;gap:6px}
.ai-ask-input{width:100%;padding:10px 14px;border-radius:8px;border:1px solid #334155;background:#0f172a;color:var(--text);font-size:.95rem;margin-bottom:10px;box-sizing:border-box}
.ai-ask-input:focus{outline:none;border-color:var(--accent)}
.ai-ask-btns{display:flex;gap:8px;flex-wrap:wrap}
.ai-ask-btn{padding:8px 16px;border-radius:8px;border:1px solid #334155;background:#1e293b;color:var(--text);cursor:pointer;font-size:.85rem;transition:all .15s}
.ai-ask-btn:hover{border-color:var(--accent2);background:#0f172a}
.ai-ask-btn.primary{background:var(--accent2);color:#fff;border-color:var(--accent2)}
.ai-ask-btn.primary:hover{background:#8b5cf6}
.or-divider{text-align:center;color:var(--muted);margin:12px 0;font-size:.85rem;position:relative}
.or-divider::before,.or-divider::after{content:'';position:absolute;top:50%;width:40%;height:1px;background:#334155}
.or-divider::before{left:0}
.or-divider::after{right:0}
.turn-indicator{text-align:center;margin-bottom:12px;font-size:.95rem}
.turn-indicator .turn-ai{color:var(--accent);font-weight:700}
.turn-indicator .turn-user{color:var(--accent2);font-weight:700}
.asked-questions{margin-top:12px}
.asked-item{padding:6px 10px;background:#0f172a;border-radius:6px;margin-bottom:4px;font-size:.85rem;color:var(--muted)}
.asked-item .ans{color:var(--success);font-weight:600}
.asked-item .ans-mix{color:var(--warning);font-weight:600}
.asked-item .ans-no{color:var(--danger);font-weight:600}
.footer{text-align:center;color:var(--muted);font-size:.8rem;margin-top:24px}
</style>
<base target="_blank">
</head>
<body>
<div class="container">
<h1>🖥️ 系统侦探</h1>
<p class="subtitle">在心里想一个操作系统……我会一步一步猜出来!你也可以反过来问我!</p>
<div id="menu" class="game-area active">
<div class="mode-select">
<button class="mode-btn" onclick="startGame('easy')">😊 简单 <span class="badge badge-easy">12 问</span></button>
<button class="mode-btn" onclick="startGame('normal')">😐 普通 <span class="badge badge-normal">8 问</span></button>
<button class="mode-btn" onclick="startGame('hard')">😈 困难 <span class="badge badge-hard">5 问</span></button>
</div>
<p style="text-align:center;color:var(--muted);font-size:.85rem">
包含 Windows、macOS、Linux 发行版、移动端系统、复古系统 等 50+ 款!<br>
<b>新玩法</b>AI 问完你也可以<b>反问 AI</b> 系统特征!
</p>
</div>
<div id="play" class="game-area">
<div class="stats">
<div class="stat">模式:<span id="mode-display">-</span></div>
<div class="stat">进度:<span id="step-display">1</span>/<span id="max-display">-</span></div>
<div class="stat">候选:<span id="cand-display">-</span></div>
</div>
<div class="progress-bar"><div class="progress-fill" id="progress" style="width:0%"></div></div>
<div class="turn-indicator" id="turn-indicator"><span class="turn-ai">🤖 AI 正在提问……</span></div>
<div id="ai-question-area">
<div class="question-box">
<div class="question-text" id="question">加载中……</div>
<div class="options" id="options"></div>
</div>
</div>
<div class="or-divider" id="or-divider" style="display:none">或者</div>
<div class="ai-ask-box" id="user-ask-box" style="display:none">
<div class="ai-ask-title">🙋 轮到你了!向 AI 提问系统特征</div>
<input type="text" class="ai-ask-input" id="user-ask-input" placeholder="例如:这个系统支持 Docker 吗?" onkeydown="if(event.key==='Enter')handleUserAsk()">
<div class="ai-ask-btns">
<button class="ai-ask-btn primary" onclick="handleUserAsk()">🔍 提问</button>
<button class="ai-ask-btn" onclick="usePresetAsk('它是开源的吗?')">是否开源</button>
<button class="ai-ask-btn" onclick="usePresetAsk('它支持图形界面吗?')">是否有 GUI</button>
<button class="ai-ask-btn" onclick="usePresetAsk('它常用于服务器吗?')">是否服务器</button>
<button class="ai-ask-btn" onclick="usePresetAsk('它支持游戏吗?')">是否游戏</button>
<button class="ai-ask-btn" onclick="usePresetAsk('它是移动操作系统吗?')">是否移动</button>
<button class="ai-ask-btn" onclick="usePresetAsk('它支持 Docker 吗?')">Docker</button>
<button class="ai-ask-btn" onclick="usePresetAsk('它使用 systemd 吗?')">systemd</button>
<button class="ai-ask-btn" onclick="usePresetAsk('它支持 Wayland 吗?')">Wayland</button>
<button class="ai-ask-btn" onclick="skipUserAsk()">⏭️ 跳过,让 AI 继续</button>
</div>
<div class="asked-questions" id="asked-questions"></div>
</div>
<div class="remaining-hint" id="remaining-hint"></div>
<div class="history" id="history"></div>
</div>
<div id="result" class="result-box">
<div class="result-icon" id="res-icon">🎯</div>
<div class="result-name" id="res-name"></div>
<div class="result-desc" id="res-desc"></div>
<button class="restart-btn" onclick="resetGame()">🔄 再来一局</button>
</div>
<div class="footer">系统侦探 v2.0 | 50+ 款操作系统数据库 | 支持双向提问</div>
</div>
<script>
const OS_DB=[
{name:"Windows 11",family:"windows",type:"desktop",kernel:"nt",gui:true,openSource:false,mobile:false,unixLike:false,year:2021,vendor:"microsoft",gaming:true,server:false,package:"msi/exe",shell:"cmd/powershell",popularity:10,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:true,wsl:true,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:true,vr:true,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"Windows 10",family:"windows",type:"desktop",kernel:"nt",gui:true,openSource:false,mobile:false,unixLike:false,year:2015,vendor:"microsoft",gaming:true,server:false,package:"msi/exe",shell:"cmd/powershell",popularity:9,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:true,wsl:true,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:true,vr:true,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"Windows 7",family:"windows",type:"desktop",kernel:"nt",gui:true,openSource:false,mobile:false,unixLike:false,year:2009,vendor:"microsoft",gaming:true,server:false,package:"msi/exe",shell:"cmd/powershell",popularity:7,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:true,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:false,riscv:false,loongarch:false},
{name:"Windows XP",family:"windows",type:"desktop",kernel:"nt",gui:true,openSource:false,mobile:false,unixLike:false,year:2001,vendor:"microsoft",gaming:true,server:false,package:"msi/exe",shell:"cmd",popularity:6,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:true,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:false,riscv:false,loongarch:false},
{name:"Windows Server 2022",family:"windows",type:"server",kernel:"nt",gui:true,openSource:false,mobile:false,unixLike:false,year:2021,vendor:"microsoft",gaming:false,server:true,package:"msi/exe",shell:"powershell",popularity:5,docker:true,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:true,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:false,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"macOS Sonoma",family:"macos",type:"desktop",kernel:"xnu",gui:true,openSource:false,mobile:false,unixLike:true,year:2023,vendor:"apple",gaming:false,server:false,package:"dmg/pkg",shell:"zsh",popularity:8,docker:true,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"macOS Ventura",family:"macos",type:"desktop",kernel:"xnu",gui:true,openSource:false,mobile:false,unixLike:true,year:2022,vendor:"apple",gaming:false,server:false,package:"dmg/pkg",shell:"zsh",popularity:7,docker:true,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"Ubuntu",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2004,vendor:"canonical",gaming:true,server:true,package:"deb/snap",shell:"bash",popularity:9,docker:true,systemd:true,wayland:true,flatpak:true,snap:true,wine:true,wsl:false,btrfs:true,zfs:true,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:true,cloud:true,arm:true,riscv:true,loongarch:true},
{name:"Debian",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:1993,vendor:"community",gaming:false,server:true,package:"deb",shell:"bash",popularity:7,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:true,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:true,loongarch:true},
{name:"Fedora",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2003,vendor:"redhat",gaming:true,server:false,package:"rpm",shell:"bash",popularity:6,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:false,selinux:true,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:true,loongarch:true},
{name:"Arch Linux",family:"linux",type:"desktop",kernel:"linux",gui:false,openSource:true,mobile:false,unixLike:true,year:2002,vendor:"community",gaming:true,server:false,package:"pacman",shell:"bash",popularity:6,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:true,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:true},
{name:"Manjaro",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2011,vendor:"community",gaming:true,server:false,package:"pacman",shell:"bash",popularity:5,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:true,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:true},
{name:"Linux Mint",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2006,vendor:"community",gaming:true,server:false,package:"deb",shell:"bash",popularity:7,docker:true,systemd:true,wayland:false,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"CentOS Stream",family:"linux",type:"server",kernel:"linux",gui:false,openSource:true,mobile:false,unixLike:true,year:2019,vendor:"redhat",gaming:false,server:true,package:"rpm",shell:"bash",popularity:5,docker:true,systemd:true,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:true,zfs:false,selinux:true,apparmor:false,firewall:true,bluetooth:false,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"RHEL",family:"linux",type:"server",kernel:"linux",gui:false,openSource:true,mobile:false,unixLike:true,year:2000,vendor:"redhat",gaming:false,server:true,package:"rpm",shell:"bash",popularity:6,docker:true,systemd:true,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:true,zfs:false,selinux:true,apparmor:false,firewall:true,bluetooth:false,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"Kali Linux",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2013,vendor:"offensive-security",gaming:false,server:false,package:"deb",shell:"bash",popularity:6,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:true,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:true},
{name:"openSUSE",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2005,vendor:"community",gaming:false,server:true,package:"rpm",shell:"bash",popularity:4,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:true,selinux:true,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:true,loongarch:true},
{name:"Gentoo",family:"linux",type:"desktop",kernel:"linux",gui:false,openSource:true,mobile:false,unixLike:true,year:2000,vendor:"community",gaming:false,server:false,package:"portage",shell:"bash",popularity:3,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:true,selinux:true,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:true},
{name:"Alpine Linux",family:"linux",type:"server",kernel:"linux",gui:false,openSource:true,mobile:false,unixLike:true,year:2005,vendor:"community",gaming:false,server:true,package:"apk",shell:"ash",popularity:5,docker:true,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:false,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:true,loongarch:true},
{name:"iOS",family:"ios",type:"mobile",kernel:"xnu",gui:true,openSource:false,mobile:true,unixLike:true,year:2007,vendor:"apple",gaming:true,server:false,package:"ipa",shell:"none",popularity:10,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:true,vr:false,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"iPadOS",family:"ios",type:"mobile",kernel:"xnu",gui:true,openSource:false,mobile:true,unixLike:true,year:2019,vendor:"apple",gaming:true,server:false,package:"ipa",shell:"none",popularity:7,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:true,vr:false,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"Android",family:"android",type:"mobile",kernel:"linux",gui:true,openSource:true,mobile:true,unixLike:true,year:2008,vendor:"google",gaming:true,server:false,package:"apk",shell:"none",popularity:10,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:true,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:true,vr:true,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"HarmonyOS",family:"harmonyos",type:"mobile",kernel:"linux",gui:true,openSource:true,mobile:true,unixLike:true,year:2019,vendor:"huawei",gaming:true,server:false,package:"hap",shell:"none",popularity:6,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:true,vr:false,ai:true,cloud:true,arm:true,riscv:false,loongarch:true},
{name:"Chrome OS",family:"chromeos",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2011,vendor:"google",gaming:false,server:false,package:"web",shell:"bash",popularity:5,docker:false,systemd:true,wayland:true,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:true,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:true,vr:false,ai:false,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"FreeBSD",family:"bsd",type:"server",kernel:"bsd",gui:false,openSource:true,mobile:false,unixLike:true,year:1993,vendor:"community",gaming:false,server:true,package:"pkg",shell:"sh",popularity:4,docker:true,systemd:false,wayland:false,flatpak:false,snap:false,wine:true,wsl:false,btrfs:false,zfs:true,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:true,loongarch:false},
{name:"OpenBSD",family:"bsd",type:"server",kernel:"bsd",gui:false,openSource:true,mobile:false,unixLike:true,year:1996,vendor:"community",gaming:false,server:true,package:"pkg",shell:"ksh",popularity:3,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:false},
{name:"NetBSD",family:"bsd",type:"server",kernel:"bsd",gui:false,openSource:true,mobile:false,unixLike:true,year:1993,vendor:"community",gaming:false,server:true,package:"pkg",shell:"sh",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:true},
{name:"Solaris",family:"solaris",type:"server",kernel:"solaris",gui:true,openSource:false,mobile:false,unixLike:true,year:1992,vendor:"oracle",gaming:false,server:true,package:"pkg",shell:"sh",popularity:2,docker:true,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:true,selinux:true,apparmor:false,firewall:true,bluetooth:false,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:true,arm:false,riscv:false,loongarch:false},
{name:"AIX",family:"unix",type:"server",kernel:"unix",gui:true,openSource:false,mobile:false,unixLike:true,year:1986,vendor:"ibm",gaming:false,server:true,package:"rpm",shell:"ksh",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:true,selinux:false,apparmor:false,firewall:true,bluetooth:false,wifi:false,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:false,riscv:false,loongarch:false},
{name:"HP-UX",family:"unix",type:"server",kernel:"unix",gui:true,openSource:false,mobile:false,unixLike:true,year:1984,vendor:"hp",gaming:false,server:true,package:"swinstall",shell:"sh",popularity:1,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:true,selinux:false,apparmor:false,firewall:true,bluetooth:false,wifi:false,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:false,riscv:false,loongarch:false},
{name:"MS-DOS",family:"dos",type:"desktop",kernel:"dos",gui:false,openSource:false,mobile:false,unixLike:false,year:1981,vendor:"microsoft",gaming:true,server:false,package:"exe",shell:"command",popularity:4,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:false,bluetooth:false,wifi:false,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:false,riscv:false,loongarch:false},
{name:"TempleOS",family:"templeos",type:"desktop",kernel:"custom",gui:true,openSource:true,mobile:false,unixLike:false,year:2013,vendor:"community",gaming:true,server:false,package:"custom",shell:"holyC",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:false,bluetooth:false,wifi:false,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:false,riscv:false,loongarch:false},
{name:"ReactOS",family:"windows",type:"desktop",kernel:"nt-like",gui:true,openSource:true,mobile:false,unixLike:false,year:1996,vendor:"community",gaming:false,server:false,package:"exe",shell:"cmd",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:false,riscv:false,loongarch:false},
{name:"Haiku",family:"beos",type:"desktop",kernel:"custom",gui:true,openSource:true,mobile:false,unixLike:false,year:2001,vendor:"community",gaming:false,server:false,package:"hpkg",shell:"bash",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:false},
{name:"AmigaOS",family:"amiga",type:"desktop",kernel:"custom",gui:true,openSource:false,mobile:false,unixLike:false,year:1985,vendor:"commodore",gaming:true,server:false,package:"custom",shell:"amigados",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:false,bluetooth:false,wifi:false,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"MorphOS",family:"amiga",type:"desktop",kernel:"custom",gui:true,openSource:false,mobile:false,unixLike:false,year:2000,vendor:"community",gaming:true,server:false,package:"custom",shell:"ambientshell",popularity:1,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:false,bluetooth:false,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"QNX",family:"qnx",type:"embedded",kernel:"microkernel",gui:true,openSource:false,mobile:false,unixLike:true,year:1982,vendor:"blackberry",gaming:false,server:false,package:"pkg",shell:"ksh",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"VxWorks",family:"vxworks",type:"embedded",kernel:"custom",gui:false,openSource:false,mobile:false,unixLike:false,year:1987,vendor:"windriver",gaming:false,server:false,package:"custom",shell:"c",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:false},
{name:"watchOS",family:"ios",type:"wearable",kernel:"xnu",gui:true,openSource:false,mobile:false,unixLike:true,year:2015,vendor:"apple",gaming:false,server:false,package:"ipa",shell:"none",popularity:5,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:false,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"Wear OS",family:"android",type:"wearable",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2014,vendor:"google",gaming:false,server:false,package:"apk",shell:"none",popularity:4,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:true,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"Tizen",family:"tizen",type:"mobile",kernel:"linux",gui:true,openSource:true,mobile:true,unixLike:true,year:2012,vendor:"samsung",gaming:false,server:false,package:"wgt",shell:"none",popularity:3,docker:false,systemd:true,wayland:true,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:true,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:true,vr:false,ai:true,cloud:true,arm:true,riscv:false,loongarch:false},
{name:"KaiOS",family:"kaios",type:"mobile",kernel:"linux",gui:true,openSource:true,mobile:true,unixLike:true,year:2017,vendor:"kaios",gaming:false,server:false,package:"web",shell:"none",popularity:3,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:false,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"SteamOS",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2013,vendor:"valve",gaming:true,server:false,package:"deb",shell:"bash",popularity:4,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:true,ai:false,cloud:false,arm:false,riscv:false,loongarch:false},
{name:"Raspberry Pi OS",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2012,vendor:"raspberrypi",gaming:false,server:false,package:"deb",shell:"bash",popularity:5,docker:true,systemd:true,wayland:true,flatpak:false,snap:false,wine:true,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"LineageOS",family:"android",type:"mobile",kernel:"linux",gui:true,openSource:true,mobile:true,unixLike:true,year:2016,vendor:"community",gaming:true,server:false,package:"apk",shell:"none",popularity:4,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:true,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"Pop!_OS",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2017,vendor:"system76",gaming:true,server:false,package:"deb",shell:"bash",popularity:5,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:true,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"elementary OS",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2011,vendor:"community",gaming:false,server:false,package:"deb",shell:"bash",popularity:4,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"Zorin OS",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2009,vendor:"zorin",gaming:true,server:false,package:"deb",shell:"bash",popularity:4,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:true,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:false,loongarch:false},
{name:"Slackware",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:1993,vendor:"community",gaming:false,server:false,package:"tgz",shell:"bash",popularity:3,docker:true,systemd:false,wayland:false,flatpak:false,snap:false,wine:true,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:false},
{name:"Void Linux",family:"linux",type:"desktop",kernel:"linux",gui:false,openSource:true,mobile:false,unixLike:true,year:2008,vendor:"community",gaming:false,server:false,package:"xbps",shell:"bash",popularity:2,docker:true,systemd:false,wayland:true,flatpak:false,snap:false,wine:true,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:true},
{name:"NixOS",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2003,vendor:"community",gaming:false,server:true,package:"nix",shell:"bash",popularity:3,docker:true,systemd:true,wayland:true,flatpak:true,snap:false,wine:true,wsl:false,btrfs:true,zfs:true,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:true,arm:true,riscv:true,loongarch:true},
{name:"Guix System",family:"linux",type:"desktop",kernel:"linux",gui:true,openSource:true,mobile:false,unixLike:true,year:2012,vendor:"community",gaming:false,server:false,package:"guix",shell:"bash",popularity:2,docker:true,systemd:false,wayland:true,flatpak:false,snap:false,wine:true,wsl:false,btrfs:true,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:true},
{name:"Plan 9",family:"plan9",type:"desktop",kernel:"custom",gui:true,openSource:true,mobile:false,unixLike:false,year:1992,vendor:"belllabs",gaming:false,server:false,package:"custom",shell:"rc",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:false,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:false},
{name:"SerenityOS",family:"serenity",type:"desktop",kernel:"custom",gui:true,openSource:true,mobile:false,unixLike:false,year:2018,vendor:"community",gaming:false,server:false,package:"custom",shell:"bash",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:false,pen:false,vr:false,ai:false,cloud:false,arm:true,riscv:true,loongarch:false},
{name:"Fuchsia",family:"fuchsia",type:"embedded",kernel:"zircon",gui:true,openSource:true,mobile:false,unixLike:false,year:2016,vendor:"google",gaming:false,server:false,package:"fuchsia",shell:"none",popularity:2,docker:false,systemd:false,wayland:false,flatpak:false,snap:false,wine:false,wsl:false,btrfs:false,zfs:false,selinux:false,apparmor:false,firewall:true,bluetooth:true,wifi:true,touchscreen:true,pen:false,vr:false,ai:true,cloud:true,arm:true,riscv:true,loongarch:false}
];
const QUESTIONS=[
{key:"type",text:"这个系统主要用于什么设备?",options:[{label:"💻 台式机 / 笔记本",value:"desktop"},{label:"📱 手机 / 平板",value:"mobile"},{label:"⌚ 手表 / 可穿戴",value:"wearable"},{label:"🖥️ 服务器",value:"server"},{label:"🔌 嵌入式 / IoT",value:"embedded"}]},
{key:"family",text:"它属于哪个操作系统家族?",options:[{label:"🪟 Windows 家族",value:"windows"},{label:"🍎 ApplemacOS/iOS",value:"apple"},{label:"🐧 Linux / GNU",value:"linux"},{label:"🤖 Android",value:"android"},{label:"🐡 BSD / Unix",value:"bsd"},{label:"🕹️ 其他 / 复古",value:"other"}],map:(v,os)=>{if(v==="apple")return os.family==="macos"||os.family==="ios";if(v==="bsd")return os.family==="bsd"||os.family==="solaris"||os.family==="unix";if(v==="other")return!["windows","macos","ios","linux","android"].includes(os.family);return os.family===v}},
{key:"gui",text:"它有图形用户界面(GUI)吗?",options:[{label:"✅ 有,默认带 GUI",value:true},{label:"❌ 没有,主要是命令行",value:false}]},
{key:"openSource",text:"它是开源的吗?",options:[{label:"✅ 是,开源",value:true},{label:"❌ 不是,闭源商业软件",value:false}]},
{key:"vendor",text:"它的主要开发商是谁?",options:[{label:"🏢 微软(Microsoft",value:"microsoft"},{label:"🍎 苹果(Apple",value:"apple"},{label:"🔍 谷歌(Google",value:"google"},{label:"🐧 社区 / 非营利组织",value:"community"},{label:"🏭 企业(IBM/Oracle/HP 等)",value:"enterprise"}],map:(v,os)=>{if(v==="enterprise")return["ibm","oracle","hp","redhat","canonical","windriver","blackberry","huawei","samsung","valve","system76","zorin","raspberrypi","kaios","offensive-security"].includes(os.vendor);if(v==="community")return os.vendor==="community"||os.vendor==="belllabs";return os.vendor===v}},
{key:"unixLike",text:"它是类 Unix 系统吗?",options:[{label:"✅ 是,类 Unix",value:true},{label:"❌ 不是,非 Unix",value:false}]},
{key:"gaming",text:"它常用于游戏吗?",options:[{label:"🎮 是,游戏向 / 支持游戏",value:true},{label:"🚫 不是,不用于游戏",value:false}]},
{key:"kernel",text:"它使用什么类型的内核?",options:[{label:"🐧 Linux 内核",value:"linux"},{label:"🪟 Windows NT 内核",value:"nt"},{label:"🍎 XNU(苹果)",value:"xnu"},{label:"🐡 BSD 内核",value:"bsd"},{label:"⚙️ 自定义 / 其他",value:"other"}],map:(v,os)=>{if(v==="other")return!["linux","nt","xnu","bsd"].includes(os.kernel);return os.kernel===v}},
{key:"year",text:"它首次发布于哪个年代?",options:[{label:"📅 1990 年之前",value:"old"},{label:"📅 1990 - 2005 年",value:"mid"},{label:"📅 2006 - 2015 年",value:"recent"},{label:"📅 2016 年至今",value:"modern"}],map:(v,os)=>{if(v==="old")return os.year<1990;if(v==="mid")return os.year>=1990&&os.year<=2005;if(v==="recent")return os.year>=2006&&os.year<=2015;return os.year>=2016}},
{key:"server",text:"它常用作服务器操作系统吗?",options:[{label:"✅ 是,服务器级",value:true},{label:"❌ 不是,仅限桌面/移动",value:false}]},
{key:"package",text:"它的主要软件包格式是什么?",options:[{label:"📦 .deb / APTDebian/Ubuntu",value:"deb"},{label:"📦 .rpm / YUMRedHat/Fedora",value:"rpm"},{label:"📦 .exe / .msiWindows",value:"exe"},{label:"📦 .apkAndroid",value:"apk"},{label:"📦 其他 / 自定义",value:"other"}],map:(v,os)=>{if(v==="deb")return os.package.includes("deb");if(v==="rpm")return os.package.includes("rpm");if(v==="exe")return os.package.includes("exe")||os.package.includes("msi");if(v==="apk")return os.package.includes("apk");return!["deb","rpm","exe","msi","apk"].some(x=>os.package.includes(x))}},
{key:"mobile",text:"它是移动操作系统吗?",options:[{label:"📱 是,移动 OS",value:true},{label:"💻 不是,非移动",value:false}]}
];
const USER_ASK_MAP={
docker:{check:os=>os.docker,name:"支持 Docker"},
systemd:{check:os=>os.systemd,name:"使用 systemd"},
wayland:{check:os=>os.wayland,name:"支持 Wayland"},
flatpak:{check:os=>os.flatpak,name:"支持 Flatpak"},
snap:{check:os=>os.snap,name:"支持 Snap"},
wine:{check:os=>os.wine,name:"支持 Wine"},
wsl:{check:os=>os.wsl,name:"支持 WSL"},
btrfs:{check:os=>os.btrfs,name:"支持 Btrfs 文件系统"},
zfs:{check:os=>os.zfs,name:"支持 ZFS 文件系统"},
selinux:{check:os=>os.selinux,name:"使用 SELinux"},
apparmor:{check:os=>os.apparmor,name:"使用 AppArmor"},
"防火墙":{check:os=>os.firewall,name:"内置防火墙"},
"蓝牙":{check:os=>os.bluetooth,name:"支持蓝牙"},
wifi:{check:os=>os.wifi,name:"支持 WiFi"},
"无线":{check:os=>os.wifi,name:"支持 WiFi"},
"触摸屏":{check:os=>os.touchscreen,name:"支持触摸屏"},
"触控":{check:os=>os.touchscreen,name:"支持触摸屏"},
"手写笔":{check:os=>os.pen,name:"支持手写笔/触控笔"},
vr:{check:os=>os.vr,name:"支持 VR"},
"虚拟现实":{check:os=>os.vr,name:"支持 VR"},
ai:{check:os=>os.ai,name:"内置 AI 功能"},
"人工智能":{check:os=>os.ai,name:"内置 AI 功能"},
"云":{check:os=>os.cloud,name:"支持云服务集成"},
cloud:{check:os=>os.cloud,name:"支持云服务集成"},
arm:{check:os=>os.arm,name:"支持 ARM 架构"},
riscv:{check:os=>os.riscv,name:"支持 RISC-V 架构"},
"龙芯":{check:os=>os.loongarch,name:"支持龙芯 LoongArch 架构"},
loongarch:{check:os=>os.loongarch,name:"支持龙芯 LoongArch 架构"},
"开源":{check:os=>os.openSource,name:"开源"},
"图形界面":{check:os=>os.gui,name:"有图形界面"},
gui:{check:os=>os.gui,name:"有图形界面"},
"游戏":{check:os=>os.gaming,name:"支持游戏"},
gaming:{check:os=>os.gaming,name:"支持游戏"},
"服务器":{check:os=>os.server,name:"服务器系统"},
server:{check:os=>os.server,name:"服务器系统"},
"移动":{check:os=>os.mobile,name:"移动操作系统"},
"手机":{check:os=>os.mobile,name:"移动操作系统"},
unix:{check:os=>os.unixLike,name:"类 Unix"},
linux:{check:os=>os.kernel==="linux",name:"使用 Linux 内核"},
nt:{check:os=>os.kernel==="nt",name:"使用 NT 内核"},
windows:{check:os=>os.family==="windows",name:"Windows 家族"},
"苹果":{check:os=>os.vendor==="apple",name:"苹果出品"},
apple:{check:os=>os.vendor==="apple",name:"苹果出品"},
"微软":{check:os=>os.vendor==="microsoft",name:"微软出品"},
microsoft:{check:os=>os.vendor==="microsoft",name:"微软出品"},
"谷歌":{check:os=>os.vendor==="google",name:"谷歌出品"},
google:{check:os=>os.vendor==="google",name:"谷歌出品"},
"华为":{check:os=>os.vendor==="huawei",name:"华为出品"},
debian:{check:os=>os.package.includes("deb"),name:"基于 Debian"},
redhat:{check:os=>os.package.includes("rpm"),name:"基于 RedHat"},
arch:{check:os=>os.package.includes("pacman"),name:"Arch 系"},
pacman:{check:os=>os.package.includes("pacman"),name:"使用 pacman"}
};
let state={mode:null,step:0,maxSteps:0,candidates:[],history:[],askedKeys:new Set(),userAsked:[],isUserTurn:false};
function startGame(mode){
state.mode=mode;state.step=0;state.candidates=[...OS_DB];state.history=[];state.askedKeys=new Set();state.userAsked=[];state.isUserTurn=false;
state.maxSteps=mode==="easy"?12:mode==="normal"?8:5;
document.getElementById("menu").classList.remove("active");
document.getElementById("result").classList.remove("active");
document.getElementById("play").classList.add("active");
document.getElementById("mode-display").textContent=mode==="easy"?"简单":mode==="normal"?"普通":"困难";
document.getElementById("max-display").textContent=state.maxSteps;
document.getElementById("asked-questions").innerHTML="";
updateUI();aiTurn();
}
function updateUI(){
document.getElementById("step-display").textContent=state.step+1;
document.getElementById("cand-display").textContent=state.candidates.length;
const pct=((state.step)/state.maxSteps)*100;
document.getElementById("progress").style.width=pct+"%";
}
function renderHistory(){
const el=document.getElementById("history");
if(state.history.length===0){el.innerHTML="";return;}
let html='<div class="history-title">你的回答记录</div>';
state.history.forEach(h=>{html+='<div class="history-item"><span class="q">'+h.q+'</span> → <span class="a">'+h.a+'</span></div>';});
el.innerHTML=html;
}
function getBestQuestion(){
const available=QUESTIONS.filter(q=>!state.askedKeys.has(q.key));
if(available.length===0)return null;
let best=null,bestScore=-1;
for(const q of available){
const counts={};
for(const opt of q.options){
const fn=q.map||((v,os)=>os[q.key]===v);
counts[opt.value]=state.candidates.filter(os=>fn(opt.value,os)).length;
}
const total=state.candidates.length;
const entropy=Object.values(counts).reduce((sum,c)=>{if(c===0||c===total)return sum;const p=c/total;return sum-p*Math.log2(p);},0);
const balance=1-Math.abs(counts[q.options[0].value]-(counts[q.options[1]?.value??0]))/total;
const score=entropy*0.7+balance*0.3;
if(score>bestScore){bestScore=score;best=q;}
}
return best;
}
function aiTurn(){
if(state.candidates.length<=1||state.step>=state.maxSteps){return showResult();}
const q=getBestQuestion();
if(!q)return showResult();
state.isUserTurn=false;
state.askedKeys.add(q.key);
document.getElementById("turn-indicator").innerHTML='<span class="turn-ai">🤖 AI 正在提问……</span>';
document.getElementById("ai-question-area").style.display="block";
document.getElementById("or-divider").style.display="none";
document.getElementById("user-ask-box").style.display="none";
document.getElementById("question").textContent=q.text;
const optsEl=document.getElementById("options");
optsEl.innerHTML="";
q.options.forEach(opt=>{
const btn=document.createElement("button");
btn.className="opt-btn";
btn.textContent=opt.label;
btn.onclick=()=>answerAI(q,opt.value,opt.label);
optsEl.appendChild(btn);
});
const hintNames=state.candidates.slice(0,5).map(c=>c.name).join("、");
const more=state.candidates.length>5?" 等共 "+state.candidates.length+" 个":"";
document.getElementById("remaining-hint").textContent="剩余候选:"+hintNames+more;
}
function answerAI(q,value,label){
const fn=q.map||((v,os)=>os[q.key]===v);
state.candidates=state.candidates.filter(os=>fn(value,os));
state.history.push({q:q.text,a:label});
state.step++;
updateUI();
renderHistory();
if(state.candidates.length>1&&state.step<state.maxSteps){userTurn();}else{showResult();}
}
function userTurn(){
state.isUserTurn=true;
document.getElementById("turn-indicator").innerHTML='<span class="turn-user">🙋 轮到你了!向 AI 提问系统特征</span>';
document.getElementById("ai-question-area").style.display="none";
document.getElementById("or-divider").style.display="block";
document.getElementById("user-ask-box").style.display="block";
document.getElementById("user-ask-input").value="";
document.getElementById("user-ask-input").focus();
const hintNames=state.candidates.slice(0,5).map(c=>c.name).join("、");
const more=state.candidates.length>5?" 等共 "+state.candidates.length+" 个":"";
document.getElementById("remaining-hint").textContent="剩余候选:"+hintNames+more;
}
function usePresetAsk(text){
document.getElementById("user-ask-input").value=text;
handleUserAsk();
}
function skipUserAsk(){
aiTurn();
}
function handleUserAsk(){
const input=document.getElementById("user-ask-input").value.trim();
if(!input)return;
let matched=null,matchedKey=null;
for(const[key,info]of Object.entries(USER_ASK_MAP)){
if(input.toLowerCase().includes(key.toLowerCase())){matched=info;matchedKey=key;break;}
}
const askedEl=document.getElementById("asked-questions");
if(!matched){
askedEl.innerHTML+='<div class="asked-item">❓ "'+input+'" — AI 无法识别这个问题,试试其他关键词</div>';
return;
}
const yesCount=state.candidates.filter(os=>matched.check(os)).length;
const noCount=state.candidates.length-yesCount;
let resultText="",resultClass="";
if(yesCount===state.candidates.length){
resultText="✅ 是的,所有 "+state.candidates.length+" 个候选系统都"+matched.name;
resultClass="ans";
}else if(noCount===state.candidates.length){
resultText="❌ 不是,所有 "+state.candidates.length+" 个候选系统都不"+matched.name;
resultClass="ans-no";
}else{
const yesNames=state.candidates.filter(os=>matched.check(os)).map(c=>c.name).join("、");
const noNames=state.candidates.filter(os=>!matched.check(os)).map(c=>c.name).join("、");
resultText="🟡 部分是的:"+yesNames+""+yesCount+"个)"+matched.name+";"+noNames+""+noCount+"个)不"+matched.name;
resultClass="ans-mix";
}
askedEl.innerHTML+='<div class="asked-item">🙋 "'+input+'" → <span class="'+resultClass+'">'+resultText+'</span></div>';
state.userAsked.push({q:input,result:resultText});
setTimeout(()=>{aiTurn();},800);
}
function showResult(){
document.getElementById("play").classList.remove("active");
document.getElementById("result").classList.add("active");
if(state.candidates.length===1){
const os=state.candidates[0];
document.getElementById("res-icon").textContent="🎯";
document.getElementById("res-name").textContent=os.name;
document.getElementById("res-desc").innerHTML=
"家族:<b>"+os.family+"</b> | 内核:<b>"+os.kernel+"</b> | 开发商:<b>"+os.vendor+"</b><br>"+
"发布年份:<b>"+os.year+"</b> | 开源:<b>"+(os.openSource?"是":"否")+"</b> | 图形界面:<b>"+(os.gui?"有":"无")+"</b><br>"+
"支持 Docker<b>"+(os.docker?"是":"否")+"</b> | 使用 systemd<b>"+(os.systemd?"是":"否")+"</b> | 支持 Wayland<b>"+(os.wayland?"是":"否")+"</b>";
}else if(state.candidates.length===0){
document.getElementById("res-icon").textContent="🤔";
document.getElementById("res-name").textContent="没有找到匹配的系统!";
document.getElementById("res-desc").textContent="你的回答排除了所有候选系统。也许你想的是一个不在数据库里的系统?";
}else{
const best=state.candidates.sort((a,b)=>b.popularity-a.popularity)[0];
const others=state.candidates.filter(c=>c!==best).map(c=>c.name).join("、");
document.getElementById("res-icon").textContent="🤔";
document.getElementById("res-name").textContent="最佳猜测:"+best.name;
document.getElementById("res-desc").innerHTML="但以下系统也有可能:<b>"+others+"</b><br><small>试试更高难度,或者想一个更具体的系统!</small>";
}
}
function resetGame(){
document.getElementById("result").classList.remove("active");
document.getElementById("play").classList.remove("active");
document.getElementById("menu").classList.add("active");
document.getElementById("history").innerHTML="";
document.getElementById("asked-questions").innerHTML="";
}
</script>
</body>
</html>