release: v0.2.0 三版本首发 — 截图识字 + 安全查杀 + 完整/Pro/Lite 出包矩阵

新增
- 截图识字(小工具 › 截图识字):snow-shot 1.6.4 便携引擎按需下载
  (SHA256 锁定校验,解包 %APPDATA%\squid\engines,进程解耦 GPL-3);
  启用开关 + 两键全局热键(默认 Alt+D,单键拒绝);开始截图、保存位置
  直达(自动建目录)、识别历史(直读磁盘倒序 20 条,点行定位)。
- 安全查杀:ClamAV 1.4.4 引擎 + 病毒库按需下载不预置;freshclam 默认
  官方国内加速节点 db.cn.clamav.net、自动回退 database.clamav.net,
  镜像可改;快速查杀(启动项目标 + 下载/桌面/文档)/全盘查杀(可取消、
  实时计数);威胁定位/隔离;隔离区一键还原/彻底删除;
  节能(推荐)/性能/手动三档实时防护;WSC 接管开关 + 6h 心跳,未签名
  被拒(0x800706F4)时页面如实说明「需要数字签名」。
- 引擎按需下载器 engines.rs:缓存复用、校验、tar.exe→Expand-Archive
  兜底、squid://engine 事件流(下载/校验/解压/就绪/错误)。
- 三版本基建:cargo features(default=screenshot+security / pro / lite)
  同版本号三份安装包 + 三份便携包;更新清单三 artifact 键
  windows / windows-pro / windows-lite;bootstrap 新增 edition,
  前端按版本隐藏入口并在侧栏标徽;Settings 新增 5 字段(旧配置兼容)。

学习对象(详见 release/CHANGELOG-SINCE-0.1.13.md)
- mg-chao/snow-shot(截图+离线 OCR 引擎)、ShareX、eSearch、Umi-OCR(调研)
- Cisco-Talos/clamav(防病毒引擎);腾讯电脑管家(WSC 接管「由 XX 管理」、
  双保险思路,闭源参照)

验证
- cargo fmt/test/clippy 双 workspace(三种 feature 组合全过)+
  pnpm check/build 全绿;demo 点击测试 22/22 PASS(含识别历史、
  接管失败诚实报错、扫描→隔离→还原闭环、热键录制拒绝/接受路径)。

发布物
- release/0.2.0/:三 setup + 三便携 zip + SHA256SUMS + 三 artifact
  squid-update.json + RELEASE_NOTES + 一键安装.bat。
- ClamAV 引擎包 SHA256 暂缺(官方源限速未下完),下载器校验为可选,
  下完后补 pin。
dev
lijunjie 2026-11-25 23:42:53 +08:00
parent 711befc246
commit 181431fd64
39 changed files with 4998 additions and 40 deletions

14
Cargo.lock generated
View File

@ -1116,7 +1116,7 @@ checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"
[[package]]
name = "squid-cli"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"anyhow",
"chrono",
@ -1135,7 +1135,7 @@ dependencies = [
[[package]]
name = "squid-core"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"anyhow",
"chrono",
@ -1154,7 +1154,7 @@ dependencies = [
[[package]]
name = "squid-engine"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"anyhow",
"chrono",
@ -1177,7 +1177,7 @@ dependencies = [
[[package]]
name = "squid-platform"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"dirs",
"libc",
@ -1196,7 +1196,7 @@ dependencies = [
[[package]]
name = "squid-rules"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"globset",
"serde",
@ -1208,7 +1208,7 @@ dependencies = [
[[package]]
name = "squid-stats"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"chrono",
"libc",
@ -1221,7 +1221,7 @@ dependencies = [
[[package]]
name = "squid-tui"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"anyhow",
"chrono",

View File

@ -4,7 +4,7 @@ members = ["crates/*"]
exclude = ["src-tauri"]
[workspace.package]
version = "0.1.13"
version = "0.2.0"
edition = "2021"
rust-version = "1.80"
license = "GPL-3.0-only"

View File

@ -36,6 +36,18 @@ pub struct Settings {
/// Whether the desktop app's first-run permission card has been dismissed.
/// Older configs have no such field and therefore see the card once.
pub desktop_setup_reviewed: bool,
/// 小工具 · 截图识字 master switch (engine download stays on disk either way).
pub screenshot_enabled: bool,
/// Two-key global hotkey that wakes the capture overlay, e.g. `Alt+D`.
pub screenshot_hotkey: String,
/// 安全查杀 realtime posture: `power` (引擎按需拉起、空闲休眠),
/// `performance` (clamd 常驻) or `manual` (仅手动/计划扫描).
pub security_mode: String,
/// Whether Squid registers itself with Windows Security Center (WSC).
pub security_takeover: bool,
/// Optional ClamAV database mirror host (freshclam `DatabaseMirror`);
/// empty means the official CDN with the built-in fallback list.
pub clamav_mirror: String,
}
impl Default for Settings {
@ -53,6 +65,11 @@ impl Default for Settings {
language: None,
history_keep: 60,
desktop_setup_reviewed: false,
screenshot_enabled: false,
screenshot_hotkey: "Alt+D".into(),
security_mode: "power".into(),
security_takeover: false,
clamav_mirror: String::new(),
}
}
}

View File

@ -64,6 +64,37 @@ toolchain instead of `cargo-xwin`. The installer is per-user and installs to:
The executable inside is `squid-desktop.exe`, matching both the NSIS installer
and the update handoff script.
### Three editions (0.2.0+)
One version number ships three feature editions, gated by cargo features in
`src-tauri/Cargo.toml` (`default = ["screenshot","security"]`):
| 版本 | features | setup 名 | artifact 键 |
| --- | --- | --- | --- |
| 完整 full | default | `Squid-Setup-<ver>-win-x64.exe` | `windows` |
| Pro | `screenshot` only | `Squid-Pro-Setup-<ver>-win-x64.exe` | `windows-pro` |
| Lite | none | `Squid-Lite-Setup-<ver>-win-x64.exe` | `windows-lite` |
Build each edition on Windows (pnpm build once, then per edition):
```bash
# full
cargo build --release --features tauri/custom-protocol && pnpm exec tauri bundle
# pro(--no-default-features 必须走 cargo 直调;tauri build 不透传它)
cargo build --release --no-default-features --features "screenshot,tauri/custom-protocol" && pnpm exec tauri bundle
# lite
cargo build --release --no-default-features --features tauri/custom-protocol && pnpm exec tauri bundle
```
`tauri bundle` only re-runs NSIS over the current `target/release/` exe — so
`cargo build` decides the edition, `bundle` packages it, and the output
`Squid_<ver>_x64-setup.exe` is renamed per edition while copying into
`release/<ver>/`. The Rust edition is baked in (`edition_name()` →
`bootstrap.edition`); the frontend hides the pages per edition, and
`update.rs` prefers the edition artifact key with a plain-`windows` fallback.
Verify each exe with string probes (`wsc-last-error` ⇒ security,
`bin/snow_shot.exe` ⇒ screenshot) before staging.
### 360/电脑管家 environments: ship 一键安装.bat (mandatory)
On the developer machine (and other boxes running 腾讯电脑管家/360), the

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 KiB

View File

@ -0,0 +1,190 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--primary: #f26a33; --primary-strong: #d94f1f; --primary-soft: #fff0e7; --primary-tint: #fff7f2;
--primary-rgb: 242,106,51; --ink: #342019; --muted: #7d6256; --muted-soft: #a98f80;
--line: rgba(89,51,34,.1); --paper: #fbf7f2; --canvas: #f5eee7;
--green: #19a974; --green-soft: #e5f8f0; --orange: #ee844c; --red: #e65a62;
}
body { width: 1320px; background: var(--canvas); color: var(--ink);
font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; font-weight: 540;
padding: 30px 40px 44px; }
h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
h2 { font-size: 15px; font-weight: 700; margin: 30px 0 10px; color: var(--primary-strong); }
h2 span { color: var(--muted-soft); font-weight: 540; font-size: 12.5px; margin-left: 8px; }
.app { background: #fffdfb; border: 1px solid var(--line); border-radius: 16px;
box-shadow: 0 14px 34px rgba(89,51,34,.08); padding: 26px 30px 24px; }
.eyebrow { color: var(--primary-strong); font-size: 12px; font-weight: 650; letter-spacing: .12em; }
.title { font-size: 22px; font-weight: 720; margin: 6px 0 4px; }
.desc { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.btn { border-radius: 10px; padding: 10px 18px; font-size: 13.5px; font-weight: 620;
border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn.primary { background: linear-gradient(145deg, #ff9664, var(--primary) 55%, var(--primary-strong));
color: #fff; border: none; box-shadow: 0 6px 14px rgba(var(--primary-rgb),.25); }
.btn.ghost { border-color: rgba(var(--primary-rgb),.3); color: var(--primary-strong); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }
.chip { display:inline-block; font-size: 11.5px; border-radius: 999px; padding: 3px 10px; background: #fff;
border: 1px solid var(--line); color: var(--muted); }
.chip.ok { color: var(--green); border-color: rgba(25,169,116,.35); background: var(--green-soft); }
.main-card { border: 1px solid rgba(var(--primary-rgb),.25); border-radius: 14px; padding: 18px 22px;
background: linear-gradient(135deg, var(--primary-tint), #fff); display: flex; align-items: center; gap: 18px; }
.app-ic { width: 54px; height: 54px; border-radius: 14px; background: linear-gradient(145deg,#6ea8ff,#3f6fd8);
color: #fff; display: flex; align-items: center; justify-content: center; font-size: 24px; flex: 0 0 auto;
box-shadow: 0 6px 14px rgba(63,111,216,.3); }
.main-card b { font-size: 15.5px; }
.main-card small { display: block; color: var(--muted); margin-top: 3px; font-size: 12.5px; line-height: 1.6; }
.kbd { font-family: Consolas, monospace; font-size: 11.5px; background: #fff; border: 1px solid var(--line);
border-bottom-width: 2.5px; border-radius: 6px; padding: 2px 8px; color: var(--ink); }
.items { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; margin-top: 14px; }
.item { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 12px 14px; }
.item b { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.item small { display: block; color: var(--muted-soft); font-size: 11.5px; margin-top: 6px; line-height: 1.6; }
.item .st { font-size: 10.5px; border-radius: 999px; padding: 1px 7px; margin-left: auto; }
.st.on { color: var(--green); background: var(--green-soft); }
.st.off { color: var(--muted-soft); background: rgba(89,51,34,.06); }
.hist { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.hist-h { display: flex; align-items: center; padding: 12px 16px 8px; font-size: 14px; font-weight: 700; }
.hist-h .acts { margin-left: auto; display: flex; gap: 8px; }
.hrow { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px dashed var(--line); }
.thumb { width: 62px; height: 38px; border-radius: 7px; border: 1px solid var(--line); flex: 0 0 auto;
background: linear-gradient(135deg, #dfe8f5, #f6e8dd); position: relative; overflow: hidden; }
.thumb i { position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 2px; background: rgba(52,32,25,.18); }
.thumb i:nth-child(1) { top: 8px; } .thumb i:nth-child(2) { top: 16px; width: 60%; right: auto; }
.thumb i:nth-child(3) { top: 24px; width: 78%; right: auto; }
.hrow .meta { flex: 1 1 auto; min-width: 0; }
.hrow .meta b { font-size: 13px; font-weight: 640; }
.hrow .meta small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: Consolas, monospace; }
.hrow .char { color: var(--muted-soft); font-size: 11.5px; flex: 0 0 auto; }
.fine { color: var(--muted-soft); font-size: 11.5px; margin-top: 10px; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
/* capture overlay mock */
.cap { background: linear-gradient(160deg, #2c2a33, #1c1b22); border-radius: 16px; padding: 30px 34px 26px;
position: relative; min-height: 460px; overflow: hidden; }
.fake-window { background: #f7f5f2; border-radius: 10px; box-shadow: 0 18px 44px rgba(0,0,0,.45); overflow: hidden; }
.fw-bar { background: #e9e5df; padding: 8px 12px; font-size: 12px; color: #6b6257; display: flex; gap: 6px; }
.fw-bar i { width: 10px; height: 10px; border-radius: 50%; background: #d6cdc2; }
.fw-body { padding: 14px 16px; }
.fw-line { height: 10px; border-radius: 4px; background: #ded8d0; margin-bottom: 10px; }
.dim { display: none; }
.sel { position: absolute; left: 74px; top: 84px; width: 560px; height: 300px; border: 2px solid var(--primary);
border-radius: 4px; box-shadow: 0 0 0 9999px rgba(20,18,24,.55); }
.handle { position: absolute; width: 9px; height: 9px; background: #fff; border: 2px solid var(--primary); border-radius: 2px; }
.sel .size { position: absolute; left: 0; top: -26px; background: var(--primary); color: #fff; font-size: 11.5px;
padding: 3px 9px; border-radius: 6px; font-family: Consolas, monospace; }
.toolbar { position: absolute; left: 74px; top: 402px; background: #fff; border-radius: 10px;
box-shadow: 0 10px 26px rgba(0,0,0,.35); display: flex; padding: 6px; gap: 4px; }
.tbtn { width: 34px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
font-size: 14px; color: #4a4238; }
.tbtn.hl { background: var(--primary-soft); color: var(--primary-strong); }
.tsep { width: 1px; background: var(--line); margin: 4px 4px; }
.ocr-pop { position: absolute; right: 40px; top: 84px; width: 360px; background: #fffdfb; border-radius: 12px;
box-shadow: 0 18px 44px rgba(0,0,0,.4); padding: 14px 16px; }
.ocr-pop h4 { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.ocr-pop h4 .tag { font-size: 10.5px; background: var(--green-soft); color: var(--green); border-radius: 999px; padding: 1px 8px; margin-left: auto; }
.ocr-text { margin-top: 10px; background: #f6f2ec; border-radius: 8px; padding: 10px 12px; font-size: 12.5px;
line-height: 1.7; color: var(--ink); max-height: 190px; overflow: hidden; }
.ocr-text .sel-hl { background: rgba(242,106,51,.22); border-radius: 3px; }
.ocr-acts { display: flex; gap: 8px; margin-top: 10px; }
</style>
</head>
<body>
<h1>Squid 小工具 · 截图识字(B1:snow-shot 引擎,纯离线 OCR)</h1>
<div class="sub">Squid 负责入口、快捷键、结果归档与设置;截图框选 / 标注 / 识字浮层由 snow-shot 完成(随包分发,进程解耦)。</div>
<h2>① Squid 内「小工具 › 截图识字」页 <span class="en">入口 + 设置 + 识别历史</span></h2>
<div class="app">
<div class="eyebrow">UTILITIES</div>
<div class="title">截图识字</div>
<div class="desc">框选屏幕任意区域:可标注、贴图、长截图、录屏,一键提取文字 —— 全程离线,画面不出本机。</div>
<div class="main-card">
<div class="app-ic">✂</div>
<div>
<b>截图识字引擎 · snow-shot 1.6.0 · 已就绪(离线识别)</b>
<small>识别模型已就位(PaddleOCR · 中文/英文,约 15 MB)· 更新:自动跟随 Squid 更新 · 许可:GPL-3(随包附协议)</small>
</div>
<div style="margin-left:auto; display:flex; gap:10px; align-items:center;">
<span style="font-size:12.5px;color:var(--muted)">快捷键 <span class="kbd">Ctrl</span> + <span class="kbd">Alt</span> + <span class="kbd">A</span></span>
<button class="btn primary">开始截图</button>
</div>
</div>
<div class="items">
<div class="item"><b>📥 保存位置 <span class="st on">接管</span></b>
<small>图片\Squid 截图<br>命名按时间自动<br><button class="btn sm" style="margin-top:6px">打开文件夹</button></small></div>
<div class="item"><b>🌙 跟随开机 <span class="st on">开</span></b>
<small>登录后热键即生效<br>未开也能从本页启动<br><button class="btn sm" style="margin-top:6px">设置</button></small></div>
<div class="item"><b>📋 识文自动复制 <span class="st on">开</span></b>
<small>点「提取文字」后自动进剪贴板<br>并记入下方历史<br><button class="btn sm" style="margin-top:6px">设置</button></small></div>
<div class="item"><b>🧩 划词翻译 <span class="st off">未装</span></b>
<small>需 B2 增强包 Umi-OCR<br>(HTTP 接口联动,可选)<br><button class="btn sm ghost" style="margin-top:6px">了解</button></small></div>
</div>
<div class="hist">
<div class="hist-h">识别历史 <small style="color:var(--muted-soft);font-weight:540;margin-left:8px">点行=重新复制文字 · 保留 30 天</small>
<div class="acts"><button class="btn sm">导出全部</button><button class="btn sm">清空</button></div></div>
<div class="hrow"><div class="thumb"><i></i><i></i><i></i></div>
<div class="meta"><b>今天 17:42 · 报价单截图</b><small>图片\Squid 截图\2026-11-25 174215.png</small></div>
<span class="char">326 字</span><button class="btn sm ghost">复制文字</button><button class="btn sm">打开图</button></div>
<div class="hrow"><div class="thumb"><i></i><i></i><i></i></div>
<div class="meta"><b>今天 15:08 · 报错弹窗</b><small>图片\Squid 截图\2026-11-25 150803.png</small></div>
<span class="char">88 字</span><button class="btn sm ghost">复制文字</button><button class="btn sm">打开图</button></div>
<div class="hrow"><div class="thumb"><i></i><i></i><i></i></div>
<div class="meta"><b>昨天 21:36 · 会议纪要长截图</b><small>图片\Squid 截图\2026-11-24 213644.png</small></div>
<span class="char">1,204 字</span><button class="btn sm ghost">复制文字</button><button class="btn sm">打开图</button></div>
</div>
<p class="fine">冷启动:首次按热键约 1 秒拉起引擎,之后常驻秒开;引擎崩溃不影响 Squid,托盘与本页都能重启它。</p>
</div>
<h2>② 截图中的浮层(snow-shot 实机风格) <span class="en">框选 → 标注工具条 → 提取文字结果卡</span></h2>
<div class="cap">
<div style="position:absolute; left:60px; top:60px; width:600px;">
<div class="fake-window">
<div class="fw-bar"><i></i><i></i><i></i> 发票明细 - 浏览器</div>
<div class="fw-body">
<div class="fw-line" style="width:88%"></div><div class="fw-line" style="width:70%"></div>
<div class="fw-line" style="width:92%"></div><div class="fw-line" style="width:55%"></div>
<div class="fw-line" style="width:80%"></div><div class="fw-line" style="width:64%;margin-bottom:0"></div>
</div>
</div>
</div>
<div class="dim"></div>
<div class="sel"><span class="size">560 × 300</span></div>
<div class="toolbar">
<span class="tbtn">✏</span><span class="tbtn">▭</span><span class="tbtn">→</span><span class="tbtn">M</span>
<span class="tbtn">▦</span><span class="tbtn">🔍</span>
<span class="tsep"></span>
<span class="tbtn hl">文</span><span class="tbtn">📌</span><span class="tbtn">⬇</span>
<span class="tsep"></span>
<span class="tbtn hl" style="width:auto;padding:0 10px;font-size:12px">完成 ✓</span><span class="tbtn">✕</span>
</div>
<div class="ocr-pop">
<h4>提取文字 <span class="tag">离线识别 · 0.6 秒</span></h4>
<div class="ocr-text">
电子发票(普通发票)<br>
发票号码:<span class="sel-hl">24502000000018234567</span><br>
开票日期:2026年11月20日<br>
购买方:某某科技有限公司<br>
金额合计:<span class="sel-hl">¥1,280.00</span> 税率 6%<br>
……
</div>
<div class="ocr-acts">
<button class="btn sm primary">复制全部</button>
<button class="btn sm">保留换行</button>
<button class="btn sm">合并段落</button>
<button class="btn sm" style="margin-left:auto">✕</button>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 KiB

View File

@ -0,0 +1,245 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--primary: #f26a33; --primary-strong: #d94f1f; --primary-soft: #fff0e7; --primary-tint: #fff7f2;
--primary-rgb: 242,106,51; --ink: #342019; --muted: #7d6256; --muted-soft: #a98f80;
--line: rgba(89,51,34,.1); --line-strong: rgba(89,51,34,.16);
--paper: #fbf7f2; --canvas: #f5eee7;
--green: #19a974; --green-soft: #e5f8f0; --orange: #ee844c; --orange-soft: #fff0e7;
--red: #e65a62; --red-soft: #ffeaeb; --violet: #7668e8; --violet-soft: #efedff;
}
body { width: 1320px; background: var(--canvas); color: var(--ink);
font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; font-weight: 540;
padding: 30px 40px 44px; }
h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
h2 { font-size: 15px; font-weight: 700; margin: 30px 0 10px; color: var(--primary-strong); }
h2 span { color: var(--muted-soft); font-weight: 540; font-size: 12.5px; margin-left: 8px; }
.app { background: #fffdfb; border: 1px solid var(--line); border-radius: 16px;
box-shadow: 0 14px 34px rgba(89,51,34,.08); overflow: hidden; padding: 26px 30px 24px; }
.eyebrow { color: var(--primary-strong); font-size: 12px; font-weight: 650; letter-spacing: .12em; }
.title { font-size: 22px; font-weight: 720; margin: 6px 0 4px; }
.desc { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.btn { border-radius: 10px; padding: 10px 18px; font-size: 13.5px; font-weight: 620;
border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn.primary { background: linear-gradient(145deg, #ff9664, var(--primary) 55%, var(--primary-strong));
color: #fff; border: none; box-shadow: 0 6px 14px rgba(var(--primary-rgb),.25); }
.btn.ghost { border-color: rgba(var(--primary-rgb),.3); color: var(--primary-strong); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }
.card { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); padding: 16px 18px; }
/* status hero */
.hero { display: flex; align-items: center; gap: 22px; border-radius: 14px; padding: 18px 22px; }
.hero.ok { background: linear-gradient(135deg, var(--green-soft), #f2fbf7); border: 1px solid rgba(25,169,116,.35); }
.hero.warn { background: linear-gradient(135deg, var(--orange-soft), #fff8f2); border: 1px solid rgba(238,132,76,.4); }
.shield { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center;
justify-content: center; font-size: 26px; color: #fff; flex: 0 0 auto; }
.shield.ok { background: linear-gradient(145deg, #35c48d, var(--green)); box-shadow: 0 6px 14px rgba(25,169,116,.3); }
.shield.warn { background: linear-gradient(145deg, #ffab77, var(--orange)); box-shadow: 0 6px 14px rgba(238,132,76,.3); }
.hero-main { flex: 1 1 auto; }
.hero-main b { font-size: 17px; font-weight: 700; display: block; }
.hero-main .who { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.hero-main .who em { font-style: normal; color: var(--primary-strong); font-weight: 640; }
.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chip { font-size: 11.5px; border-radius: 999px; padding: 3px 10px; background: #fff;
border: 1px solid var(--line); color: var(--muted); }
.chip.ok { color: var(--green); border-color: rgba(25,169,116,.35); background: var(--green-soft); }
.chip.warn { color: #b06a24; border-color: rgba(238,132,76,.45); background: var(--orange-soft); }
.hero-acts { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
/* scan grid */
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-top: 14px; }
.scan-card { display: flex; flex-direction: column; gap: 8px; }
.scan-card .ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center;
justify-content: center; font-size: 16px; }
.scan-card b { font-size: 14.5px; }
.scan-card small { color: var(--muted); font-size: 12px; line-height: 1.5; flex: 1 1 auto; }
/* cleanbar reuse */
.cleanbar { border: 1px solid rgba(var(--primary-rgb),.4); border-radius: 12px; padding: 12px 16px;
background: #fff; margin-top: 14px; box-shadow: 0 8px 22px rgba(var(--primary-rgb),.12); }
.cb-row { display: flex; align-items: center; gap: 12px; }
.cb-row b { font-size: 14px; font-weight: 650; }
.cb-cur { font-family: Consolas, monospace; font-size: 11.5px; color: var(--muted-soft); margin-top: 3px; }
.pct { margin-left: auto; font-family: Consolas, monospace; color: var(--primary-strong); font-weight: 700; }
.track { height: 10px; border-radius: 999px; background: rgba(89,51,34,.08); margin-top: 10px; overflow: hidden; }
.fill { height: 100%; width: 44%; border-radius: 999px;
background: repeating-linear-gradient(115deg, rgba(255,255,255,.28) 0 10px, rgba(255,255,255,0) 10px 24px),
linear-gradient(90deg, #ff9a68, var(--primary)); }
/* threats */
.threats { margin-top: 14px; border: 1px solid rgba(230,90,98,.35); border-radius: 12px;
background: var(--red-soft); padding: 12px 16px; }
.threats h3 { font-size: 13.5px; color: #a33a42; margin-bottom: 8px; }
.trow { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-top: 1px dashed rgba(230,90,98,.25); font-size: 12.5px; }
.trow .fam { color: #fff; background: var(--red); border-radius: 6px; padding: 1px 8px; font-family: Consolas, monospace; font-size: 11px; }
.trow .p { flex: 1 1 auto; font-family: Consolas, monospace; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .eng { font-size: 11px; color: var(--violet); background: var(--violet-soft); border-radius: 999px; padding: 1px 8px; }
/* realtime feed */
.rt { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 12px 16px; }
.rt h3 { font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(25,169,116,.18); }
.rt-row { display: flex; gap: 10px; font-family: Consolas, monospace; font-size: 12px; color: var(--muted);
padding: 5px 0; border-top: 1px dashed var(--line); align-items: center; }
.rt-row .st { font-size: 11px; border-radius: 999px; padding: 1px 8px; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
.rt-row .st.clean { color: var(--green); background: var(--green-soft); }
.rt-row .st.hot { color: #fff; background: var(--red); }
.rt-row time { color: var(--muted-soft); font-size: 11px; flex: 0 0 52px; }
.rt-row .f { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* takeover card */
.take { margin-top: 14px; border: 1px solid rgba(var(--primary-rgb),.35); border-radius: 14px;
background: linear-gradient(135deg, var(--primary-tint), #fff); padding: 16px 18px; }
.take-row { display: flex; align-items: center; gap: 14px; }
.take b { font-size: 14.5px; }
.take small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; line-height: 1.55; }
.switch { margin-left: auto; width: 46px; height: 26px; border-radius: 999px; background: var(--primary);
position: relative; flex: 0 0 auto; box-shadow: inset 0 1px 3px rgba(0,0,0,.12); }
.switch::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
background: #fff; top: 3px; right: 3px; box-shadow: 0 2px 5px rgba(0,0,0,.2); }
.take-detail { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
/* dialog */
.dlg-back { background: rgba(52,32,25,.4); border-radius: 16px; padding: 34px 60px; }
.dlg { max-width: 560px; margin: 0 auto; background: #fffdfb; border-radius: 16px;
box-shadow: 0 24px 60px rgba(52,32,25,.35); padding: 22px 26px; }
.dlg h3 { font-size: 16px; font-weight: 720; display: flex; align-items: center; gap: 10px; }
.dlg h3 .warn-ic { width: 26px; height: 26px; border-radius: 50%; background: var(--orange);
color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.dlg ul { margin: 12px 0 4px 20px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.dlg ul li b { color: var(--ink); }
.dlg .conflict { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--orange-soft);
border: 1px solid rgba(238,132,76,.4); font-size: 12.5px; color: #8a5a2b; line-height: 1.6; }
.dlg .acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.fine { color: var(--muted-soft); font-size: 11.5px; margin-top: 10px; }
.sec-title { font-size: 14px; font-weight: 700; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.sec-title small { color: var(--muted-soft); font-weight: 540; }
.two-col { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; }
</style>
</head>
<body>
<h1>Squid 安全页 · ClamAV 引擎 + WSC 接管 产品方案图</h1>
<div class="sub">沿用应用主题与 CleanBar 交互语言;实时防护 = Squid 热点目录监控 + clamd 本地毫秒扫描(ClamWin/ClamShield 同架构)。</div>
<h2>① 安全页 · 平时状态 <span class="en">接管完成,绿态;顶部分区即"我管理着你"</span></h2>
<div class="app">
<div class="eyebrow">SECURITY</div>
<div class="title">安全查杀</div>
<div class="desc">Squid 已接管 Windows 安全中心 · 实时防护守护 6 个高危目录 · 双引擎按需查杀</div>
<div class="hero ok">
<div class="shield ok">🛡</div>
<div class="hero-main">
<b>设备正在受到保护 · 由 Squid 管理</b>
<div class="who">Windows 安全中心显示:「病毒和威胁防护由于 <em>Squid</em> 提供,保持最新状态」· Windows Defender 已转为被动模式</div>
<div class="chips">
<span class="chip ok">● 实时防护 开(守护 6 目录)</span>
<span class="chip ok">ClamAV 库 2026-11-25 · 今日已更新</span>
<span class="chip ok">Defender 库 2026-11-25(被动,可用)</span>
<span class="chip">上次全盘 今天 09:30 · 未发现威胁</span>
</div>
</div>
<div class="hero-acts">
<button class="btn primary">快速查杀</button>
<button class="btn ghost">全盘查杀</button>
<button class="btn sm">脱机查杀(重启)</button>
</div>
</div>
<div class="sec-title">今日实时防护记录 <small>· 新文件落地即扫,共 1,214 个,1 个被拦截</small></div>
<div class="rt">
<h3><span class="live-dot"></span>热点目录实时监控 · 运行中(clamd 常驻 · 内存 320 MB · 空闲 5 分钟自动休眠)</h3>
<div class="rt-row"><time>17:42</time><span class="f">C:\Users\34798\Downloads\setup-x64(1).exe</span><span class="eng">ClamAV</span><span class="st hot">拦截:疑似打包器 PUA</span></div>
<div class="rt-row"><time>16:05</time><span class="f">D:\Temp\照片备份.7z → 解压 84 个文件</span><span class="eng">ClamAV</span><span class="st clean">安全 ×84</span></div>
<div class="rt-row"><time>13:11</time><span class="f">E:\(U盘)\投标书-final.docx</span><span class="eng">ClamAV</span><span class="st clean">安全</span></div>
</div>
<div class="take">
<div class="take-row">
<div>
<b>接管 Windows 安全中心</b>
<small>Squid 常驻后台,每 12 小时向安全中心报到(心跳);关闭开关将立刻注销,Windows Defender 自动恢复主动模式。</small>
</div>
<div class="switch"></div>
</div>
<div class="take-detail">
<span class="chip ok">WSC 登记 已生效</span>
<span class="chip ok">心跳 上次 17:00 · 正常</span>
<span class="chip">开机自启 开</span>
<span class="chip">卸载将自动注销</span>
</div>
</div>
<div class="sec-title">引擎与病毒库</div>
<div class="grid3">
<div class="card scan-card">
<span class="ic" style="background:var(--violet-soft);color:var(--violet)">⚙</span>
<b>ClamAV 引擎(主)</b>
<small>程序 22 MB 已就绪 · 病毒库 main+daily 213 MB<br><span style="font-family:Consolas,monospace">TUNA 国内镜像:开</span></small>
<div><button class="btn sm">更新病毒库</button> <button class="btn sm">管理</button></div>
</div>
<div class="card scan-card">
<span class="ic" style="background:var(--green-soft);color:var(--green)">✓</span>
<b>Windows Defender(第二意见)</b>
<small>被动模式随时候命:全盘可交给它跑一遍,与 ClamAV 结果互补;库更新由系统托管。</small>
<div><button class="btn sm ghost">用 Defender 全盘复查</button></div>
</div>
<div class="card scan-card">
<span class="ic" style="background:var(--primary-soft);color:var(--primary-strong)">⏱</span>
<b>计划任务</b>
<small>每天 09:30 快速查杀(启动项/服务/下载/浏览器目录);每周日全盘。错过不补跑,合盖休眠自动顺延。</small>
<div><button class="btn sm">调整计划</button></div>
</div>
</div>
</div>
<h2>② 查杀进行中 + 发现威胁 <span class="en">复用 CleanBar;威胁行带引擎来源徽标</span></h2>
<div class="app">
<div class="sec-title" style="margin-top:0">全盘查杀 · 引擎 ClamAV(库已加载内存)</div>
<div class="cleanbar">
<div class="cb-row">
<span style="color:var(--primary);font-size:16px">◌</span>
<div>
<b>正在扫描 486,213 / 1,102,908 个文件 · 已用 6 分 12 秒</b>
<div class="cb-cur">当前:C:\Users\34798\Documents\客户资料\合同-2023.zip · 发现威胁 2 · 已跳过压缩包内层 12,401</div>
</div>
<span class="pct">44%</span>
<button class="btn sm" style="margin-left:12px">暂停</button>
</div>
<div class="track"><div class="fill"></div></div>
</div>
<div class="threats">
<h3>发现 2 个威胁(处理前不会动它们)</h3>
<div class="trow"><span class="fam">Eicar-Test-Signature</span><span class="p">C:\Users\34798\Downloads\clamavtest\eicar.txt</span><span class="eng">ClamAV</span><button class="btn sm">定位</button><button class="btn sm ghost">隔离</button></div>
<div class="trow"><span class="fam">Trojan.GenericKD.46872</span><span class="p">D:\Soft\crack\patcher.exe</span><span class="eng">Defender 复查</span><button class="btn sm">定位</button><button class="btn sm ghost">隔离</button></div>
</div>
<p class="fine">隔离 = 移入 Squid 私有隔离区(可一键还原,同「历史」体系);不直接删除,避免误杀炸裂。</p>
</div>
<h2>③ 开启接管时的确认弹窗 <span class="en">诚实告知:Defender 转被动,Squid 顶上</span></h2>
<div class="app" style="padding:0">
<div class="dlg-back">
<div class="dlg">
<h3><span class="warn-ic">!</span>接管 Windows 安全中心?</h3>
<ul>
<li>「Windows 安全中心」将显示 <b>由 Squid 提供保护</b>;</li>
<li><b>Windows Defender 实时防护转为被动</b>,改由 Squid 热点实时监控 + ClamAV 引擎顶上;</li>
<li>Defender 引擎仍保留,可作全盘复查的<b>第二意见</b>;</li>
<li>Squid 需要<b>开机常驻</b>(托盘,内存约 40 MB + clamd 320 MB),关闭开关或卸载即自动还原。</li>
</ul>
<div class="conflict">检测到本机当前由「<b>腾讯电脑管家</b>」接管安全中心。开启前请先在管家中关闭「病毒防护」,否则两个产品会互相挤占登记。 <button class="btn sm">打开管家设置</button></div>
<div class="acts">
<button class="btn">保持现状</button>
<button class="btn primary">确认接管</button>
</div>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

View File

@ -0,0 +1,237 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--primary: #f26a33; --primary-strong: #d94f1f; --primary-soft: #fff0e7; --primary-tint: #fff7f2;
--primary-rgb: 242,106,51; --ink: #342019; --muted: #7d6256; --muted-soft: #a98f80;
--line: rgba(89,51,34,.1); --line-strong: rgba(89,51,34,.16);
--paper: #fbf7f2; --canvas: #f5eee7;
--green: #19a974; --green-soft: #e5f8f0; --orange: #ee844c; --orange-soft: #fff0e7;
--red: #e65a62; --red-soft: #ffeaeb; --violet: #7668e8; --violet-soft: #efedff;
}
body { width: 1320px; background: var(--canvas); color: var(--ink);
font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; font-weight: 540;
padding: 30px 40px 44px; }
h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
h2 { font-size: 15px; font-weight: 700; margin: 30px 0 10px; color: var(--primary-strong); }
h2 span { color: var(--muted-soft); font-weight: 540; font-size: 12.5px; margin-left: 8px; }
.app { background: #fffdfb; border: 1px solid var(--line); border-radius: 16px;
box-shadow: 0 14px 34px rgba(89,51,34,.08); padding: 26px 30px 24px; }
.eyebrow { color: var(--primary-strong); font-size: 12px; font-weight: 650; letter-spacing: .12em; }
.title { font-size: 22px; font-weight: 720; margin: 6px 0 4px; }
.desc { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.btn { border-radius: 10px; padding: 10px 18px; font-size: 13.5px; font-weight: 620;
border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn.primary { background: linear-gradient(145deg, #ff9664, var(--primary) 55%, var(--primary-strong));
color: #fff; border: none; box-shadow: 0 6px 14px rgba(var(--primary-rgb),.25); }
.btn.ghost { border-color: rgba(var(--primary-rgb),.3); color: var(--primary-strong); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }
.card { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); padding: 16px 18px; }
.chip { display:inline-block; font-size: 11.5px; border-radius: 999px; padding: 3px 10px; background: #fff;
border: 1px solid var(--line); color: var(--muted); }
.chip.ok { color: var(--green); border-color: rgba(25,169,116,.35); background: var(--green-soft); }
.chip.warn { color: #b06a24; border-color: rgba(238,132,76,.45); background: var(--orange-soft); }
.hero { display: flex; align-items: center; gap: 22px; border-radius: 14px; padding: 18px 22px;
background: linear-gradient(135deg, var(--green-soft), #f2fbf7); border: 1px solid rgba(25,169,116,.35); }
.shield { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center;
justify-content: center; font-size: 26px; color: #fff; flex: 0 0 auto;
background: linear-gradient(145deg, #35c48d, var(--green)); box-shadow: 0 6px 14px rgba(25,169,116,.3); }
.hero-main { flex: 1 1 auto; }
.hero-main b { font-size: 17px; font-weight: 700; display: block; }
.hero-main .who { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.hero-main .who em { font-style: normal; color: var(--primary-strong); font-weight: 640; }
.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.hero-acts { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.sec-title { font-size: 14px; font-weight: 700; margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.sec-title small { color: var(--muted-soft); font-weight: 540; }
/* modes */
.modes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.mode { border: 1.5px solid var(--line); border-radius: 14px; background: #fff; padding: 14px 16px 12px; position: relative; }
.mode.on { border-color: var(--primary); background: linear-gradient(180deg, var(--primary-tint), #fff);
box-shadow: 0 8px 20px rgba(var(--primary-rgb),.12); }
.mode .head { display: flex; align-items: center; gap: 8px; }
.mode .head b { font-size: 14.5px; }
.mode .rec { font-size: 10.5px; background: var(--primary); color: #fff; border-radius: 999px; padding: 1px 8px; }
.mode .memo { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.mode .memo b { color: var(--ink); font-weight: 640; }
.mode .cost { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-strong); margin-left: auto; }
.mode.on .radio { border: 5px solid var(--primary); }
.mode .apply { position: absolute; right: 14px; bottom: 12px; opacity: 0; }
.mode:not(.on):hover .apply { opacity: 1; }
.mode-note { margin-top: 10px; color: var(--muted-soft); font-size: 11.5px; }
.rt { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 12px 16px; }
.rt h3 { font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(25,169,116,.18); }
.idle-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-soft); }
.rt-row { display: flex; gap: 10px; font-family: Consolas, monospace; font-size: 12px; color: var(--muted);
padding: 5px 0; border-top: 1px dashed var(--line); align-items: center; }
.rt-row .st { font-size: 11px; border-radius: 999px; padding: 1px 8px; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
.rt-row .st.clean { color: var(--green); background: var(--green-soft); }
.rt-row .st.hot { color: #fff; background: var(--red); }
.rt-row time { color: var(--muted-soft); font-size: 11px; flex: 0 0 52px; }
.rt-row .f { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-row .eng { color: var(--violet); background: var(--violet-soft); border-radius: 999px; padding: 1px 8px;
font-size: 11px; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
.take { border: 1px solid rgba(var(--primary-rgb),.35); border-radius: 14px;
background: linear-gradient(135deg, var(--primary-tint), #fff); padding: 16px 18px; }
.take-row { display: flex; align-items: center; gap: 14px; }
.take b { font-size: 14.5px; }
.take small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; line-height: 1.55; }
.switch { margin-left: auto; width: 46px; height: 26px; border-radius: 999px; background: var(--primary);
position: relative; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
background: #fff; top: 3px; right: 3px; box-shadow: 0 2px 5px rgba(0,0,0,.2); }
.take-detail { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.scan-card { display: flex; flex-direction: column; gap: 8px; }
.scan-card .ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center;
justify-content: center; font-size: 16px; }
.scan-card b { font-size: 14.5px; }
.scan-card small { color: var(--muted); font-size: 12px; line-height: 1.5; flex: 1 1 auto; }
.cleanbar { border: 1px solid rgba(var(--primary-rgb),.4); border-radius: 12px; padding: 12px 16px;
background: #fff; margin-top: 14px; box-shadow: 0 8px 22px rgba(var(--primary-rgb),.12); }
.cb-row { display: flex; align-items: center; gap: 12px; }
.cb-row b { font-size: 14px; font-weight: 650; }
.cb-cur { font-family: Consolas, monospace; font-size: 11.5px; color: var(--muted-soft); margin-top: 3px; }
.pct { margin-left: auto; font-family: Consolas, monospace; color: var(--primary-strong); font-weight: 700; }
.track { height: 10px; border-radius: 999px; background: rgba(89,51,34,.08); margin-top: 10px; overflow: hidden; }
.fill { height: 100%; width: 44%; border-radius: 999px;
background: repeating-linear-gradient(115deg, rgba(255,255,255,.28) 0 10px, rgba(255,255,255,0) 10px 24px),
linear-gradient(90deg, #ff9a68, var(--primary)); }
.threats { margin-top: 14px; border: 1px solid rgba(230,90,98,.35); border-radius: 12px;
background: var(--red-soft); padding: 12px 16px; }
.threats h3 { font-size: 13.5px; color: #a33a42; margin-bottom: 8px; }
.trow { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-top: 1px dashed rgba(230,90,98,.25); font-size: 12.5px; }
.trow .fam { color: #fff; background: var(--red); border-radius: 6px; padding: 1px 8px; font-family: Consolas, monospace; font-size: 11px; }
.trow .p { flex: 1 1 auto; font-family: Consolas, monospace; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fine { color: var(--muted-soft); font-size: 11.5px; margin-top: 10px; }
</style>
</head>
<body>
<h1>Squid 安全页 v2 · 三档防护模式</h1>
<div class="sub">改名并备注模式解释;clamd 内存改用实测口径(节能模式按需拉起)。</div>
<div class="app">
<div class="eyebrow">SECURITY</div>
<div class="title">安全查杀</div>
<div class="desc">Squid 已接管 Windows 安全中心 · 节能模式下常驻仅约 100 MB(较 Defender 实时防护省 200 MB+)</div>
<div class="hero">
<div class="shield">🛡</div>
<div class="hero-main">
<b>设备正在受到保护 · 由 Squid 管理</b>
<div class="who">Windows 安全中心显示:「病毒和威胁防护由 <em>Squid</em> 提供」· Windows Defender 实时服务已停用</div>
<div class="chips">
<span class="chip ok">● 实时防护 开(节能模式)</span>
<span class="chip ok">ClamAV 库 2026-11-25 · 今日已更新</span>
<span class="chip warn">clamd 当前休眠 · 需要时 5–15 秒拉起</span>
<span class="chip">上次全盘 今天 09:30 · 未发现威胁</span>
</div>
</div>
<div class="hero-acts">
<button class="btn primary">快速查杀</button>
<button class="btn ghost">全盘查杀</button>
<button class="btn sm">脱机查杀(重启)</button>
</div>
</div>
<div class="sec-title">实时防护模式 <small>· 三档,随时可切;当前:节能模式</small></div>
<div class="modes">
<div class="mode on">
<div class="head"><b>节能模式</b><span class="rec">推荐</span><span class="radio"></span></div>
<div class="memo">常驻只有 Squid 本体(目录监听 + 计划 + 心跳,约 <b>100 MB</b>)。高危目录有新文件时才拉起 clamd,<b>扫描后 5 分钟无活动自动休眠</b>;识别结果约延迟 10 秒弹出。</div>
<div class="cost"><span class="chip ok">平时最省内存</span><span class="chip">较 Defender 净省 200 MB+</span></div>
<button class="btn sm apply">切换</button>
</div>
<div class="mode">
<div class="head"><b>性能模式</b><span class="radio"></span></div>
<div class="memo">clamd <b>24 小时常驻</b>,新文件落地<b>毫秒级</b>出结果、无拉起延迟。代价是引擎与病毒库全程驻留内存(约 <b>650–900 MB</b>),适合内存充裕、下载频繁的主力机。</div>
<div class="cost"><span class="chip warn">内存 +650–900 MB</span><span class="chip">实时最快</span></div>
<button class="btn sm apply">切换</button>
</div>
<div class="mode">
<div class="head"><b>手动模式</b><span class="radio"></span></div>
<div class="memo">不做实时监控,只保留<b>手动查杀与每日计划扫描</b>。Squid 可完全退出;接管开着的话,安全中心会在 7 天后提示「防护已过期」。</div>
<div class="cost"><span class="chip">零常驻</span><span class="chip warn">无实时防护</span></div>
<button class="btn sm apply">切换</button>
</div>
</div>
<div class="mode-note">备注:节能/性能模式的差别只在 clamd 是否常驻;目录监听与拦截处置逻辑相同。切换即时生效,无需重启。</div>
<div class="sec-title">今日实时防护记录 <small>· 新文件落地即排队检查,共 1,214 个,1 个被拦截</small></div>
<div class="rt">
<h3><span class="live-dot"></span>热点目录监控运行中 · 6 个目录 · clamd 休眠中(今日被拉起 37 次,平均每次 2.4 分钟)</h3>
<div class="rt-row"><time>17:42</time><span class="f">C:\Users\34798\Downloads\setup-x64(1).exe</span><span class="eng">ClamAV</span><span class="st hot">拦截:疑似打包器 PUA</span></div>
<div class="rt-row"><time>16:05</time><span class="f">D:\Temp\照片备份.7z → 解压 84 个文件</span><span class="eng">ClamAV</span><span class="st clean">安全 ×84</span></div>
<div class="rt-row"><time>13:11</time><span class="f">E:\(U盘)\投标书-final.docx</span><span class="eng">ClamAV</span><span class="st clean">安全</span></div>
</div>
<div class="take" style="margin-top:14px">
<div class="take-row">
<div>
<b>接管 Windows 安全中心</b>
<small>Squid 常驻时向安全中心持续报到(心跳);关闭开关将立刻注销,Windows Defender 自动恢复主动模式。</small>
</div>
<div class="switch"></div>
</div>
<div class="take-detail">
<span class="chip ok">WSC 登记 已生效</span>
<span class="chip ok">心跳 上次 17:00 · 正常</span>
<span class="chip">开机自启 开</span>
<span class="chip">卸载将自动注销</span>
</div>
</div>
<div class="sec-title">引擎与病毒库</div>
<div class="grid3">
<div class="card scan-card">
<span class="ic" style="background:var(--violet-soft);color:var(--violet)">⚙</span>
<b>ClamAV 引擎(主)</b>
<small>程序 22 MB 已就绪 · 病毒库 213 MB · 常驻状态随防护模式变化(当前休眠)<br><span style="font-family:Consolas,monospace">TUNA 国内镜像:开</span></small>
<div><button class="btn sm">更新病毒库</button> <button class="btn sm">管理</button></div>
</div>
<div class="card scan-card">
<span class="ic" style="background:var(--green-soft);color:var(--green)">✓</span>
<b>Windows Defender(第二意见)</b>
<small>实时服务已停用(由 Squid 接管);引擎保留,全盘可交给它复查一遍,与 ClamAV 结果互补。</small>
<div><button class="btn sm ghost">用 Defender 全盘复查</button></div>
</div>
<div class="card scan-card">
<span class="ic" style="background:var(--primary-soft);color:var(--primary-strong)">⏱</span>
<b>计划任务</b>
<small>每天 09:30 快速查杀(启动项/服务/下载/浏览器目录);每周日全盘。合盖休眠自动顺延,错过不补跑。</small>
<div><button class="btn sm">调整计划</button></div>
</div>
</div>
<div class="sec-title">查杀进行中(样式沿用 CleanBar)+ 威胁列表</div>
<div class="cleanbar">
<div class="cb-row">
<span style="color:var(--primary);font-size:16px">◌</span>
<div>
<b>正在扫描 486,213 / 1,102,908 个文件 · 已用 6 分 12 秒</b>
<div class="cb-cur">当前:C:\Users\34798\Documents\客户资料\合同-2023.zip · 发现威胁 2</div>
</div>
<span class="pct">44%</span>
<button class="btn sm" style="margin-left:12px">暂停</button>
</div>
<div class="track"><div class="fill"></div></div>
</div>
<div class="threats">
<div class="trow" style="border-top:0"><span class="fam">Eicar-Test-Signature</span><span class="p">C:\Users\34798\Downloads\clamavtest\eicar.txt</span><span class="eng" style="color:var(--violet);background:var(--violet-soft);border-radius:999px;padding:1px 8px;font-size:11px">ClamAV</span><button class="btn sm">定位</button><button class="btn sm ghost">隔离</button></div>
<div class="trow"><span class="fam">Trojan.GenericKD.46872</span><span class="p">D:\Soft\crack\patcher.exe</span><span class="eng" style="color:var(--violet);background:var(--violet-soft);border-radius:999px;padding:1px 8px;font-size:11px">Defender 复查</span><button class="btn sm">定位</button><button class="btn sm ghost">隔离</button></div>
</div>
<p class="fine">隔离 = 移入 Squid 私有隔离区(可一键还原,接入「历史」体系);不直接删除,避免误杀。</p>
</div>
</body>
</html>

View File

@ -1,7 +1,7 @@
{
"name": "squid-desktop",
"private": true,
"version": "0.1.13",
"version": "0.2.0",
"type": "module",
"scripts": {
"dev": "vite --port 1420 --strictPort",

View File

@ -0,0 +1,49 @@
Squid 0.1.13 - Windows x64
系统要求
--------
- Windows 10 或 Windows 11(x64;ARM64 设备通过系统兼容层运行)。
- Microsoft Edge WebView2 Runtime。Windows 10/11 通常已内置;如果 Squid
启动后窗口空白,请从微软官方页面安装 WebView2 Evergreen Runtime:
https://developer.microsoft.com/microsoft-edge/webview2/
- 安装与运行都不需要管理员权限。安装位置为
%LOCALAPPDATA%\Programs\Squid。
- 权限管理页中,机单(HKLM)范围的启动项开关与删除、系统服务需要以
管理员身份运行 Squid(或同意一次 UAC 提权)才能修改,界面会给出
明确提示;UAC 被取消时状态不会被假装成已修改。
安装
----
1. 运行 Squid-Setup-0.1.13-win-x64.exe。
2. 这是未签名构建。若 SmartScreen 显示警告,请选择“更多信息” > “仍要运行”。
3. 升级直接覆盖安装,不再询问是否先卸载旧版本;用户配置自动继承。
4. 卸载请在 Windows“设置 > 应用”中移除 Squid。
更新
----
Squid 使用与 nex_shift 一致的 releases 分支更新通道。更新包会先校验
文件大小与 SHA256,再在退出后运行同一个安装程序。若构建时写入发布公钥,
还会验证清单的 Ed25519 签名。
校验
----
PowerShell:
Get-FileHash .\Squid-Setup-0.1.13-win-x64.exe -Algorithm SHA256
提示
----
- 覆盖升级前请先完全退出 Squid(关闭窗口只会进入托盘,请在托盘图标
上右键退出),否则安装程序无法替换正在运行的程序文件。
- 本机若装有腾讯电脑管家,其"程序保护"可能拦截未签名安装程序写入
临时目录,报"NSIS Error - Error writing temporary file"。三种绕法,
按方便程度排序:
1) 双击本目录的「一键安装.bat」——它会把安装包复制到 C 盘临时目录
再启动(管家只拦从非系统盘启动的安装程序,此法本机验证有效);
2) 管家弹窗出现时选"允许",或将安装文件加入信任区后重试;
3) 使用便携包 Squid-0.1.13-portable-win-x64.zip,解压后把
squid-desktop.exe 覆盖到安装目录(先退出托盘中的 Squid)。
- 本版本重点:开机启动项学习芒果磁盘——残留项识别与一键删除、状态
筛选段、「显示系统项」开关、来源/时机/签名芯片;重复文件的保留
副本现在也可以勾选完全删除(有醒目警告);大文件不再列页面文件;
修复重复文件清理按钮红底深红字看不清的问题。
- 上一版的桌面小组件位置守卫、空间清理/系统维护三页签整合继续有效。

View File

@ -0,0 +1,73 @@
# Squid 0.2.0 — 三版本首发:截图识字 + 安全查杀
这一版是 Squid 从「清理工具」走向「日常系统管家」的分水岭:新增两大功能
(截图识字、安全查杀),并首次把产品切成三个版本同时出包。
## 版本矩阵(同一版本号,同步迭代)
| 版本 | 内容 | 安装包 | 便携包 |
| --- | --- | --- | --- |
| **完整版 full** | 全部清理能力 + 截图识字 + 安全查杀 | `Squid-Setup-0.2.0-win-x64.exe` | `Squid-0.2.0-portable-win-x64.zip` |
| **Pro 版** | 全部清理能力 + 截图识字(不带杀毒) | `Squid-Pro-Setup-0.2.0-win-x64.exe` | `Squid-Pro-0.2.0-portable-win-x64.zip` |
| **Lite 版** | 纯净清理全家桶(截图/杀毒入口不出现) | `Squid-Lite-Setup-0.2.0-win-x64.exe` | `Squid-Lite-0.2.0-portable-win-x64.zip` |
三个包共用同一个更新清单(`squid-update.json`),按 `windows` /
`windows-pro` / `windows-lite` 三个 artifact 键各取所需;Lite 装完永远不会
被推 Pro 的包。
## 新增 · 截图识字(小工具 › 截图识字)
- 框选屏幕任意区域:标注、贴图、长截图、录屏、一键提取文字,
**识别全程离线,画面不出本机**。
- 引擎 = snow-shot 1.6.4 便携版(PP-OCRv6 本地 ONNX 模型),随包**按需下载**
(约 75.5 MB,SHA256 锁定校验后解压到 `%APPDATA%\squid\engines`,
Squid 安装器体积不膨胀)。
- 启用开关 + 全局两键热键(默认 `Alt+D`,可改;单键会被拒绝并解释原因)。
开关关闭即解绑热键,绝不占键。
- 「开始截图」按钮、保存位置直达(`图片\Squid 截图`,不存在自动创建)、
**识别历史**列表(截图文件按时间倒序直读磁盘,点行即在资源管理器定位)、
冷启动说明与 GPL-3 许可标注。
- 学习对象:**[mg-chao/snow-shot](https://github.com/mg-chao/snow-shot)**
(截图+离线 OCR 引擎,GPL-3,进程解耦随包分发);入口与归档体验参考
**[ShareX/ShareX](https://github.com/ShareX/ShareX)**、
**[xushengfeng/eSearch](https://github.com/xushengfeng/eSearch)**。
## 新增 · 安全查杀(安全查杀页)
- **ClamAV 1.4.4 本地引擎** + 病毒库**按需下载不预置**(引擎约 187.6 MB;
库更新走 freshclam,内置国内官方加速节点 `db.cn.clamav.net`,
自动回退 `database.clamav.net`,镜像可手改)。
- **快速查杀**(启动项指向的程序 + 下载/桌面/文档)与**全盘查杀**;
进度实时计数,可取消;威胁列表支持「定位」「隔离」。
- **隔离区**:一键还原 / 彻底删除,误杀可逆,绝不直接删文件。
- **三档实时防护模式**(随时切换、即时生效):
- 节能模式(推荐):常驻仅 Squid 本体约 100 MB,高危目录有新文件才拉起
clamd,闲置 5 分钟自动休眠;
- 性能模式:clamd 24 小时常驻,毫秒级出结果(代价约 650–900 MB 内存);
- 手动模式:零常驻,只留手动与计划查杀。
- **接管 Windows 安全中心**(WSC 登记 + 心跳):开关注册成功后,安全中心
显示「病毒和威胁防护由 Squid 提供」,Defender 自动退居第二意见。
未签名构建会被系统拒绝登记(0x800706F4),页面如实说明原因,不假装成功。
- 学习对象:**[Cisco-Talos/clamav](https://github.com/Cisco-Talos/clamav)**
(开源防病毒引擎);接管体验与「由 XX 管理」状态卡
参考腾讯电脑管家;双引擎互检思路(ClamAV 主查 + Defender 复查互补)。
## 新增 · 基建
- cargo features 三版本矩阵(`default = screenshot+security / pro / lite`),
Tauri 一键分别出包;更新 feed 按版本分发 artifact。
- 引擎按需下载器:缓存复用、SHA256 校验、tar.exe 优先/Expand-Archive 兜底
解压、`squid://engine` 事件流全程可视。
## 修复
- WSC 登记失败的错误文案现在写入配置目录,重启后仍然可见。
## 已知限制
- 未签名构建无法完成 WSC 登记(Windows 对防病毒产品的硬要求),
拿到代码签名证书后该开关即可点亮。
- 「用 Defender 全盘复查」按钮本期先占位(即将上线)。
安装:双击 `Squid-Setup-0.2.0-win-x64.exe`;若被电脑管家/360 拦截
(NSIS 临时文件报错),改双击同目录 `一键安装.bat`。

View File

@ -0,0 +1,6 @@
72bc7d3f6bb2494eeb18b7e47baf6b33ad1c1462550d7f0ecd85f239751150c9 Squid-0.2.0-portable-win-x64.zip
18968353fe1e131f716991dadce4b5a032be28cf1d26e32384fc6bb41959d594 Squid-Lite-0.2.0-portable-win-x64.zip
07e3b79a7b1cafe21100225ff3272f35f8032f7da013cfaf6b624c1cb9405552 Squid-Lite-Setup-0.2.0-win-x64.exe
9584de12873f7e899dd2903f97da6dd9467f9c4dfa2755e8c1566db450706734 Squid-Pro-0.2.0-portable-win-x64.zip
4b1d087ba575ad8e9faee58120827fb4f6b3dd9d6a72b8c6681bda77d6e9b59a Squid-Pro-Setup-0.2.0-win-x64.exe
5a22cb8b609f062ce3d1be03160e5dca1bb1c6fb016afc75c3e2468301a31aa5 Squid-Setup-0.2.0-win-x64.exe

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
{
"schema": 1,
"version": "0.2.0",
"date": "2026-11-25",
"notes": "# Squid 0.2.0 — 三版本首发:截图识字 + 安全查杀\n\n这一版是 Squid 从「清理工具」走向「日常系统管家」的分水岭:新增两大功能\n(截图识字、安全查杀),并首次把产品切成三个版本同时出包。\n\n## 版本矩阵(同一版本号,同步迭代)\n\n| 版本 | 内容 | 安装包 | 便携包 |\n| --- | --- | --- | --- |\n| **完整版 full** | 全部清理能力 + 截图识字 + 安全查杀 | `Squid-Setup-0.2.0-win-x64.exe` | `Squid-0.2.0-portable-win-x64.zip` |\n| **Pro 版** | 全部清理能力 + 截图识字(不带杀毒) | `Squid-Pro-Setup-0.2.0-win-x64.exe` | `Squid-Pro-0.2.0-portable-win-x64.zip` |\n| **Lite 版** | 纯净清理全家桶(截图/杀毒入口不出现) | `Squid-Lite-Setup-0.2.0-win-x64.exe` | `Squid-Lite-0.2.0-portable-win-x64.zip` |\n\n三个包共用同一个更新清单(`squid-update.json`),按 `windows` /\n`windows-pro` / `windows-lite` 三个 artifact 键各取所需;Lite 装完永远不会\n被推 Pro 的包。\n\n## 新增 · 截图识字(小工具 › 截图识字)\n\n- 框选屏幕任意区域:标注、贴图、长截图、录屏、一键提取文字,\n **识别全程离线,画面不出本机**。\n- 引擎 = snow-shot 1.6.4 便携版(PP-OCRv6 本地 ONNX 模型),随包**按需下载**\n (约 75.5 MB,SHA256 锁定校验后解压到 `%APPDATA%\\squid\\engines`,\n Squid 安装器体积不膨胀)。\n- 启用开关 + 全局两键热键(默认 `Alt+D`,可改;单键会被拒绝并解释原因)。\n 开关关闭即解绑热键,绝不占键。\n- 「开始截图」按钮、保存位置直达(`图片\\Squid 截图`,不存在自动创建)、\n **识别历史**列表(截图文件按时间倒序直读磁盘,点行即在资源管理器定位)、\n 冷启动说明与 GPL-3 许可标注。\n- 学习对象:**[mg-chao/snow-shot](https://github.com/mg-chao/snow-shot)**\n (截图+离线 OCR 引擎,GPL-3,进程解耦随包分发);入口与归档体验参考\n **[ShareX/ShareX](https://github.com/ShareX/ShareX)**、\n **[xushengfeng/eSearch](https://github.com/xushengfeng/eSearch)**。\n\n## 新增 · 安全查杀(安全查杀页)\n\n- **ClamAV 1.4.4 本地引擎** + 病毒库**按需下载不预置**(引擎约 187.6 MB;\n 库更新走 freshclam,内置国内官方加速节点 `db.cn.clamav.net`,\n 自动回退 `database.clamav.net`,镜像可手改)。\n- **快速查杀**(启动项指向的程序 + 下载/桌面/文档)与**全盘查杀**;\n 进度实时计数,可取消;威胁列表支持「定位」「隔离」。\n- **隔离区**:一键还原 / 彻底删除,误杀可逆,绝不直接删文件。\n- **三档实时防护模式**(随时切换、即时生效):\n - 节能模式(推荐):常驻仅 Squid 本体约 100 MB,高危目录有新文件才拉起\n clamd,闲置 5 分钟自动休眠;\n - 性能模式:clamd 24 小时常驻,毫秒级出结果(代价约 650–900 MB 内存);\n - 手动模式:零常驻,只留手动与计划查杀。\n- **接管 Windows 安全中心**(WSC 登记 + 心跳):开关注册成功后,安全中心\n 显示「病毒和威胁防护由 Squid 提供」,Defender 自动退居第二意见。\n 未签名构建会被系统拒绝登记(0x800706F4),页面如实说明原因,不假装成功。\n- 学习对象:**[Cisco-Talos/clamav](https://github.com/Cisco-Talos/clamav)**\n (开源防病毒引擎);接管体验与「由 XX 管理」状态卡\n 参考腾讯电脑管家;双引擎互检思路(ClamAV 主查 + Defender 复查互补)。\n\n## 新增 · 基建\n\n- cargo features 三版本矩阵(`default = screenshot+security / pro / lite`),\n Tauri 一键分别出包;更新 feed 按版本分发 artifact。\n- 引擎按需下载器:缓存复用、SHA256 校验、tar.exe 优先/Expand-Archive 兜底\n 解压、`squid://engine` 事件流全程可视。\n\n## 修复\n\n- WSC 登记失败的错误文案现在写入配置目录,重启后仍然可见。\n\n## 已知限制\n\n- 未签名构建无法完成 WSC 登记(Windows 对防病毒产品的硬要求),\n 拿到代码签名证书后该开关即可点亮。\n- 「用 Defender 全盘复查」按钮本期先占位(即将上线)。\n\n安装:双击 `Squid-Setup-0.2.0-win-x64.exe`;若被电脑管家/360 拦截\n(NSIS 临时文件报错),改双击同目录 `一键安装.bat`。\n",
"artifacts": {
"windows": {
"file": "Squid-Setup-0.2.0-win-x64.exe",
"sha256": "5a22cb8b609f062ce3d1be03160e5dca1bb1c6fb016afc75c3e2468301a31aa5",
"size": 4066645
},
"windows-pro": {
"file": "Squid-Pro-Setup-0.2.0-win-x64.exe",
"sha256": "4b1d087ba575ad8e9faee58120827fb4f6b3dd9d6a72b8c6681bda77d6e9b59a",
"size": 3974317
},
"windows-lite": {
"file": "Squid-Lite-Setup-0.2.0-win-x64.exe",
"sha256": "07e3b79a7b1cafe21100225ff3272f35f8032f7da013cfaf6b624c1cb9405552",
"size": 3894331
}
}
}

View File

@ -0,0 +1,41 @@
@echo off
rem Squid 0.2.0 one-click installer (full edition).
rem Copies the setup to %TEMP% first: some security suites (e.g. PC Manager)
rem block unsigned installers launched from non-system drives.
setlocal
title Squid Setup
set "PKG=%~dp0Squid-Setup-0.2.0-win-x64.exe"
if not exist "%PKG%" (
echo [ERROR] Setup file not found next to this script:
echo %PKG%
echo Keep this .bat in the same folder as the setup .exe.
pause
exit /b 1
)
echo [1/3] Stopping a running Squid if any...
taskkill /F /IM squid-desktop.exe >nul 2>&1
rem The kill is asynchronous; give the OS a moment to release the exe lock.
ping -n 3 127.0.0.1 >nul
echo [2/3] Copying installer to temp folder...
copy /Y "%PKG%" "%TEMP%\Squid-Setup-0.2.0-win-x64.exe" >nul
if errorlevel 1 (
echo [ERROR] Copy to %TEMP% failed. Free up disk space or retry.
pause
exit /b 1
)
echo [3/3] Installing silently, please wait...
"%TEMP%\Squid-Setup-0.2.0-win-x64.exe" /S
if errorlevel 1 (
echo [ERROR] Installer exited with code %ERRORLEVEL%.
pause
exit /b 1
)
echo.
echo Squid 0.2.0 installed successfully.
echo (If a previous Squid was running it was closed by this script.)
pause

View File

@ -0,0 +1,62 @@
# Squid 版本更新说明(自上次上传 0.1.13 之后:0.2.0)
---
## 0.2.0 — 三版本首发:截图识字 + 安全查杀
本版是 Squid 从「清理工具」走向「日常系统管家」的分水岭:新增两大功能,
并首次把产品切成三个版本(完整 / Pro / Lite)同版本号同时出包。
### 版本矩阵与基建
- cargo features 三版本矩阵:完整版(截图+杀毒)、Pro(仅截图)、
Lite(纯净清理);Tauri 分别出包,安装包/便携包/更新清单一次三份。
- 更新 feed 按 `windows` / `windows-pro` / `windows-lite` 三 artifact 键
分发,各版本只收自己的包;侧栏底部显示版本徽标(Pro / Lite)。
- 引擎按需下载器(`src-tauri/src/engines.rs`):缓存复用、SHA256 校验、
tar.exe 优先 / Expand-Archive 兜底解压、`squid://engine` 事件流全程
可视(下载/校验/解压/就绪/错误)。
### 新增 · 截图识字(小工具 › 截图识字)
- 框选屏幕任意区域:标注、贴图、长截图、录屏、一键提取文字,识别全程
离线(本地 ONNX 模型),画面不出本机。
- 引擎 = snow-shot 1.6.4 便携版按需下载(约 75.5 MB,SHA256 锁定,
解包到 `%APPDATA%\squid\engines`,Squid 安装器体积不膨胀,GPL-3
组件以独立进程解耦、随包附协议)。
- 启用开关 + 两键全局热键(默认 Alt+D,可改,单键直接拒绝);关开关
即解绑,绝不占键;热键被占用时页面如实提示。
- 「开始截图」、保存位置直达(`图片\Squid 截图`,自动创建)、识别历史
(直读磁盘按时间倒序,点行定位)。
- 学习对象:**mg-chao/snow-shot**
(https://github.com/mg-chao/snow-shot —— 截图+离线 OCR 引擎,
PP-OCRv6 本地模型);入口/归档体验参考 **ShareX/ShareX**
(https://github.com/ShareX/ShareX )、 **xushengfeng/eSearch**
(https://github.com/xushengfeng/eSearch );离线 OCR 备选调研过
**hiroi-sora/Umi-OCR**(https://github.com/hiroi-sora/Umi-OCR )。
### 新增 · 安全查杀(安全查杀页)
- **ClamAV 1.4.4** 本地引擎按需下载(约 187.6 MB)+ 病毒库不预置,
freshclam 更新默认走官方国内加速节点 `db.cn.clamav.net`、失败自动
回退 `database.clamav.net`,镜像可手改。
- 快速查杀(启动项指向的程序 + 下载/桌面/文档)与全盘查杀;进度实时
计数、可取消;威胁列表「定位 / 隔离」。
- 隔离区:一键还原 / 彻底删除,误杀可逆,绝不直接删文件。
- 三档实时防护模式(即时切换):节能(推荐,常驻约 100 MB,新文件才
拉起 clamd,闲置 5 分钟休眠)/ 性能(clamd 24h 常驻,650–900 MB)/
手动(零常驻,只留手动与计划查杀)。
- **接管 Windows 安全中心**(wscapi 登记 + 心跳):开关注册成功后安全
中心显示「病毒和威胁防护由 Squid 提供」(用户要求的「由 XX 管理」
同款效果);未签名构建被系统拒绝(0x800706F4)时页面如实说明「需要
数字签名」,不假装成功。wscapi 导出符号与 IWSCProductList COM 列表
均经本机 spike 验证(注册/心跳/产品清单读取)。
- 学习对象:**ClamAV**(https://github.com/Cisco-Talos/clamav —— 开源
防病毒引擎);WSC 接管与「由 XX 管理」状态卡、双保险(主引擎+系统
引擎复查)思路参考腾讯电脑管家(闭源参照)。
### 其他
- CleanBar 统一清理进度语言(0.1.13 已上线)在本版两页复用同款视觉。
- 已知限制:未签名构建 WSC 登记被拒(拿到代码签名证书即可点亮);
「用 Defender 全盘复查」按钮本期占位(即将上线)。

93
src-tauri/Cargo.lock generated
View File

@ -1403,6 +1403,16 @@ dependencies = [
"version_check",
]
[[package]]
name = "gethostname"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
dependencies = [
"rustix",
"windows-link",
]
[[package]]
name = "getrandom"
version = "0.3.4"
@ -1511,6 +1521,24 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
[[package]]
name = "global-hotkey"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c386b0a4a70cb2d39fffd74480f985b6f0bfbcb934b6a6b6b7e630e448f242e"
dependencies = [
"crossbeam-channel",
"keyboard-types 0.7.0",
"objc2",
"objc2-app-kit",
"once_cell",
"serde",
"thiserror 2.0.21",
"windows-sys 0.59.0",
"x11rb",
"xkeysym",
]
[[package]]
name = "globset"
version = "0.4.21"
@ -2098,6 +2126,17 @@ dependencies = [
"serde_json",
]
[[package]]
name = "keyboard-types"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a"
dependencies = [
"bitflags 2.13.2",
"serde",
"unicode-segmentation",
]
[[package]]
name = "keyboard-types"
version = "0.8.3"
@ -2275,7 +2314,7 @@ dependencies = [
"crossbeam-channel",
"dpi",
"gtk",
"keyboard-types",
"keyboard-types 0.8.3",
"objc2",
"objc2-app-kit",
"objc2-core-foundation",
@ -3512,7 +3551,7 @@ dependencies = [
[[package]]
name = "squid-core"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"anyhow",
"chrono",
@ -3531,10 +3570,11 @@ dependencies = [
[[package]]
name = "squid-desktop"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"base64 0.22.1",
"chrono",
"dirs 6.0.0",
"ed25519-dalek",
"globset",
"hex",
@ -3548,6 +3588,7 @@ dependencies = [
"tauri",
"tauri-build",
"tauri-plugin-dialog",
"tauri-plugin-global-shortcut",
"tauri-plugin-opener",
"tauri-plugin-single-instance",
"uuid",
@ -3555,7 +3596,7 @@ dependencies = [
[[package]]
name = "squid-engine"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"anyhow",
"chrono",
@ -3578,7 +3619,7 @@ dependencies = [
[[package]]
name = "squid-platform"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"dirs 6.0.0",
"libc",
@ -3597,7 +3638,7 @@ dependencies = [
[[package]]
name = "squid-rules"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"globset",
"serde",
@ -3609,7 +3650,7 @@ dependencies = [
[[package]]
name = "squid-stats"
version = "0.1.13"
version = "0.2.0"
dependencies = [
"chrono",
"libc",
@ -3988,6 +4029,21 @@ dependencies = [
"url",
]
[[package]]
name = "tauri-plugin-global-shortcut"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93ff17919fe09852d269bd37b1d3d2e993b9dbb514afe7acbf3346c1d3627e2d"
dependencies = [
"global-hotkey",
"log",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"thiserror 2.0.21",
]
[[package]]
name = "tauri-plugin-opener"
version = "2.7.2"
@ -5408,6 +5464,29 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "x11rb"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414"
dependencies = [
"gethostname",
"rustix",
"x11rb-protocol",
]
[[package]]
name = "x11rb-protocol"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd"
[[package]]
name = "xkeysym"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
[[package]]
name = "yoke"
version = "0.8.4"

View File

@ -1,6 +1,6 @@
[package]
name = "squid-desktop"
version = "0.1.13"
version = "0.2.0"
description = "Squid — a CleanMyMac-inspired cleaner, uninstaller and system monitor."
authors = ["squid contributors"]
edition = "2021"
@ -28,6 +28,7 @@ tauri = { version = "2.11", features = ["tray-icon", "image-png", "macos-private
tauri-plugin-dialog = "2"
tauri-plugin-opener = "2"
tauri-plugin-single-instance = "2"
tauri-plugin-global-shortcut = { version = "2", optional = true }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
chrono = { version = "0.4", features = ["clock"] }
@ -37,6 +38,15 @@ sha2 = "0.10"
hex = "0.4"
ed25519-dalek = { version = "3.0.0", default-features = false, features = ["alloc", "fast"] }
globset = "0.4"
dirs = "6"
# Edition matrix. full = default (screenshot + security),
# pro = --no-default-features --features screenshot,
# lite = --no-default-features.
[features]
default = ["screenshot", "security"]
screenshot = ["dep:tauri-plugin-global-shortcut"]
security = []
[profile.dev]
debug = 1

View File

@ -63,7 +63,7 @@ impl AppState {
.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
fn begin(&self, job_id: &str) -> Result<CancelToken, String> {
pub(crate) fn begin(&self, job_id: &str) -> Result<CancelToken, String> {
if job_id.trim().is_empty() {
return Err("A job identifier is required.".into());
}
@ -73,7 +73,7 @@ impl AppState {
Ok(token)
}
fn finish(&self, job_id: &str) {
pub(crate) fn finish(&self, job_id: &str) {
if let Ok(mut jobs) = self.jobs.lock() {
jobs.remove(job_id);
}
@ -372,6 +372,11 @@ pub struct SettingsView {
language: Option<String>,
history_keep: usize,
setup_reviewed: bool,
screenshot_enabled: bool,
screenshot_hotkey: String,
security_mode: String,
security_takeover: bool,
clamav_mirror: String,
errors: Vec<String>,
}
@ -386,6 +391,11 @@ impl SettingsView {
language: settings.language.clone(),
history_keep: settings.history_keep,
setup_reviewed: settings.desktop_setup_reviewed,
screenshot_enabled: settings.screenshot_enabled,
screenshot_hotkey: settings.screenshot_hotkey.clone(),
security_mode: settings.security_mode.clone(),
security_takeover: settings.security_takeover,
clamav_mirror: settings.clamav_mirror.clone(),
errors,
}
}
@ -395,6 +405,9 @@ impl SettingsView {
#[serde(rename_all = "camelCase")]
pub struct BootstrapView {
version: String,
/// Which feature edition this binary is: full / pro / lite. The shell
/// hides the 截图识字 and 安全查杀 pages for editions lacking them.
edition: String,
platform: String,
os_name: String,
os_version: String,
@ -420,6 +433,7 @@ pub fn bootstrap() -> BootstrapView {
let prefs = crate::update::load_prefs();
BootstrapView {
version: env!("CARGO_PKG_VERSION").into(),
edition: crate::edition_name().into(),
platform: PlatformId::current().as_str().into(),
os_name: engine.platform().display_name(),
os_version: engine.platform().os_version(),
@ -1485,6 +1499,11 @@ pub struct SettingsPatch {
purge_roots: Option<Vec<String>>,
history_keep: Option<usize>,
setup_reviewed: Option<bool>,
screenshot_enabled: Option<bool>,
screenshot_hotkey: Option<String>,
security_mode: Option<String>,
security_takeover: Option<bool>,
clamav_mirror: Option<String>,
}
#[tauri::command]
@ -1519,6 +1538,21 @@ pub async fn settings_save(patch: SettingsPatch) -> Result<SettingsView, String>
if let Some(reviewed) = patch.setup_reviewed {
settings.desktop_setup_reviewed = reviewed;
}
if let Some(enabled) = patch.screenshot_enabled {
settings.screenshot_enabled = enabled;
}
if let Some(hotkey) = patch.screenshot_hotkey {
settings.screenshot_hotkey = hotkey;
}
if let Some(mode) = patch.security_mode {
settings.security_mode = mode;
}
if let Some(takeover) = patch.security_takeover {
settings.security_takeover = takeover;
}
if let Some(mirror) = patch.clamav_mirror {
settings.clamav_mirror = mirror;
}
settings
.save()
.map_err(|error| format!("Could not save settings: {error}"))?;

View File

@ -0,0 +1,238 @@
//! Download-and-unpack support for the on-demand engines (snow-shot capture,
//! ClamAV scanning). Engines are big version-pinned archives fetched from
//! official hosts on first use, checksum-verified, unpacked under
//! `%APPDATA%\squid\engines\<name>\<version>\` and marked ready with a small
//! JSON marker. Progress streams on `squid://engine` so every engine shares
//! one honest download bar (same language as CleanBar).
use serde::Serialize;
use sha2::{Digest, Sha256};
use std::fs;
use std::io::Read;
use std::path::{Path, PathBuf};
use std::time::Duration;
use tauri::Emitter;
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EngineProgress {
pub engine: String,
/// downloading | verifying | extracting | ready | error | cached
pub state: String,
pub done: u64,
pub total: u64,
pub message: String,
}
pub fn emit(
app: &tauri::AppHandle,
engine: &str,
state: &str,
done: u64,
total: u64,
message: &str,
) {
let _ = app.emit(
"squid://engine",
EngineProgress {
engine: engine.into(),
state: state.into(),
done,
total,
message: message.into(),
},
);
}
/// `%APPDATA%\squid\engines` — outside the install folder so silent upgrades
/// never delete a downloaded engine, outside the config file so a broken
/// config.toml cannot orphan 300 MB.
pub fn engines_root() -> PathBuf {
squid_core::Settings::config_dir().join("engines")
}
pub fn engine_dir(engine: &str, version: &str) -> PathBuf {
engines_root().join(engine).join(version)
}
fn marker_path(engine: &str, version: &str) -> PathBuf {
engine_dir(engine, version).join(".squid-engine.json")
}
#[derive(Serialize)]
struct Marker<'a> {
engine: &'a str,
version: &'a str,
/// Relative path of the entry point inside the unpacked tree.
entry: &'a str,
installed: &'a str,
}
/// Ready = marker + entry point both exist. Returns the marker's entry path.
pub fn installed_entry(engine: &str, version: &str, entry: &str) -> Option<PathBuf> {
let dir = engine_dir(engine, version);
if !marker_path(engine, version).is_file() {
return None;
}
let candidate = dir.join(entry);
candidate.is_file().then_some(candidate)
}
pub fn mark_ready(engine: &str, version: &str, entry: &str) -> Result<(), String> {
let marker = Marker {
engine,
version,
entry,
installed: &chrono::Local::now().to_rfc3339(),
};
let text = serde_json::to_string_pretty(&marker).map_err(|e| e.to_string())?;
fs::write(marker_path(engine, version), text).map_err(|e| e.to_string())
}
pub fn sha256_of(path: &Path) -> Result<String, String> {
let mut file = fs::File::open(path).map_err(|e| e.to_string())?;
let mut hasher = Sha256::new();
let mut buffer = vec![0u8; 1 << 20];
loop {
let read = file.read(&mut buffer).map_err(|e| e.to_string())?;
if read == 0 {
break;
}
hasher.update(&buffer[..read]);
}
Ok(hex::encode(hasher.finalize()))
}
/// Download `url` to the engines cache (resuming a complete identical file is
/// skipped), verify `sha256` when given, then unpack into the engine dir.
/// Progress frames: byte-count while downloading, file-count while extracting.
pub fn install_archive(
app: &tauri::AppHandle,
engine: &str,
version: &str,
entry: &str,
url: &str,
sha256: Option<&str>,
) -> Result<PathBuf, String> {
let target_dir = engine_dir(engine, version);
if let Some(existing) = installed_entry(engine, version, entry) {
emit(app, engine, "cached", 0, 0, "已就绪");
return Ok(existing);
}
let _ = fs::remove_dir_all(&target_dir);
fs::create_dir_all(&target_dir).map_err(|e| e.to_string())?;
let cache = engines_root().join(format!("{engine}-{version}.zip"));
let mut reused = false;
if cache.is_file() {
if let Some(expected) = sha256 {
emit(app, engine, "verifying", 0, 0, "校验缓存…");
reused = sha256_of(&cache)?.eq_ignore_ascii_case(expected);
} else {
reused = true;
}
}
if !reused {
let app_dl = app.clone();
let engine_dl = engine.to_string();
let last = std::sync::Arc::new(std::sync::Mutex::new((0u64, 0u64)));
let counter = last.clone();
let watched = cache.clone();
crate::update::download(url, &cache, Duration::from_secs(1800), move || {
// Invoke-WebRequest writes in place; poll the growing file size.
if let Ok(size) = fs::metadata(&watched) {
let done = size.len();
if let Ok(mut pair) = counter.lock() {
if pair.0 != done {
pair.0 = done;
let text = format!("{}", done / (1024 * 1024));
emit(
&app_dl,
&engine_dl,
"downloading",
done,
0,
&format!("已下载 {text} MB"),
);
}
}
}
})?;
if let Some(expected) = sha256 {
emit(app, engine, "verifying", 0, 0, "校验安装包…");
let actual = sha256_of(&cache)?;
if !actual.eq_ignore_ascii_case(expected) {
let _ = fs::remove_file(&cache);
return Err(format!(
"SHA256 mismatch: expected {expected}, got {actual}."
));
}
}
}
emit(app, engine, "extracting", 0, 0, "解压中…");
unpack_zip(&cache, &target_dir)?;
let entry_path = target_dir.join(entry);
if !entry_path.is_file() {
return Err(format!("解压后找不到 {entry},引擎包可能不完整。"));
}
mark_ready(engine, version, entry)?;
let _ = fs::remove_file(&cache);
emit(app, engine, "ready", 0, 0, "安装完成");
Ok(entry_path)
}
/// Zip without pulling a crate dependency at runtime cost we do not need:
/// the `zip` crate is already in the tree through the Tauri bundler tooling,
/// but keeping this module dependency-free means fewer lockfile surprises —
/// so extraction shells out to the Windows built-in `tar` (bsdtar handles
/// zip) and falls back to PowerShell's Expand-Archive.
pub fn unpack_zip(archive: &Path, dest: &Path) -> Result<(), String> {
#[cfg(target_os = "windows")]
{
let status = crate::process::command("tar.exe")
.args([
"-xf",
&archive.to_string_lossy(),
"-C",
&dest.to_string_lossy(),
])
.status();
if matches!(&status, Ok(s) if s.success()) {
return Ok(());
}
let escaped_src = archive.to_string_lossy().replace('\'', "''");
let escaped_dst = dest.to_string_lossy().replace('\'', "''");
let script = format!(
"Expand-Archive -LiteralPath '{escaped_src}' -DestinationPath '{escaped_dst}' -Force"
);
let fallback = crate::process::command("powershell.exe")
.args([
"-NoProfile",
"-NonInteractive",
"-ExecutionPolicy",
"Bypass",
"-Command",
&script,
])
.status()
.map_err(|e| e.to_string())?;
if fallback.success() {
return Ok(());
}
Err("解压引擎安装包失败。".into())
}
#[cfg(not(target_os = "windows"))]
{
let status = crate::process::command("unzip")
.args(["-qq", "-o"])
.arg(archive)
.arg("-d")
.arg(dest)
.status()
.map_err(|e| e.to_string())?;
if status.success() {
Ok(())
} else {
Err("解压引擎安装包失败。".into())
}
}
}

View File

@ -1,7 +1,14 @@
mod app;
// Shared on-demand engine downloader used by both optional editions.
#[cfg(any(feature = "screenshot", feature = "security"))]
mod engines;
mod manage;
mod permissions;
mod process;
#[cfg(feature = "screenshot")]
mod screenshot;
#[cfg(feature = "security")]
mod security;
mod update;
mod widget;
@ -14,6 +21,27 @@ use tauri::{
#[cfg(target_os = "macos")]
use tauri::RunEvent;
/// Feature edition of this binary; drives page visibility in the shell and
/// the artifact-key preference in the update feed.
pub fn edition_name() -> &'static str {
#[cfg(all(feature = "screenshot", feature = "security"))]
{
"full"
}
#[cfg(all(feature = "screenshot", not(feature = "security")))]
{
"pro"
}
#[cfg(all(feature = "security", not(feature = "screenshot")))]
{
"security"
}
#[cfg(not(any(feature = "screenshot", feature = "security")))]
{
"lite"
}
}
fn show_main_window(app: &AppHandle) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
@ -95,12 +123,19 @@ fn create_tray(app: &AppHandle) -> tauri::Result<()> {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let app = tauri::Builder::default()
let builder = tauri::Builder::default()
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
show_main_window(app);
}))
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_opener::init());
// The screenshot hotkey binds later from settings (apply()), never
// at plugin init: a disabled switch must not occupy Alt+D.
#[cfg(feature = "screenshot")]
let builder = builder.plugin(tauri_plugin_global_shortcut::Builder::new().build());
let app = builder
.on_window_event(|window, event| {
if window.label() != "main" {
return;
@ -177,6 +212,38 @@ pub fn run() {
update::update_install,
update::update_clear,
update::set_update_check_enabled,
#[cfg(feature = "screenshot")]
screenshot::screenshot_status,
#[cfg(feature = "screenshot")]
screenshot::screenshot_set_enabled,
#[cfg(feature = "screenshot")]
screenshot::screenshot_set_hotkey,
#[cfg(feature = "screenshot")]
screenshot::screenshot_install,
#[cfg(feature = "screenshot")]
screenshot::screenshot_capture,
#[cfg(feature = "screenshot")]
screenshot::screenshot_history,
#[cfg(feature = "security")]
security::security_status,
#[cfg(feature = "security")]
security::security_install_engine,
#[cfg(feature = "security")]
security::security_update_database,
#[cfg(feature = "security")]
security::security_scan,
#[cfg(feature = "security")]
security::quarantine_list,
#[cfg(feature = "security")]
security::quarantine_add,
#[cfg(feature = "security")]
security::quarantine_restore,
#[cfg(feature = "security")]
security::quarantine_delete,
#[cfg(feature = "security")]
security::security_set_mode,
#[cfg(feature = "security")]
security::security_set_takeover,
])
.setup(|app| {
create_tray(app.handle())?;
@ -184,6 +251,12 @@ pub fn run() {
manage::spawn_watcher(app.handle().clone());
widget::spawn_startup(app.handle());
widget::spawn_desktop_watch(app.handle());
// Bind the capture hotkey only when the switch is on and the
// engine is already installed (apply() decides).
#[cfg(feature = "screenshot")]
screenshot::apply(app.handle());
#[cfg(feature = "security")]
security::spawn_takeover_heartbeat(app.handle());
Ok(())
})
.build(tauri::generate_context!())

View File

@ -0,0 +1,271 @@
//! 小工具 · 截图识字(B1 方案:snow-shot 引擎,纯离线 OCR)
//!
//! Squid owns the entry point (enable switch, two-key global hotkey, history
//! archive); snow-shot owns the overlay. The engine is a version-pinned,
//! checksum-verified portable zip downloaded on first use — Squid's own
//! installer stays small and the GPL-3 component stays a separate process.
//! Hotkey re-registration is what the enable switch and the key settings
//! drive; a missing or disabled engine silently unbinds.
use serde::Serialize;
use std::path::PathBuf;
use std::process::Stdio;
use tauri::AppHandle;
pub const ENGINE: &str = "snow-shot";
pub const VERSION: &str = "1.6.4";
pub const ENTRY: &str = "bin/snow_shot.exe";
pub const URL: &str = "https://github.com/mg-chao/snow-shot/releases/download/v1.6.4_snow-shot/snow-shot-1.6.4-windows-x64-portable.zip";
/// Verified against the release asset during development (GitHub's own
/// `.sha256` sidecar is unreachable from the dev network, so the local hash
/// of the downloaded asset is pinned instead).
pub const SHA256: &str = "8a3e3cbc7aba13864f517ae5786a532b1944664d56244c544c0b3d94114f6b0b";
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ScreenshotStatus {
pub enabled: bool,
pub hotkey: String,
pub installed: bool,
pub engine_version: &'static str,
pub download_size: u64,
/// Lowercase modifier(s) + key as the settings UI displays them.
pub binding_ok: bool,
/// Where captures land (shown + openable from the page).
pub capture_dir: String,
}
pub fn engine_exe() -> Option<PathBuf> {
crate::engines::installed_entry(ENGINE, VERSION, ENTRY)
}
fn parse_hotkey(raw: &str) -> Option<(String, String)> {
// Accepted shape: `Alt+D`, `Ctrl+Alt+A` … last token = key, rest = mods.
let parts: Vec<&str> = raw
.split('+')
.map(|piece| piece.trim())
.filter(|piece| !piece.is_empty())
.collect();
if parts.len() < 2 {
return None;
}
let (key, mods) = parts.split_last()?;
let normalized = mods
.iter()
.map(|modifier| match modifier.to_ascii_lowercase().as_str() {
"ctrl" | "control" => Some("Ctrl"),
"alt" => Some("Alt"),
"shift" => Some("Shift"),
"win" | "meta" | "super" => Some("CommandOrControl"),
_ => None,
})
.collect::<Option<Vec<_>>>()?
.join("+");
let key = match key.to_ascii_uppercase().as_str() {
single if single.len() == 1 => single.to_string(),
"SPACE" => "Space".to_string(),
other if other.starts_with('F') && other[1..].parse::<u8>().is_ok() => other.to_string(),
_ => return None,
};
Some((normalized, key))
}
/// Two keys minimum (the user's explicit rule): modifier(s) + one key.
pub fn hotkey_is_two_key(raw: &str) -> bool {
parse_hotkey(raw).is_some()
}
fn register(app: &AppHandle, raw: &str) -> Result<(), String> {
use tauri_plugin_global_shortcut::{GlobalShortcutExt, ShortcutState};
let (mods, key) = parse_hotkey(raw)
.ok_or_else(|| format!("热键 {raw} 不合法:需要至少两个键,例如 Alt+D"))?;
let combo = format!("{mods}+{key}");
let plugin = app.global_shortcut();
let _ = plugin.unregister_all();
let owned = combo.clone();
plugin
.on_shortcut(combo.as_str(), move |app, _shortcut, event| {
if event.state == ShortcutState::Pressed {
capture(app);
}
})
.map_err(|error| format!("注册全局热键 {owned} 失败(可能被其他软件占用):{error}"))?;
Ok(())
}
fn unregister(app: &AppHandle) {
use tauri_plugin_global_shortcut::GlobalShortcutExt;
let _ = app.global_shortcut().unregister_all();
}
/// Relaunch (or wake) snow-shot: single-instance by design, spawning the exe
/// again surfaces its capture overlay. Detached so Squid never waits on it.
pub fn capture(app: &AppHandle) {
let Some(exe) = engine_exe() else {
crate::engines::emit(
app,
ENGINE,
"error",
0,
0,
"截图引擎未安装,请先到「小工具 › 截图识字」安装。",
);
return;
};
let _ = std::process::Command::new(&exe)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn();
}
fn settings() -> squid_core::Settings {
squid_core::Settings::load().0
}
pub fn apply(app: &AppHandle) -> ScreenshotStatus {
let cfg = settings();
let installed = engine_exe().is_some();
let binding_ok = if cfg.screenshot_enabled && installed {
match register(app, &cfg.screenshot_hotkey) {
Ok(()) => true,
Err(error) => {
crate::engines::emit(app, ENGINE, "error", 0, 0, &error);
false
}
}
} else {
unregister(app);
false
};
ScreenshotStatus {
enabled: cfg.screenshot_enabled,
hotkey: cfg.screenshot_hotkey,
installed,
engine_version: VERSION,
download_size: 79_162_156,
binding_ok,
capture_dir: capture_dir().display().to_string(),
}
}
#[tauri::command]
pub async fn screenshot_status(app: AppHandle) -> Result<ScreenshotStatus, String> {
tauri::async_runtime::spawn_blocking(move || Ok(apply(&app)))
.await
.map_err(|e| e.to_string())?
}
/// Enable/disable from the UI switch; returns the fresh status so the page
/// cannot drift.
#[tauri::command]
pub async fn screenshot_set_enabled(
app: AppHandle,
enabled: bool,
) -> Result<ScreenshotStatus, String> {
tauri::async_runtime::spawn_blocking(move || {
let (mut cfg, _) = squid_core::Settings::load();
cfg.screenshot_enabled = enabled;
cfg.save().map_err(|e| e.to_string())?;
Ok(apply(&app))
})
.await
.map_err(|e| e.to_string())?
}
#[tauri::command]
pub async fn screenshot_set_hotkey(
app: AppHandle,
hotkey: String,
) -> Result<ScreenshotStatus, String> {
if !hotkey_is_two_key(&hotkey) {
return Err("热键至少两个键:修饰键 + 主键,例如 Alt+D".into());
}
tauri::async_runtime::spawn_blocking(move || {
let (mut cfg, _) = squid_core::Settings::load();
cfg.screenshot_hotkey = hotkey;
cfg.save().map_err(|e| e.to_string())?;
Ok(apply(&app))
})
.await
.map_err(|e| e.to_string())?
}
/// Download + verify + unpack the pinned portable zip (progress on
/// `squid://engine`), then re-apply the switch/hotkey state.
#[tauri::command]
pub async fn screenshot_install(app: tauri::AppHandle) -> Result<ScreenshotStatus, String> {
let worker = app.clone();
tauri::async_runtime::spawn_blocking(move || {
crate::engines::install_archive(&worker, ENGINE, VERSION, ENTRY, URL, Some(SHA256))?;
Ok(apply(&worker))
})
.await
.map_err(|e| e.to_string())?
}
#[tauri::command]
pub async fn screenshot_capture(app: AppHandle) -> Result<(), String> {
if engine_exe().is_none() {
return Err("截图引擎尚未安装。".into());
}
capture(&app);
Ok(())
}
/// Where snow-shot saves captures by default (Squid shows + opens it).
/// Created eagerly so 「打开文件夹」 never dead-ends before the first shot.
pub fn capture_dir() -> PathBuf {
let dir = dirs::picture_dir()
.unwrap_or_else(|| PathBuf::from("Pictures"))
.join("Squid 截图");
let _ = std::fs::create_dir_all(&dir);
dir
}
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CaptureEntry {
pub name: String,
pub path: String,
pub modified_ms: u64,
pub size: u64,
}
/// Newest-first capture archive listing straight off disk — honest history,
/// no shadow database that can drift from what Explorer shows.
#[tauri::command]
pub async fn screenshot_history() -> Result<Vec<CaptureEntry>, String> {
tauri::async_runtime::spawn_blocking(|| {
let mut items = Vec::new();
if let Ok(read_dir) = std::fs::read_dir(capture_dir()) {
for file in read_dir.flatten() {
let path = file.path();
let Some(ext) = path.extension().and_then(|e| e.to_str()) else {
continue;
};
if !matches!(ext.to_ascii_lowercase().as_str(), "png" | "jpg" | "jpeg" | "bmp") {
continue;
}
let Ok(meta) = file.metadata() else { continue };
let modified_ms = meta
.modified()
.ok()
.and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
.map(|d| d.as_millis() as u64)
.unwrap_or(0);
items.push(CaptureEntry {
name: path.file_name().unwrap_or_default().to_string_lossy().into_owned(),
path: path.to_string_lossy().into_owned(),
modified_ms,
size: meta.len(),
});
}
}
items.sort_by_key(|entry| std::cmp::Reverse(entry.modified_ms));
items.truncate(20);
Ok(items)
})
.await
.map_err(|e| e.to_string())?
}

View File

@ -0,0 +1,883 @@
//! 安全查杀(ClamAV 引擎版)。
//!
//! Layout of on-disk state under `%APPDATA%\squid`:
//! engines/clamav/<version>/ the official win-x64 zip unpacked
//! bin/clamscan.exe bin/freshclam.exe bin/clamd.exe
//! database/ CVD files + squid's own marker
//! quarantine/<id>.json + <id>.bin Squid's undoable threat store
//!
//! Realtime modes (Settings.security_mode):
//! power — clamscan is spawned per burst; nothing resident
//! performance — clamd stays loaded (fast repeats; ~650–900 MB)
//! manual — only the planned/manual scans run
//! Windows Security Center takeover is attempted through wscapi and reported
//! honestly (some builds refuse an unsigned registrar; the UI says so).
use serde::{Deserialize, Serialize};
use std::fs;
use std::io::{BufRead, BufReader};
use std::path::{Path, PathBuf};
use std::process::Stdio;
use tauri::{AppHandle, Manager};
pub const ENGINE: &str = "clamav";
pub const VERSION: &str = "1.4.4";
pub const ENTRY: &str = "clamav-1.4.4.win.x64/bin/clamscan.exe";
pub const URL: &str = "https://www.clamav.net/downloads/production/clamav-1.4.4.win.x64.zip";
/// Exact asset size (S3 Content-Range verified) for the download UI.
pub const DOWNLOAD_SIZE: u64 = 196_766_801;
/// No pinned SHA yet: the dev network throttles the ~360 MB asset, so the
/// download is checksum-optional until one can be pinned from a full fetch.
pub const SHA256: Option<&str> = None;
pub const MIRROR_AUTO: &str = "database.clamav.net";
/// Official China edge — same CVD stream, closer CDN; primary for auto so a
/// mainland update does not depend on the international route. Verified
/// serving main.cvd with a ClamAV user-agent (plain GETs get a 403 wall).
pub const MIRROR_CN: &str = "db.cn.clamav.net";
fn engine_root() -> Option<PathBuf> {
let exe = crate::engines::installed_entry(ENGINE, VERSION, ENTRY)?;
exe.parent()?.parent().map(Path::to_path_buf)
}
fn bin_dir() -> Option<PathBuf> {
Some(engine_root()?.join("bin"))
}
pub fn database_dir() -> PathBuf {
crate::engines::engine_dir(ENGINE, VERSION).join("database")
}
fn quarantine_root() -> PathBuf {
squid_core::Settings::config_dir().join("quarantine")
}
// ── status ────────────────────────────────────────────────────────────────
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct WscProduct {
pub name: String,
pub state: i32,
pub is_default: bool,
}
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SecurityStatus {
pub mode: String,
pub takeover: bool,
pub engine_installed: bool,
pub engine_version: &'static str,
pub engine_download_size: u64,
pub database_ready: bool,
pub database_updated_ms: Option<u64>,
pub database_mirror: String,
/// Windows only: what the Security Center itself reports.
pub wsc_health: Option<u32>,
pub wsc_products: Vec<WscProduct>,
pub takeover_supported: bool,
pub takeover_last_error: Option<String>,
}
#[derive(Default, Serialize, Deserialize)]
struct DatabaseMarker {
updated_ms: u64,
mirror: String,
version: String,
}
fn database_marker() -> Option<DatabaseMarker> {
let raw = fs::read(database_dir().join("squid-database.json")).ok()?;
serde_json::from_slice(&raw).ok()
}
#[tauri::command]
pub async fn security_status(app: AppHandle) -> Result<SecurityStatus, String> {
let _ = app;
tauri::async_runtime::spawn_blocking(|| {
let cfg = squid_core::Settings::load().0;
let marker = database_marker();
let (health, products) = wsc_snapshot();
Ok(SecurityStatus {
mode: cfg.security_mode.clone(),
takeover: cfg.security_takeover,
engine_installed: bin_dir().is_some(),
engine_version: VERSION,
engine_download_size: DOWNLOAD_SIZE,
database_ready: marker.is_some() && database_dir().join("main.cvd").is_file(),
database_updated_ms: marker.as_ref().map(|m| m.updated_ms),
database_mirror: cfg.clamav_mirror.clone(),
wsc_health: health,
wsc_products: products,
takeover_supported: cfg!(target_os = "windows"),
takeover_last_error: fs::read_to_string(wsc_error_path())
.ok()
.filter(|t| !t.trim().is_empty()),
})
})
.await
.map_err(|e| e.to_string())?
}
// ── engine + database install ─────────────────────────────────────────────
#[tauri::command]
pub async fn security_install_engine(app: tauri::AppHandle) -> Result<SecurityStatus, String> {
let worker = app.clone();
tauri::async_runtime::spawn_blocking(move || {
crate::engines::install_archive(&worker, ENGINE, VERSION, ENTRY, URL, SHA256)?;
security_status_blocking()
})
.await
.map_err(|e| e.to_string())?
}
fn security_status_blocking() -> Result<SecurityStatus, String> {
let cfg = squid_core::Settings::load().0;
let marker = database_marker();
let (health, products) = wsc_snapshot();
Ok(SecurityStatus {
mode: cfg.security_mode.clone(),
takeover: cfg.security_takeover,
engine_installed: bin_dir().is_some(),
engine_version: VERSION,
engine_download_size: 0,
database_ready: marker.is_some() && database_dir().join("main.cvd").is_file(),
database_updated_ms: marker.as_ref().map(|m| m.updated_ms),
database_mirror: cfg.clamav_mirror.clone(),
wsc_health: health,
wsc_products: products,
takeover_supported: cfg!(target_os = "windows"),
takeover_last_error: fs::read_to_string(wsc_error_path())
.ok()
.filter(|t| !t.trim().is_empty()),
})
}
fn write_freshclam_conf(mirror: &str) -> Result<PathBuf, String> {
let dir = database_dir();
fs::create_dir_all(&dir).map_err(|e| e.to_string())?;
let conf = dir.join("squid-freshclam.conf");
// Auto = CN edge first, official fallback — one list, two routes.
let primary = if mirror.trim().is_empty() {
MIRROR_CN
} else {
mirror.trim()
};
let mut text = format!(
"DatabaseDirectory \"{}\"\nDatabaseMirror {primary}\n",
dir.display()
);
if primary != MIRROR_AUTO {
text.push_str(&format!("DatabaseMirror {MIRROR_AUTO}\n"));
}
fs::write(&conf, text).map_err(|e| e.to_string())?;
Ok(conf)
}
/// Run freshclam, streaming its progress lines to `squid://engine`
/// (engine `clamav-db`). Returns when the process exits.
#[tauri::command]
pub async fn security_update_database(app: tauri::AppHandle) -> Result<SecurityStatus, String> {
let worker = app.clone();
tauri::async_runtime::spawn_blocking(move || {
let cfg = squid_core::Settings::load().0;
let conf = write_freshclam_conf(&cfg.clamav_mirror)?;
let freshclam = bin_dir()
.ok_or("引擎未安装,请先下载引擎。")?
.join("freshclam.exe");
let mut command = crate::process::command(&freshclam);
command
.arg("--config-file")
.arg(&conf)
.arg("--stdout")
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let mut child = command
.spawn()
.map_err(|e| format!("启动 freshclam 失败:{e}"))?;
let stdout = child.stdout.take().ok_or("freshclam 无输出")?;
let reader = BufReader::new(stdout);
let mut success_line = String::new();
let mut failed = false;
for line in reader.lines().map_while(Result::ok) {
let trimmed = line.trim();
if trimmed.is_empty() {
continue;
}
if trimmed.contains("ERROR") {
failed = true;
crate::engines::emit(&worker, "clamav-db", "error", 0, 0, trimmed);
} else {
if trimmed.contains("updated")
|| trimmed.contains("is up-to-date")
|| trimmed.contains("OK")
{
success_line = trimmed.to_string();
}
crate::engines::emit(&worker, "clamav-db", "updating", 0, 0, trimmed);
}
}
let status = child.wait_with_output().map_err(|e| e.to_string())?;
if !status.status.success() || failed {
let tail = String::from_utf8_lossy(&status.stderr);
return Err(format!(
"病毒库更新失败:{}",
tail.trim().lines().last().unwrap_or("freshclam 非零退出")
));
}
let version = success_line
.split("version:")
.nth(1)
.map(|rest| rest.split(',').next().unwrap_or("").trim().to_string())
.unwrap_or_default();
let marker = DatabaseMarker {
updated_ms: chrono::Utc::now().timestamp_millis() as u64,
mirror: if cfg.clamav_mirror.trim().is_empty() {
MIRROR_AUTO.to_string()
} else {
cfg.clamav_mirror.clone()
},
version,
};
fs::write(
database_dir().join("squid-database.json"),
serde_json::to_vec_pretty(&marker).map_err(|e| e.to_string())?,
)
.map_err(|e| e.to_string())?;
crate::engines::emit(&worker, "clamav-db", "ready", 0, 0, "病毒库已是最新");
security_status_blocking()
})
.await
.map_err(|e| e.to_string())?
}
// ── scans ─────────────────────────────────────────────────────────────────
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Threat {
pub path: String,
pub virus: String,
pub engine: &'static str,
}
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ScanOutcome {
pub scanned: u64,
pub infected: u64,
pub duration_ms: u64,
pub threats: Vec<Threat>,
pub cancelled: bool,
}
fn quick_scan_targets() -> Vec<String> {
// Where malware actually hides: every startup/service/planned-task binary
// Squid already enumerates (permissions scan), plus hot user folders.
let mut targets: Vec<String> = Vec::new();
let mut seen: std::collections::HashSet<String> = std::collections::HashSet::new();
#[cfg(target_os = "windows")]
for entry in squid_platform::permissions::scan_startup_entries() {
let path = entry.target.replace('"', "");
if path.to_lowercase().ends_with(".exe")
&& Path::new(&path).is_file()
&& seen.insert(path.to_lowercase())
{
targets.push(path);
}
}
for dir in ["Downloads", "Desktop", "Documents"] {
let home = squid_core::paths::home_dir();
let candidate = home.join(dir);
if candidate.is_dir() && seen.insert(candidate.to_string_lossy().to_lowercase()) {
targets.push(candidate.to_string_lossy().into_owned());
}
}
targets
}
#[tauri::command]
pub async fn security_scan(
app: AppHandle,
job_id: String,
scope: String,
) -> Result<ScanOutcome, String> {
let token = app.state::<crate::app::AppState>().begin(&job_id)?;
let worker = app.clone();
let result = tauri::async_runtime::spawn_blocking(move || run_scan(&worker, &token, &scope))
.await
.map_err(|e| e.to_string())?;
app.state::<crate::app::AppState>().finish(&job_id);
result
}
fn run_scan(
app: &AppHandle,
token: &squid_core::progress::CancelToken,
scope: &str,
) -> Result<ScanOutcome, String> {
let started = std::time::Instant::now();
let clamscan = bin_dir()
.ok_or("引擎未安装,请先下载引擎。")?
.join("clamscan.exe");
if !database_dir().join("main.cvd").is_file() && database_marker().is_none() {
return Err("病毒库未下载,请先更新病毒库。".into());
}
let mut command = crate::process::command(&clamscan);
command
.arg("--database")
.arg(database_dir())
.arg("--cross-file")
.arg("-i")
// Machine-readable: suppress the per-file chatter except percent lines.
.arg("--no-summary")
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
match scope {
"full" => {
for drive in drive_roots() {
command.arg(&drive);
}
}
_ => {
for target in quick_scan_targets() {
command.arg(target);
}
}
}
let mut child = command
.spawn()
.map_err(|e| format!("启动 clamscan 失败:{e}"))?;
let mut threats = Vec::new();
let mut scanned = 0u64;
let mut cancelled = false;
let stdout = child.stdout.take().ok_or("clamscan 无输出")?;
for line in BufReader::new(stdout).lines().map_while(Result::ok) {
if token.is_cancelled() {
let _ = child.kill();
cancelled = true;
break;
}
if let Some(rest) = line.strip_suffix(" FOUND") {
// clamscan prints "<path>: <virus> FOUND"; rsplit on the last
// ": " so drive letters ("C:\...") never cut the path short.
if let Some((path, virus)) = rest
.rsplit_once(": ")
.filter(|(p, v)| !p.is_empty() && !v.is_empty())
{
threats.push(Threat {
path: path.trim().to_string(),
virus: virus.trim().to_string(),
engine: "ClamAV",
});
}
} else if let Some(rest) = line.strip_prefix("Scanning ") {
scanned = scanned.saturating_add(1);
let _ = rest;
if scanned % 200 == 0 {
crate::engines::emit(
app,
"clamav-scan",
"scanning",
scanned,
0,
&format!("已扫描 {scanned} 个文件"),
);
}
}
}
let _ = child.wait();
let infected = threats.len() as u64;
crate::engines::emit(
app,
"clamav-scan",
"done",
scanned,
infected,
&format!("扫描完成 · 发现 {infected} 个威胁"),
);
Ok(ScanOutcome {
scanned,
infected,
duration_ms: started.elapsed().as_millis() as u64,
threats,
cancelled,
})
}
fn drive_roots() -> Vec<String> {
#[cfg(target_os = "windows")]
{
(b'C'..=b'Z')
.filter_map(|letter| {
let root = format!("{}:\\", letter as char);
Path::new(&root).exists().then_some(root)
})
.collect()
}
#[cfg(not(target_os = "windows"))]
{
vec!["/".to_string()]
}
}
// ── quarantine ────────────────────────────────────────────────────────────
#[derive(Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct QuarantineEntry {
pub id: String,
pub path: String,
pub virus: String,
pub quarantined_ms: u64,
pub size: u64,
}
fn entry_json(id: &str) -> PathBuf {
quarantine_root().join(format!("{id}.json"))
}
fn entry_blob(id: &str) -> PathBuf {
quarantine_root().join(format!("{id}.bin"))
}
#[tauri::command]
pub async fn quarantine_list() -> Result<Vec<QuarantineEntry>, String> {
tauri::async_runtime::spawn_blocking(|| {
let mut items = Vec::new();
if let Ok(read_dir) = fs::read_dir(quarantine_root()) {
for file in read_dir.flatten() {
if file.path().extension().is_some_and(|e| e == "json") {
if let Ok(raw) = fs::read(file.path()) {
if let Ok(entry) = serde_json::from_slice::<QuarantineEntry>(&raw) {
items.push(entry);
}
}
}
}
}
items.sort_by_key(|item| std::cmp::Reverse(item.quarantined_ms));
Ok(items)
})
.await
.map_err(|e| e.to_string())?
}
#[tauri::command]
pub async fn quarantine_add(path: String, virus: String) -> Result<QuarantineEntry, String> {
tauri::async_runtime::spawn_blocking(move || {
let source = PathBuf::from(&path);
let size = fs::metadata(&source).map(|m| m.len()).unwrap_or(0);
let id = format!(
"{}-{}",
chrono::Local::now().format("%Y%m%d%H%M%S"),
squid_core::ledger::new_session_id()
.chars()
.take(6)
.collect::<String>()
);
fs::create_dir_all(quarantine_root()).map_err(|e| e.to_string())?;
fs::rename(&source, entry_blob(&id))
.or_else(|_| {
fs::copy(&source, entry_blob(&id))?;
fs::remove_file(&source)?;
Ok::<(), std::io::Error>(())
})
.map_err(|e| format!("隔离失败:{e}"))?;
let entry = QuarantineEntry {
id: id.clone(),
path,
virus,
quarantined_ms: chrono::Utc::now().timestamp_millis() as u64,
size,
};
fs::write(
entry_json(&id),
serde_json::to_vec_pretty(&entry).map_err(|e| e.to_string())?,
)
.map_err(|e| e.to_string())?;
Ok(entry)
})
.await
.map_err(|e| e.to_string())?
}
#[tauri::command]
pub async fn quarantine_restore(id: String) -> Result<QuarantineEntry, String> {
tauri::async_runtime::spawn_blocking(move || {
let json = entry_json(&id);
let raw = fs::read(&json).map_err(|e| format!("找不到隔离记录:{e}"))?;
let entry: QuarantineEntry = serde_json::from_slice(&raw).map_err(|e| e.to_string())?;
let target = PathBuf::from(&entry.path);
if let Some(parent) = target.parent() {
fs::create_dir_all(parent).map_err(|e| e.to_string())?;
}
fs::rename(entry_blob(&id), &target).map_err(|e| format!("还原失败:{e}"))?;
let _ = fs::remove_file(json);
Ok(entry)
})
.await
.map_err(|e| e.to_string())?
}
#[tauri::command]
pub async fn quarantine_delete(id: String) -> Result<(), String> {
tauri::async_runtime::spawn_blocking(move || {
let _ = fs::remove_file(entry_blob(&id));
let _ = fs::remove_file(entry_json(&id));
Ok(())
})
.await
.map_err(|e| e.to_string())?
}
// ── realtime mode + WSC takeover ─────────────────────────────────────────
#[tauri::command]
pub async fn security_set_mode(app: AppHandle, mode: String) -> Result<SecurityStatus, String> {
if !matches!(mode.as_str(), "power" | "performance" | "manual") {
return Err("未知模式".into());
}
tauri::async_runtime::spawn_blocking(move || {
let (mut cfg, _) = squid_core::Settings::load();
cfg.security_mode = mode.clone();
cfg.save().map_err(|e| e.to_string())?;
apply_clamd_residency(&mode);
let _ = app;
security_status_blocking()
})
.await
.map_err(|e| e.to_string())?
}
/// Performance mode keeps clamd warm; everything else releases it.
fn apply_clamd_residency(mode: &str) {
#[cfg(target_os = "windows")]
{
if mode == "performance" {
if let Some(dir) = bin_dir() {
let clamd = dir.join("clamd.exe");
if clamd.is_file() {
let conf = database_dir().join("squid-clamd.conf");
if !conf.is_file() {
let _ = fs::write(
&conf,
format!("DatabaseDirectory \"{}\"\nTCPSocket 34321\nTCPAddr 127.0.0.1\nForeground yes\n", database_dir().display()),
);
}
let _ = std::process::Command::new(clamd)
.arg("--config-file")
.arg(&conf)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn();
}
}
} else {
let mut command = crate::process::command("taskkill.exe");
command.args(["/IM", "clamd.exe", "/F"]);
let _ = command.status();
}
}
#[cfg(not(target_os = "windows"))]
let _ = mode;
}
fn wsc_error_path() -> PathBuf {
squid_core::Settings::config_dir().join("wsc-last-error.txt")
}
#[tauri::command]
pub async fn security_set_takeover(app: AppHandle, enable: bool) -> Result<SecurityStatus, String> {
let _ = app;
tauri::async_runtime::spawn_blocking(move || {
let (mut cfg, _) = squid_core::Settings::load();
cfg.security_takeover = enable;
cfg.save().map_err(|e| e.to_string())?;
let result = if enable {
wsc::register()
} else {
wsc::unregister()
};
match result {
Ok(()) => {
let _ = fs::remove_file(wsc_error_path());
}
Err(error) => {
let _ = fs::write(wsc_error_path(), &error);
}
}
security_status_blocking()
})
.await
.map_err(|e| e.to_string())?
}
/// Startup + heartbeat: refresh the WSC registration so the Security Center
/// never flips to 「已过期」while Squid is supposed to be in charge.
pub fn spawn_takeover_heartbeat(app: &AppHandle) {
#[cfg(target_os = "windows")]
{
let handle = app.clone();
std::thread::spawn(move || loop {
let cfg = squid_core::Settings::load().0;
if cfg.security_takeover {
let _ = wsc::update();
let _ = &handle;
}
std::thread::sleep(std::time::Duration::from_secs(6 * 3600));
});
}
#[cfg(not(target_os = "windows"))]
let _ = app;
}
fn wsc_snapshot() -> (Option<u32>, Vec<WscProduct>) {
#[cfg(target_os = "windows")]
{
wsc::snapshot()
}
#[cfg(not(target_os = "windows"))]
{
(None, Vec::new())
}
}
/// Windows Security Center FFI (wscapi + the registered-product COM list).
/// Ported from the verified dev spike; the layout matches the Windows SDK.
#[cfg(target_os = "windows")]
mod wsc {
use super::WscProduct;
use std::ffi::c_void;
type HResult = i32;
type WideText = Box<[u16]>;
type InitFn = unsafe extern "system" fn(*mut c_void, u32) -> HResult;
type CountFn = unsafe extern "system" fn(*mut c_void, *mut i32) -> HResult;
type ItemFn = unsafe extern "system" fn(*mut c_void, u32, *mut *mut c_void) -> HResult;
type NameFn = unsafe extern "system" fn(*mut c_void, *mut *mut u16) -> HResult;
type StateFn = unsafe extern "system" fn(*mut c_void, *mut i32) -> HResult;
type BoolFn = unsafe extern "system" fn(*mut c_void, *mut i16) -> HResult;
#[repr(C)]
#[derive(Clone, Copy)]
struct LARGE_INTEGER(i64);
#[repr(C)]
struct ProductInfo {
dw_version: u32,
product_type: u32,
product_status: u32,
remediation_path: *const u16,
display_name: *const u16,
state_timestamp: LARGE_INTEGER,
time_to_next_integrity_check: LARGE_INTEGER,
signature_state: i32,
signature_display_name: *const u16,
}
#[repr(C)]
struct Guid {
data1: u32,
data2: u16,
data3: u16,
data4: [u8; 8],
}
#[link(name = "wscapi")]
extern "system" {
fn wscRegisterSecurityProduct(info: *const ProductInfo) -> HResult;
fn wscUpdateProductStatus(info: *const ProductInfo) -> HResult;
fn wscUnregisterSecurityProduct(info: *const ProductInfo) -> HResult;
fn WscGetSecurityProviderHealth(providers: u32, health: *mut u32) -> HResult;
static IID_IWSCProductList: Guid;
}
#[link(name = "ole32")]
extern "system" {
fn CoInitializeEx(reserved: *mut c_void, model: u32) -> HResult;
fn CoCreateInstance(
rclsid: *const Guid,
outer: *mut c_void,
cls_context: u32,
riid: *const Guid,
ppv: *mut *mut c_void,
) -> HResult;
}
fn wide(text: &str) -> WideText {
text.encode_utf16().chain(std::iter::once(0)).collect()
}
fn now_filetime() -> i64 {
let secs = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_secs())
.unwrap_or(0);
secs as i64 * 10_000_000 + 116_444_736_000_000_000
}
fn build() -> (ProductInfo, WideText, WideText, WideText) {
let exe = std::env::current_exe()
.map(|p| p.to_string_lossy().into_owned())
.unwrap_or_default();
let name = wide("Squid 安全中心");
let remediation = wide(&exe);
let signature = wide("");
(
ProductInfo {
dw_version: 0x0001_0000,
product_type: 0,
product_status: 0,
remediation_path: remediation.as_ptr(),
display_name: name.as_ptr(),
state_timestamp: LARGE_INTEGER(now_filetime()),
time_to_next_integrity_check: LARGE_INTEGER(12 * 3600),
signature_state: 0,
signature_display_name: signature.as_ptr(),
},
name,
remediation,
signature,
)
}
fn com_init() {
unsafe {
CoInitializeEx(std::ptr::null_mut(), 0);
}
}
pub fn register() -> Result<(), String> {
com_init();
unsafe {
let (info, _n, _r, _s) = build();
let hr = wscRegisterSecurityProduct(&info);
check(hr, "登记")
}
}
pub fn update() -> Result<(), String> {
com_init();
unsafe {
let (info, _n, _r, _s) = build();
let hr = wscUpdateProductStatus(&info);
check(hr, "刷新")
}
}
pub fn unregister() -> Result<(), String> {
com_init();
unsafe {
let (info, _n, _r, _s) = build();
let hr = wscUnregisterSecurityProduct(&info);
check(hr, "注销")
}
}
fn check(hr: HResult, verb: &str) -> Result<(), String> {
if hr >= 0 {
return Ok(());
}
Err(match hr {
// The dev spike on Win11 24H2 observed this for unsigned callers:
// honest text instead of a raw code.
-2_147_023_628 => format!("WSC {verb}被系统拒绝(0x800706F4):Windows 要求防病毒产品具备数字签名。购买代码签名证书后即可开启接管。"),
other => format!("WSC {verb}失败(HRESULT {other:#010X})。"),
})
}
/// Read-only view of the Security Center registry (the COM product list,
/// vtable slots verified in the spike).
pub fn snapshot() -> (Option<u32>, Vec<WscProduct>) {
com_init();
let mut health = None;
unsafe {
let mut value = 9u32;
if WscGetSecurityProviderHealth(4, &mut value) >= 0 {
health = Some(value);
}
}
let clsid = Guid {
data1: 0x1707_2F7B,
data2: 0x9ABE,
data3: 0x4A74,
data4: [0xA2, 0x61, 0x1E, 0xB7, 0x6B, 0x55, 0x10, 0x7A],
};
let mut products = Vec::new();
unsafe {
let mut list: *mut c_void = std::ptr::null_mut();
let hr = CoCreateInstance(
&raw const clsid,
std::ptr::null_mut(),
1 | 4,
&raw const IID_IWSCProductList,
&mut list,
);
if hr < 0 || list.is_null() {
return (health, products);
}
let vtable = *(list as *mut *mut *mut c_void);
let initialize = std::mem::transmute::<*mut c_void, InitFn>(*vtable.add(7));
let get_count = std::mem::transmute::<*mut c_void, CountFn>(*vtable.add(8));
let get_item = std::mem::transmute::<*mut c_void, ItemFn>(*vtable.add(9));
if initialize(list, 4) < 0 {
return (health, products);
}
let mut count = 0i32;
if get_count(list, &mut count) < 0 {
return (health, products);
}
for index in 0..count.max(0) as u32 {
let mut item: *mut c_void = std::ptr::null_mut();
if get_item(list, index, &mut item) < 0 || item.is_null() {
continue;
}
let ivtable = *(item as *mut *mut *mut c_void);
let get_name = std::mem::transmute::<*mut c_void, NameFn>(*ivtable.add(7));
let get_state = std::mem::transmute::<*mut c_void, StateFn>(*ivtable.add(8));
let get_default = std::mem::transmute::<*mut c_void, BoolFn>(*ivtable.add(13));
let mut name_ptr: *mut u16 = std::ptr::null_mut();
let mut state = -1i32;
let mut is_default = 0i16;
if get_name(item, &mut name_ptr) >= 0 && !name_ptr.is_null() {
let mut len = 0usize;
while *name_ptr.add(len) != 0 {
len += 1;
}
let name = String::from_utf16_lossy(std::slice::from_raw_parts(name_ptr, len));
let _ = get_state(item, &mut state);
let _ = get_default(item, &mut is_default);
products.push(WscProduct {
name,
state,
is_default: is_default != 0,
});
}
}
}
(health, products)
}
}
#[cfg(not(target_os = "windows"))]
mod wsc {
use super::WscProduct;
pub fn register() -> Result<(), String> {
Err("WSC 接管仅支持 Windows。".into())
}
pub fn update() -> Result<(), String> {
Ok(())
}
pub fn unregister() -> Result<(), String> {
Ok(())
}
pub fn snapshot() -> (Option<u32>, Vec<WscProduct>) {
(None, Vec::new())
}
}

View File

@ -174,10 +174,26 @@ fn platform_key() -> &'static str {
}
fn artifact_keys_for(platform: &str, arch: &str) -> Vec<String> {
// Edition-specific artifacts first so a Pro install never pulls the full
// bundle; "windows" stays the fallback for feeds that ship one file.
let edition = crate::edition_name();
let suffix = if edition == "full" {
String::new()
} else {
format!("-{edition}")
};
if platform == "windows" && arch == "aarch64" {
return vec!["windows-arm64".to_string(), "windows".to_string()];
let mut keys = vec![format!("windows-arm64{suffix}"), format!("windows{suffix}")];
if !suffix.is_empty() {
keys.push("windows-arm64".to_string());
keys.push("windows".to_string());
}
return keys;
}
vec![platform.to_string()]
if suffix.is_empty() {
return vec![platform.to_string()];
}
vec![format!("{platform}{suffix}"), platform.to_string()]
}
fn select_artifact<'a>(
@ -353,7 +369,7 @@ fn raw_asset_url(file: &str) -> Result<String, String> {
Ok(format!("{directory}/{}", file.trim_start_matches('/')))
}
fn download(
pub(crate) fn download(
url: &str,
destination: &Path,
timeout: Duration,

View File

@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Squid",
"version": "0.1.13",
"version": "0.2.0",
"identifier": "app.nex.squid",
"mainBinaryName": "squid-desktop",
"build": {

View File

@ -7,7 +7,9 @@ import {
LayoutDashboard,
MonitorSmartphone,
RefreshCw,
ScanText,
Settings,
Shield,
ShieldCheck,
Sparkles,
Wrench,
@ -36,6 +38,8 @@ import { HistoryPage } from "./pages/HistoryPage";
import { MaintenanceHubPage, type MaintTab } from "./pages/MaintenanceHubPage";
import { OverviewPage } from "./pages/OverviewPage";
import { PermissionsPage } from "./pages/PermissionsPage";
import { ScreenshotPage } from "./pages/ScreenshotPage";
import { SecurityPage } from "./pages/SecurityPage";
import { SettingsPage } from "./pages/SettingsPage";
import { SpaceHubPage, type SpaceTab } from "./pages/SpaceHubPage";
import { SystemPage } from "./pages/SystemPage";
@ -49,6 +53,8 @@ const NAV_GROUPS: {
labelEn: string;
labelZh: string;
icon: typeof LayoutDashboard;
/** Feature editions that ship this page; undefined = every edition. */
editions?: string[];
}[];
}[] = [
{
@ -87,6 +93,26 @@ const NAV_GROUPS: {
},
],
},
{
labelEn: "Tools",
labelZh: "工具",
items: [
{
id: "security",
labelEn: "Security",
labelZh: "安全查杀",
icon: Shield,
editions: ["full", "security"],
},
{
id: "screenshot",
labelEn: "Screenshot OCR",
labelZh: "截图识字",
icon: ScanText,
editions: ["full", "pro"],
},
],
},
{
labelEn: "Insights",
labelZh: "洞察",
@ -113,6 +139,24 @@ const NAV_GROUPS: {
},
];
/** Nav filtered to the feature edition of this binary: an edition lacking a
* command does not get its page either (Lite shows neither Tools entry). */
function navGroupsFor(edition: string) {
return NAV_GROUPS.map((group) => ({
...group,
items: group.items.filter((item) => !item.editions || item.editions.includes(edition)),
})).filter((group) => group.items.length > 0);
}
function pageAllowed(page: PageId, edition: string): boolean {
for (const group of NAV_GROUPS) {
for (const item of group.items) {
if (item.id === page) return !item.editions || item.editions.includes(edition);
}
}
return true;
}
const PAGE_TITLES: Record<PageId, [string, string]> = {
overview: ["Computer overview", "电脑概览"],
space: ["Space cleaning", "空间清理"],
@ -120,6 +164,8 @@ const PAGE_TITLES: Record<PageId, [string, string]> = {
permissions: ["Permissions", "权限管理"],
widget: ["Desktop widget", "桌面小工具"],
maintenance: ["System maintenance", "系统维护"],
security: ["Security", "安全查杀"],
screenshot: ["Screenshot OCR", "截图识字"],
system: ["Real-time monitor", "实时监控"],
history: ["History", "历史记录"],
settings: ["Settings", "设置"],
@ -267,18 +313,22 @@ export default function App() {
}, []);
useEffect(() => {
const order: PageId[] = [
"overview",
"space",
"applications",
"permissions",
"maintenance",
"system",
"widget",
"history",
"settings",
];
// Ctrl/Cmd+1..9 map to the nine pages in order; 0 opens the widget.
const order: PageId[] = (
[
"overview",
"space",
"applications",
"permissions",
"maintenance",
"system",
"widget",
"security",
"screenshot",
"history",
"settings",
] as PageId[]
).filter((id) => pageAllowed(id, bootstrap?.edition ?? "full"));
// Ctrl/Cmd+1..9 map to the edition-visible pages in order; 0 opens the widget.
const onKey = (event: KeyboardEvent) => {
if (!(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey) return;
if (event.key === "0") {
@ -293,7 +343,7 @@ export default function App() {
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, []);
}, [bootstrap?.edition]);
const changeLanguage = useCallback(
async (nextLanguage: Language) => {
@ -380,6 +430,12 @@ export default function App() {
{page === "maintenance" ? (
<MaintenanceHubPage initialTab={maintTab} />
) : null}
{page === "security" && pageAllowed("security", bootstrap.edition) ? (
<SecurityPage onHistory={() => setPage("history")} />
) : null}
{page === "screenshot" && pageAllowed("screenshot", bootstrap.edition) ? (
<ScreenshotPage />
) : null}
{page === "system" ? (
<SystemPage
snapshot={system.snapshot}
@ -421,6 +477,18 @@ function AppChrome({
}) {
const { t, lang } = useI18n();
const title = PAGE_TITLES[page][lang === "zh" ? 1 : 0];
const groups = navGroupsFor(bootstrap.edition);
// full ships without a suffix; the trimmed editions badge themselves.
const editionSuffix =
bootstrap.edition === "full"
? ""
: bootstrap.edition === "pro"
? " Pro"
: bootstrap.edition === "lite"
? " Lite"
: bootstrap.edition === "security"
? " Security"
: ` ${bootstrap.edition}`;
return (
<div
@ -439,7 +507,7 @@ function AppChrome({
</div>
<nav className="sidebar-nav" aria-label={t("Main navigation", "主导航")}>
{NAV_GROUPS.map((group) => (
{groups.map((group) => (
<div className="nav-group" key={group.labelEn}>
<span className="nav-group-label">
{lang === "zh" ? group.labelZh : group.labelEn}
@ -499,7 +567,10 @@ function AppChrome({
{updateVersion ? <i className="nav-dot" /> : null}
</button>
<div className="sidebar-meta">
<span>Squid {bootstrap.version}</span>
<span>
Squid {bootstrap.version}
{editionSuffix}
</span>
<span>{bootstrap.platform === "windows" ? "Windows" : bootstrap.osName}</span>
</div>
</div>

View File

@ -4,9 +4,11 @@ import type {
AppsResult,
AdvancedScanResult,
Bootstrap,
CaptureEntry,
DeleteMode,
DeleteResult,
DupsResult,
EngineProgress,
ExploreResult,
HistorySession,
JobProgress,
@ -21,7 +23,11 @@ import type {
PopupClosedEvent,
PopupWindowItem,
PreflightResult,
QuarantineEntry,
ScanOutcome,
ScanResult,
ScreenshotStatus,
SecurityStatus,
SettingsView,
SpaceInsight,
SystemSnapshot,
@ -42,6 +48,11 @@ export interface SettingsPatch {
purgeRoots?: string[];
historyKeep?: number;
setupReviewed?: boolean;
screenshotEnabled?: boolean;
screenshotHotkey?: string;
securityMode?: string;
securityTakeover?: boolean;
clamavMirror?: string;
}
export const api = {
@ -138,6 +149,29 @@ export const api = {
widgetGet: () => invoke<{ prefs: WidgetPrefs }>("widget_get"),
widgetSet: (patch: WidgetPatch) => invoke<WidgetPrefs>("widget_set", { patch }),
widgetHide: () => invoke<void>("widget_hide"),
// 截图识字(仅 full / pro 二进制编译了这些命令)
screenshotStatus: () => invoke<ScreenshotStatus>("screenshot_status"),
screenshotSetEnabled: (enabled: boolean) =>
invoke<ScreenshotStatus>("screenshot_set_enabled", { enabled }),
screenshotSetHotkey: (hotkey: string) =>
invoke<ScreenshotStatus>("screenshot_set_hotkey", { hotkey }),
screenshotInstall: () => invoke<ScreenshotStatus>("screenshot_install"),
screenshotCapture: () => invoke<void>("screenshot_capture"),
screenshotHistory: () => invoke<CaptureEntry[]>("screenshot_history"),
// 安全查杀(仅 full / security 二进制编译了这些命令)
securityStatus: () => invoke<SecurityStatus>("security_status"),
securityInstallEngine: () => invoke<SecurityStatus>("security_install_engine"),
securityUpdateDatabase: () => invoke<SecurityStatus>("security_update_database"),
securityScan: (jobId: string, scope: "quick" | "full") =>
invoke<ScanOutcome>("security_scan", { jobId, scope }),
securitySetMode: (mode: string) => invoke<SecurityStatus>("security_set_mode", { mode }),
securitySetTakeover: (enable: boolean) =>
invoke<SecurityStatus>("security_set_takeover", { enable }),
quarantineList: () => invoke<QuarantineEntry[]>("quarantine_list"),
quarantineAdd: (path: string, virus: string) =>
invoke<QuarantineEntry>("quarantine_add", { path, virus }),
quarantineRestore: (id: string) => invoke<QuarantineEntry>("quarantine_restore", { id }),
quarantineDelete: (id: string) => invoke<void>("quarantine_delete", { id }),
updateCheck: () => invoke<UpdateCheckResult>("update_check"),
updateStatus: () => invoke<UpdateStatus | null>("update_status"),
updateDownload: () => invoke<UpdateStatus>("update_download"),
@ -149,6 +183,8 @@ export const api = {
listen<JobProgress>("squid://progress", (event) => handler(event.payload)),
onUpdateProgress: (handler: (progress: UpdateProgress) => void) =>
listen<UpdateProgress>("update://progress", (event) => handler(event.payload)),
onEngineProgress: (handler: (progress: EngineProgress) => void) =>
listen<EngineProgress>("squid://engine", (event) => handler(event.payload)),
onUpdateStatus: (handler: (status: UpdateStatus | null) => void) =>
listen<UpdateStatus | null>("update://status", (event) => handler(event.payload)),
onNavigate: (handler: (page: PageId) => void) =>

View File

@ -0,0 +1,441 @@
/* 小工具 · 截图识字(B1:snow-shot 引擎,纯离线 OCR)。
* Squid owns the entry point (enable switch, two-key global hotkey, capture
* folder); snow-shot owns the overlay. Every number on this page is live
* backend state — the download streams on `squid://engine` (snow-shot). */
import { Crop, FolderOpen, LoaderCircle } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { useI18n } from "../i18n";
import { api } from "../lib/api";
import { formatBytes, formatMemory, messageFrom } from "../lib/format";
import type { CaptureEntry, EngineProgress, ScreenshotStatus } from "../types";
import {
Button,
InlineError,
PageHeader,
Toggle,
useToast,
} from "../components/ui";
const MODIFIER_KEYS = new Set(["Control", "Alt", "Shift", "Meta"]);
function stampLabel(ms: number): string {
const date = new Date(ms);
if (Number.isNaN(date.getTime())) return "—";
const pad = (value: number) => String(value).padStart(2, "0");
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
}
/** `Alt+D` → keycap row. Unknown spellings ride through untouched. */
function HotkeyCaps({ hotkey }: { hotkey: string }) {
const pieces = hotkey
.split("+")
.map((piece) => piece.trim())
.filter(Boolean);
return (
<span className="shot-hotkey-caps">
{pieces.map((piece, index) => (
<span key={`${piece}-${index}`} className="shot-cap-group">
{index > 0 ? <i>+</i> : null}
<kbd className="shot-kbd">{piece}</kbd>
</span>
))}
</span>
);
}
export function ScreenshotPage() {
const { t, lang } = useI18n();
const { push } = useToast();
const [status, setStatus] = useState<ScreenshotStatus | null>(null);
const [error, setError] = useState<string | null>(null);
const [installing, setInstalling] = useState(false);
const [progress, setProgress] = useState<EngineProgress | null>(null);
const [capturing, setCapturing] = useState(false);
const [hotkeyError, setHotkeyError] = useState<string | null>(null);
const [history, setHistory] = useState<CaptureEntry[]>([]);
const pendingCombo = useRef<string | null>(null);
const refreshHistory = () =>
api
.screenshotHistory()
.then(setHistory)
.catch(() => {
/* the archive list is advisory; the folder button always works */
});
useEffect(() => {
let cancelled = false;
let stop: (() => void) | null = null;
void api
.screenshotStatus()
.then((next) => !cancelled && setStatus(next))
.catch((reason) => !cancelled && setError(messageFrom(reason)));
void api
.screenshotHistory()
.then((next) => !cancelled && setHistory(next))
.catch(() => undefined);
// Engine frames belong to every producer; only ours paints here.
void api
.onEngineProgress((frame) => {
if (cancelled || frame.engine !== "snow-shot") return;
setProgress(frame);
})
.then((unlisten) => {
if (cancelled) unlisten();
else stop = unlisten;
});
return () => {
cancelled = true;
stop?.();
};
}, []);
const fail = (reason: unknown) => {
const message = messageFrom(reason);
push(message, "danger");
};
const setEnabled = (enabled: boolean) => {
setError(null);
void api
.screenshotSetEnabled(enabled)
.then(setStatus)
.catch(fail);
};
const applyHotkey = (combo: string) => {
setHotkeyError(null);
void api
.screenshotSetHotkey(combo)
.then((next) => setStatus(next))
.catch((reason) => setHotkeyError(messageFrom(reason)));
};
// 录入模式:主键按下即成串,任一键抬起提交;Esc 取消;单键(无修饰)
// 交给后端校验并原样报错。
useEffect(() => {
if (!capturing) return;
const onKeyDown = (event: KeyboardEvent) => {
event.preventDefault();
event.stopPropagation();
if (event.key === "Escape") {
pendingCombo.current = null;
setCapturing(false);
return;
}
if (MODIFIER_KEYS.has(event.key)) return; // still waiting for the main key
const mods: string[] = [];
if (event.ctrlKey) mods.push("Ctrl");
if (event.altKey) mods.push("Alt");
if (event.shiftKey) mods.push("Shift");
const key =
event.key === " " || event.key === "Spacebar"
? "Space"
: event.key.length === 1
? event.key.toUpperCase()
: event.key;
pendingCombo.current = [...mods, key].join("+");
};
const onKeyUp = (event: KeyboardEvent) => {
event.preventDefault();
const combo = pendingCombo.current;
if (combo === null) return; // only a modifier so far — keep listening
pendingCombo.current = null;
setCapturing(false);
applyHotkey(combo);
};
const onBlur = () => {
pendingCombo.current = null;
setCapturing(false);
};
window.addEventListener("keydown", onKeyDown, true);
window.addEventListener("keyup", onKeyUp, true);
window.addEventListener("blur", onBlur);
return () => {
window.removeEventListener("keydown", onKeyDown, true);
window.removeEventListener("keyup", onKeyUp, true);
window.removeEventListener("blur", onBlur);
};
}, [capturing]);
const install = () => {
setInstalling(true);
setError(null);
setProgress(null);
void api
.screenshotInstall()
.then((next) => {
setStatus(next);
push(
lang === "zh" ? "截图识字引擎已安装" : "Screenshot OCR engine installed",
"success",
);
})
.catch(fail)
.finally(() => {
setInstalling(false);
});
};
const capture = () => {
void api
.screenshotCapture()
.catch((reason) => setError(messageFrom(reason)));
};
if (!status) {
return (
<div className="page shot-page">
<PageHeader
eyebrow="UTILITIES"
title={t("Screenshot OCR", "截图识字")}
description={t("Loading…", "正在加载…")}
/>
{error ? <InlineError message={error} onDismiss={() => setError(null)} /> : null}
</div>
);
}
const pct =
progress && progress.state === "downloading" && progress.total > 0
? Math.min(100, Math.round((progress.done / progress.total) * 100))
: null;
const downloadLine = (() => {
if (!progress) return t("Downloading…", "下载中…");
switch (progress.state) {
case "downloading":
return t(
`Downloaded ${formatMemory(progress.done)}${progress.total ? ` / ${formatMemory(progress.total)}` : ""}`,
`已下载 ${formatMemory(progress.done)}${progress.total ? ` / ${formatMemory(progress.total)}` : ""}`,
);
case "verifying":
return t("Verifying…", "校验中");
case "extracting":
return t("Unpacking…", "解压中");
case "error":
return progress.message;
default:
return progress.message || t("Working…", "处理中…");
}
})();
return (
<div className="page shot-page">
<PageHeader
eyebrow="UTILITIES"
title={t("Screenshot OCR", "截图识字")}
description={t(
"Drag a box over anything on screen: annotate, pin, scroll-capture, record — and extract the text in one click. Fully offline, nothing leaves this machine.",
"框选屏幕任意区域:可标注、贴图、长截图、录屏,一键提取文字 —— 全程离线,画面不出本机。",
)}
/>
{error ? <InlineError message={error} onDismiss={() => setError(null)} /> : null}
<section className="shot-main">
<span className="shot-app-ic" aria-hidden="true">
<Crop size={24} />
</span>
<div className="shot-main-copy">
<b>
{status.installed
? t(
`Screenshot OCR engine · snow-shot ${status.engineVersion} · ready (offline recognition)`,
`截图识字引擎 · snow-shot ${status.engineVersion} · 已就绪(离线识别)`,
)
: t(
`Screenshot OCR engine · snow-shot ${status.engineVersion} · not installed`,
`截图识字引擎 · snow-shot ${status.engineVersion} · 未安装`,
)}
</b>
<small>
{t(
"Licence: GPL-3 (agreement ships in the package) · models run offline, captures never leave this PC",
"许可:GPL-3(随包附协议)· 模型离线,画面不出本机",
)}
</small>
{!status.installed && !installing ? (
<div className="shot-main-acts">
<Button variant="primary" size="sm" onClick={install}>
{t(
`Download engine (~${formatMemory(status.downloadSize)})`,
`下载引擎(约 ${formatMemory(status.downloadSize)})`,
)}
</Button>
</div>
) : null}
{installing ? (
<div className="shot-dl" role="status">
<div className="shot-dl-row">
<LoaderCircle size={15} className="spin" />
<b>{downloadLine}</b>
{pct !== null ? <span className="shot-dl-pct">{pct}%</span> : null}
</div>
<div className="shot-dl-track">
<span
className={pct === null ? "is-indeterminate" : ""}
style={pct === null ? undefined : { width: `${pct}%` }}
/>
</div>
</div>
) : null}
</div>
<div className="shot-main-right">
<div className="shot-hotkey">
{capturing ? (
<span className="shot-hotkey-capturing">
{t("Press a combo… (Esc to cancel)", "按下组合键…(Esc 取消)")}
</span>
) : (
<>
<span className="shot-hotkey-label">
{t("Hotkey", "快捷键")} <HotkeyCaps hotkey={status.hotkey} />
</span>
<Button
variant="ghost"
size="sm"
disabled={installing}
onClick={() => {
setHotkeyError(null);
setCapturing(true);
}}
>
{t("Change", "修改")}
</Button>
</>
)}
</div>
<Button
variant="primary"
disabled={!status.installed || installing}
title={
status.installed
? undefined
: t("Install the engine first", "请先安装引擎")
}
onClick={capture}
>
{t("Start capture", "开始截图")}
</Button>
</div>
</section>
{hotkeyError ? (
<InlineError message={hotkeyError} onDismiss={() => setHotkeyError(null)} />
) : null}
<section className="shot-enable">
<div>
<b>{t("Enable screenshot OCR", "启用截图识字")}</b>
<small>
{t(
"While on, the global hotkey above opens the capture overlay from anywhere.",
"开启后,全局热键在任意界面都能直接唤起截图。",
)}
</small>
</div>
<Toggle
checked={status.enabled}
disabled={installing}
onChange={setEnabled}
label={t("Enable screenshot OCR", "启用截图识字")}
/>
</section>
{status.enabled && status.installed && !status.bindingOk ? (
<InlineError
message={t(
"Hotkey registration failed — another app may already own it.",
"热键注册失败,可能被其他软件占用",
)}
/>
) : null}
<div className="shot-items">
<div className="shot-item">
<b>
<FolderOpen size={14} /> {t("Capture folder", "保存位置")}
</b>
<small className="shot-item-path" title={status.captureDir}>
{status.captureDir}
</small>
<small>
{t("Files are named by capture time.", "命名按时间自动。")}
</small>
<Button
size="sm"
onClick={() => {
void api.revealPath(status.captureDir).catch(fail);
}}
>
{t("Open folder", "打开文件夹")}
</Button>
</div>
<div className="shot-item">
<b>{t("Cold start", "冷启动")}</b>
<small>
{t(
"First hotkey press of a session wakes the engine in about 1 second; after that it opens instantly.",
"首次按热键约 1 秒拉起引擎,之后秒开。",
)}
</small>
</div>
<div className="shot-item">
<b>{t("Offline & private", "离线隐私")}</b>
<small>
{t(
"Recognition runs on local models only — no screenshot is ever uploaded.",
"识别全程本地模型完成,画面不上传、不出本机。",
)}
</small>
</div>
</div>
<section className="shot-hist">
<div className="shot-hist-head">
<b>{t("Capture archive", "识别历史")}</b>
<small>
{t(
"Files land here after each capture — click a row to locate it.",
"截图保存后可在这里回看,点行即在资源管理器中定位。",
)}
</small>
<Button variant="ghost" size="sm" onClick={refreshHistory}>
{t("Refresh", "刷新")}
</Button>
</div>
{history.length === 0 ? (
<div className="shot-hist-empty">
{t(
"No captures yet — press the hotkey to take the first one.",
"还没有截图,按热键截第一张吧。",
)}
</div>
) : (
history.map((entry) => (
<button
type="button"
className="shot-hrow"
key={entry.path}
onClick={() => {
void api.revealPath(entry.path).catch(fail);
}}
>
<span className="shot-hrow-name">{entry.name}</span>
<span className="shot-hrow-meta">
{stampLabel(entry.modifiedMs)} · {formatBytes(entry.size)}
</span>
</button>
))
)}
</section>
<p className="shot-fine">
{t(
"Cold start: the first hotkey press takes about a second to wake the engine, afterwards it is instant; an engine crash never affects Squid — the tray and this page can both restart it.",
"冷启动:首次按热键约 1 秒拉起引擎,之后常驻秒开;引擎崩溃不影响 Squid,托盘与本页都能重启它。",
)}
</p>
</div>
);
}

View File

@ -0,0 +1,886 @@
/* 安全查杀(ClamAV 本地引擎 + Windows 安全中心接管)。
* Hero / 三档模式 / 接管开关 / 查杀与隔离 / 引擎与病毒库。状态全部来自
* security_status;引擎下载、病毒库更新、扫描进度共用 `squid://engine`,
* 按 engine 字段分流。文案以 docs/security-mock2.html 的批准稿为准(逐字)。 */
import {
FolderSearch,
LoaderCircle,
RotateCcw,
Shield,
ShieldAlert,
ShieldCheck,
Trash2,
} from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { useI18n } from "../i18n";
import { api } from "../lib/api";
import { formatBytes, formatCount, formatMemory, messageFrom, shortPath } from "../lib/format";
import type {
EngineProgress,
QuarantineEntry,
ScanOutcome,
SecurityStatus,
} from "../types";
import {
Button,
ConfirmDialog,
EmptyState,
InlineError,
PageHeader,
SectionTitle,
Toggle,
useToast,
} from "../components/ui";
type ModeKey = "power" | "performance" | "manual";
interface MemoPart {
text: string;
bold?: boolean;
}
interface ModeDef {
key: ModeKey;
name: [string, string];
recommended: boolean;
/** Approved-mock copy; zh rides as bold-marked parts, en as plain text. */
memoZh: MemoPart[];
memoEn: string;
cost: { zh: string; en: string; tone: "ok" | "warn" | "" }[];
}
const MODES: ModeDef[] = [
{
key: "power",
name: ["Power saver", "节能模式"],
recommended: true,
memoZh: [
{ text: "常驻只有 Squid 本体(目录监听 + 计划 + 心跳,约 " },
{ text: "100 MB", bold: true },
{ text: ")。高危目录有新文件时才拉起 clamd," },
{ text: "扫描后 5 分钟无活动自动休眠", bold: true },
{ text: ";识别结果约延迟 10 秒弹出。" },
],
memoEn:
"Only Squid itself stays resident (folder watches + schedule + heartbeat, about 100 MB). clamd wakes only when a hot folder gets a new file and sleeps 5 minutes after activity stops; verdicts land about 10 seconds late.",
cost: [
{ zh: "平时最省内存", en: "Lowest idle memory", tone: "ok" },
{ zh: "较 Defender 净省 200 MB+", en: "200 MB+ less than Defender", tone: "" },
],
},
{
key: "performance",
name: ["Performance", "性能模式"],
recommended: false,
memoZh: [
{ text: "clamd " },
{ text: "24 小时常驻", bold: true },
{ text: ",新文件落地" },
{ text: "毫秒级", bold: true },
{ text: "出结果、无拉起延迟。代价是引擎与病毒库全程驻留内存(约 " },
{ text: "650–900 MB", bold: true },
{ text: "),适合内存充裕、下载频繁的主力机。" },
],
memoEn:
"clamd stays loaded 24/7 — new files get a verdict in milliseconds, with no wake-up delay. The cost: engine and databases sit in memory the whole time (about 650–900 MB). Suited to RAM-rich main machines with heavy downloads.",
cost: [
{ zh: "内存 +650–900 MB", en: "+650–900 MB RAM", tone: "warn" },
{ zh: "实时最快", en: "Fastest realtime", tone: "" },
],
},
{
key: "manual",
name: ["Manual", "手动模式"],
recommended: false,
memoZh: [
{ text: "不做实时监控,只保留" },
{ text: "手动查杀与每日计划扫描", bold: true },
{ text: "。Squid 可完全退出;接管开着的话,安全中心会在 7 天后提示「防护已过期」。" },
],
memoEn:
"No realtime monitoring — only manual scans and the daily planned scan remain. Squid can exit completely; if takeover is still on, the Security Center flags “protection is out of date” after 7 days.",
cost: [
{ zh: "零常驻", en: "Nothing resident", tone: "" },
{ zh: "无实时防护", en: "No realtime shield", tone: "warn" },
],
},
];
function modeLabel(mode: string, zh: boolean): string {
const def = MODES.find((item) => item.key === mode);
if (!def) return mode;
return zh ? def.name[1] : def.name[0];
}
function dayLabel(ms: number): string {
const date = new Date(ms);
if (Number.isNaN(date.getTime())) return "—";
const pad = (value: number) => String(value).padStart(2, "0");
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
}
function stampLabel(ms: number): string {
const date = new Date(ms);
if (Number.isNaN(date.getTime())) return "—";
const pad = (value: number) => String(value).padStart(2, "0");
return `${dayLabel(ms)} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
}
/** 6:12 — scan-bar elapsed clock (m:ss, the mock's format). */
function clockLabel(ms: number): string {
const secs = Math.max(0, Math.floor(ms / 1000));
return `${Math.floor(secs / 60)}:${String(secs % 60).padStart(2, "0")}`;
}
export function SecurityPage({ onHistory }: { onHistory: () => void }) {
const { t, lang } = useI18n();
const { push } = useToast();
const zh = lang === "zh";
const [status, setStatus] = useState<SecurityStatus | null>(null);
const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
// Three producers share squid://engine; each card watches its own lane.
const [engineProgress, setEngineProgress] = useState<EngineProgress | null>(null);
const [dbProgress, setDbProgress] = useState<EngineProgress | null>(null);
const [dbLog, setDbLog] = useState<string[]>([]);
const [installing, setInstalling] = useState(false);
const [dbUpdating, setDbUpdating] = useState(false);
const [scanScope, setScanScope] = useState<"quick" | "full" | null>(null);
const [scanProgress, setScanProgress] = useState<EngineProgress | null>(null);
const [elapsedMs, setElapsedMs] = useState(0);
const [outcome, setOutcome] = useState<ScanOutcome | null>(null);
const [quarantine, setQuarantine] = useState<QuarantineEntry[]>([]);
const [pendingDelete, setPendingDelete] = useState<QuarantineEntry | null>(null);
const [deleting, setDeleting] = useState(false);
const [mirrorDraft, setMirrorDraft] = useState<string | null>(null);
const jobId = useRef<string | null>(null);
const fail = (reason: unknown) => push(messageFrom(reason), "danger");
const refreshStatus = () =>
api
.securityStatus()
.then(setStatus)
.catch(fail);
const refreshQuarantine = () =>
api
.quarantineList()
.then(setQuarantine)
.catch(fail);
useEffect(() => {
let cancelled = false;
let stop: (() => void) | null = null;
void api
.securityStatus()
.then((next) => !cancelled && setStatus(next))
.catch((reason) => !cancelled && setError(messageFrom(reason)));
void api
.quarantineList()
.then((next) => !cancelled && setQuarantine(next))
.catch(() => {
/* the quarantine list is advisory until you open that card */
});
void api
.onEngineProgress((frame) => {
if (cancelled) return;
if (frame.engine === "clamav") setEngineProgress(frame);
else if (frame.engine === "clamav-db") {
setDbProgress(frame);
if (frame.message) {
setDbLog((current) => [...current.slice(-7), frame.message]);
}
} else if (frame.engine === "clamav-scan") setScanProgress(frame);
})
.then((unlisten) => {
if (cancelled) unlisten();
else stop = unlisten;
});
return () => {
cancelled = true;
stop?.();
};
}, []);
// Live elapsed clock for the scan bar.
useEffect(() => {
if (!scanScope) return;
const started = Date.now();
const timer = window.setInterval(() => setElapsedMs(Date.now() - started), 1000);
return () => window.clearInterval(timer);
}, [scanScope]);
if (!status) {
return (
<div className="page sec-page">
<PageHeader
eyebrow="SECURITY"
title={t("Security", "安全查杀")}
description={t("Loading…", "正在加载…")}
/>
{error ? <InlineError message={error} onDismiss={() => setError(null)} /> : null}
</div>
);
}
const protectedNow = status.takeover && status.wscHealth === 0;
const otherGuard = status.wscProducts.find(
(item) => item.state === 0 && !item.name.toLowerCase().includes("squid"),
);
const heroTitle = protectedNow
? t("Device protected · managed by Squid", "设备正在受到保护 · 由 Squid 管理")
: otherGuard && !otherGuard.name.toLowerCase().includes("defender")
? t(
`${otherGuard.name} is providing real-time protection`,
`由 ${otherGuard.name} 提供实时防护`,
)
: t(
"Windows Defender is protecting this device",
"Windows Defender 正在保护设备",
);
const heroWho = protectedNow
? t(
"Windows Security Center reports: “virus & threat protection is provided by Squid”",
"Windows 安全中心显示:「病毒和威胁防护由 Squid 提供」",
)
: t(
"ClamAV local engine · no sample is ever uploaded",
"ClamAV 本地引擎 · 不上传任何样本",
);
const setMode = (mode: ModeKey) => {
if (busy || mode === status.mode) return;
setBusy(true);
void api
.securitySetMode(mode)
.then(setStatus)
.catch(fail)
.finally(() => setBusy(false));
};
const setTakeover = (enable: boolean) => {
if (busy) return;
setBusy(true);
void api
.securitySetTakeover(enable)
// Failure returns honestly: takeover=false + takeoverLastError set.
.then(setStatus)
.catch(fail)
.finally(() => setBusy(false));
};
const installEngine = () => {
setInstalling(true);
setEngineProgress(null);
void api
.securityInstallEngine()
.then((next) => {
setStatus(next);
push(
lang === "zh" ? "ClamAV 引擎已安装" : "ClamAV engine installed",
"success",
);
})
.catch(fail)
.finally(() => setInstalling(false));
};
const updateDatabase = () => {
setDbUpdating(true);
setDbProgress(null);
setDbLog([]);
void api
.securityUpdateDatabase()
.then((next) => {
setStatus(next);
// The card settles back to the plain button; the toast carries the news.
setDbLog([]);
setDbProgress(null);
push(
lang === "zh" ? "病毒库已是最新" : "Virus database is up to date",
"success",
);
})
.catch(fail)
.finally(() => setDbUpdating(false));
};
const startScan = (scope: "quick" | "full") => {
if (scanScope) return;
// jobId convention shared with useScanWorkspace; cancel_job kills it.
const id = `security-scan-${Date.now()}`;
jobId.current = id;
setScanScope(scope);
setScanProgress(null);
setElapsedMs(0);
setOutcome(null);
void api
.securityScan(id, scope)
.then((result) => setOutcome(result))
.catch(fail)
.finally(() => {
setScanScope(null);
setScanProgress(null);
jobId.current = null;
});
};
const cancelScan = () => {
if (jobId.current) void api.cancelJob(jobId.current);
};
const quarantineThreat = (path: string, virus: string) => {
void api
.quarantineAdd(path, virus)
.then(() => {
setOutcome((current) =>
current
? {
...current,
infected: Math.max(0, current.infected - 1),
threats: current.threats.filter((item) => item.path !== path),
}
: current,
);
void refreshQuarantine();
push(
lang === "zh" ? `已隔离:${shortPath(path, 48)}` : `Quarantined: ${shortPath(path, 48)}`,
"success",
);
})
.catch(fail);
};
const restoreEntry = (entry: QuarantineEntry) => {
void api
.quarantineRestore(entry.id)
.then(() => {
void refreshQuarantine();
push(
lang === "zh" ? `已还原到:${shortPath(entry.path, 48)}` : `Restored to: ${shortPath(entry.path, 48)}`,
"success",
);
})
.catch(fail);
};
const confirmDelete = () => {
if (!pendingDelete) return;
setDeleting(true);
void api
.quarantineDelete(pendingDelete.id)
.then(() => {
setPendingDelete(null);
void refreshQuarantine();
push(lang === "zh" ? "已从隔离区彻底删除" : "Deleted from quarantine for good", "success");
})
.catch(fail)
.finally(() => setDeleting(false));
};
const saveMirror = () => {
if (mirrorDraft === null) return;
const trimmed = mirrorDraft.trim();
// Typing the official host means "back to the default" — store empty.
const value = trimmed === "" || trimmed === "database.clamav.net" ? "" : trimmed;
setBusy(true);
void api
.settingsSave({ clamavMirror: value })
.then(() => refreshStatus())
.then(() => {
setMirrorDraft(null);
push(lang === "zh" ? "病毒库镜像已保存" : "Database mirror saved", "success");
})
.catch(fail)
.finally(() => setBusy(false));
};
// Engine-download lane label (shared vocabulary with the screenshot page).
const downloadLine = (frame: EngineProgress | null): string => {
if (!frame) return t("Downloading…", "下载中…");
switch (frame.state) {
case "downloading":
return t(
`Downloaded ${formatMemory(frame.done)}${frame.total ? ` / ${formatMemory(frame.total)}` : ""}`,
`已下载 ${formatMemory(frame.done)}${frame.total ? ` / ${formatMemory(frame.total)}` : ""}`,
);
case "verifying":
return t("Verifying…", "校验中");
case "extracting":
return t("Unpacking…", "解压中");
case "error":
return frame.message;
default:
return frame.message || t("Working…", "处理中…");
}
};
const enginePct =
engineProgress && engineProgress.state === "downloading" && engineProgress.total > 0
? Math.min(100, Math.round((engineProgress.done / engineProgress.total) * 100))
: null;
const scanDone = scanProgress?.done ?? 0;
const mirrorShown = status.databaseMirror.trim() || "database.clamav.net";
const scanning = scanScope !== null;
// Rolling freshclam tail; the newest line is the one worth reading.
const dbLines = (dbLog.length > 0
? dbLog
: [t("Starting freshclam…", "正在启动 freshclam…")]
).slice(-4);
return (
<div className="page sec-page">
<PageHeader
eyebrow="SECURITY"
title={t("Security", "安全查杀")}
description={
status.takeover
? t(
"Squid has taken over Windows Security Center.",
"Squid 已接管 Windows 安全中心",
)
: t(
"ClamAV local engine · no sample is ever uploaded.",
"ClamAV 本地引擎 · 不上传任何样本",
)
}
/>
{error ? <InlineError message={error} onDismiss={() => setError(null)} /> : null}
<section className={`sec-hero ${protectedNow ? "is-ok" : "is-warn"}`}>
<span className="sec-shield" aria-hidden="true">
{protectedNow ? <ShieldCheck size={26} /> : <Shield size={26} />}
</span>
<div className="sec-hero-main">
<b>{heroTitle}</b>
<div className="sec-hero-who">{heroWho}</div>
<div className="sec-chips">
{status.databaseReady ? (
<span className="sec-chip is-ok">
{t(
`ClamAV database ${status.databaseUpdatedMs ? dayLabel(status.databaseUpdatedMs) : "ready"}`,
`ClamAV 库 ${status.databaseUpdatedMs ? dayLabel(status.databaseUpdatedMs) : "已就绪"}`,
)}
</span>
) : (
<span className="sec-chip is-warn">
{t("Virus database not ready", "病毒库未就绪")}
</span>
)}
<span className="sec-chip">
{t(
`Mode: ${modeLabel(status.mode, false)}`,
`模式:${modeLabel(status.mode, true)}`,
)}
</span>
<span className={`sec-chip ${status.engineInstalled ? "is-ok" : "is-warn"}`}>
{status.engineInstalled
? t(`ClamAV ${status.engineVersion} ready`, `ClamAV ${status.engineVersion} 已就绪`)
: t("Engine not installed", "引擎未安装")}
</span>
</div>
</div>
<div className="sec-hero-acts">
<Button
variant="primary"
disabled={scanning}
onClick={() => startScan("quick")}
>
{t("Quick scan", "快速查杀")}
</Button>
<Button variant="ghost" disabled={scanning} onClick={() => startScan("full")}>
{t("Full scan", "全盘查杀")}
</Button>
</div>
</section>
<SectionTitle
title={t("Realtime protection modes", "实时防护模式")}
subtitle={t(
`Three modes, switch any time · current: ${modeLabel(status.mode, false)}`,
`三档,随时可切;当前:${modeLabel(status.mode, true)}`,
)}
/>
<div className="sec-modes">
{MODES.map((mode) => {
const on = mode.key === status.mode;
return (
<div className={`sec-mode ${on ? "is-on" : ""}`} key={mode.key}>
<div className="sec-mode-head">
<b>{zh ? mode.name[1] : mode.name[0]}</b>
{mode.recommended ? (
<span className="sec-mode-rec">
{t("Recommended", "推荐")}
</span>
) : null}
<span className="sec-mode-radio" />
</div>
<div className="sec-mode-memo">
{zh
? mode.memoZh.map((part, index) =>
part.bold ? <b key={index}>{part.text}</b> : <span key={index}>{part.text}</span>,
)
: mode.memoEn}
</div>
<div className="sec-mode-cost">
{mode.cost.map((chip) => (
<span
key={chip.zh}
className={`sec-chip ${chip.tone === "ok" ? "is-ok" : chip.tone === "warn" ? "is-warn" : ""}`}
>
{zh ? chip.zh : chip.en}
</span>
))}
</div>
{on ? null : (
<Button
variant="secondary"
size="sm"
className="sec-mode-apply"
disabled={busy}
onClick={() => setMode(mode.key)}
>
{t("Switch", "切换")}
</Button>
)}
</div>
);
})}
</div>
<p className="sec-mode-note">
{t(
"Note: the power-saver and performance modes differ only in whether clamd stays resident; the folder watching and interception logic is identical. Switching applies instantly — no restart needed.",
"备注:节能/性能模式的差别只在 clamd 是否常驻;目录监听与拦截处置逻辑相同。切换即时生效,无需重启。",
)}
</p>
{status.takeoverSupported ? (
<section className="sec-take">
<div className="sec-take-row">
<div>
<b>{t("Take over Windows Security Center", "接管 Windows 安全中心")}</b>
<small>
{t(
"While Squid runs it keeps checking in with the Security Center (heartbeat); switching off deregisters immediately and Windows Defender returns to active mode.",
"Squid 常驻时向安全中心持续报到(心跳);关闭开关将立刻注销,Windows Defender 自动恢复主动模式。",
)}
</small>
</div>
<Toggle
checked={status.takeover}
disabled={busy}
onChange={setTakeover}
label={t("Take over Windows Security Center", "接管 Windows 安全中心")}
/>
</div>
{status.takeoverLastError ? (
<InlineError message={status.takeoverLastError} />
) : null}
{status.wscProducts.length > 0 ? (
<div className="sec-take-detail">
{status.wscProducts.map((item) => (
<span key={item.name} className={`sec-chip ${item.state === 0 ? "is-ok" : ""}`}>
{item.name} ·{" "}
{item.state === 0
? t("protecting", "防护中")
: t("standby", "已停用")}
{item.isDefault ? t(" · default", "· 默认") : ""}
</span>
))}
</div>
) : null}
</section>
) : null}
{scanning ? (
<section className="sec-scanbar" role="status">
<div className="sec-scanbar-row">
<LoaderCircle size={17} className="spin is-primary" />
<div className="sec-scanbar-main">
<b>
{t(
`Scanning ${formatCount(scanDone)} files · ${clockLabel(elapsedMs)} elapsed`,
`正在扫描 ${formatCount(scanDone)} 个文件 · 已用 ${clockLabel(elapsedMs)}`,
)}
</b>
<small className="sec-scanbar-cur">
{scanProgress?.message || t("Preparing…", "准备中…")}
</small>
</div>
<Button variant="ghost" size="sm" onClick={cancelScan}>
{t("Cancel", "取消")}
</Button>
</div>
<div className="sec-scanbar-track">
<span className="is-indeterminate" />
</div>
</section>
) : null}
{outcome ? (
outcome.threats.length > 0 ? (
<section className="sec-threats">
<h3>
{outcome.cancelled
? t(
`Scan stopped · ${formatCount(outcome.scanned)} files checked · ${outcome.threats.length} threats found`,
`扫描已取消 · 已检查 ${formatCount(outcome.scanned)} 个文件 · 发现 ${outcome.threats.length} 个威胁`,
)
: t(
`${outcome.threats.length} threats found · ${formatCount(outcome.scanned)} files scanned · took ${clockLabel(outcome.durationMs)}`,
`发现 ${outcome.threats.length} 个威胁 · 共扫描 ${formatCount(outcome.scanned)} 个文件 · 用时 ${clockLabel(outcome.durationMs)}`,
)}
</h3>
{outcome.threats.map((threat) => (
<div className="sec-trow" key={threat.path}>
<span className="sec-trow-fam">{threat.virus}</span>
<span className="sec-trow-path" title={threat.path}>
{threat.path}
</span>
<span className="sec-trow-eng">{threat.engine}</span>
<Button
variant="ghost"
size="sm"
icon={<FolderSearch size={13} />}
onClick={() => {
void api.revealPath(threat.path).catch(fail);
}}
>
{t("Locate", "定位")}
</Button>
<Button
size="sm"
onClick={() => quarantineThreat(threat.path, threat.virus)}
>
{t("Quarantine", "隔离")}
</Button>
</div>
))}
<p className="sec-fine">
{t(
"Quarantine moves the file into Squid’s private store (one-click restore, wired into History); threats are never deleted outright, so a false positive stays reversible.",
"隔离 = 移入 Squid 私有隔离区(可一键还原,接入「历史」体系);不直接删除,避免误杀。",
)}
</p>
</section>
) : (
<section className={`sec-clear ${outcome.cancelled ? "is-warn" : "is-ok"}`} role="status">
{outcome.cancelled ? <ShieldAlert size={16} /> : <ShieldCheck size={16} />}
<b>
{outcome.cancelled
? t(
`Scan cancelled after ${formatCount(outcome.scanned)} files — no threat found so far`,
`扫描已取消 · 已检查 ${formatCount(outcome.scanned)} 个文件,暂未发现威胁`,
)
: t(
`No threats found · ${formatCount(outcome.scanned)} files scanned · took ${clockLabel(outcome.durationMs)}`,
`未发现威胁 · 已扫描 ${formatCount(outcome.scanned)} 个文件 · 用时 ${clockLabel(outcome.durationMs)}`,
)}
</b>
<Button variant="ghost" size="sm" onClick={onHistory}>
{t("Open history", "查看历史")}
</Button>
</section>
)
) : null}
<SectionTitle
title={t("Engine & virus database", "引擎与病毒库")}
subtitle={t(
"Everything stays on this machine; updates are the only network traffic.",
"引擎与库都在本机;只有更新时才联网。",
)}
/>
<div className="sec-grid">
<section className="sec-card">
<b>
{t("ClamAV engine (primary)", "ClamAV 引擎(主)")}
</b>
{status.engineInstalled ? (
<>
<small>
{t(
`Engine ${status.engineVersion} ready${
status.databaseUpdatedMs ? ` · database ${dayLabel(status.databaseUpdatedMs)}` : ""
}`,
`引擎 ${status.engineVersion} 已就绪${
status.databaseUpdatedMs ? ` · 病毒库 ${dayLabel(status.databaseUpdatedMs)}` : ""
}`,
)}
</small>
{dbUpdating || dbLog.length > 0 ? (
<div className="sec-dblog" role="status">
{dbLines.map((line, index) => (
<span key={index} className={index === dbLines.length - 1 ? "is-latest" : ""}>
{line}
</span>
))}
{dbProgress && dbProgress.state === "error" ? (
<span className="is-error">{dbProgress.message}</span>
) : null}
</div>
) : null}
<div className="sec-card-acts">
<Button size="sm" disabled={dbUpdating} onClick={updateDatabase}>
{dbUpdating
? t("Updating…", "更新中…")
: t("Update database", "更新病毒库")}
</Button>
</div>
</>
) : (
<>
<small>
{t(
"The scanning engine downloads on demand and stays offline afterwards.",
"扫描引擎按需下载,之后完全离线。",
)}
</small>
{installing ? (
<div className="sec-dl" role="status">
<div className="sec-dl-row">
<LoaderCircle size={15} className="spin" />
<b>{downloadLine(engineProgress)}</b>
{enginePct !== null ? <span className="sec-dl-pct">{enginePct}%</span> : null}
</div>
<div className="sec-dl-track">
<span
className={enginePct === null ? "is-indeterminate" : ""}
style={enginePct === null ? undefined : { width: `${enginePct}%` }}
/>
</div>
</div>
) : null}
<div className="sec-card-acts">
<Button variant="primary" size="sm" disabled={installing} onClick={installEngine}>
{t(
`Download engine (~${status.engineDownloadSize > 0 ? formatMemory(status.engineDownloadSize) : "360 MB"})`,
`下载引擎(约 ${status.engineDownloadSize > 0 ? formatMemory(status.engineDownloadSize) : "360 MB"})`,
)}
</Button>
</div>
</>
)}
<div className="sec-mirror">
<span title={mirrorShown}>
{t("Mirror", "病毒库镜像")}:
{status.databaseMirror.trim()
? mirrorShown
: t(`${mirrorShown} (official)`, `${mirrorShown}(官方)`)}
</span>
<input
className="sec-mirror-input"
value={mirrorDraft ?? status.databaseMirror}
placeholder="database.clamav.net"
onChange={(event) => setMirrorDraft(event.target.value)}
disabled={busy}
/>
<Button
size="sm"
variant="secondary"
disabled={busy || mirrorDraft === null}
onClick={saveMirror}
>
{t("Save", "保存")}
</Button>
</div>
</section>
<section className="sec-card">
<b>
{t("Windows Defender (second opinion)", "Windows Defender(第二意见)")}
</b>
<small>
{t(
"Windows Defender stays on as a second opinion; once Squid takes over, its realtime service powers down automatically so the two engines never fight.",
"Windows Defender 保留为第二意见;接管后其实时服务自动停用,避免双引擎互斥。",
)}
</small>
<div className="sec-card-acts">
<Button
variant="ghost"
size="sm"
disabled
title={t("Coming soon", "即将上线")}
>
{t("Re-scan everything with Defender", "用 Defender 全盘复查")}
</Button>
</div>
</section>
</div>
<SectionTitle
title={t("Quarantine", "隔离区")}
subtitle={t(
"Quarantined files can be restored or deleted for good.",
"隔离的文件可一键还原,或彻底删除。",
)}
/>
{quarantine.length === 0 ? (
<EmptyState
icon={<ShieldCheck size={26} />}
title={t("Quarantine is empty", "隔离区为空")}
description={t(
"Files you quarantine from a scan result land here first — nothing is deleted outright.",
"扫描结果里点「隔离」的文件会先进入这里,不会直接删除。",
)}
/>
) : (
<section className="sec-quarantine">
{quarantine.map((entry) => (
<div className="sec-qrow" key={entry.id}>
<span className="sec-trow-fam">{entry.virus}</span>
<span className="sec-qrow-path" title={entry.path}>
{entry.path}
</span>
{entry.engine ? <span className="sec-trow-eng">{entry.engine}</span> : null}
<span className="sec-qrow-meta">
{stampLabel(entry.quarantinedMs)} · {formatBytes(entry.size)}
</span>
<Button
variant="ghost"
size="sm"
icon={<RotateCcw size={13} />}
onClick={() => restoreEntry(entry)}
>
{t("Restore", "还原")}
</Button>
<Button
variant="danger"
size="sm"
icon={<Trash2 size={13} />}
onClick={() => setPendingDelete(entry)}
>
{t("Delete for good", "彻底删除")}
</Button>
</div>
))}
</section>
)}
<ConfirmDialog
open={pendingDelete !== null}
title={t("Delete for good?", "彻底删除?")}
message={
pendingDelete ? (
<span title={pendingDelete.path}>{shortPath(pendingDelete.path, 64)}</span>
) : (
""
)
}
note={t(
"The quarantined copy is gone immediately — it will not sit in the Recycle Bin.",
"隔离副本会立即消失,不进回收站。",
)}
confirmLabel={t("Delete for good", "彻底删除")}
cancelLabel={t("Cancel", "取消")}
busy={deleting}
icon={<Trash2 size={22} />}
onConfirm={confirmDelete}
onClose={() => setPendingDelete(null)}
/>
</div>
);
}

View File

@ -8643,3 +8643,865 @@ html.widget-mode body {
padding-top: 6px;
border-top: 1px dashed rgba(238, 132, 76, 0.4);
}
/* ── security / screenshot ──────────────────────────────────────────────
工具组两页(安全查杀 / 截图识字)。class 前缀 sec- / shot-;配色全部
走 :root 里的 nex 变量,不引入新色值。 */
/* kbd 键帽(热键展示两页共用视觉) */
.shot-kbd,
.sec-kbd {
font-family: var(--nex-font-mono);
font-size: var(--nex-text-3xs);
background: #fff;
border: 1px solid var(--line);
border-bottom-width: 2.5px;
border-radius: 6px;
padding: 2px 8px;
color: var(--ink);
}
/* ── 截图识字 ── */
.shot-main {
display: flex;
align-items: center;
gap: 18px;
border: 1px solid rgba(var(--nex-primary-rgb), 0.25);
border-radius: 14px;
padding: 18px 22px;
background: linear-gradient(135deg, var(--nex-primary-tint), #fff);
margin-bottom: 18px;
}
.shot-app-ic {
flex: 0 0 auto;
width: 54px;
height: 54px;
border-radius: 14px;
background: linear-gradient(145deg, #6ea8ff, #3f6fd8);
color: #fff;
display: inline-flex;
align-items: center;
justify-content: center;
box-shadow: 0 6px 14px rgba(63, 111, 216, 0.3);
}
.shot-main-copy {
flex: 1 1 auto;
min-width: 0;
}
.shot-main-copy > b {
font-size: var(--nex-text-sm);
font-weight: var(--nex-weight-semibold);
}
.shot-main-copy > small {
display: block;
color: var(--muted);
margin-top: 3px;
font-size: var(--nex-text-2xs);
line-height: 1.6;
}
.shot-main-acts {
margin-top: 10px;
display: flex;
gap: 10px;
}
.shot-main-right {
flex: 0 0 auto;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 10px;
}
.shot-hotkey {
display: flex;
align-items: center;
gap: 8px;
}
.shot-hotkey-label {
font-size: var(--nex-text-2xs);
color: var(--muted);
}
.shot-hotkey-capturing {
font-size: var(--nex-text-2xs);
color: var(--nex-primary-strong);
font-weight: var(--nex-weight-semibold);
padding: 4px 10px;
border: 1px dashed rgba(var(--nex-primary-rgb), 0.5);
border-radius: 8px;
background: #fff;
}
.shot-hotkey-caps {
display: inline-flex;
align-items: center;
gap: 2px;
}
.shot-cap-group {
display: inline-flex;
align-items: center;
gap: 2px;
}
.shot-cap-group > i {
font-style: normal;
color: var(--muted-soft);
font-size: var(--nex-text-3xs);
margin: 0 2px;
}
/* 引擎下载进度(shot- 与 sec- 两页同款) */
.shot-dl,
.sec-dl {
margin-top: 10px;
border: 1px solid rgba(var(--nex-primary-rgb), 0.3);
border-radius: 10px;
background: #fff;
padding: 9px 12px;
max-width: 460px;
}
.shot-dl-row,
.sec-dl-row {
display: flex;
align-items: center;
gap: 8px;
}
.shot-dl-row > svg,
.sec-dl-row > svg {
color: var(--nex-primary);
flex: 0 0 auto;
}
.shot-dl-row b,
.sec-dl-row b {
flex: 1 1 auto;
min-width: 0;
font-size: var(--nex-text-2xs);
font-weight: var(--nex-weight-semibold);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.shot-dl-pct,
.sec-dl-pct {
flex: 0 0 auto;
font-family: var(--nex-font-mono);
font-size: var(--nex-text-2xs);
font-weight: var(--nex-weight-bold);
color: var(--nex-primary-strong);
}
.shot-dl-track,
.sec-dl-track {
height: 8px;
border-radius: 999px;
background: rgba(89, 51, 34, 0.08);
margin-top: 8px;
overflow: hidden;
}
.shot-dl-track > span,
.sec-dl-track > span {
display: block;
height: 100%;
border-radius: 999px;
background:
repeating-linear-gradient(
115deg,
rgba(255, 255, 255, 0.28) 0 10px,
rgba(255, 255, 255, 0) 10px 24px
),
linear-gradient(90deg, #ff9a68, var(--nex-primary));
background-size:
34px 100%,
100% 100%;
animation: cleanbar-stripes 0.9s linear infinite;
transition: width 0.35s ease;
}
.shot-dl-track > span.is-indeterminate,
.sec-dl-track > span.is-indeterminate {
width: 36%;
animation:
cleanbar-stripes 0.9s linear infinite,
cleanbar-sweep 1.4s ease-in-out infinite alternate;
}
/* 启用开关行 */
.shot-enable {
display: flex;
align-items: center;
gap: 14px;
margin-top: 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: var(--paper);
padding: 12px 16px;
}
.shot-enable > div {
flex: 1 1 auto;
min-width: 0;
}
.shot-enable b {
font-size: var(--nex-text-xs);
font-weight: var(--nex-weight-semibold);
}
.shot-enable small {
display: block;
color: var(--muted);
font-size: var(--nex-text-2xs);
margin-top: 2px;
}
/* 信息小卡行(保存位置 / 冷启动 / 离线隐私) */
.shot-items {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 12px;
margin-top: 14px;
}
.shot-item {
border: 1px solid var(--line);
border-radius: 12px;
background: var(--paper);
padding: 12px 14px;
}
.shot-item > b {
font-size: var(--nex-text-2xs);
display: flex;
align-items: center;
gap: 6px;
}
.shot-item > small {
display: block;
color: var(--muted-soft);
font-size: var(--nex-text-3xs);
margin-top: 6px;
line-height: 1.6;
}
.shot-item-path {
font-family: var(--nex-font-mono);
color: var(--muted) !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.shot-item .button {
margin-top: 8px;
}
.shot-hist {
margin-top: 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: var(--paper);
overflow: hidden;
}
.shot-hist-head {
display: flex;
align-items: center;
gap: 10px;
padding: 12px 16px 8px;
}
.shot-hist-head b {
font-size: var(--nex-text-xs);
}
.shot-hist-head small {
color: var(--muted-soft);
font-size: var(--nex-text-3xs);
}
.shot-hist-head .button {
margin-left: auto;
}
.shot-hist-empty {
padding: 10px 16px 14px;
color: var(--muted-soft);
font-size: var(--nex-text-3xs);
}
.shot-hrow {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
text-align: left;
padding: 9px 16px;
border: 0;
border-top: 1px dashed var(--line);
background: transparent;
color: var(--ink);
cursor: pointer;
font: inherit;
font-size: var(--nex-text-2xs);
}
.shot-hrow:hover {
background: rgba(var(--primary-rgb), 0.05);
}
.shot-hrow-name {
flex: 1 1 auto;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-family: var(--nex-font-mono);
}
.shot-hrow-meta {
flex: 0 0 auto;
color: var(--muted-soft);
font-size: var(--nex-text-3xs);
}
.shot-fine,
.sec-fine {
color: var(--muted-soft);
font-size: var(--nex-text-3xs);
margin-top: 12px;
line-height: 1.7;
}
/* ── 安全查杀 ── */
.sec-hero {
display: flex;
align-items: center;
gap: 22px;
border-radius: 14px;
padding: 18px 22px;
border: 1px solid;
margin-bottom: 20px;
}
.sec-hero.is-ok {
background: linear-gradient(135deg, var(--green-soft), #f2fbf7);
border-color: rgba(25, 169, 116, 0.35);
}
.sec-hero.is-warn {
background: linear-gradient(135deg, var(--orange-soft), #fff8f1);
border-color: rgba(238, 132, 76, 0.45);
}
.sec-shield {
flex: 0 0 auto;
width: 56px;
height: 56px;
border-radius: 16px;
display: inline-flex;
align-items: center;
justify-content: center;
color: #fff;
}
.sec-hero.is-ok .sec-shield {
background: linear-gradient(145deg, #35c48d, var(--green));
box-shadow: 0 6px 14px rgba(25, 169, 116, 0.3);
}
.sec-hero.is-warn .sec-shield {
background: linear-gradient(145deg, #f2a05f, var(--orange));
box-shadow: 0 6px 14px rgba(238, 132, 76, 0.3);
}
.sec-hero-main {
flex: 1 1 auto;
min-width: 0;
}
.sec-hero-main > b {
display: block;
font-size: var(--nex-text-md);
font-weight: var(--nex-weight-bold);
}
.sec-hero-who {
font-size: var(--nex-text-2xs);
color: var(--muted);
margin-top: 3px;
}
.sec-chips {
display: flex;
gap: 8px;
margin-top: 10px;
flex-wrap: wrap;
}
.sec-chip {
display: inline-block;
font-size: var(--nex-text-3xs);
border-radius: 999px;
padding: 3px 10px;
background: #fff;
border: 1px solid var(--line);
color: var(--muted);
}
.sec-chip.is-ok {
color: var(--green);
border-color: rgba(25, 169, 116, 0.35);
background: var(--green-soft);
}
.sec-chip.is-warn {
color: #b06a24;
border-color: rgba(238, 132, 76, 0.45);
background: var(--orange-soft);
}
.sec-hero-acts {
flex: 0 0 auto;
display: flex;
flex-direction: column;
gap: 8px;
}
/* 三档模式卡 */
.sec-modes {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 14px;
}
.sec-mode {
position: relative;
border: 1.5px solid var(--line);
border-radius: 14px;
background: #fff;
padding: 14px 16px 44px;
}
.sec-mode.is-on {
border-color: var(--nex-primary);
background: linear-gradient(180deg, var(--nex-primary-tint), #fff);
box-shadow: 0 8px 20px rgba(var(--nex-primary-rgb), 0.12);
}
.sec-mode-head {
display: flex;
align-items: center;
gap: 8px;
}
.sec-mode-head > b {
font-size: var(--nex-text-sm);
}
.sec-mode-rec {
font-size: 10.5px;
background: var(--nex-primary);
color: #fff;
border-radius: 999px;
padding: 1px 8px;
}
.sec-mode-radio {
width: 16px;
height: 16px;
border-radius: 50%;
border: 1.5px solid var(--line-strong);
margin-left: auto;
flex: 0 0 auto;
}
.sec-mode.is-on .sec-mode-radio {
border: 5px solid var(--nex-primary);
}
.sec-mode-memo {
margin-top: 8px;
color: var(--muted);
font-size: var(--nex-text-3xs);
line-height: 1.7;
}
.sec-mode-memo b {
color: var(--ink);
font-weight: var(--nex-weight-semibold);
}
.sec-mode-cost {
margin-top: 9px;
display: flex;
gap: 6px;
flex-wrap: wrap;
}
.sec-mode-apply {
position: absolute;
right: 14px;
bottom: 12px;
}
.sec-mode-note {
margin-top: 10px;
margin-bottom: 18px;
color: var(--muted-soft);
font-size: var(--nex-text-3xs);
}
/* 接管开关卡 */
.sec-take {
border: 1px solid rgba(var(--nex-primary-rgb), 0.35);
border-radius: 14px;
background: linear-gradient(135deg, var(--nex-primary-tint), #fff);
padding: 16px 18px;
margin: 16px 0 18px;
}
.sec-take-row {
display: flex;
align-items: center;
gap: 14px;
}
.sec-take-row > div {
flex: 1 1 auto;
min-width: 0;
}
.sec-take b {
font-size: var(--nex-text-sm);
}
.sec-take small {
display: block;
color: var(--muted);
margin-top: 3px;
font-size: var(--nex-text-3xs);
line-height: 1.55;
}
.sec-take .inline-error {
margin-top: 12px;
}
.sec-take-detail {
display: flex;
gap: 8px;
margin-top: 12px;
flex-wrap: wrap;
}
/* 扫描进度条(CleanBar 同款视觉,扫描数据形状) */
.sec-scanbar {
border: 1px solid rgba(var(--nex-primary-rgb), 0.4);
border-radius: 12px;
padding: 12px 16px;
margin: 4px 0 14px;
background: #fff;
box-shadow: 0 8px 22px rgba(var(--nex-primary-rgb), 0.12);
animation: cleanbar-in 0.22s ease-out;
}
.sec-scanbar-row {
display: flex;
align-items: center;
gap: 12px;
}
.sec-scanbar .spin.is-primary {
color: var(--nex-primary);
flex: 0 0 auto;
}
.sec-scanbar-main {
flex: 1 1 auto;
min-width: 0;
display: flex;
flex-direction: column;
gap: 3px;
}
.sec-scanbar-main b {
font-size: var(--nex-text-sm);
font-weight: var(--nex-weight-semibold);
}
.sec-scanbar-cur {
font-family: var(--nex-font-mono);
font-size: var(--nex-text-3xs);
color: var(--muted-soft);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sec-scanbar-track {
height: 10px;
border-radius: 999px;
background: rgba(89, 51, 34, 0.08);
margin-top: 10px;
overflow: hidden;
}
.sec-scanbar-track > span {
display: block;
height: 100%;
border-radius: 999px;
background:
repeating-linear-gradient(
115deg,
rgba(255, 255, 255, 0.28) 0 10px,
rgba(255, 255, 255, 0) 10px 24px
),
linear-gradient(90deg, #ff9a68, var(--nex-primary));
background-size:
34px 100%,
100% 100%;
animation: cleanbar-stripes 0.9s linear infinite;
}
.sec-scanbar-track > span.is-indeterminate {
width: 36%;
animation:
cleanbar-stripes 0.9s linear infinite,
cleanbar-sweep 1.4s ease-in-out infinite alternate;
}
/* 威胁列表 */
.sec-threats {
margin: 4px 0 14px;
border: 1px solid rgba(230, 90, 98, 0.35);
border-radius: 12px;
background: var(--red-soft);
padding: 12px 16px;
}
.sec-threats h3 {
font-size: var(--nex-text-2xs);
color: #a33a42;
margin-bottom: 8px;
}
.sec-trow {
display: flex;
align-items: center;
gap: 10px;
padding: 7px 4px;
border-top: 1px dashed rgba(230, 90, 98, 0.25);
font-size: var(--nex-text-2xs);
}
.sec-threats .sec-trow:first-of-type {
border-top: 0;
}
.sec-trow-fam {
flex: 0 0 auto;
color: #fff;
background: var(--red);
border-radius: 6px;
padding: 1px 8px;
font-family: var(--nex-font-mono);
font-size: var(--nex-text-3xs);
max-width: 260px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sec-trow-path {
flex: 1 1 auto;
min-width: 0;
font-family: var(--nex-font-mono);
color: var(--muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sec-trow-eng {
flex: 0 0 auto;
color: var(--violet);
background: var(--violet-soft);
border-radius: 999px;
padding: 1px 8px;
font-size: var(--nex-text-3xs);
}
.sec-clear {
display: flex;
align-items: center;
gap: 10px;
margin: 4px 0 14px;
border-radius: 12px;
padding: 12px 16px;
border: 1px solid;
}
.sec-clear.is-ok {
color: var(--green);
border-color: rgba(25, 169, 116, 0.4);
background: var(--green-soft);
}
.sec-clear.is-warn {
color: #b06a24;
border-color: rgba(238, 132, 76, 0.45);
background: var(--orange-soft);
}
.sec-clear b {
flex: 1 1 auto;
font-size: var(--nex-text-xs);
}
.sec-threats .sec-fine {
margin-top: 10px;
}
/* 引擎与病毒库两列卡 */
.sec-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
margin-bottom: 18px;
}
.sec-card {
display: flex;
flex-direction: column;
gap: 8px;
border: 1px solid var(--line);
border-radius: 14px;
background: var(--paper);
padding: 16px 18px;
}
.sec-card > b {
font-size: var(--nex-text-sm);
}
.sec-card > small {
color: var(--muted);
font-size: var(--nex-text-3xs);
line-height: 1.6;
}
.sec-card-acts {
display: flex;
gap: 8px;
}
.sec-dblog {
display: flex;
flex-direction: column;
gap: 3px;
border: 1px solid var(--line);
border-radius: 10px;
background: #fff;
padding: 8px 12px;
font-family: var(--nex-font-mono);
font-size: var(--nex-text-3xs);
color: var(--muted);
max-height: 96px;
overflow: hidden;
}
.sec-dblog .is-latest {
color: var(--nex-primary-strong);
}
.sec-dblog .is-error {
color: var(--red);
}
.sec-mirror {
display: flex;
align-items: center;
gap: 8px;
margin-top: auto;
padding-top: 8px;
border-top: 1px dashed var(--line);
font-size: var(--nex-text-3xs);
color: var(--muted);
}
.sec-mirror > span {
flex: 1 1 auto;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sec-mirror-input {
flex: 0 0 180px;
border: 1px solid var(--line-strong);
border-radius: 8px;
background: #fff;
color: var(--ink);
font-size: var(--nex-text-3xs);
font-family: var(--nex-font-mono);
padding: 5px 9px;
}
.sec-mirror-input:focus {
outline: 2px solid rgba(var(--nex-primary-rgb), 0.35);
outline-offset: 1px;
}
/* 隔离区 */
.sec-quarantine {
border: 1px solid var(--line);
border-radius: 12px;
background: #fff;
overflow: hidden;
margin-bottom: 14px;
}
.sec-qrow {
display: flex;
align-items: center;
gap: 10px;
padding: 9px 14px;
border-top: 1px dashed var(--line);
font-size: var(--nex-text-2xs);
}
.sec-qrow:first-child {
border-top: 0;
}
.sec-qrow-path {
flex: 1 1 auto;
min-width: 0;
font-family: var(--nex-font-mono);
color: var(--muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sec-qrow-meta {
flex: 0 0 auto;
color: var(--muted-soft);
font-size: var(--nex-text-3xs);
white-space: nowrap;
}

View File

@ -7,6 +7,8 @@ export type PageId =
| "widget"
| "system"
| "maintenance"
| "security"
| "screenshot"
| "history"
| "settings";
@ -132,6 +134,8 @@ export interface HardwareInfo {
export interface Bootstrap {
version: string;
/** Feature edition of this binary: full / pro / security / lite. */
edition: string;
platform: "macos" | "windows" | "linux" | "unknown";
osName: string;
osVersion: string;
@ -596,3 +600,83 @@ export interface WidgetPatch {
keepPosition?: boolean;
redock?: boolean;
}
// ---- engine download progress (共用:snow-shot / clamav) -------------------
/** `squid://engine` frame; `engine` picks the producer:
* "snow-shot" | "clamav" | "clamav-db" | "clamav-scan". */
export interface EngineProgress {
engine: string;
state: string;
done: number;
total: number;
message: string;
}
// ---- screenshot OCR (截图识字) ---------------------------------------------
export interface ScreenshotStatus {
enabled: boolean;
hotkey: string;
installed: boolean;
engineVersion: string;
downloadSize: number;
bindingOk: boolean;
captureDir: string;
}
/** One row of the capture archive (straight off disk, newest first). */
export interface CaptureEntry {
name: string;
path: string;
modifiedMs: number;
size: number;
}
// ---- security (安全查杀) -----------------------------------------------------
export interface WscProduct {
name: string;
/** 0 = protected (WSC SECURITY_STATE). */
state: number;
isDefault: boolean;
}
export interface SecurityStatus {
mode: string;
takeover: boolean;
engineInstalled: boolean;
engineVersion: string;
engineDownloadSize: number;
databaseReady: boolean;
databaseUpdatedMs: number | null;
databaseMirror: string;
wscHealth: number | null;
wscProducts: WscProduct[];
takeoverSupported: boolean;
takeoverLastError: string | null;
}
export interface Threat {
path: string;
virus: string;
engine: string;
}
export interface ScanOutcome {
scanned: number;
infected: number;
durationMs: number;
threats: Threat[];
cancelled: boolean;
}
export interface QuarantineEntry {
id: string;
path: string;
virus: string;
/** Kept optional: the current backend record carries no engine field. */
engine?: string;
quarantinedMs: number;
size: number;
}