Release Squid 0.1.7 with redesigned overview and corrected system metrics
parent
eb8f899fe0
commit
8490f9213c
|
|
@ -68,3 +68,5 @@ __pycache__/
|
|||
!release/0.1.5/Squid-Setup-0.1.5-win-x64.exe
|
||||
!release/0.1.6/Squid-0.1.6-macOS-universal.dmg
|
||||
!release/0.1.6/Squid-Setup-0.1.6-win-x64.exe
|
||||
!release/0.1.7/Squid-0.1.7-macOS-universal.dmg
|
||||
!release/0.1.7/Squid-Setup-0.1.7-win-x64.exe
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -4,7 +4,7 @@ members = ["crates/*"]
|
|||
exclude = ["src-tauri"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
edition = "2021"
|
||||
rust-version = "1.95"
|
||||
license = "GPL-3.0-only"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ The desktop app supports macOS 12+ and Windows 10/11 x64. The CLI and TUI share
|
|||
|
||||
| Feature | Description |
|
||||
| --- | --- |
|
||||
| Computer overview | Disk health, common actions, and CPU, memory, and storage summaries |
|
||||
| Overview | Disk health, common actions, and CPU, memory, and storage summaries |
|
||||
| Daily cleanup | 38 built-in rules on macOS and 30 on Windows, covering app and browser caches, logs, crash reports, developer caches, Trash, and more |
|
||||
| Uninstall apps | Finds an app by name and builds one plan containing the app bundle plus preferences, caches, containers, or AppData leftovers |
|
||||
| Deep Clean | Finds rebuildable build output such as `node_modules`, disk images, installers, and stale downloads while protecting recently used projects |
|
||||
|
|
@ -39,7 +39,7 @@ Language settings offer only Simplified Chinese and English, with the current sy
|
|||
|
||||
### Sidebar
|
||||
|
||||
- **Maintenance**: Computer overview, Daily cleanup, Uninstall apps, Deep Clean
|
||||
- **Maintenance**: Overview, Daily cleanup, Uninstall apps, Deep Clean
|
||||
- **Protection**: Security, Startup items
|
||||
- **Insights**: Storage, Real-time monitor
|
||||
- **Bottom**: History, Settings
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ Squid 是面向 macOS 与 Windows 的本地系统维护工具:清理可重建
|
|||
|
||||
| 功能 | 说明 |
|
||||
| --- | --- |
|
||||
| 电脑概览 | 磁盘健康、常用操作入口与 CPU、内存、存储摘要 |
|
||||
| 概览 | 磁盘健康、常用操作入口与 CPU、内存、存储摘要 |
|
||||
| 日常清理 | macOS 38 条 / Windows 30 条内置规则,覆盖应用与浏览器缓存、日志、崩溃报告、开发缓存与废纸篓等 |
|
||||
| 应用卸载 | 按名称定位应用,把应用本体与偏好、缓存、容器或 AppData 残留组成同一个卸载计划 |
|
||||
| 深度清理 | 查找 `node_modules` 等可重建构建产物、磁盘镜像、安装包和陈旧下载,并保护近期仍在使用的项目 |
|
||||
|
|
@ -39,7 +39,7 @@ Squid 是面向 macOS 与 Windows 的本地系统维护工具:清理可重建
|
|||
|
||||
### 左侧菜单
|
||||
|
||||
- **维护**:电脑概览、日常清理、应用卸载、深度清理
|
||||
- **维护**:概览、日常清理、应用卸载、深度清理
|
||||
- **保护**:安全、启动项
|
||||
- **洞察**:存储空间、实时监控
|
||||
- **底部**:历史记录、设置
|
||||
|
|
|
|||
|
|
@ -358,6 +358,10 @@ pub struct AppInfo {
|
|||
pub name: String,
|
||||
pub bundle_id: Option<String>,
|
||||
pub path: PathBuf,
|
||||
/// The file or bundle the desktop icon is read from. `path` may be an
|
||||
/// install directory or an uninstall helper, neither of which carries the
|
||||
/// icon the user recognises.
|
||||
pub icon_source: Option<PathBuf>,
|
||||
pub version: Option<String>,
|
||||
pub size: Bytes,
|
||||
/// Where the app was found: /Applications, ~/Applications, Homebrew Cask…
|
||||
|
|
|
|||
|
|
@ -464,6 +464,7 @@ mod tests {
|
|||
name: "Demo".into(),
|
||||
bundle_id: Some("com.example.Demo".into()),
|
||||
path: PathBuf::from(path),
|
||||
icon_source: None,
|
||||
version: Some("1.0".into()),
|
||||
size: Bytes(1_000),
|
||||
source: source.into(),
|
||||
|
|
|
|||
|
|
@ -32,3 +32,7 @@ windows-sys = { version = "0.59", features = [
|
|||
"Win32_Security_WinTrust",
|
||||
"Win32_System_Threading",
|
||||
] }
|
||||
|
||||
[target.'cfg(any(target_os = "macos", target_os = "windows"))'.dependencies]
|
||||
file_icon_provider = "1.0.2"
|
||||
png = "0.17"
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ pub fn app_from_bundle(
|
|||
name,
|
||||
bundle_id: bundle.bundle_id.clone(),
|
||||
path: path.clone(),
|
||||
icon_source: Some(path.clone()),
|
||||
version: bundle
|
||||
.short_version
|
||||
.clone()
|
||||
|
|
@ -142,6 +143,32 @@ pub fn app_from_bundle(
|
|||
Some(app)
|
||||
}
|
||||
|
||||
/// Render an application's system icon as PNG bytes.
|
||||
///
|
||||
/// macOS and Windows let the file manager do the work, so the result is the
|
||||
/// same icon Finder or Explorer shows, including HiDPI-safe source artwork.
|
||||
/// Linux has no equivalent without a GTK dependency; the desktop falls back to
|
||||
/// the app's initial.
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
pub fn icon_png(app: &AppInfo, size: u16) -> Option<Vec<u8>> {
|
||||
let source = app.icon_source.as_ref()?;
|
||||
let icon = file_icon_provider::get_file_icon(source, size).ok()?;
|
||||
let mut output = Vec::new();
|
||||
{
|
||||
let mut encoder = png::Encoder::new(&mut output, icon.width, icon.height);
|
||||
encoder.set_color(png::ColorType::Rgba);
|
||||
encoder.set_depth(png::BitDepth::Eight);
|
||||
let mut writer = encoder.write_header().ok()?;
|
||||
writer.write_image_data(&icon.pixels).ok()?;
|
||||
}
|
||||
Some(output)
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
pub fn icon_png(_app: &AppInfo, _size: u16) -> Option<Vec<u8>> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Match "is this app running" against the process executable list.
|
||||
pub fn is_running(dir_name: &str, executable: Option<&str>, running: &[String]) -> bool {
|
||||
let mut candidates: Vec<String> = Vec::with_capacity(3);
|
||||
|
|
@ -167,3 +194,20 @@ pub fn stem_lower(path: &Path) -> String {
|
|||
.map(|n| n.to_string_lossy().trim_end_matches(".app").to_lowercase())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
fn a_system_icon_is_encoded_as_png() {
|
||||
let app = AppInfo {
|
||||
name: "Squid".into(),
|
||||
icon_source: std::env::current_exe().ok(),
|
||||
..Default::default()
|
||||
};
|
||||
let png = icon_png(&app, 32).expect("the running executable has a system icon");
|
||||
assert_eq!(&png[..8], b"\x89PNG\r\n\x1a\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ pub trait Platform: Send + Sync {
|
|||
fn display_name(&self) -> String;
|
||||
fn os_version(&self) -> String;
|
||||
fn hardware_model(&self) -> String;
|
||||
/// Display adapter(s), when the platform exposes a stable name.
|
||||
fn graphics_adapter(&self) -> String {
|
||||
String::new()
|
||||
}
|
||||
|
||||
/// Directories to scan for installed applications.
|
||||
fn app_sources(&self) -> Vec<AppSource>;
|
||||
|
|
|
|||
|
|
@ -112,6 +112,29 @@ impl Platform for Linux {
|
|||
.to_string()
|
||||
}
|
||||
|
||||
fn graphics_adapter(&self) -> String {
|
||||
run("lspci", &[])
|
||||
.map(|text| {
|
||||
text.lines()
|
||||
.filter(|line| {
|
||||
line.contains("VGA compatible controller")
|
||||
|| line.contains("3D controller")
|
||||
|| line.contains("Display controller")
|
||||
})
|
||||
.filter_map(|line| line.split_once(": ").map(|(_, value)| value.trim()))
|
||||
.map(|value| {
|
||||
value
|
||||
.split_once(": ")
|
||||
.map(|(_, name)| name.trim())
|
||||
.unwrap_or(value)
|
||||
.to_string()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(" · ")
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn app_sources(&self) -> Vec<AppSource> {
|
||||
[
|
||||
("/usr/share/applications", "System", 1, true),
|
||||
|
|
@ -193,6 +216,7 @@ impl Platform for Linux {
|
|||
name: desktop.name.clone(),
|
||||
bundle_id: Some(id.clone()),
|
||||
path: path.clone(),
|
||||
icon_source: None,
|
||||
version: None,
|
||||
size: Bytes::ZERO,
|
||||
source: source.label.clone(),
|
||||
|
|
@ -222,6 +246,7 @@ impl Platform for Linux {
|
|||
.unwrap_or_else(|| id.to_string()),
|
||||
bundle_id: Some(id.to_string()),
|
||||
path: PathBuf::from(format!("flatpak:{id}")),
|
||||
icon_source: None,
|
||||
version: None,
|
||||
size: cols
|
||||
.get(2)
|
||||
|
|
|
|||
|
|
@ -74,6 +74,25 @@ impl Platform for MacOs {
|
|||
parts.join(" · ")
|
||||
}
|
||||
|
||||
fn graphics_adapter(&self) -> String {
|
||||
run(
|
||||
"/usr/sbin/system_profiler",
|
||||
&["SPDisplaysDataType", "-detailLevel", "mini"],
|
||||
)
|
||||
.map(|text| {
|
||||
text.lines()
|
||||
.filter_map(|line| {
|
||||
line.trim()
|
||||
.strip_prefix("Chipset Model:")
|
||||
.map(|value| value.trim().to_string())
|
||||
.filter(|value| !value.is_empty())
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(" · ")
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn app_sources(&self) -> Vec<AppSource> {
|
||||
let mut sources = vec![
|
||||
AppSource {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
|||
use sysinfo::{ProcessRefreshKind, ProcessesToUpdate, RefreshKind, System, Users};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProcessRow {
|
||||
pub pid: u32,
|
||||
pub parent: Option<u32>,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
//! default: every entry says whether squid may change it, and the ones it may
|
||||
//! not say why in the same field the UI shows.
|
||||
//!
|
||||
//! Entries are also attributed to the application that installed them, because
|
||||
//! nobody reads 800 plist labels: both operating systems show this list per app,
|
||||
//! and `StartupOwner` is what makes that possible without guessing.
|
||||
//!
|
||||
//! Disabling an entry means renaming its plist to `*.plist.disabled` on macOS
|
||||
//! and moving its registry value into a sibling backup key on Windows. Both are
|
||||
//! reversible without a privileged helper, which is the whole point: squid never
|
||||
|
|
@ -63,6 +67,9 @@ pub enum StartupRisk {
|
|||
InTempDir,
|
||||
/// The target exists but carries no usable code signature.
|
||||
Unsigned,
|
||||
/// The target is not readable by this user, so its signature was never asked
|
||||
/// about. Different from `Unsigned`, which is an answer and an accusation.
|
||||
SignatureUnreadable,
|
||||
/// Started through a script interpreter rather than a binary.
|
||||
ScriptInterpreter,
|
||||
/// Created within the last fortnight.
|
||||
|
|
@ -73,7 +80,66 @@ pub enum StartupRisk {
|
|||
HiddenHomeDirectory,
|
||||
}
|
||||
|
||||
/// Which of the two lists the operating systems themselves show an entry
|
||||
/// belongs to. macOS splits "Login Items" (apps that open when you log in) from
|
||||
/// "Allow in the Background" (helpers that keep running); Windows splits the
|
||||
/// Startup folder and Run keys from scheduled tasks and services. A page that
|
||||
/// shows one flat list of 800 labels answers neither question.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum StartupCategory {
|
||||
/// Opens an application or window at login: a login item, a Startup folder
|
||||
/// shortcut, or a Run value that launches an app.
|
||||
OpenAtLogin,
|
||||
/// A helper that keeps running without a window: LaunchAgents and
|
||||
/// LaunchDaemons, scheduled tasks, services.
|
||||
Background,
|
||||
}
|
||||
|
||||
impl StartupCategory {
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
StartupCategory::OpenAtLogin => "open-at-login",
|
||||
StartupCategory::Background => "background",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Why squid will not change an entry. A typed answer rather than a sentence
|
||||
/// from the platform layer, because the platform layer does not know which
|
||||
/// language the page is wearing; each variant becomes one short localised phrase.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum StartupLock {
|
||||
/// Apple's or Microsoft's own entry.
|
||||
OperatingSystem,
|
||||
/// Root-owned plist, HKLM value, system task or service: one authorisation away.
|
||||
NeedsAuthorisation,
|
||||
/// The declaring file or folder is not writable by this user.
|
||||
NotWritable,
|
||||
/// macOS owns the login-item list and changes it through System Settings.
|
||||
ManagedBySystemSettings,
|
||||
/// This release reports these entries and leaves them alone.
|
||||
NotManaged,
|
||||
}
|
||||
|
||||
/// The application an entry belongs to, worked out from the paths launchd or the
|
||||
/// registry name, never from the entry's label. This is what lets the list be
|
||||
/// "Docker · 3 background items" instead of three opaque plist names.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StartupOwner {
|
||||
/// The name to show the user: the bundle's `CFBundleDisplayName`, or the
|
||||
/// application folder name when the bundle cannot be read.
|
||||
pub name: String,
|
||||
/// The `.app` bundle, or the directory the entry lives in.
|
||||
pub bundle_path: Option<PathBuf>,
|
||||
/// True when the owning application is Apple's or Microsoft's own.
|
||||
pub vendor: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StartupItem {
|
||||
/// Stable identifier: the plist path, registry value, task path or service.
|
||||
pub id: String,
|
||||
|
|
@ -91,12 +157,17 @@ pub struct StartupItem {
|
|||
/// An entry the operating system vendor owns.
|
||||
pub system_vendor: bool,
|
||||
pub disabled: bool,
|
||||
/// False means squid will refuse to touch it, with `readonly_reason`.
|
||||
/// False means squid will refuse to touch it, and `lock` says which kind of
|
||||
/// refusal it is.
|
||||
pub modifiable: bool,
|
||||
pub readonly_reason: Option<String>,
|
||||
pub lock: Option<StartupLock>,
|
||||
pub hidden: bool,
|
||||
pub modified_ms: Option<u64>,
|
||||
pub risks: Vec<StartupRisk>,
|
||||
/// Which list of the operating system's own this entry would appear in.
|
||||
pub category: StartupCategory,
|
||||
/// The application that installed the entry, when one could be named.
|
||||
pub owner: Option<StartupOwner>,
|
||||
}
|
||||
|
||||
impl StartupItem {
|
||||
|
|
@ -124,20 +195,66 @@ impl StartupItem {
|
|||
system_vendor: false,
|
||||
disabled: false,
|
||||
modifiable: false,
|
||||
readonly_reason: None,
|
||||
lock: None,
|
||||
hidden: false,
|
||||
modified_ms: None,
|
||||
risks: Vec::new(),
|
||||
category: StartupCategory::Background,
|
||||
owner: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Everything squid could read. Unreadable folders are simply absent, and the
|
||||
/// notes say which roots could not be listed.
|
||||
/// notes say which ones and why.
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct StartupInventory {
|
||||
pub items: Vec<StartupItem>,
|
||||
pub notes: Vec<String>,
|
||||
pub notes: Vec<StartupNote>,
|
||||
}
|
||||
|
||||
/// Something the page has to admit it could not read. `kind` is typed rather than
|
||||
/// a sentence, because the platform layer does not know whether the page is
|
||||
/// wearing Chinese or English; a note that arrives already translated is a note
|
||||
/// that arrives in the wrong language. `detail` carries the operating system's own
|
||||
/// words beside it, which are never translated and are therefore honest.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StartupNote {
|
||||
pub kind: StartupNoteKind,
|
||||
/// The folder, tool or list this note is about.
|
||||
pub subject: String,
|
||||
pub detail: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum StartupNoteKind {
|
||||
/// A folder holding entries that could not be listed.
|
||||
UnreadableRoot,
|
||||
/// The login-item list could not be read at all, which on macOS means the
|
||||
/// automation permission has not been granted.
|
||||
LoginItemsUnavailable,
|
||||
}
|
||||
|
||||
/// The command line speaks English, so it prints the note whole; the GUI reads
|
||||
/// `kind` and translates it. One fact, two honest renderings.
|
||||
impl std::fmt::Display for StartupNote {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self.kind {
|
||||
StartupNoteKind::UnreadableRoot => {
|
||||
write!(formatter, "{} could not be listed", self.subject)?;
|
||||
}
|
||||
StartupNoteKind::LoginItemsUnavailable => {
|
||||
write!(formatter, "login items could not be read")?;
|
||||
}
|
||||
}
|
||||
if self.detail.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
write!(formatter, ": {}", self.detail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StartupInventory {
|
||||
|
|
@ -215,6 +332,11 @@ pub fn entry_for(program: &Path) -> Option<StartupItem> {
|
|||
}
|
||||
}
|
||||
|
||||
/// What a refused change says. The reason itself is shown from `StartupLock`,
|
||||
/// which the page can translate; this is only what the command returns when the
|
||||
/// inventory it was given has already gone stale.
|
||||
const LOCK_REFUSAL: &str = "Squid cannot change this entry.";
|
||||
|
||||
pub fn home_dir() -> PathBuf {
|
||||
dirs::home_dir().unwrap_or_else(|| PathBuf::from("/"))
|
||||
}
|
||||
|
|
@ -236,7 +358,8 @@ fn now_ms() -> u64 {
|
|||
|
||||
const RECENT_MS: u64 = 14 * 24 * 60 * 60 * 1000;
|
||||
|
||||
/// Judges one resolved program: signature, freshness, and where it lives.
|
||||
/// Judges one resolved program: freshness and where it lives. The signature half
|
||||
/// is deliberately not here — see `apply_trust`.
|
||||
fn judge_program(item: &mut StartupItem, program: Option<&Path>) {
|
||||
let Some(program) = program else {
|
||||
return;
|
||||
|
|
@ -286,8 +409,29 @@ fn judge_program(item: &mut StartupItem, program: Option<&Path>) {
|
|||
item.risks.push(StartupRisk::ScriptInterpreter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let trust = crate::trust::assess(program);
|
||||
/// The signature half of the judgement, kept apart from `judge_program` because
|
||||
/// on macOS it costs one `codesign` process per entry. An M1 Pro has ~870 startup
|
||||
/// entries, 845 of which Apple owns and nobody is going to inspect, so assessing
|
||||
/// all of them took 8 s to answer a question about 25. Entries whose target is
|
||||
/// gone are not assessed either: "not there" is already the finding.
|
||||
fn apply_trust(item: &mut StartupItem) {
|
||||
if item.system_vendor || item.risks.contains(&StartupRisk::MissingTarget) {
|
||||
return;
|
||||
}
|
||||
let Some(program) = item.program.clone() else {
|
||||
return;
|
||||
};
|
||||
// A root-owned helper installed mode 0711 — `/Library/PrivilegedHelperTools/
|
||||
// com.docker.socket`, for one — can be run and cannot be read, and `codesign`
|
||||
// answers that with "Permission denied". Reporting it as *unsigned* would be a
|
||||
// false accusation against a program that is signed and merely private.
|
||||
if !program.is_dir() && std::fs::File::open(&program).is_err() {
|
||||
item.risks.push(StartupRisk::SignatureUnreadable);
|
||||
return;
|
||||
}
|
||||
let trust = crate::trust::assess(&program);
|
||||
item.signed = trust.signed;
|
||||
item.publisher = trust.signer.clone();
|
||||
if !trust.signed {
|
||||
|
|
@ -295,6 +439,382 @@ fn judge_program(item: &mut StartupItem, program: Option<&Path>) {
|
|||
}
|
||||
}
|
||||
|
||||
/// The `.app` bundle an entry belongs to, found in the path launchd will run.
|
||||
/// macOS nests helpers inside the bundle that owns them, which is why this works
|
||||
/// without asking Launch Services anything.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn bundle_owning(path: &Path) -> Option<PathBuf> {
|
||||
let mut current = Some(path);
|
||||
while let Some(candidate) = current {
|
||||
if candidate.to_string_lossy().to_lowercase().ends_with(".app") {
|
||||
return Some(candidate.to_path_buf());
|
||||
}
|
||||
current = candidate.parent();
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// The installed applications, keyed by bundle id.
|
||||
///
|
||||
/// A helper installed in `/Library/PrivilegedHelperTools` says nothing about its
|
||||
/// owner in its path, but launchd's convention is that its label begins with the
|
||||
/// bundle id of the app that installed it. Checking that against what is actually
|
||||
/// installed is a lookup rather than a guess: `com.docker.socket` is Docker's
|
||||
/// because `com.docker.*` belongs to exactly one installed application.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[derive(Default)]
|
||||
struct AppIndex {
|
||||
by_id: std::collections::BTreeMap<String, StartupOwner>,
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
impl AppIndex {
|
||||
fn scan() -> AppIndex {
|
||||
let mut out = AppIndex::default();
|
||||
let roots = [
|
||||
PathBuf::from("/Applications"),
|
||||
home_dir().join("Applications"),
|
||||
PathBuf::from("/System/Applications"),
|
||||
PathBuf::from("/System/Library/CoreServices"),
|
||||
];
|
||||
for root in roots {
|
||||
let Ok(entries) = std::fs::read_dir(&root) else {
|
||||
continue;
|
||||
};
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if !path.to_string_lossy().ends_with(".app") {
|
||||
continue;
|
||||
}
|
||||
let Some(info) = bundle_info(&path) else {
|
||||
continue;
|
||||
};
|
||||
out.by_id.entry(info.0).or_insert(StartupOwner {
|
||||
name: info.1,
|
||||
bundle_path: Some(path.clone()),
|
||||
vendor: root.starts_with("/System"),
|
||||
});
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The longest bundle-id prefix of `label` that one installed app owns.
|
||||
fn owner_of(&self, label: &str) -> Option<StartupOwner> {
|
||||
let mut parts: Vec<String> = label
|
||||
.to_lowercase()
|
||||
.split('.')
|
||||
.map(|part| part.to_string())
|
||||
.collect();
|
||||
// The shortest usable prefix has two components. `org` on its own is a
|
||||
// registry suffix, not a vendor, and stopping there matched
|
||||
// `org.wireshark.ChmodBPF` to the only `org.*` application installed.
|
||||
while parts.len() > 2 {
|
||||
parts.pop();
|
||||
let prefix = parts.join(".");
|
||||
let matches: Vec<&StartupOwner> = self
|
||||
.by_id
|
||||
.range(prefix.clone()..)
|
||||
.take_while(|(id, _)| *id == &prefix || id.starts_with(&format!("{prefix}.")))
|
||||
.map(|(_, owner)| owner)
|
||||
.collect();
|
||||
// Only claim it when a single application is in the family; two
|
||||
// installers sharing a vendor prefix is a tie, and a tie is a guess.
|
||||
if matches.len() == 1 {
|
||||
return Some(matches[0].clone());
|
||||
}
|
||||
if matches.len() > 1 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// The bundle id and display name an `.app` declares for itself.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn bundle_info(bundle: &Path) -> Option<(String, String)> {
|
||||
let dict = plist::Value::from_file(bundle.join("Contents/Info.plist"))
|
||||
.ok()?
|
||||
.into_dictionary()?;
|
||||
let id = dict
|
||||
.get("CFBundleIdentifier")
|
||||
.and_then(|value| value.as_string())?
|
||||
.to_lowercase();
|
||||
let name = ["CFBundleDisplayName", "CFBundleName"]
|
||||
.iter()
|
||||
.find_map(|key| dict.get(key).and_then(|value| value.as_string()))
|
||||
.map(str::to_string)
|
||||
.or_else(|| {
|
||||
bundle
|
||||
.file_stem()
|
||||
.map(|stem| stem.to_string_lossy().into_owned())
|
||||
})?;
|
||||
Some((id, name))
|
||||
}
|
||||
|
||||
/// Name the application every entry belongs to.
|
||||
///
|
||||
/// macOS nests helpers inside the `.app` that installed them, so the path usually
|
||||
/// answers it; where it does not, the entry's launchd label is matched against the
|
||||
/// bundle ids of the applications that are actually installed. Windows has no such
|
||||
/// nesting, so the install folder under Program Files carries the name. An entry
|
||||
/// that still names nothing stays ungrouped rather than being filed under a guess.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn attribute_owners(items: &mut [StartupItem]) {
|
||||
let mut index: Option<AppIndex> = None;
|
||||
for item in items {
|
||||
if item.system_vendor {
|
||||
continue;
|
||||
}
|
||||
let bundle = item
|
||||
.program
|
||||
.clone()
|
||||
.or_else(|| {
|
||||
(item.id.contains('/') || item.id.ends_with(".app"))
|
||||
.then(|| PathBuf::from(&item.id))
|
||||
})
|
||||
.as_deref()
|
||||
.and_then(bundle_owning);
|
||||
if let Some(bundle) = bundle {
|
||||
let vendor = bundle.starts_with("/System");
|
||||
let name = bundle_info(&bundle)
|
||||
.map(|(_, name)| name)
|
||||
.unwrap_or_else(|| {
|
||||
bundle
|
||||
.file_stem()
|
||||
.map(|stem| stem.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| bundle.display().to_string())
|
||||
});
|
||||
item.owner = Some(StartupOwner {
|
||||
name,
|
||||
bundle_path: Some(bundle),
|
||||
vendor,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
// Nothing in the path names an application: a helper in
|
||||
// `/Library/PrivilegedHelperTools`, or an entry whose target is gone.
|
||||
let label = item
|
||||
.id
|
||||
.rsplit('/')
|
||||
.next()
|
||||
.unwrap_or(&item.id)
|
||||
.trim_end_matches(".plist")
|
||||
.trim_end_matches(".disabled");
|
||||
let index = index.get_or_insert_with(AppIndex::scan);
|
||||
if let Some(owner) = index.owner_of(label) {
|
||||
item.owner = Some(owner);
|
||||
continue;
|
||||
}
|
||||
// The signing organisation is the last honest answer, and it is the same
|
||||
// one System Settings groups background items by.
|
||||
if let Some(organisation) = item.publisher.as_deref().and_then(organisation_of) {
|
||||
item.owner = Some(StartupOwner {
|
||||
name: organisation,
|
||||
bundle_path: None,
|
||||
vendor: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `Developer ID Application: Docker Inc (9P49FL5KQ8)` to `Docker Inc`.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn organisation_of(signer: &str) -> Option<String> {
|
||||
let tail = signer.rsplit(": ").next().unwrap_or(signer);
|
||||
let name = tail.split(" (").next().unwrap_or(tail).trim();
|
||||
(!name.is_empty() && name != "not set").then(|| name.to_string())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn attribute_owners(items: &mut [StartupItem]) {
|
||||
for item in items {
|
||||
if item.system_vendor {
|
||||
continue;
|
||||
}
|
||||
let Some(program) = item.program.as_deref() else {
|
||||
continue;
|
||||
};
|
||||
// The publisher the Authenticode signature names is what Control Panel and
|
||||
// Task Manager both show, so it leads where the folder is a vendor directory.
|
||||
if let Some(name) = item
|
||||
.publisher
|
||||
.as_deref()
|
||||
.and_then(organisation_of)
|
||||
.or_else(|| install_folder_owning(program))
|
||||
{
|
||||
item.owner = Some(StartupOwner {
|
||||
name,
|
||||
bundle_path: None,
|
||||
vendor: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `CN = "Microsoft Corporation"` and `Microsoft Corporation` to one name.
|
||||
#[cfg(windows)]
|
||||
fn organisation_of(signer: &str) -> Option<String> {
|
||||
let tail = signer.rsplit('=').next().unwrap_or(signer);
|
||||
let name = tail.trim_matches(|c| c == '"' || c == '\'').trim();
|
||||
(!name.is_empty()).then(|| name.to_string())
|
||||
}
|
||||
|
||||
/// The folder under Program Files that holds one executable, which is the unit
|
||||
/// Windows itself groups installed programs by.
|
||||
#[cfg(windows)]
|
||||
fn install_folder_owning(program: &Path) -> Option<String> {
|
||||
let text = program.to_string_lossy();
|
||||
// Located without regard to case, then cut out of the original: the folder is
|
||||
// shown to the user, and `MOZILLA firefox` is not what it is called.
|
||||
let start = text.to_lowercase().find("program files")? + "program files".len();
|
||||
let mut parts = text[start..]
|
||||
.split(['\\', '/'])
|
||||
.filter(|part| !part.trim().is_empty());
|
||||
// ` (x86)` is part of the root, not a product, so the one folder after it is
|
||||
// the vendor or product a person would recognise.
|
||||
let first = parts.next()?;
|
||||
let name = if first.trim_start().starts_with('(') {
|
||||
parts.next()?
|
||||
} else {
|
||||
first
|
||||
};
|
||||
(!name.trim().is_empty()).then(|| name.trim().to_string())
|
||||
}
|
||||
|
||||
/// What the operating system shows an entry under. Both platforms keep the same
|
||||
/// two lists — the things that open a window when you log in, and the helpers
|
||||
/// that run behind it — so the entry's own source decides it.
|
||||
fn categorise(item: &mut StartupItem) {
|
||||
item.category = match item.source {
|
||||
StartupSource::LoginItem | StartupSource::StartupFolder | StartupSource::RegistryRun => {
|
||||
StartupCategory::OpenAtLogin
|
||||
}
|
||||
_ => StartupCategory::Background,
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod attribution_tests {
|
||||
use super::*;
|
||||
|
||||
/// The helper in `/Library/PrivilegedHelperTools` is named after nobody: its
|
||||
/// path says where helpers live, not who installed it. Its label is matched
|
||||
/// against installed bundle ids instead, which is honest only while exactly one
|
||||
/// application owns the family.
|
||||
#[test]
|
||||
#[cfg(target_os = "macos")]
|
||||
fn a_helper_is_claimed_only_by_an_unambiguous_bundle_family() {
|
||||
let owner = |name: &str| StartupOwner {
|
||||
name: name.to_string(),
|
||||
bundle_path: None,
|
||||
vendor: false,
|
||||
};
|
||||
let index = AppIndex {
|
||||
by_id: [
|
||||
("com.docker.docker".to_string(), owner("Docker")),
|
||||
(
|
||||
"com.apphousekitchen.aldente-pro".to_string(),
|
||||
owner("AlDente"),
|
||||
),
|
||||
("org.geogebra6.mac".to_string(), owner("GeoGebra")),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
};
|
||||
assert_eq!(
|
||||
index.owner_of("com.docker.socket").map(|o| o.name),
|
||||
Some("Docker".into())
|
||||
);
|
||||
assert_eq!(
|
||||
index
|
||||
.owner_of("com.apphousekitchen.aldente-pro.helper")
|
||||
.map(|o| o.name),
|
||||
Some("AlDente".into())
|
||||
);
|
||||
// `org` on its own is a registry suffix, not a vendor. Without that bound
|
||||
// `org.wireshark.ChmodBPF` was matched to the only `org.*` app installed.
|
||||
assert_eq!(index.owner_of("org.wireshark.ChmodBPF"), None);
|
||||
assert_eq!(index.owner_of("us.zoom.ZoomDaemon"), None);
|
||||
|
||||
// Two applications in one family is a tie, and a tie is not an answer.
|
||||
let tied = AppIndex {
|
||||
by_id: [
|
||||
("com.google.chrome".to_string(), owner("Chrome")),
|
||||
("com.google.keystone".to_string(), owner("Keystone")),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
};
|
||||
// Where a prefix names one application exactly, that is the answer even
|
||||
// though a shallower prefix would be a tie.
|
||||
assert_eq!(
|
||||
tied.owner_of("com.google.keystone.agent").map(|o| o.name),
|
||||
Some("Keystone".into())
|
||||
);
|
||||
assert_eq!(
|
||||
tied.owner_of("com.google.Chrome.helper").map(|o| o.name),
|
||||
Some("Chrome".into()),
|
||||
"the deeper prefix that does resolve is still used"
|
||||
);
|
||||
assert_eq!(
|
||||
tied.owner_of("com.google.SomeUpdater"),
|
||||
None,
|
||||
"the only prefix left is a tie between two applications, so nothing is claimed"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn a_program_files_path_names_the_product_folder() {
|
||||
assert_eq!(
|
||||
install_folder_owning(Path::new(
|
||||
r"C:\Program Files\Google\Chrome\Application\chrome.exe"
|
||||
)),
|
||||
Some("Google".into())
|
||||
);
|
||||
// ` (x86)` belongs to the root, so the product is the folder after it.
|
||||
assert_eq!(
|
||||
install_folder_owning(Path::new(
|
||||
r"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
|
||||
)),
|
||||
Some("Mozilla Firefox".into())
|
||||
);
|
||||
assert_eq!(
|
||||
install_folder_owning(Path::new(
|
||||
r"C:\program files (x86)\MOZILLA Firefox\firefox.exe"
|
||||
)),
|
||||
Some("MOZILLA Firefox".into()),
|
||||
"found without regard to case, shown exactly as the folder is named"
|
||||
);
|
||||
assert_eq!(
|
||||
install_folder_owning(Path::new(r"D:\tools\bin\thing.exe")),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_entry_goes_to_the_list_its_source_declares() {
|
||||
let mut login = StartupItem::new(
|
||||
"login-item://Docker",
|
||||
"Docker",
|
||||
StartupSource::LoginItem,
|
||||
StartupScope::User,
|
||||
);
|
||||
let mut daemon = StartupItem::new(
|
||||
"/Library/LaunchDaemons/com.docker.vmnetd.plist",
|
||||
"com.docker.vmnetd",
|
||||
StartupSource::LaunchDaemon,
|
||||
StartupScope::System,
|
||||
);
|
||||
categorise(&mut login);
|
||||
categorise(&mut daemon);
|
||||
assert_eq!(login.category, StartupCategory::OpenAtLogin);
|
||||
assert_eq!(daemon.category, StartupCategory::Background);
|
||||
}
|
||||
}
|
||||
|
||||
/// True when the path lives in a dot-directory directly under home, which is
|
||||
/// where updaters and helpers that nobody installed tend to sit.
|
||||
fn in_hidden_home_dir(program: &Path) -> bool {
|
||||
|
|
@ -309,6 +829,24 @@ fn in_hidden_home_dir(program: &Path) -> bool {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// What happens to every entry once both platforms have finished collecting them.
|
||||
///
|
||||
/// Trust comes first because an entry whose path names no application is filed
|
||||
/// under whoever signed it, and that is only known once the signature has been
|
||||
/// asked about. On macOS that question costs one `codesign` process per entry, so
|
||||
/// it is asked in parallel: ~870 sequential calls took 8 s on an M1 Pro, and the
|
||||
/// same calls across the available cores take under 1 s.
|
||||
fn finish(items: &mut [StartupItem]) {
|
||||
use rayon::prelude::*;
|
||||
|
||||
items.par_iter_mut().for_each(apply_trust);
|
||||
attribute_owners(items);
|
||||
for item in items.iter_mut() {
|
||||
categorise(item);
|
||||
}
|
||||
sort_items(items);
|
||||
}
|
||||
|
||||
/// Order user-owned entries first; inside a scope, alphabetically.
|
||||
fn sort_items(items: &mut [StartupItem]) {
|
||||
items.sort_by(|a, b| {
|
||||
|
|
@ -369,10 +907,11 @@ mod macos {
|
|||
Ok(entries) => entries,
|
||||
Err(error) => {
|
||||
if error.kind() != std::io::ErrorKind::NotFound {
|
||||
out.notes.push(format!(
|
||||
"{} could not be listed: {error}",
|
||||
root.dir.display()
|
||||
));
|
||||
out.notes.push(StartupNote {
|
||||
kind: StartupNoteKind::UnreadableRoot,
|
||||
subject: root.dir.display().to_string(),
|
||||
detail: error.to_string(),
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -395,8 +934,8 @@ mod macos {
|
|||
}
|
||||
}
|
||||
}
|
||||
out.items.extend(login_items());
|
||||
sort_items(&mut out.items);
|
||||
out.items.extend(login_items(&mut out.notes));
|
||||
finish(&mut out.items);
|
||||
out
|
||||
}
|
||||
|
||||
|
|
@ -443,16 +982,16 @@ mod macos {
|
|||
/// entries Apple owns: a hundred unsigned system agents is not a signal.
|
||||
fn classify(item: &mut StartupItem, path: &Path, scope: StartupScope) {
|
||||
if item.system_vendor {
|
||||
item.readonly_reason = Some("part of macOS".into());
|
||||
item.lock = Some(StartupLock::OperatingSystem);
|
||||
item.risks.clear();
|
||||
} else if scope == StartupScope::System {
|
||||
item.readonly_reason = Some("requires an administrator authorisation".into());
|
||||
item.lock = Some(StartupLock::NeedsAuthorisation);
|
||||
} else {
|
||||
let writable = crate::is_user_writable(path)
|
||||
&& crate::is_user_writable(path.parent().unwrap_or(path));
|
||||
item.modifiable = writable;
|
||||
if !writable {
|
||||
item.readonly_reason = Some("this file is not owned by you".into());
|
||||
item.lock = Some(StartupLock::NotWritable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -491,71 +1030,125 @@ mod macos {
|
|||
.unwrap_or(expanded)
|
||||
}
|
||||
|
||||
/// The login-item database macOS still maintains beside the modern
|
||||
/// per-app setting. Reading it costs one file scan; changing it belongs to
|
||||
/// System Settings, so these entries are reported read-only.
|
||||
fn login_items() -> Vec<StartupItem> {
|
||||
let path = home_dir().join(
|
||||
"Library/Application Support/com.apple.backgroundtaskmanagementagent/backgrounditems.btm",
|
||||
);
|
||||
/// What System Settings shows under "Open at Login".
|
||||
///
|
||||
/// Asking System Events rather than parsing a file is the point: the list is
|
||||
/// maintained by backgroundtaskmanagement, its on-disk archive is a keychain
|
||||
/// of security-scoped bookmarks that only root can resolve, and the one
|
||||
/// readable copy in the home folder held 9 of the 30 groups the panel shows.
|
||||
/// System Events *is* the panel's own view, so the two cannot disagree.
|
||||
///
|
||||
/// Changing an entry still belongs to System Settings — the scriptable
|
||||
/// `delete` is unreliable across macOS versions — so every row is reported
|
||||
/// with its lock rather than with a toggle that might not hold.
|
||||
fn login_items(notes: &mut Vec<StartupNote>) -> Vec<StartupItem> {
|
||||
let script = "tell application \"System Events\"\n\
|
||||
set collected to {}\n\
|
||||
repeat with anItem in (every login item)\n\
|
||||
set theName to \"\"\n\
|
||||
try\n\
|
||||
set theName to name of anItem\n\
|
||||
end try\n\
|
||||
set thePath to \"\"\n\
|
||||
try\n\
|
||||
set thePath to (path of anItem) as text\n\
|
||||
end try\n\
|
||||
set hiddenFlag to false\n\
|
||||
try\n\
|
||||
set hiddenFlag to (hidden of anItem)\n\
|
||||
end try\n\
|
||||
set end of collected to theName & tab & thePath & tab & (hiddenFlag as text)\n\
|
||||
end repeat\n\
|
||||
set AppleScript's text item delimiters to linefeed\n\
|
||||
return collected as text\n\
|
||||
end tell";
|
||||
let output = match std::process::Command::new("osascript")
|
||||
.args(["-e", script])
|
||||
.output()
|
||||
{
|
||||
Ok(output) if output.status.success() => {
|
||||
String::from_utf8_lossy(&output.stdout).into_owned()
|
||||
}
|
||||
Ok(output) => {
|
||||
let reason = String::from_utf8_lossy(&output.stderr).trim().to_string();
|
||||
notes.push(StartupNote {
|
||||
kind: StartupNoteKind::LoginItemsUnavailable,
|
||||
subject: String::new(),
|
||||
detail: if reason.is_empty() {
|
||||
"osascript failed".into()
|
||||
} else {
|
||||
reason
|
||||
},
|
||||
});
|
||||
return Vec::new();
|
||||
}
|
||||
Err(error) => {
|
||||
notes.push(StartupNote {
|
||||
kind: StartupNoteKind::LoginItemsUnavailable,
|
||||
subject: String::new(),
|
||||
detail: error.to_string(),
|
||||
});
|
||||
return Vec::new();
|
||||
}
|
||||
};
|
||||
|
||||
parse_login_items(&output)
|
||||
}
|
||||
|
||||
/// Turn the script's report into entries. One line per item, tab-separated:
|
||||
/// name, path, and whether it launches hidden.
|
||||
pub(super) fn parse_login_items(output: &str) -> Vec<StartupItem> {
|
||||
let mut items = Vec::new();
|
||||
for found in printable_paths(&path, 8) {
|
||||
if !found.contains("/Applications/") && !found.starts_with("/Library/") {
|
||||
for line in output
|
||||
.lines()
|
||||
.map(str::trim)
|
||||
.filter(|line| !line.is_empty())
|
||||
{
|
||||
let mut fields = line.split('\t');
|
||||
let name = fields.next().unwrap_or_default().trim();
|
||||
if name.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let label = Path::new(&found)
|
||||
.file_name()
|
||||
.map(|name| name.to_string_lossy().trim_end_matches(".app").to_string())
|
||||
.unwrap_or_else(|| found.clone());
|
||||
// System Events reports `missing value` for an item whose file is
|
||||
// gone, which is the interesting case rather than a reason to drop it.
|
||||
let path = fields.next().unwrap_or_default().trim();
|
||||
let path = if path.is_empty() || path == "missing value" {
|
||||
String::new()
|
||||
} else {
|
||||
path.to_string()
|
||||
};
|
||||
let hidden = fields.next().unwrap_or_default().trim() == "true";
|
||||
let mut item = StartupItem::builder(
|
||||
found.clone(),
|
||||
label,
|
||||
format!("login-item://{name}"),
|
||||
name.to_string(),
|
||||
StartupSource::LoginItem,
|
||||
StartupScope::User,
|
||||
);
|
||||
item.command = found.clone();
|
||||
judge_program(&mut item, Some(Path::new(&found)));
|
||||
item.readonly_reason = Some("login items are managed in System Settings".into());
|
||||
// Left empty rather than filled with the name: repeating the name under
|
||||
// itself says nothing, and the page can say what is actually true.
|
||||
item.command = path.clone();
|
||||
item.hidden = hidden;
|
||||
judge_program(
|
||||
&mut item,
|
||||
(!path.is_empty()).then(|| Path::new(path.as_str())),
|
||||
);
|
||||
if hidden {
|
||||
item.risks.push(StartupRisk::HiddenEntry);
|
||||
}
|
||||
item.modifiable = false;
|
||||
item.lock = Some(StartupLock::ManagedBySystemSettings);
|
||||
items.push(item);
|
||||
}
|
||||
items
|
||||
}
|
||||
|
||||
/// Pull printable absolute paths out of a binary archive without a parser.
|
||||
fn printable_paths(path: &Path, minimum: usize) -> Vec<String> {
|
||||
let Ok(bytes) = std::fs::read(path) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let mut found = Vec::new();
|
||||
let mut current = String::new();
|
||||
for byte in bytes {
|
||||
if byte.is_ascii_graphic() || byte == b' ' {
|
||||
current.push(byte as char);
|
||||
} else {
|
||||
if current.len() >= minimum && current.starts_with('/') {
|
||||
found.push(current.clone());
|
||||
}
|
||||
current.clear();
|
||||
}
|
||||
}
|
||||
if current.len() >= minimum && current.starts_with('/') {
|
||||
found.push(current);
|
||||
}
|
||||
found.sort();
|
||||
found.dedup();
|
||||
found
|
||||
}
|
||||
|
||||
pub fn set_enabled(id: &str, enabled: bool) -> Result<StartupItem, String> {
|
||||
let current = inventory();
|
||||
let item = current
|
||||
.find(id)
|
||||
.ok_or_else(|| "That startup item is no longer there.".to_string())?;
|
||||
if !item.modifiable {
|
||||
return Err(item
|
||||
.readonly_reason
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Squid cannot change this item.".into()));
|
||||
return Err(LOCK_REFUSAL.to_string());
|
||||
}
|
||||
let path = PathBuf::from(id);
|
||||
let to = if enabled {
|
||||
|
|
@ -680,6 +1273,54 @@ mod tests {
|
|||
path
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_login_item_report_becomes_entries_that_cannot_be_touched() {
|
||||
// The shape System Events answers with: name, path, hidden. Nothing about a
|
||||
// real machine is assumed, so the three rows are a bundle that is there, one
|
||||
// that is gone, and the `missing value` an item whose file vanished is
|
||||
// reported as. Dropping the last two would hide the entries worth seeing.
|
||||
let f = fixture("loginitems");
|
||||
let present = f.home.join("Keeper.app");
|
||||
std::fs::create_dir_all(&present).expect("bundle");
|
||||
let gone = f.home.join("Uninstalled.app");
|
||||
let report = format!(
|
||||
"Keeper\t{}\tfalse\nUninstalled\t{}\tfalse\nDoubao\tmissing value\ttrue\n",
|
||||
present.display(),
|
||||
gone.display()
|
||||
);
|
||||
|
||||
let mut items = macos::parse_login_items(&report);
|
||||
assert_eq!(items.len(), 3);
|
||||
// Which list an entry belongs to is settled once, over the whole inventory,
|
||||
// by the same step the real inventory runs.
|
||||
for item in &mut items {
|
||||
categorise(item);
|
||||
}
|
||||
|
||||
for item in &items {
|
||||
assert_eq!(item.source, StartupSource::LoginItem);
|
||||
assert_eq!(item.scope, StartupScope::User);
|
||||
assert_eq!(item.category, StartupCategory::OpenAtLogin);
|
||||
assert!(!item.modifiable, "macOS owns this list");
|
||||
assert_eq!(item.lock, Some(StartupLock::ManagedBySystemSettings));
|
||||
assert_eq!(item.id, format!("login-item://{}", item.name));
|
||||
}
|
||||
|
||||
assert_eq!(items[0].program.as_deref(), Some(present.as_path()));
|
||||
assert!(
|
||||
items[1].risks.contains(&StartupRisk::MissingTarget),
|
||||
"an entry pointing at nothing says so rather than disappearing"
|
||||
);
|
||||
|
||||
let vanished = &items[2];
|
||||
assert!(
|
||||
vanished.command.is_empty(),
|
||||
"a name is not a path, and repeating one under the other says nothing"
|
||||
);
|
||||
assert!(vanished.hidden);
|
||||
assert!(vanished.risks.contains(&StartupRisk::HiddenEntry));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_user_agent_is_listed_with_the_program_it_runs() {
|
||||
let f = fixture("listed");
|
||||
|
|
@ -860,8 +1501,7 @@ mod windows {
|
|||
program_of_command(&command).as_deref().map(Path::new),
|
||||
);
|
||||
if scope == StartupScope::System {
|
||||
item.readonly_reason =
|
||||
Some("requires an administrator authorisation".into());
|
||||
item.lock = Some(StartupLock::NeedsAuthorisation);
|
||||
} else {
|
||||
item.modifiable = true;
|
||||
}
|
||||
|
|
@ -903,11 +1543,11 @@ mod windows {
|
|||
item.modified_ms = modified_ms(&path);
|
||||
judge_program(&mut item, Some(&path));
|
||||
if scope == StartupScope::System {
|
||||
item.readonly_reason = Some("requires an administrator authorisation".into());
|
||||
item.lock = Some(StartupLock::NeedsAuthorisation);
|
||||
} else {
|
||||
item.modifiable = crate::is_user_writable(&folder);
|
||||
if !item.modifiable {
|
||||
item.readonly_reason = Some("this folder is not writable".into());
|
||||
item.lock = Some(StartupLock::NotWritable);
|
||||
}
|
||||
}
|
||||
out.items.push(item);
|
||||
|
|
@ -917,7 +1557,7 @@ mod windows {
|
|||
out.items.extend(parked_entries());
|
||||
out.items.extend(scheduled_tasks());
|
||||
out.items.extend(services());
|
||||
sort_items(&mut out.items);
|
||||
finish(&mut out.items);
|
||||
out
|
||||
}
|
||||
|
||||
|
|
@ -978,7 +1618,7 @@ mod windows {
|
|||
);
|
||||
item.modifiable = hive_name == "HKCU";
|
||||
if !item.modifiable {
|
||||
item.readonly_reason = Some("requires an administrator authorisation".into());
|
||||
item.lock = Some(StartupLock::NeedsAuthorisation);
|
||||
}
|
||||
items.push(item);
|
||||
}
|
||||
|
|
@ -1058,7 +1698,7 @@ mod windows {
|
|||
if item.system_vendor {
|
||||
item.risks.clear();
|
||||
}
|
||||
item.readonly_reason = Some("scheduled tasks are read-only in this release".into());
|
||||
item.lock = Some(StartupLock::NotManaged);
|
||||
items.push(item);
|
||||
}
|
||||
items
|
||||
|
|
@ -1152,7 +1792,7 @@ mod windows {
|
|||
if item.system_vendor {
|
||||
item.risks.clear();
|
||||
}
|
||||
item.readonly_reason = Some("services are read-only in this release".into());
|
||||
item.lock = Some(StartupLock::NotManaged);
|
||||
items.push(item);
|
||||
}
|
||||
items
|
||||
|
|
@ -1180,10 +1820,7 @@ mod windows {
|
|||
.cloned()
|
||||
.ok_or_else(|| "That startup item is no longer there.".to_string())?;
|
||||
if !item.modifiable {
|
||||
return Err(item
|
||||
.readonly_reason
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Squid cannot change this item.".into()));
|
||||
return Err(LOCK_REFUSAL.to_string());
|
||||
}
|
||||
match item.source {
|
||||
StartupSource::RegistryRun => set_registry_enabled(&item, enabled),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use std::path::Path;
|
|||
|
||||
/// What the signature says about one file.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Trust {
|
||||
/// A signature exists and the operating system considers it intact.
|
||||
pub signed: bool,
|
||||
|
|
@ -62,13 +63,20 @@ pub fn assess(path: &Path) -> Trust {
|
|||
// into an answer instead of a cached guess.
|
||||
return assess_uncached(path);
|
||||
};
|
||||
if let Some(found) = cache()
|
||||
.lock()
|
||||
.unwrap_or_else(|poisoned| poisoned.into_inner())
|
||||
.get(&key)
|
||||
.cloned()
|
||||
{
|
||||
return found;
|
||||
}
|
||||
// Asked with no lock held: the question costs a subprocess, so holding the
|
||||
// cache across it would make every bulk caller take these one at a time.
|
||||
let trust = assess_uncached(path);
|
||||
let mut cache = cache()
|
||||
.lock()
|
||||
.unwrap_or_else(|poisoned| poisoned.into_inner());
|
||||
if let Some(found) = cache.get(&key) {
|
||||
return found.clone();
|
||||
}
|
||||
let trust = assess_uncached(path);
|
||||
// Bounded, because a utility that grows its own footprint to answer a
|
||||
// display question is its own kind of junk. Half is dropped rather than all,
|
||||
// so a table that is still on screen keeps the answers it is showing.
|
||||
|
|
@ -318,41 +326,47 @@ fn pe_has_certificate_at(path: &Path) -> Option<bool> {
|
|||
|
||||
/// Cheap gate for a table with hundreds of rows: only Mach-O and PE files can
|
||||
/// carry a signature, so everything else is answered without a subprocess.
|
||||
///
|
||||
/// The header decides, not the name. A macOS privileged helper is called
|
||||
/// `us.zoom.ZoomDaemon` and a Windows one `com.microsoft.autoupdate.helper`, where
|
||||
/// the last dot is part of the name rather than an extension; judging by extension
|
||||
/// never asked about a signed helper whose name happens to contain a dot. Reading
|
||||
/// eight bytes is close to free next to the subprocess being avoided, and it is the
|
||||
/// same question the signature actually answers.
|
||||
pub fn might_be_executable(path: &Path) -> bool {
|
||||
if path.is_dir() {
|
||||
return false;
|
||||
}
|
||||
if path.extension().is_some() {
|
||||
const SIGNED_KINDS: [&str; 9] = [
|
||||
"app",
|
||||
"framework",
|
||||
"bundle",
|
||||
"xpc",
|
||||
"dylib",
|
||||
"so",
|
||||
"exe",
|
||||
"dll",
|
||||
"sys",
|
||||
];
|
||||
let ext = path
|
||||
.extension()
|
||||
/// Bundles are signed as a unit, so the directory itself is the question.
|
||||
const BUNDLES: [&str; 4] = ["app", "framework", "bundle", "xpc"];
|
||||
|
||||
let extension = || {
|
||||
path.extension()
|
||||
.map(|ext| ext.to_string_lossy().to_lowercase())
|
||||
.unwrap_or_default();
|
||||
return SIGNED_KINDS.contains(&ext.as_str()) || ext.is_empty();
|
||||
.unwrap_or_default()
|
||||
};
|
||||
if path.is_dir() {
|
||||
return BUNDLES.contains(&extension().as_str());
|
||||
}
|
||||
match header(path) {
|
||||
Some(head) => header_is_executable(&head),
|
||||
// Nothing to read: an executable the current user may run but not open is
|
||||
// common among root-owned helpers, and `codesign` may still answer for it.
|
||||
None => {
|
||||
BUNDLES.contains(&extension().as_str())
|
||||
|| ["dylib", "so", "exe", "dll", "sys"].contains(&extension().as_str())
|
||||
|| extension().is_empty()
|
||||
}
|
||||
}
|
||||
// Extension-less binaries are the norm on macOS, so the header decides.
|
||||
header_is_executable(path)
|
||||
}
|
||||
|
||||
fn header_is_executable(path: &Path) -> bool {
|
||||
/// The first eight bytes, or `None` when the file cannot be opened.
|
||||
fn header(path: &Path) -> Option<[u8; 8]> {
|
||||
use std::io::Read;
|
||||
let Ok(mut file) = std::fs::File::open(path) else {
|
||||
return false;
|
||||
};
|
||||
let mut file = std::fs::File::open(path).ok()?;
|
||||
let mut head = [0_u8; 8];
|
||||
let Ok(_) = file.read(&mut head) else {
|
||||
return false;
|
||||
};
|
||||
file.read_exact(&mut head).ok()?;
|
||||
Some(head)
|
||||
}
|
||||
|
||||
fn header_is_executable(head: &[u8; 8]) -> bool {
|
||||
// Mach-O 32/64, fat binary, and their byte-swapped forms.
|
||||
const MACHOS: [[u8; 4]; 6] = [
|
||||
[0xcf, 0xfa, 0xed, 0xfe],
|
||||
|
|
|
|||
|
|
@ -90,6 +90,26 @@ fn uninstall_program(uninstall_string: &str) -> Option<PathBuf> {
|
|||
candidate.exists().then_some(candidate)
|
||||
}
|
||||
|
||||
/// `DisplayIcon` is a path with an optional icon index, usually quoted:
|
||||
/// `"C:\Program Files\App\app.exe",0`. The file manager accepts the path
|
||||
/// without the index and returns the application's default icon.
|
||||
fn display_icon_path(value: Option<String>) -> Option<PathBuf> {
|
||||
let raw = value?.trim().to_string();
|
||||
let unquoted = raw
|
||||
.strip_prefix('"')
|
||||
.and_then(|value| value.split('"').next())
|
||||
.unwrap_or(&raw)
|
||||
.trim();
|
||||
let without_index = unquoted
|
||||
.rsplit_once(',')
|
||||
.filter(|(_, index)| index.trim().parse::<i32>().is_ok())
|
||||
.map(|(path, _)| path)
|
||||
.unwrap_or(unquoted)
|
||||
.trim();
|
||||
let path = PathBuf::from(without_index);
|
||||
path.exists().then_some(path)
|
||||
}
|
||||
|
||||
impl Platform for Windows {
|
||||
fn id(&self) -> PlatformId {
|
||||
PlatformId::Windows
|
||||
|
|
@ -138,6 +158,27 @@ impl Platform for Windows {
|
|||
None => String::new(),
|
||||
}
|
||||
}
|
||||
fn graphics_adapter(&self) -> String {
|
||||
let Ok(class) = RegKey::predef(HKEY_LOCAL_MACHINE).open_subkey_with_flags(
|
||||
r"SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}",
|
||||
KEY_READ,
|
||||
) else {
|
||||
return String::new();
|
||||
};
|
||||
let mut adapters = Vec::new();
|
||||
for name in class.enum_keys().flatten() {
|
||||
let Ok(adapter) = class.open_subkey_with_flags(&name, KEY_READ) else {
|
||||
continue;
|
||||
};
|
||||
let Some(description) = str_value(&adapter, "DriverDesc") else {
|
||||
continue;
|
||||
};
|
||||
if !adapters.contains(&description) {
|
||||
adapters.push(description);
|
||||
}
|
||||
}
|
||||
adapters.join(" · ")
|
||||
}
|
||||
fn app_sources(&self) -> Vec<AppSource> {
|
||||
let env = |key: &str| std::env::var_os(key).map(PathBuf::from);
|
||||
let mut dirs: Vec<PathBuf> = vec![
|
||||
|
|
@ -207,6 +248,7 @@ impl Platform for Windows {
|
|||
name: display_name,
|
||||
bundle_id: None,
|
||||
path,
|
||||
icon_source: display_icon_path(str_value(&key, "DisplayIcon")),
|
||||
version: str_value(&key, "DisplayVersion"),
|
||||
size: Bytes::ZERO,
|
||||
source: source.into(),
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ fn macos_battery() -> Option<Battery> {
|
|||
battery.cycle_count = cycles;
|
||||
battery.temperature_c = temp;
|
||||
}
|
||||
if let Some(health) = maximum_capacity() {
|
||||
battery.health_percent = Some(health);
|
||||
}
|
||||
Some(battery)
|
||||
}
|
||||
|
||||
|
|
@ -129,19 +132,77 @@ fn battery_details() -> Option<(Option<u8>, Option<u32>, Option<f32>)> {
|
|||
.ok()
|
||||
.filter(|output| output.status.success())?;
|
||||
let text = String::from_utf8_lossy(&output.stdout);
|
||||
let design = find_number(&text, "DesignCapacity");
|
||||
let max = find_number(&text, "MaxCapacity");
|
||||
let health = match (design, max) {
|
||||
(Some(design), Some(max)) if design > 0 => {
|
||||
Some(((max as f64 / design as f64) * 100.0).round() as u8)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
let health = health_from_ioreg(&text);
|
||||
let cycles = find_number(&text, "CycleCount").map(|value| value as u32);
|
||||
let temp = find_number(&text, "Temperature").map(|tenths| tenths as f32 / 100.0);
|
||||
Some((health, cycles, temp))
|
||||
}
|
||||
|
||||
/// macOS already publishes the same figure it shows in System Settings. Read it
|
||||
/// once every ten minutes rather than deriving it from `MaxCapacity`, which on
|
||||
/// Apple Silicon is a percentage rather than a mAh reading.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn maximum_capacity() -> Option<u8> {
|
||||
use std::sync::Mutex;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
static CACHE: Mutex<Option<(Instant, Option<u8>)>> = Mutex::new(None);
|
||||
let stale = CACHE
|
||||
.lock()
|
||||
.ok()
|
||||
.and_then(|guard| *guard)
|
||||
.map(|(at, _)| at.elapsed() > Duration::from_secs(600))
|
||||
.unwrap_or(true);
|
||||
if !stale {
|
||||
return CACHE
|
||||
.lock()
|
||||
.ok()
|
||||
.and_then(|guard| guard.and_then(|(_, health)| health));
|
||||
}
|
||||
let output = std::process::Command::new("/usr/sbin/system_profiler")
|
||||
.arg("SPPowerDataType")
|
||||
.output()
|
||||
.ok()
|
||||
.filter(|output| output.status.success());
|
||||
let health = output
|
||||
.as_ref()
|
||||
.and_then(|output| parse_maximum_capacity(&String::from_utf8_lossy(&output.stdout)));
|
||||
if let Ok(mut guard) = CACHE.lock() {
|
||||
*guard = Some((Instant::now(), health));
|
||||
}
|
||||
health
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn parse_maximum_capacity(text: &str) -> Option<u8> {
|
||||
let line = text
|
||||
.lines()
|
||||
.find(|line| line.trim_start().starts_with("Maximum Capacity:"))?;
|
||||
let value = line.split_once(':')?.1.trim().trim_end_matches('%').trim();
|
||||
value
|
||||
.parse::<u8>()
|
||||
.ok()
|
||||
.filter(|value| (1..=100).contains(value))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn health_from_ioreg(text: &str) -> Option<u8> {
|
||||
let design = find_number(text, "DesignCapacity")?;
|
||||
if design == 0 {
|
||||
return None;
|
||||
}
|
||||
// `MaxCapacity` is a percentage on Apple Silicon. The raw/nominal fields are
|
||||
// the actual mAh readings and are the only values that can form a ratio.
|
||||
let maximum = find_number(text, "AppleRawMaxCapacity")
|
||||
.filter(|value| *value > 0)
|
||||
.or_else(|| find_number(text, "NominalChargeCapacity").filter(|value| *value > 0))?;
|
||||
Some(
|
||||
((maximum as f64 / design as f64) * 100.0)
|
||||
.round()
|
||||
.min(100.0) as u8,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn find_number(text: &str, key: &str) -> Option<u64> {
|
||||
let (_, after) = text.split_once(&format!("\"{key}\""))?;
|
||||
|
|
@ -228,6 +289,21 @@ mod tests {
|
|||
assert!(parse_pmset(text).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "macos")]
|
||||
fn maximum_capacity_is_read_from_the_os_health_figure() {
|
||||
let text = " Health Information:\n Cycle Count: 516\n Maximum Capacity: 86%\n";
|
||||
assert_eq!(parse_maximum_capacity(text), Some(86));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "macos")]
|
||||
fn apple_silicon_health_ignores_the_percentage_in_max_capacity() {
|
||||
let text =
|
||||
"\"DesignCapacity\" = 6075\n\"MaxCapacity\" = 100\n\"AppleRawMaxCapacity\" = 4911\n";
|
||||
assert_eq!(health_from_ioreg(text), Some(81));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
fn hhmm_parsing() {
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ pub struct HostInfo {
|
|||
pub os_name: String,
|
||||
pub os_version: String,
|
||||
pub hardware: String,
|
||||
pub gpu: String,
|
||||
pub hostname: String,
|
||||
pub user: String,
|
||||
pub arch: String,
|
||||
|
|
@ -119,6 +120,7 @@ impl HostInfo {
|
|||
os_name: platform.display_name(),
|
||||
os_version: platform.os_version(),
|
||||
hardware: platform.hardware_model(),
|
||||
gpu: platform.graphics_adapter(),
|
||||
hostname: hostname(),
|
||||
user: std::env::var("USER")
|
||||
.or_else(|_| std::env::var("USERNAME"))
|
||||
|
|
@ -428,35 +430,23 @@ pub struct AppUsage {
|
|||
}
|
||||
|
||||
fn cpu_stats(system: &System) -> CpuStats {
|
||||
// sysinfo puts the aggregate sample in `cpus()[0]`; the tail is one entry
|
||||
// per logical core.
|
||||
let all = system.cpus();
|
||||
let (aggregate, cores) = all
|
||||
.split_first()
|
||||
.map(|(head, tail)| (Some(head), tail))
|
||||
.unwrap_or((None, &[]));
|
||||
let per_core: Vec<f32> = cores
|
||||
let per_core: Vec<f32> = all
|
||||
.iter()
|
||||
.map(|cpu| cpu.cpu_usage().clamp(0.0, 100.0))
|
||||
.collect();
|
||||
let load = System::load_average();
|
||||
let brand = aggregate
|
||||
.or_else(|| cores.first())
|
||||
let first = all.first();
|
||||
let brand = first
|
||||
.map(|cpu| cpu.brand().trim().to_string())
|
||||
.unwrap_or_else(|| std::env::consts::ARCH.to_string());
|
||||
let base_frequency_ghz = aggregate
|
||||
.or_else(|| cores.first())
|
||||
let base_frequency_ghz = first
|
||||
.map(|cpu| cpu.frequency() as f64 / 1_000.0)
|
||||
.unwrap_or(0.0);
|
||||
let total = aggregate
|
||||
.map(|cpu| cpu.cpu_usage())
|
||||
.unwrap_or_else(|| system.global_cpu_usage())
|
||||
.clamp(0.0, 100.0);
|
||||
let logical_cores = if per_core.is_empty() {
|
||||
1
|
||||
} else {
|
||||
per_core.len()
|
||||
};
|
||||
// sysinfo keeps the aggregate independently of the per-core list. Reading
|
||||
// `cpus()[0]` as the total also dropped one core from every count.
|
||||
let total = system.global_cpu_usage().clamp(0.0, 100.0);
|
||||
let logical_cores = per_core.len().max(1);
|
||||
let physical = detect_physical_cores().unwrap_or_else(|| logical_cores.div_ceil(2));
|
||||
CpuStats {
|
||||
total,
|
||||
|
|
@ -553,30 +543,13 @@ fn vm_stat_details() -> Option<(Bytes, Bytes)> {
|
|||
let now = now_ms();
|
||||
let previous = LAST.swap(now, Ordering::Relaxed);
|
||||
static CACHE: std::sync::Mutex<Option<(Bytes, Bytes)>> = std::sync::Mutex::new(None);
|
||||
if now - previous > 5_000 || previous == 0 {
|
||||
let page_size = 4096u64;
|
||||
if now.saturating_sub(previous) > 5_000 || previous == 0 {
|
||||
let output = std::process::Command::new("/usr/bin/vm_stat")
|
||||
.output()
|
||||
.ok()
|
||||
.filter(|out| out.status.success())?;
|
||||
let text = String::from_utf8_lossy(&output.stdout);
|
||||
let mut compressor_pages = 0u64;
|
||||
let mut wired_pages = 0u64;
|
||||
for line in text.lines() {
|
||||
let mut parts = line.split(':');
|
||||
let key = parts.next()?.trim();
|
||||
let value = parts.next()?.trim().trim_end_matches('.').replace(' ', "");
|
||||
let pages: u64 = value.parse().unwrap_or(0);
|
||||
match key {
|
||||
"Occupied by compressor" => compressor_pages = pages,
|
||||
"Wired Pages" => wired_pages = pages,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let value = (
|
||||
Bytes(compressor_pages * page_size),
|
||||
Bytes(wired_pages * page_size),
|
||||
);
|
||||
let value = parse_vm_stat(&text)?;
|
||||
if let Ok(mut guard) = CACHE.lock() {
|
||||
*guard = Some(value);
|
||||
}
|
||||
|
|
@ -586,6 +559,42 @@ fn vm_stat_details() -> Option<(Bytes, Bytes)> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Apple Silicon uses 16 KiB pages, Intel Macs use 4 KiB. The header states the
|
||||
/// size, and the two fields squid reports use different labels than older
|
||||
/// versions of `vm_stat`; both facts made the previous parser return zero.
|
||||
fn parse_vm_stat(text: &str) -> Option<(Bytes, Bytes)> {
|
||||
let header = text.lines().next()?;
|
||||
let (_, after_size) = header.split_once("page size of ")?;
|
||||
let page_size: u64 = after_size
|
||||
.chars()
|
||||
.take_while(|character| character.is_ascii_digit())
|
||||
.collect::<String>()
|
||||
.parse()
|
||||
.ok()?;
|
||||
let mut compressor_pages = 0u64;
|
||||
let mut wired_pages = 0u64;
|
||||
for line in text.lines().skip(1) {
|
||||
let Some((key, value)) = line.split_once(':') else {
|
||||
continue;
|
||||
};
|
||||
let pages: u64 = value
|
||||
.trim()
|
||||
.trim_end_matches('.')
|
||||
.replace(' ', "")
|
||||
.parse()
|
||||
.unwrap_or(0);
|
||||
match key.trim().trim_matches('"') {
|
||||
"Pages occupied by compressor" => compressor_pages = pages,
|
||||
"Pages wired down" => wired_pages = pages,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Some((
|
||||
Bytes(compressor_pages.saturating_mul(page_size)),
|
||||
Bytes(wired_pages.saturating_mul(page_size)),
|
||||
))
|
||||
}
|
||||
|
||||
fn net_rates(networks: &Networks, seconds: f64) -> NetRate {
|
||||
let mut rx = 0u64;
|
||||
let mut tx = 0u64;
|
||||
|
|
@ -858,6 +867,18 @@ mod tests {
|
|||
assert_eq!(stats.percent_used(), 100);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vm_stat_uses_the_reported_page_size_and_fields() {
|
||||
let text = "\
|
||||
Mach Virtual Memory Statistics: (page size of 16384 bytes)\n\
|
||||
Pages free: 96476.\n\
|
||||
Pages wired down: 122963.\n\
|
||||
Pages occupied by compressor: 151882.\n";
|
||||
let (compressed, wired) = parse_vm_stat(text).expect("vm_stat");
|
||||
assert_eq!(wired, Bytes(122_963 * 16_384));
|
||||
assert_eq!(compressed, Bytes(151_882 * 16_384));
|
||||
}
|
||||
|
||||
/// The feature, end to end: a sample that still describes its pid stops it.
|
||||
#[test]
|
||||
fn a_process_stops_when_its_sample_asks_it_to() {
|
||||
|
|
|
|||
|
|
@ -2593,6 +2593,7 @@ mod tests {
|
|||
name: "SquidTest".to_string(),
|
||||
bundle_id: Some("com.nexsquid.test".to_string()),
|
||||
path: bundle.clone(),
|
||||
icon_source: None,
|
||||
version: Some("1.0".to_string()),
|
||||
size: Bytes(0),
|
||||
source: "test".to_string(),
|
||||
|
|
@ -2686,6 +2687,7 @@ mod tests {
|
|||
name: "SquidTest".into(),
|
||||
bundle_id: Some("com.example.SquidTest".into()),
|
||||
path: path.clone(),
|
||||
icon_source: None,
|
||||
version: None,
|
||||
size: Bytes(0),
|
||||
source: "test".into(),
|
||||
|
|
|
|||
|
|
@ -2044,6 +2044,7 @@ mod tests {
|
|||
name: "Demo".into(),
|
||||
bundle_id: Some("com.example.Demo".into()),
|
||||
path: "/Applications/Demo.app".into(),
|
||||
icon_source: None,
|
||||
version: Some("1.0".into()),
|
||||
size: Bytes(1 << 20),
|
||||
source: "Applications".into(),
|
||||
|
|
@ -2602,6 +2603,7 @@ mod tests {
|
|||
.map(|index| AppInfo {
|
||||
name: format!("Sq{index:02}"),
|
||||
path: format!("/Applications/Sq{index:02}.app").into(),
|
||||
icon_source: None,
|
||||
source: "Applications".into(),
|
||||
size: Bytes(1 << 20),
|
||||
..Default::default()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings
|
|||
|
||||
| Screen | What it does |
|
||||
| --- | --- |
|
||||
| Computer overview | Security status strip, cleanup scan entry, disk health, cleanup result categories and live CPU/memory/storage summaries |
|
||||
| Overview | Security status strip, cleanup scan entry, disk health, cleanup result categories and live CPU/memory/storage summaries |
|
||||
| Daily cleanup | Runs the normal cleanup rule set, groups results by category, supports per-item and per-category selection, Trash or permanent deletion, then offers undo through History |
|
||||
| Uninstall apps | Reads installed apps, builds an app-specific removal plan, shows leftover paths and warnings, then uninstalls selected items |
|
||||
| Deep Clean | Searches chosen project roots for regenerable build artefacts with Git and file-age protections |
|
||||
|
|
|
|||
347
docs/ROADMAP.md
347
docs/ROADMAP.md
|
|
@ -1,6 +1,6 @@
|
|||
# Squid 安全与管理功能路线图
|
||||
|
||||
状态:P0–P3 已实现(0.1.6);P4 未开始
|
||||
状态:P0–P3 已实现(0.1.7),并按第 13、14 节重做了列表、下拉组件、启动项页与界面文案;P4 未开始
|
||||
更新时间:2026-11-07
|
||||
适用平台:macOS 12+、Windows 10/11(x64;ARM64 通过兼容层运行)
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ CleanMyMac 式的常驻实时防病毒产品,也不是 XProtect / Defender 的
|
|||
|
||||
```text
|
||||
维护 Maintenance
|
||||
电脑概览 Computer overview
|
||||
概览 Overview
|
||||
日常清理 Daily cleanup
|
||||
应用卸载 Uninstall apps
|
||||
深度清理 Deep Clean
|
||||
|
|
@ -127,7 +127,7 @@ CleanMyMac 式的常驻实时防病毒产品,也不是 XProtect / Defender 的
|
|||
|
||||
| 序号 | Page ID | 中文 | English | 快捷键 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 1 | `overview` | 电脑概览 | Computer overview | `Cmd/Ctrl+1` |
|
||||
| 1 | `overview` | 概览 | Overview | `Cmd/Ctrl+1` |
|
||||
| 2 | `cleanup` | 日常清理 | Daily cleanup | `Cmd/Ctrl+2` |
|
||||
| 3 | `applications` | 应用卸载 | Uninstall apps | `Cmd/Ctrl+3` |
|
||||
| 4 | `purge` | 深度清理 | Deep Clean | `Cmd/Ctrl+4` |
|
||||
|
|
@ -177,7 +177,7 @@ CleanMyMac 式的常驻实时防病毒产品,也不是 XProtect / Defender 的
|
|||
|
||||
| 页面 | 主要职责 | 主要动作 | 不承载 |
|
||||
| --- | --- | --- | --- |
|
||||
| 电脑概览 | 汇总电脑状态、清理结果和安全状态 | 开始清理扫描、开始安全扫描、跳转 | 复杂发现处置、启动项编辑 |
|
||||
| 概览 | 汇总电脑状态、清理结果和安全状态 | 开始清理扫描、开始安全扫描、跳转 | 复杂发现处置、启动项编辑 |
|
||||
| 日常清理 | 按规则扫描并删除可重建缓存和垃圾 | 选择、删除、撤销入口 | 安全发现和隔离 |
|
||||
| 应用卸载 | 读取应用、生成卸载计划 | 卸载 App 与残留 | 安全扫描、启动项管理 |
|
||||
| 深度清理 | 查找项目构建产物和旧安装包 | 选择、删除 | 安全扫描 |
|
||||
|
|
@ -188,7 +188,7 @@ CleanMyMac 式的常驻实时防病毒产品,也不是 XProtect / Defender 的
|
|||
| 历史记录 | 清理/卸载账本与恢复 | 查看会话、撤销 | 安全事件审计 |
|
||||
| 设置 | 全局偏好、权限、排除项、更新 | 修改设置、打开系统设置 | 扫描结果和处置 |
|
||||
|
||||
### 4.2 电脑概览
|
||||
### 4.2 概览
|
||||
|
||||
职责:给用户一个“现在该做什么”的入口,不在这里完成复杂处置。
|
||||
|
||||
|
|
@ -262,30 +262,41 @@ CleanMyMac 式的常驻实时防病毒产品,也不是 XProtect / Defender 的
|
|||
|
||||
职责:展示并管理登录/启动时自动运行的持久化入口,解释每个条目的来源和风险。
|
||||
|
||||
页面区块:
|
||||
页面按操作系统自己的分法组织,而不是按实现文件的分法。macOS 把它拆成「登录时打开」
|
||||
和「允许在后台」两张列表,并把每个条目归到安装它的应用下面;0.1.6 的第一版把两者拍平成
|
||||
一条 873 行的 plist 标签列表,结果既看不到系统设置里那两三项「登录时打开」,也读不懂剩下
|
||||
八百项。现在:
|
||||
|
||||
1. 页头摘要:
|
||||
- 用户级数量、系统级数量、已停用数量、需要管理员授权的数量。
|
||||
- 不显示“优化分数”。
|
||||
2. 过滤与搜索:
|
||||
- 范围:全部 / 当前用户 / 系统。
|
||||
- 来源:LaunchAgent、LaunchDaemon、登录项、Run/RunOnce、启动文件夹、计划任务、服务。
|
||||
- 状态:已启用 / 已停用。
|
||||
- 风险:全部 / 需要注意 / 仅系统项。
|
||||
- 默认隐藏 Apple / Microsoft 系统项,可开启“显示系统项”。
|
||||
3. 列表:
|
||||
- 名称、来源、范围、发布者/签名、目标路径、状态、风险标签。
|
||||
- 风险标签:目标不存在、路径在临时目录、未签名、命令包含脚本解释器、近期创建、隐藏任务。
|
||||
- 风险标签只表示“需要检查”,不等于恶意。
|
||||
4. 详情抽屉:
|
||||
- 完整命令、参数、工作目录、父 App、签名状态、文件哈希、修改时间。
|
||||
- 关联进程:显示 PID、CPU、内存,跳转实时监控 → 进程。
|
||||
- 操作:停用/启用、在 Finder/资源管理器中显示、扫描该文件、打开系统设置。
|
||||
5. 修改确认:
|
||||
- 展示将被移动/修改的具体 plist、注册表值或任务。
|
||||
- 说明影响和恢复方式。
|
||||
- 系统级项目要求一次系统授权。
|
||||
- 操作后刷新真实状态,不只更新前端缓存。
|
||||
1. 页头:一句话说明按应用分组、以及「风险标记只代表值得检查」,不显示“优化分数”。
|
||||
2. 两个页签,数字与点进去看到的条数一致:
|
||||
- **登录项**:登录时会打开界面/应用的条目。macOS 的登录项,Windows 的启动文件夹与
|
||||
Run/RunOnce。平铺不分组,组头位置放一个「打开系统设置」入口——这一列表在两个平台
|
||||
都不归 squid 写。
|
||||
- **后台程序**:不打开界面的 helper。macOS 的 LaunchAgents/LaunchDaemons、
|
||||
Windows 的计划任务与服务。按所属应用折叠,组头显示应用名、条目数、已停用数、
|
||||
值得检查数与签名状态。
|
||||
3. 过滤:范围下拉(全部 / 当前用户 / 系统)、仅看值得检查、显示系统自带条目
|
||||
(默认关闭,chip 上带着被藏起来的条数)。搜索匹配名称、命令、路径与应用名,
|
||||
搜索时所有分组自动展开。
|
||||
4. 列表行:名称、目标路径、风险标签、来源(分组视图里才显示,因为组头已经说明来源相同)、
|
||||
系统级标记;右侧是开关或只读原因。
|
||||
- 风险标签:目标不存在、路径在临时目录、无可用签名、**签名无法读取**、经由脚本解释器启动、
|
||||
近期创建、隐藏条目、位于隐藏目录。
|
||||
5. 详情抽屉:完整命令、所属应用、工作目录、可执行文件、声明位置、修改时间、签名;
|
||||
关联进程跳转实时监控,文件可以单独送去扫描。
|
||||
不可修改时,只读原因是本地化后的 `StartupLock` 枚举,不是后端拼好的英文句子。
|
||||
6. 修改确认:展示将被改名/移动的 plist、注册表值或启动文件夹条目,说明影响与恢复方式;
|
||||
操作后重新读取真实状态,不只更新前端缓存。
|
||||
|
||||
`StartupItem` 因此新增三个字段,全部由路径推导,不需要管理员权限:
|
||||
|
||||
- `category`:条目属于上面两张列表中的哪一张,由 `source` 决定。
|
||||
- `owner`:安装它的应用。macOS 先取目标路径里的 `.app` 祖先并读它的 `CFBundleDisplayName`;
|
||||
`/Library/PrivilegedHelperTools` 里的 helper 路径不携带答案,改用 launchd 标签去匹配
|
||||
**已安装应用**的 bundle id 前缀,且只有该前缀只被一个应用拥有时才认领
|
||||
(`org.wireshark.ChmodBPF` 曾经因为只比较首段而被归给 GeoGebra)。都失败时退回签名里的组织名。
|
||||
Windows 用 Authenticode 发布者,其次 Program Files 下的产品目录。
|
||||
- `lock`:不可修改的原因,枚举值,交给界面翻译。
|
||||
|
||||
首版操作范围:
|
||||
|
||||
|
|
@ -299,7 +310,7 @@ CleanMyMac 式的常驻实时防病毒产品,也不是 XProtect / Defender 的
|
|||
- macOS 全局 LaunchAgents/Daemons:一次性管理员授权,备份后停用/恢复。
|
||||
- Windows HKLM Run、系统计划任务:一次性 UAC 授权。
|
||||
- Windows 服务:保持只读,不提供启停。
|
||||
- macOS 登录项:保持只读,跳转系统设置。
|
||||
- macOS 登录项:保持只读,页面直接打开系统设置对应 pane(13.4)。
|
||||
|
||||
### 4.5 实时监控
|
||||
|
||||
|
|
@ -312,11 +323,15 @@ CleanMyMac 式的常驻实时防病毒产品,也不是 XProtect / Defender 的
|
|||
- 高占用进程标题右侧增加“查看全部进程”。
|
||||
2. **进程 / Processes**
|
||||
- 全量进程表格,按需加载,不跟随 1Hz 刷新。
|
||||
- 列:进程、PID、父进程、用户、路径、CPU、内存、启动时间、签名、关联启动项。
|
||||
- 列:进程(路径并到名称下面一行)、PID、用户、CPU、内存、启动时间、签名,
|
||||
行尾是「由启动项启动」标记与结束进程按钮。父进程只在详情抽屉里给,不占一列。
|
||||
- 搜索、排序、按应用聚合、只看当前用户、只看未签名、只看有启动项。
|
||||
- 行详情抽屉:命令行、可执行文件、哈希、签名、工作目录、启动项、父进程。
|
||||
- 操作:结束进程、停止并隔离(仅已确认恶意)、打开文件位置、复制路径、跳转启动项。
|
||||
|
||||
「只看有启动项」和那个标记读的是同一个字段。0.1.6 里那个字段从来没被赋过值,
|
||||
所以这一列和这个筛选都是 13.9 之后才真正可用的——上面这行是照实现改的,不是照愿望写的。
|
||||
|
||||
安全约束:
|
||||
|
||||
- 保留现有 PID/名称复核和关键进程保护。
|
||||
|
|
@ -452,6 +467,12 @@ CleanMyMac 式的常驻实时防病毒产品,也不是 XProtect / Defender 的
|
|||
- 系统级修改必须经过一次系统授权。
|
||||
- 操作后重新读取真实状态,不信任前端缓存。
|
||||
- 目标消失、权限变化、条目被 App 重建时,报告实际状态而不是假装成功。
|
||||
- 「无法读取签名」和「没有签名」是两件事:root 安装成 0711 的 helper 能执行、不能打开,
|
||||
`codesign` 回答 Permission denied。把它报成未签名是在指控一个其实签过名的程序。
|
||||
- 归属只写有依据的名字:路径里的 `.app`、唯一匹配的 bundle id 前缀、签名里的组织名。
|
||||
两个应用共享同一前缀时是平局,平局不写答案,条目留在未分组里。
|
||||
- 只读原因、读不到的目录、读不到的登录项都以枚举/结构体上传,由界面翻译;
|
||||
平台层不拼接句子,否则中文界面会漏出英文。
|
||||
|
||||
### 6.5 规则包
|
||||
|
||||
|
|
@ -512,10 +533,14 @@ security_exclusions
|
|||
security_update_rules
|
||||
startup_items
|
||||
startup_set_enabled
|
||||
open_startup_settings
|
||||
process_inventory
|
||||
process_detail
|
||||
```
|
||||
|
||||
`open_startup_settings` 只打开系统设置对应的 pane:登录项、计划任务和服务在两个平台
|
||||
都不归 squid 写,能给的诚实动作是送到那一页,而不是给一个未必生效的开关。
|
||||
|
||||
扫描结果、启动项清单和隔离项都由后端保存并分配 ID;前端只提交 ID。
|
||||
运行中的扫描复用 `Progress`、`CancelToken` 和现有 `ProgressReporter` 模式。
|
||||
|
||||
|
|
@ -651,6 +676,11 @@ TUI 的 Guard 面板放到后续版本,不阻塞桌面端 MVP。
|
|||
- Apple/Microsoft 系统项默认隐藏且只读。
|
||||
- 关键进程结束被拒绝并说明原因。
|
||||
- 进程详情能正确关联启动项。
|
||||
- 「登录项」页签显示的条目与系统设置「登录项与扩展 → 登录时打开」一致;
|
||||
读不到时页面说明原因,而不是显示一张空表假装「没有」。
|
||||
- 后台程序按应用分组,组名是可辨认的应用名,不是 plist 标签;归不了类的条目集中在一组,
|
||||
不被随便塞进某个应用。
|
||||
- 打开启动项页的等待时间与进程表同级,不出现「转圈几秒」。
|
||||
|
||||
### 9.4 发布
|
||||
|
||||
|
|
@ -802,6 +832,10 @@ TUI 的 Guard 面板放到后续版本,不阻塞桌面端 MVP。
|
|||
**不新增的规范也要说清楚。** 隔离行、启动项行原来各自定义了边框/圆角/背景,现在都来自
|
||||
`.item-row` 一处;改一处两个页面同时生效,这正是不开第二套规范的目的。
|
||||
|
||||
> 13.1 把这一节里的三件事改掉了:`.item-row` 的定义换成扁平分隔线、`.settings-select`
|
||||
> 变成组件 `Select`、`.stat` 删除。这一节保留原文,因为它记录的判断(复用而不是新造)
|
||||
> 依然成立,被改掉的只是它当时选中的具体 class。
|
||||
|
||||
### 12.8 6.6 的体积预算超了,并且部分是我自己造成的
|
||||
|
||||
6.6 写「安装包增加目标不超过 10 MB」。0.1.6 实测:
|
||||
|
|
@ -825,3 +859,256 @@ TUI 的 Guard 面板放到后续版本,不阻塞桌面端 MVP。
|
|||
|
||||
预算本身不改成 11 MB:超了就是超了,写在这里比改数字更有用。下一版如果要还这笔账,
|
||||
方向是二进制本身(例如等 yara-x 提供关掉 wasm 后端的选项),不是砍功能。
|
||||
|
||||
## 13. 第二轮修订:列表样式、下拉组件与启动项重做
|
||||
|
||||
0.1.6 发出去以后收到的三条反馈都成立,而且第三条最严重:启动项页把 873 个 launchd
|
||||
标签拍平成一列,用户在这页既找不到系统设置里那两三项「登录时打开」,也读不懂剩下的八百项。
|
||||
|
||||
### 13.1 列表统一成扁平分隔线,不要指示器
|
||||
|
||||
0.1.6 的两个新页面给每一行套了一张 1px 描边的圆角卡片,再用 3px 左边框当严重级别指示器。
|
||||
这一条不只是审美问题:它和旧模块根本不通约,而且同一版里自己就不统一——
|
||||
安全页/启动项页是描边圆角盒,新进程表是斑马纹,`.evidence-list li` 是实心色块,
|
||||
旧模块则从来不是这个样子。现在:
|
||||
|
||||
- `.item-row` 重新定义:`min-height: 44px`、`padding: 7px 10px`、
|
||||
`border-bottom: 1px solid var(--nex-line)`、无圆角、hover 用 `--nex-cream`,最后一行不画线。
|
||||
旧页面本来只有两种行:一种带分隔线(`.process-row` + `.process-head`),一种是圆角但
|
||||
不画边的悬浮高亮(`.cleanup-row`、`.app-row`、`.large-file-row`、`.whitelist-row`)。
|
||||
0.1.6 造的是第三种——每行一个 1px 描边圆角盒子,再加 3px 左边框,哪一种是都不像。
|
||||
新页面并入第一种:安全页和启动项页的条目是「几百行里扫一眼」的列表,
|
||||
和进程表同类;`.history-card` 那种整卡是「一次会话」的容器,不是同一件事。
|
||||
- 级别不再用边框表示。`.level-dot` 和 `.risk-chip` 删除;色调改为给
|
||||
`.item-copy strong` 着色(`is-danger` / `is-warning`),级别文字仍由 `.status-chip` 承担。
|
||||
- 同一版里剩下的两处也并入分隔线:`.evidence-list li`(原来是实心色块圆角)、
|
||||
`.ptable.pt-rows li` 与 `.process-group-head`(原来是斑马纹圆角)。
|
||||
改完之后**安全页和启动项页**与旧模块里带分隔线的那种行完全一致。旧模块本身仍有两种行
|
||||
(带分隔线的 `.process-row`,和不画边、圆角高亮的 `.cleanup-row`/`.app-row`/`.large-file-row`/
|
||||
`.whitelist-row`),这一轮没有去统一它们:用户要的是新模块别再自己发明第三种,
|
||||
而不是把八个旧页面重排一遍。
|
||||
- 我这次新增的类只有 12 个(`group-*` 5 个、`select*` 3 个、`is-{start,end,current,nested}`),
|
||||
同时删掉 9 个(`level-dot`、`risk-chip`、`settings-select`、`startup-batch*` 3 个、
|
||||
`startup-meta`、`stat`、`stat-grid`)。启动项页原来的五块 `.stat` 摘要删除,
|
||||
数字回到页签和筛选 chip 上,和 12.7 的结论一致。
|
||||
|
||||
### 13.2 下拉组件不用原生控件
|
||||
|
||||
`<select>` 的弹出层由操作系统绘制,字号、配色、圆角都不受应用控制,放进这套界面里
|
||||
像另一个程序。`ui.tsx` 增加组件 `Select`(触发按钮 + `.panel` 同款浮层 + `Check` 标记当前项,
|
||||
支持指针外点、Esc、↑↓、Enter),`.settings-select` 删除。三处原生 `<select>` 全部换掉:
|
||||
安全设置的扫描计划、设置页的历史保留条数、启动项页的范围筛选。`Select` 的触发框沿用原来
|
||||
的 86×31 与 8px 圆角,所以替换不会挪动任何布局。全应用现在没有原生下拉。
|
||||
|
||||
启动项页的「来源」下拉本来有七个选项,重做之后被两件事取代:页签表示 `category`,
|
||||
分组标题表示所属应用。少一个控件比把控件做漂亮更有用。
|
||||
|
||||
### 13.3 启动项按操作系统的分法重排
|
||||
|
||||
`StartupItem` 增加三个字段,都由路径推导,不需要管理员权限:
|
||||
|
||||
- `category`:`open-at-login`(macOS 登录项、Windows 启动文件夹与 Run/RunOnce)
|
||||
或 `background`(LaunchAgent/Daemon、计划任务、服务)。这就是页签的两栏,
|
||||
名字直接沿用系统设置「登录项与扩展」的分区。
|
||||
- `owner`:安装该条目的应用。macOS 先看目标路径的 `.app` 祖先并读 `CFBundleDisplayName`;
|
||||
`/Library/PrivilegedHelperTools` 里的 helper 路径不带答案,改用 launchd 标签去匹配
|
||||
**已安装应用**的 bundle id 前缀,且只有该前缀只被一个应用拥有时才认领;都失败时退回
|
||||
签名里的组织名。Windows 用 Authenticode 发布者,其次 Program Files 下的产品目录。
|
||||
- `lock`:不可修改的原因,是枚举而不是句子,由界面翻译。12.6 已经为
|
||||
`schedule_note` 犯过同样的错——后端拼好的英文会漏进中文界面。
|
||||
|
||||
页面结构:页签(登录项 / 后台程序,数字与点进去看到的条数一致)→ 搜索 + 范围 +
|
||||
「值得检查」+「系统自带条目」四个筛选 → 登录项平铺、后台按应用折叠。
|
||||
系统自带条目仍然默认隐藏,chip 上直接写明被藏起来的是多少条(本机 845 条)——
|
||||
「默认帮你藏了 845 条」必须让人看见,否则「全部」这个词在这页是假的。
|
||||
|
||||
**本机实测**(M1 Pro,macOS 15.7.1):874 条,其中 Apple 845 条;非系统条目
|
||||
归成 19 组,例如 Google Chrome 4 条、Docker 2 条、Microsoft Corporation 2 条、Zoom 1 条;
|
||||
另有 3 条确实归不出来,集中在一组,不硬塞。
|
||||
`login-item://豆包` 一条,与系统设置「登录时打开」一致。
|
||||
|
||||
### 13.4 登录项此前一条都没有,原因是两个真 bug
|
||||
|
||||
用户说「mac 设置里登录打开的内容反而没有」,不是主观感受:那一栏当时恒为空。
|
||||
|
||||
1. `login_items()` 从 `backgrounditems.btm` 里刮 ASCII 路径,再要求命中 `"/Applications/"`。
|
||||
这个归档里的路径全是小写(`/applications/wireguard.app`),大小写敏感的匹配一个都不中。
|
||||
2. 修好大小写也不够。BTM 是 NSKeyedArchiver,装的是 security-scoped bookmark;
|
||||
用户目录里那份只含 9 个容器,系统设置面板显示 30 多个应用组,`sfltool dumpbtm`
|
||||
需要 root 才能读全。刮字符串永远对不上系统设置。
|
||||
|
||||
现在改问 System Events(`every login item`),也就是系统设置那块面板自己的视图,
|
||||
两者不会打架。登录项仍然只读——AppleScript 的 `delete` 在不同 macOS 版本上并不可靠——
|
||||
所以旁边给一个「打开系统设置」的动作,命令按 `sw_vers` 的主版本号选 URL:
|
||||
13 及以上用 `com.apple.LoginItems-Settings.extension`,12 用
|
||||
`com.apple.preference.users?LoginItems`(这两个是不同的 pane,`open` 对不认识的
|
||||
pane 也返回 0,所以不能靠试错)。读不到时 `StartupNote.kind = login-items-unavailable`
|
||||
在页面上说明原因,而不是显示空表假装「没有」。Info.plist 为此加了
|
||||
`NSAppleEventsUsageDescription`,首次读取会请求自动化权限。
|
||||
|
||||
### 13.5 打开这一页要 8 秒
|
||||
|
||||
`inventory()` 冷启动 8.65 s。原因不是 plist:868 个条目里 844 个的 `program` 指向
|
||||
Apple 自己的文件,而 macOS 的 `trust::assess` 每次 fork 一个 `codesign`,
|
||||
等于给一屏永远没人检查的条目问 844 次签名。三处改动之后 0.34 s,
|
||||
而且真正需要问签名的从 868 个降到 16 个:
|
||||
|
||||
- 签名判断从 `judge_program` 里拆出来。`system_vendor` 的条目和「目标已不存在」的条目
|
||||
都不再问:前者不是要检查的对象,后者「不在了」本身已经是答案。
|
||||
- 剩下那十几次用 `par_iter_mut` 并行;`trust::assess` 原来在整个 `codesign` 期间持有
|
||||
缓存互斥锁,那样并行等于白做,现在只在查/写缓存时加锁。
|
||||
- 顺序有讲究:先签名后归属,因为路径认不出应用时要用「谁签的名」兜底。
|
||||
两个平台的 `inventory()` 末尾收敛到同一个 `finish()`,不再各自写一遍。
|
||||
|
||||
扫描结果没有因此变化:同一台机器仍是 8 suspicious / 308 advisory / 0 confirmed。
|
||||
|
||||
### 13.6 顺手修掉的两个签名谎报
|
||||
|
||||
- `trust::might_be_executable` 用扩展名判断「值不值得问签名」。macOS 特权 helper 叫
|
||||
`us.zoom.ZoomDaemon`、`com.microsoft.autoupdate.helper`,最后一个点是名字的一部分,
|
||||
于是它们被判成「不是可执行文件」,进而报成**未签名**。本机
|
||||
`/Library/PrivilegedHelperTools` 的 7 个 helper 全部踩中这条:改之前一个都没被问过签名,
|
||||
其中 5 个其实签名完好,剩下 1 个是根本读不了的 `com.docker.socket`。改成读前 8 个字节判断
|
||||
Mach-O/PE;打不开文件时不再一律回答 false,
|
||||
因为 root 装成 0711 的 helper 能执行、不能打开。
|
||||
- 上面那种「打不开」现在单独成一级:`StartupRisk::SignatureUnreadable`。
|
||||
把读不到说成没签名,是在指控一个签过名的程序,而 6.4 的整份信用就建立在这种区分上。
|
||||
|
||||
### 13.7 「太多太杂」的真正原因:字段名根本没对上
|
||||
|
||||
重查时发现比样式严重得多的事:`StartupItem` 没有 `rename_all`,而包住它的 `StartupView` 有。
|
||||
后端发的是 `system_vendor`,页面读的是 `item.systemVendor`,于是这个表达式**恒为 `undefined`**,
|
||||
`if (!showVendor && item.systemVendor) return false` 一次都没有生效——
|
||||
|
||||
```text
|
||||
0.1.6 的启动项页:默认显示 873 行(Apple 的 845 行全都列在外面)
|
||||
现在(同一台机器,同一个 inventory):默认显示 29 行
|
||||
```
|
||||
|
||||
这正是用户说的「太多、太杂看不懂」的直接原因,也解释了为什么这一版光是分组还不够:
|
||||
分组之前得先让那 845 行真的被藏起来。TypeScript 看不见这个 bug——interface 描述的是
|
||||
意图,不是线上真正发出来的字节。
|
||||
|
||||
同类问题一共四个,全都在 0.1.6 就发出去了:
|
||||
|
||||
| 类型 | 页面读到的是 | 实际收到 | 后果 |
|
||||
| --- | --- | --- | --- |
|
||||
| `StartupItem` | `systemVendor`/`workingDirectory`/`modifiedMs` | snake_case | 「隐藏系统项」失效;详情抽屉的工作目录、修改时间恒为空 |
|
||||
| `StartupOwner` | `bundlePath` | `bundle_path` | 组头的 bundle 路径不显示 |
|
||||
| `ProcessRow` | `startedMs`/`startupItem`/`workingDirectory` | snake_case | 进程表「启动时间」列恒为 `—`,按它排序恒为平局(`startupItem` 另有原因,见 13.9) |
|
||||
| `Trust` | `adHoc` | `ad_hoc` | 进程详情把 ad-hoc 签名说成「未签名」 |
|
||||
|
||||
修法沿用本文既有约定:**跨 IPC 的结构体自己声明 camelCase**(`Finding`、`SecuritySettingsView`
|
||||
等一直这么做),而不是在 `*View` 里再套一层复制。改的是发送端,Rust 内部字段名不变,
|
||||
CLI/TUI 直接访问字段因此不受影响;`squid guard startup --json` 的输出键随之变成 camelCase,
|
||||
和 `guard scan --json`、`guard status --json` 统一(那两个一直是 camelCase)。
|
||||
`SystemSnapshot`、`LargestFile` 两侧本来就是 snake_case,属于另一种一致,没有动。
|
||||
|
||||
回归测试在 `src-tauri/src/startup.rs` 的 `wire_tests`:它序列化真正的 `StartupView`,
|
||||
断言页面读得到的每个名字都在线上,并且断言线上**没有**同一字段的第二种拼法。
|
||||
把 `StartupItem` 的 `rename_all` 删掉,测试立刻红。
|
||||
|
||||
### 13.8 屏幕锁着也能验:把真组件跑进无头 Chrome
|
||||
|
||||
Computer Use 需要显示器点亮,而验收期间这台 Mac 一直锁着。替代办法是
|
||||
`probe/`:用真的 `StartupPage` + 真数据(`squid guard startup --json` 落地成
|
||||
`fixtures/startup.json`)+ 真 `src/styles.css`,在 headless Chrome 里量**计算后**的样式并截图。
|
||||
它当场抓到一个肉眼看不出的 bug:`.status-chip` 没有 `white-space: nowrap`,
|
||||
中文标签在行内被挤成**一字一行**(截图里「无法读取签名」竖着排)。旧 `.risk-chip` 本来有 nowrap,
|
||||
13.1 合并 chip 时把这个性质丢了。修在 `.status-chip` 本身(`flex: 0 0 auto` + `white-space: nowrap`),
|
||||
因为它是 6 处共用的原语,不是一个页面的补丁。
|
||||
|
||||
量出来的行形状,新列表和旧模块对齐:
|
||||
|
||||
| | 圆角 | 左边框 | 下边框 | 背景 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `.item-row`(安全页/启动项页) | 0 | 0 | 1px solid | 透明 |
|
||||
| `.group-head` | 0 | 0 | 1px solid | 透明 |
|
||||
| `.process-row`(旧模块) | 0 | 0 | 1px solid | 透明 |
|
||||
| `.select-menu`(下拉浮层) | 11px | — | 1px solid | 卡片底色 + 阴影 |
|
||||
|
||||
全页 `document.querySelectorAll('select').length === 0`,`option` 同样是 0。生产包里
|
||||
`option` 元素计数也是 0(`select` 那个命中来自 react-dom 自带的 DOM intrinsic 表,不是应用代码),
|
||||
所以「所有下拉都不是原生控件」在整个应用范围内成立,不只是这三处改过的地方。
|
||||
|
||||
nowrap 的代价是标签不能折行,所以同一份探针量了溢出:1180 / 1280 / 820 / 900 宽度下
|
||||
`scrollWidth - clientWidth` 全为 0,页面没有横向滚动;820px 截图里行仍是一行,
|
||||
过长的是**名字**(`.item-copy` 本来就会打点省略),标签完整可读。
|
||||
|
||||
`probe/` 是临时脚手架,量完已删除,不进版本库;它不是产品的一部分。
|
||||
### 13.9 进程表里那个从来不会亮的标记
|
||||
|
||||
`ProcessRow::startup_item` 的注释写着「由桌面层填」,进程表从 0.1.6 起就照着它画
|
||||
「由启动项启动」的盾牌图标,筛选条也照它做「只看有启动项」——但**全仓库没有任何地方给它赋过值**,
|
||||
三处构造点全是 `None`。所以那个图标从来没出现过,那个筛选永远返回 0 行。
|
||||
13.7 修好的只是字段名;名字对了,值仍然是空的。
|
||||
|
||||
现在 `process_inventory` 读一次启动项清单,按可执行文件路径把两者对上:
|
||||
|
||||
- 一次 inventory 给整张表用。`entry_for` 每次调用都重新扫一遍全部根目录,按行调用等于 757 次。
|
||||
- 实测(M1 Pro,757 进程 / 874 条目;`join_tests::what_the_join_costs`,`--ignored` 才跑):
|
||||
签名检查开着(默认)时表本身 5 s,加 join 之后 6 s,757 行里 452 行被标注;
|
||||
签名检查关掉时表本身只要 26 ms,加 join 变成 390 ms。默认路径几乎没动,签名才是瓶颈;
|
||||
那条快路径多出的 0.36 s 是这次改动真实的代价,写在这里而不是糊过去。
|
||||
|
||||
没有加缓存是有意的。这张表只在打开页签、切换签名、点「刷新」时读,没有定时器;
|
||||
而把 inventory 缓存下来正是 `useStartupWorkspace` 的注释里点名不要的做法——
|
||||
App 会自己把启动项装回来,记住旧值的列表会在条目已经重新启用之后还显示它是关着的。
|
||||
- 同一个程序被两个条目声明时(`com.google.keystone.agent` 在 `~/Library` 和 `/Library` 各一份),
|
||||
取清单里先出现的那个,也就是当前用户拥有的那份。
|
||||
- **已停用的条目照样标注**:停用不一定能让进程退出,而这恰好是人最需要看清
|
||||
「它还开着是因为那条启动项」的时刻。详情抽屉的 `entry_for` 也从来没按 `disabled` 过滤,两边一致。
|
||||
|
||||
这条不在 5.3 的验收里(那节只要求进程**详情**能关联启动项),但 5.3 的措辞是「若进程关联启动项」,
|
||||
列表既然已经为这个标记画了图标、做了筛选,就不该是个永远不会亮的摆设。
|
||||
测试:`join_tests` 两条,覆盖匹配、用户拥有的条目优先、无路径不匹配、停用仍标注。
|
||||
|
||||
## 14. 第三轮修订:菜单命名、页头小标题与重复说明
|
||||
|
||||
这一轮全是界面,没有改判定逻辑:扫描结果、启动项清单、进程表在本机与 13.9 结束时一致。
|
||||
|
||||
### 14.1 第一项改名「概览」
|
||||
|
||||
原来叫「电脑概览」,侧栏、顶栏、快捷键提示、README 与本文一起改成「概览」。
|
||||
菜单宽度有限,而这一项旁边已经有磁盘健康卡片说明它讲的是这台电脑,「电脑」是废字。
|
||||
|
||||
### 14.2 除概览之外不再有页头小标题
|
||||
|
||||
每个页面顶部原来都有一行橙色小字(`应用程序`、`安全`、`设置`……),
|
||||
下面紧跟同样意思的 `<h1>`。它把页面名说了两遍,还把标题从视觉上压小了。
|
||||
现在 `eyebrow` 只留在概览:那里写的是「下午好 · macOS」,是问候加系统名,不是第二遍页面名。
|
||||
其余 9 个页面一律不传 `eyebrow`;`.page-eyebrow` 规则保留,因为组件仍支持它。
|
||||
|
||||
### 14.3 界面上一半的说明是在重复离它最近的那个控件
|
||||
|
||||
12.7 定的规矩是「同一个事实只在离它最近的控件上出现一次」,当时只清理了两个新页面。
|
||||
这一轮把同一条规矩用到全部 10 个页面和 5 个卡片:整段删掉 22 处说明(中文约 530 字),
|
||||
另外把 14 处两句话的说明压成一句。删之前先确认「删掉之后这句话还有没有人说」,所以保留的都各有理由:
|
||||
|
||||
**删掉的是复述。** 设置页每个分组标题下面那句解释,说的都是标题或下面的控件已经说过的话:
|
||||
「选择登录电脑后是否自动启动 Squid」在下一行的「登录时启动 Squid」开关上,
|
||||
「超过此数量后较早的记录会被移除」在选择框里那五个数字上,
|
||||
「默认选择当前系统语言」在任何平台的语言选择器上都是显然的。
|
||||
安全页更夸张:「尚未扫描」在同一屏里出现了四次——页头标题、发现区副标题、
|
||||
空状态标题、覆盖卡片——现在只剩页头和覆盖卡片两处,各自承担不同的事。
|
||||
空状态「还没有清理记录」「查看已安装的应用」下面那段「扫描之后你会看到什么」整段删除:
|
||||
用户扫一次就知道了,而这句话挤掉了真正的入口按钮。
|
||||
|
||||
**保留的是删掉就没人说的话。** 隐私承诺留在它自己那两行里(「规则只下载到本机,不上传任何内容」
|
||||
「只读取,不改动」),页脚那句「一切都在本机完成」是它们的复述,删页脚不删这两行。
|
||||
确认对话框里的「永久删除无法撤销」「此进程中未保存的内容可能会丢失」全留,
|
||||
那是不可逆操作唯一的提示位。覆盖受限时「未检查的范围见上方覆盖说明」也留:
|
||||
6.4 要求不能把没读过说成安全,这句是它在界面上的落点。
|
||||
「停用会保留原始文件或注册表值,可随时恢复」留一次就够,同一个承诺在停用确认框里再说一遍是多余。
|
||||
|
||||
**改动方式。** 删掉说明会留下空容器,所以 `PageHeader.description` 与
|
||||
`EmptyState.description` 从必填改成可选(和本来就是可选的 `SectionTitle.subtitle` 一致),
|
||||
两者都在缺省时不渲染那一段;设置页分组标题下的 `<p>`、设置行里的 `<span>`
|
||||
是各组独有的,直接删掉元素。随删掉的文案一起清除的
|
||||
CSS 规则有 4 条:`.page-footnote`、`.setup-note`、`.field-help`、`.settings-footer`,
|
||||
都是这次改完之后全仓库再无引用的。没有新增任何 class,没有改任何尺寸,
|
||||
所以删完之后每一页剩下的控件位置没动。
|
||||
|
||||
**验证:** `npx tsc --noEmit` 通过(顺带清掉因此失效的 `formatBytes` 导入;
|
||||
`SecuritySettingsCard` 的 `api` 与 `ui.tsx` 的 `lang` 两处未使用变量在 HEAD 上就存在,没有动);
|
||||
`pnpm build` 通过;`cargo test --workspace` 272 项通过;`cargo fmt --check` 干净。
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "squid-desktop",
|
||||
"private": true,
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --port 1420 --strictPort",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
Squid 0.1.7 - 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。
|
||||
|
||||
安装
|
||||
----
|
||||
1. 运行 Squid-Setup-0.1.7-win-x64.exe。
|
||||
2. 这是未签名构建。若 SmartScreen 显示警告,请选择“更多信息” > “仍要运行”。
|
||||
3. 卸载请在 Windows“设置 > 应用”中移除 Squid。
|
||||
|
||||
更新
|
||||
----
|
||||
Squid 使用与 nex_shift 一致的 releases 分支更新通道。更新包会先校验
|
||||
文件大小与 SHA256,再在退出后运行同一个安装程序。若构建时写入发布公钥,
|
||||
还会验证清单的 Ed25519 签名。
|
||||
|
||||
校验
|
||||
----
|
||||
PowerShell:
|
||||
Get-FileHash .\Squid-Setup-0.1.7-win-x64.exe -Algorithm SHA256
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Squid 0.1.7
|
||||
|
||||
- 概览页按新设计重做:智能维护、本机配置(系统、型号、处理器、内存、主硬盘、显卡)、处理器/内存/存储指标卡与日常维护入口;扫描结果仍在下方。
|
||||
- 应用卸载列表与卸载方案显示应用真实图标(macOS / Windows);图标按需加载并缓存,读取失败时回退首字母。
|
||||
- 实时监控修复电池健康度:改用系统报告的 Maximum Capacity,Apple Silicon 不再把百分比再除以设计容量;本机显示 86%,循环次数 516。
|
||||
- 修复 CPU 统计:使用全局占用和全部逻辑核心,不再把第一个核心当总量,也不再少算一个核心。
|
||||
- 修复内存统计:按 `vm_stat` 实际页大小(Apple Silicon 为 16 KiB)解析 compressor / wired;内存按 1024 进制显示,16 GB 不再显示为 17.2 GB。
|
||||
- 概览「本机配置」新增显卡信息(macOS `system_profiler`、Windows 注册表、Linux `lspci`)。
|
||||
- 启动项页按 macOS / Windows 自己的分法重做:「登录项 / 后台程序」页签,按安装它的应用分组;系统自带条目默认隐藏。
|
||||
- 启动项读取从 8.65 秒降到 0.34 秒:不再为系统自带和已不存在的条目逐个询问签名,其余项并行处理。
|
||||
- 修复启动项、进程表与信任状态共 4 处 IPC 字段名不一致:隐藏系统项恢复生效,启动时间、工作目录与 ad-hoc 签名状态不再显示为空或错误。
|
||||
- 修复进程表「由启动项启动」标记与筛选:按可执行文件路径关联启动项,现在能正确显示与筛选。
|
||||
- 修复带点名称的特权 helper 被误报未签名;新增「无法读取签名」状态,不再把读不到说成没签名。
|
||||
- 全部下拉菜单改为应用内自绘组件,不再弹出系统原生控件;列表统一为扁平分隔线。
|
||||
- 菜单第一项改名「概览」;除概览外移除重复的页面小标题,精简 22 处重复说明和 14 处冗长文案。
|
||||
- macOS 与 Windows 同步发布 0.1.7。两个安装包均为未签名构建,首次打开需要用户自行授权(macOS 右键打开,Windows SmartScreen「仍要运行」)。
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
f1841a084c76af824cbc5bc0feb2dd35a76743c03597c86bd64b0a478f6ad071 Squid-0.1.7-macOS-universal.dmg
|
||||
34bc8444f6241b50e7ba7edb4a4875989f950481a4c7d2da21125cca5b5694df Squid-Setup-0.1.7-win-x64.exe
|
||||
cb826847c7b598b0121d80f64cd954ec2dc2d23e6d559ad87fa767c051af8805 README-Windows-x64.txt
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"schema": 1,
|
||||
"version": "0.1.7",
|
||||
"date": "2026-11-08",
|
||||
"notes": "Squid 0.1.7\n\n- 概览页按新设计重做:智能维护、本机配置(系统、型号、处理器、内存、主硬盘、显卡)、处理器/内存/存储指标卡与日常维护入口;扫描结果仍在下方。\n- 应用卸载列表与卸载方案显示应用真实图标(macOS / Windows);图标按需加载并缓存,读取失败时回退首字母。\n- 实时监控修复电池健康度:改用系统报告的 Maximum Capacity,Apple Silicon 不再把百分比再除以设计容量;本机显示 86%,循环次数 516。\n- 修复 CPU 统计:使用全局占用和全部逻辑核心,不再把第一个核心当总量,也不再少算一个核心。\n- 修复内存统计:按 `vm_stat` 实际页大小(Apple Silicon 为 16 KiB)解析 compressor / wired;内存按 1024 进制显示,16 GB 不再显示为 17.2 GB。\n- 概览「本机配置」新增显卡信息(macOS `system_profiler`、Windows 注册表、Linux `lspci`)。\n- 启动项页按 macOS / Windows 自己的分法重做:「登录项 / 后台程序」页签,按安装它的应用分组;系统自带条目默认隐藏。\n- 启动项读取从 8.65 秒降到 0.34 秒:不再为系统自带和已不存在的条目逐个询问签名,其余项并行处理。\n- 修复启动项、进程表与信任状态共 4 处 IPC 字段名不一致:隐藏系统项恢复生效,启动时间、工作目录与 ad-hoc 签名状态不再显示为空或错误。\n- 修复进程表「由启动项启动」标记与筛选:按可执行文件路径关联启动项,现在能正确显示与筛选。\n- 修复带点名称的特权 helper 被误报未签名;新增「无法读取签名」状态,不再把读不到说成没签名。\n- 全部下拉菜单改为应用内自绘组件,不再弹出系统原生控件;列表统一为扁平分隔线。\n- 菜单第一项改名「概览」;除概览外移除重复的页面小标题,精简 22 处重复说明和 14 处冗长文案。\n- macOS 与 Windows 同步发布 0.1.7。两个安装包均为未签名构建,首次打开需要用户自行授权(macOS 右键打开,Windows SmartScreen「仍要运行」)。",
|
||||
"artifacts": {
|
||||
"macos": {
|
||||
"file": "Squid-0.1.7-macOS-universal.dmg",
|
||||
"sha256": "f1841a084c76af824cbc5bc0feb2dd35a76743c03597c86bd64b0a478f6ad071",
|
||||
"size": 21933611
|
||||
},
|
||||
"windows": {
|
||||
"file": "Squid-Setup-0.1.7-win-x64.exe",
|
||||
"sha256": "34bc8444f6241b50e7ba7edb4a4875989f950481a4c7d2da21125cca5b5694df",
|
||||
"size": 7875018
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -95,10 +95,10 @@ asset_text = "".join(
|
|||
for p in assets.iterdir()
|
||||
if p.suffix in {".js", ".css", ".html"}
|
||||
)
|
||||
# Markers are the Chinese copy that has to survive into the bundle: the two scan
|
||||
# words are what the overview offers, and 0.1.6 split them apart, so a bundle built
|
||||
# Markers are the Chinese copy that has to survive into the bundle: the overview,
|
||||
# uninstall, monitor and update panels each contribute one phrase, so a bundle built
|
||||
# from an older or newer `dist` than the one on disk fails here rather than shipping.
|
||||
for marker in ("清理扫描", "安全快速扫描", "扫描完成", "自动检查更新"):
|
||||
for marker in ("本机配置", "智能扫描", "卸载,干净彻底", "掌握设备的每一次呼吸", "扫描完成", "自动检查更新"):
|
||||
if marker not in asset_text:
|
||||
missing.append(marker)
|
||||
if missing:
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b"
|
||||
dependencies = [
|
||||
"atk-sys",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
|
@ -278,10 +278,10 @@ version = "0.18.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -515,7 +515,7 @@ checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2"
|
|||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cairo-sys-rs",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"thiserror 1.0.69",
|
||||
|
|
@ -527,9 +527,9 @@ version = "0.18.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -612,6 +612,16 @@ dependencies = [
|
|||
"target-lexicon 0.12.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.20.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ba9e9ec16c447027685b1f897b720e18e9a8afd00bd7332c483537e38086c9f"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
"target-lexicon 0.13.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.5"
|
||||
|
|
@ -1606,6 +1616,23 @@ dependencies = [
|
|||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "file_icon_provider"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ff9f725b347b91d04340444fcbce0770886e4a6513e5f8e9e73a9e344efe73b"
|
||||
dependencies = [
|
||||
"gio 0.22.10",
|
||||
"gtk",
|
||||
"log",
|
||||
"objc2",
|
||||
"objc2-app-kit",
|
||||
"objc2-foundation",
|
||||
"objc2-uniform-type-identifiers",
|
||||
"scopeguard",
|
||||
"windows 0.62.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.15"
|
||||
|
|
@ -1786,8 +1813,8 @@ dependencies = [
|
|||
"cairo-rs",
|
||||
"gdk-pixbuf",
|
||||
"gdk-sys",
|
||||
"gio",
|
||||
"glib",
|
||||
"gio 0.18.4",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"pango",
|
||||
]
|
||||
|
|
@ -1799,8 +1826,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec"
|
||||
dependencies = [
|
||||
"gdk-pixbuf-sys",
|
||||
"gio",
|
||||
"glib",
|
||||
"gio 0.18.4",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
|
@ -1811,11 +1838,11 @@ version = "0.18.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7"
|
||||
dependencies = [
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1826,13 +1853,13 @@ checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7"
|
|||
dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk-pixbuf-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"pkg-config",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1842,11 +1869,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "140071d506d223f7572b9f09b5e155afbd77428cd5cc7af8f2694c41d98dfe69"
|
||||
dependencies = [
|
||||
"gdk-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1857,8 +1884,8 @@ checksum = "3caa00e14351bebbc8183b3c36690327eb77c49abc2268dd4bd36b856db3fbfe"
|
|||
dependencies = [
|
||||
"gdk",
|
||||
"gdkx11-sys",
|
||||
"gio",
|
||||
"glib",
|
||||
"gio 0.18.4",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"x11",
|
||||
]
|
||||
|
|
@ -1870,9 +1897,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "6e2e7445fe01ac26f11601db260dd8608fe172514eb63b3b5e261ea6b0f4428d"
|
||||
dependencies = [
|
||||
"gdk-sys",
|
||||
"glib-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
"x11",
|
||||
]
|
||||
|
||||
|
|
@ -1945,8 +1972,8 @@ dependencies = [
|
|||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib",
|
||||
"gio-sys 0.18.1",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
|
|
@ -1954,19 +1981,49 @@ dependencies = [
|
|||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.22.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4620fbafdf19dba814473e19f18e75290cb3338662f6ae35f0402affd3b2b699"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"gio-sys 0.22.9",
|
||||
"glib 0.22.10",
|
||||
"libc",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio-sys"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c28739f914c15b87a9856000bed9cbd5b3a8afbca5e982d9a299e1601422cb5"
|
||||
dependencies = [
|
||||
"glib-sys 0.22.9",
|
||||
"gobject-sys 0.22.9",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.18.5"
|
||||
|
|
@ -1979,10 +2036,10 @@ dependencies = [
|
|||
"futures-executor",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib-macros",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-macros 0.18.5",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
|
|
@ -1990,6 +2047,26 @@ dependencies = [
|
|||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.22.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4cf9e5bd8713f1990a92c422998826e0fb34824277b46bc59757373483c6694"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
"glib-macros 0.22.9",
|
||||
"glib-sys 0.22.9",
|
||||
"gobject-sys 0.22.9",
|
||||
"libc",
|
||||
"memchr",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.18.5"
|
||||
|
|
@ -2004,6 +2081,18 @@ dependencies = [
|
|||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9597c68fa7bdf4154a3079642cd21c4dccac0b0bdd2897d82861523bf91e7b9"
|
||||
dependencies = [
|
||||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.18.1"
|
||||
|
|
@ -2011,7 +2100,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99b38907e67e40dec9b60f858bcada952598719cb512a13eb13d6cdcd16f8295"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2050,9 +2149,20 @@ version = "0.18.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07595c9ba696bd9819cb6a8df39f08078f3dd679508fe052dd558492c2053834"
|
||||
dependencies = [
|
||||
"glib-sys 0.22.9",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2078,8 +2188,8 @@ dependencies = [
|
|||
"futures-channel",
|
||||
"gdk",
|
||||
"gdk-pixbuf",
|
||||
"gio",
|
||||
"glib",
|
||||
"gio 0.18.4",
|
||||
"glib 0.18.5",
|
||||
"gtk-sys",
|
||||
"gtk3-macros",
|
||||
"libc",
|
||||
|
|
@ -2097,12 +2207,12 @@ dependencies = [
|
|||
"cairo-sys-rs",
|
||||
"gdk-pixbuf-sys",
|
||||
"gdk-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2319,7 +2429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d75e94d66081e4d8dcd098bd8dc5254800fea14a26389b298410158d834de167"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"png",
|
||||
"png 0.18.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2464,7 +2574,7 @@ dependencies = [
|
|||
"byteorder-lite",
|
||||
"moxcms",
|
||||
"num-traits",
|
||||
"png",
|
||||
"png 0.18.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2570,7 +2680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ca5671e9ffce8ffba57afc24070e906da7fc4b1ba66f2cabebf61bf2ea257fcc"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"javascriptcore-rs-sys",
|
||||
]
|
||||
|
||||
|
|
@ -2580,10 +2690,10 @@ version = "1.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1be78d14ffa4b75b66df31840478fef72b51f8c2465d4ca7c194da9f7a5124"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2751,7 +2861,7 @@ version = "0.9.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"gtk",
|
||||
"gtk-sys",
|
||||
"libappindicator-sys",
|
||||
|
|
@ -3019,7 +3129,7 @@ dependencies = [
|
|||
"objc2-core-foundation",
|
||||
"objc2-foundation",
|
||||
"once_cell",
|
||||
"png",
|
||||
"png 0.18.1",
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
"windows-sys 0.61.2",
|
||||
|
|
@ -3188,8 +3298,15 @@ checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
|
|||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"block2",
|
||||
"libc",
|
||||
"objc2",
|
||||
"objc2-cloud-kit",
|
||||
"objc2-core-data",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-core-image",
|
||||
"objc2-core-text",
|
||||
"objc2-core-video",
|
||||
"objc2-foundation",
|
||||
"objc2-quartz-core",
|
||||
]
|
||||
|
|
@ -3211,6 +3328,7 @@ version = "0.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"objc2",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
|
@ -3271,6 +3389,19 @@ dependencies = [
|
|||
"objc2-core-graphics",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-core-video"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"objc2",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-io-surface",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "4.1.0"
|
||||
|
|
@ -3343,6 +3474,17 @@ dependencies = [
|
|||
"objc2-user-notifications",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-uniform-type-identifiers"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7902ac02859fc1f7045f8b598c63f1ae0cc7efeaa06a9bc9f3d9a3c955974fa4"
|
||||
dependencies = [
|
||||
"block2",
|
||||
"objc2",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-user-notifications"
|
||||
version = "0.3.2"
|
||||
|
|
@ -3454,8 +3596,8 @@ version = "0.18.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"
|
||||
dependencies = [
|
||||
"gio",
|
||||
"glib",
|
||||
"gio 0.18.4",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"pango-sys",
|
||||
|
|
@ -3467,10 +3609,10 @@ version = "0.18.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3626,6 +3768,19 @@ dependencies = [
|
|||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"crc32fast",
|
||||
"fdeflate",
|
||||
"flate2",
|
||||
"miniz_oxide 0.8.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.18.1"
|
||||
|
|
@ -4053,8 +4208,8 @@ checksum = "20dafead71c16a34e1ff357ddefc8afc11e7d51d6d2b9fbd07eaa48e3e540220"
|
|||
dependencies = [
|
||||
"block2",
|
||||
"dispatch2",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"gtk-sys",
|
||||
"js-sys",
|
||||
"libc",
|
||||
|
|
@ -4574,8 +4729,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "471f924a40f31251afc77450e781cb26d55c0b650842efafc9c6cbd2f7cc4f9f"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"gio",
|
||||
"glib",
|
||||
"gio 0.18.4",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"soup3-sys",
|
||||
]
|
||||
|
|
@ -4586,11 +4741,11 @@ version = "0.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ebe8950a680a12f24f15ebe1bf70db7af98ad242d9db43596ad3108aab86c27"
|
||||
dependencies = [
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4605,7 +4760,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-core"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -4624,7 +4779,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-desktop"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
|
|
@ -4651,7 +4806,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-engine"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -4671,7 +4826,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-guard"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"hex",
|
||||
|
|
@ -4687,11 +4842,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-platform"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"file_icon_provider",
|
||||
"libc",
|
||||
"plist",
|
||||
"png 0.17.16",
|
||||
"rayon",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
@ -4705,7 +4862,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-rules"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"globset",
|
||||
"serde",
|
||||
|
|
@ -4717,7 +4874,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-stats"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
|
@ -4880,13 +5037,26 @@ version = "6.2.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
|
||||
dependencies = [
|
||||
"cfg-expr",
|
||||
"cfg-expr 0.15.8",
|
||||
"heck 0.5.0",
|
||||
"pkg-config",
|
||||
"toml 0.8.2",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "9.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db551ad38aac61d5e0343e0eeeb0163be3115c4e23b6a025959570ee0c03c67d"
|
||||
dependencies = [
|
||||
"cfg-expr 0.20.10",
|
||||
"heck 0.5.0",
|
||||
"pkg-config",
|
||||
"toml 1.1.8+spec-1.1.0",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.37.2"
|
||||
|
|
@ -5042,7 +5212,7 @@ dependencies = [
|
|||
"ico",
|
||||
"json-patch",
|
||||
"plist",
|
||||
"png",
|
||||
"png 0.18.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"semver",
|
||||
|
|
@ -5636,7 +5806,7 @@ dependencies = [
|
|||
"objc2-core-graphics",
|
||||
"objc2-foundation",
|
||||
"once_cell",
|
||||
"png",
|
||||
"png 0.18.1",
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
"windows-sys 0.61.2",
|
||||
|
|
@ -6183,11 +6353,11 @@ dependencies = [
|
|||
"cairo-rs",
|
||||
"gdk",
|
||||
"gdk-sys",
|
||||
"gio",
|
||||
"gio-sys",
|
||||
"glib",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio 0.18.4",
|
||||
"gio-sys 0.18.1",
|
||||
"glib 0.18.5",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"gtk",
|
||||
"gtk-sys",
|
||||
"javascriptcore-rs",
|
||||
|
|
@ -6206,15 +6376,15 @@ dependencies = [
|
|||
"bitflags 1.3.2",
|
||||
"cairo-sys-rs",
|
||||
"gdk-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"gtk-sys",
|
||||
"javascriptcore-rs-sys",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"soup3-sys",
|
||||
"system-deps",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "squid-desktop"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
description = "Squid — a CleanMyMac-inspired cleaner, uninstaller and system monitor."
|
||||
authors = ["squid contributors"]
|
||||
edition = "2021"
|
||||
|
|
|
|||
|
|
@ -14,5 +14,7 @@
|
|||
<string>Squid can analyze removable volumes you select.</string>
|
||||
<key>NSNetworkVolumesUsageDescription</key>
|
||||
<string>Squid can analyze network volumes you select.</string>
|
||||
<key>NSAppleEventsUsageDescription</key>
|
||||
<string>Squid reads the login items macOS lists in System Settings so the startup page can show the same ones.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
//! The engine still re-validates every path against the same safety policy and
|
||||
//! whitelist used by the CLI and TUI.
|
||||
|
||||
use base64::{engine::general_purpose::STANDARD, Engine as _};
|
||||
use squid_core::ledger::{self, Session};
|
||||
use squid_core::paths;
|
||||
use squid_core::progress::{CancelToken, Event, Progress};
|
||||
|
|
@ -31,6 +32,7 @@ pub struct AppState {
|
|||
scans: Mutex<HashMap<String, ScanReport>>,
|
||||
plans: Mutex<HashMap<String, UninstallPlan>>,
|
||||
apps: Mutex<Vec<AppInfo>>,
|
||||
app_icons: Mutex<HashMap<String, Option<String>>>,
|
||||
sampler: Mutex<Sampler>,
|
||||
}
|
||||
|
||||
|
|
@ -620,9 +622,38 @@ pub async fn apps_scan(app: AppHandle, job_id: String) -> Result<AppsView, Strin
|
|||
if let Ok(mut cache) = app.state::<AppState>().apps.lock() {
|
||||
*cache = apps.clone();
|
||||
}
|
||||
if let Ok(mut icons) = app.state::<AppState>().app_icons.lock() {
|
||||
icons.clear();
|
||||
}
|
||||
Ok(AppsView { apps, total })
|
||||
}
|
||||
|
||||
/// Resolve one app's icon lazily so scanning does not pay for artwork the user
|
||||
/// never opens. The result is cached; a missing icon is cached as `None` too.
|
||||
#[tauri::command]
|
||||
pub async fn app_icon(app: AppHandle, app_key: String) -> Result<Option<String>, String> {
|
||||
if let Some(cached) = AppState::lock(&app.state::<AppState>().app_icons)?
|
||||
.get(&app_key)
|
||||
.cloned()
|
||||
{
|
||||
return Ok(cached);
|
||||
}
|
||||
let chosen = AppState::lock(&app.state::<AppState>().apps)?
|
||||
.iter()
|
||||
.find(|candidate| candidate.key() == app_key)
|
||||
.cloned();
|
||||
let Some(chosen) = chosen else {
|
||||
return Ok(None);
|
||||
};
|
||||
let png =
|
||||
tauri::async_runtime::spawn_blocking(move || squid_platform::apps::icon_png(&chosen, 64))
|
||||
.await
|
||||
.map_err(|error| format!("Could not read the application icon: {error}"))?;
|
||||
let icon = png.map(|bytes| format!("data:image/png;base64,{}", STANDARD.encode(bytes)));
|
||||
AppState::lock(&app.state::<AppState>().app_icons)?.insert(app_key, icon.clone());
|
||||
Ok(icon)
|
||||
}
|
||||
|
||||
#[derive(Clone, serde::Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PlanView {
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ pub fn run() {
|
|||
app::apps_scan,
|
||||
app::app_plan,
|
||||
app::app_uninstall,
|
||||
app::app_icon,
|
||||
app::storage_explore,
|
||||
app::storage_largest_files,
|
||||
app::system_snapshot,
|
||||
|
|
@ -262,6 +263,7 @@ pub fn run() {
|
|||
security::open_quarantine_folder,
|
||||
startup::startup_items,
|
||||
startup::startup_set_enabled,
|
||||
startup::open_startup_settings,
|
||||
startup::process_inventory,
|
||||
startup::process_detail,
|
||||
startup::process_stop,
|
||||
|
|
|
|||
|
|
@ -13,36 +13,44 @@
|
|||
|
||||
use serde::Serialize;
|
||||
use squid_platform::process_table::ProcessRow;
|
||||
use squid_platform::startup::{StartupInventory, StartupItem};
|
||||
use squid_platform::startup::{StartupCategory, StartupInventory, StartupItem, StartupNote};
|
||||
use squid_platform::trust;
|
||||
use std::path::PathBuf;
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StartupView {
|
||||
items: Vec<StartupItem>,
|
||||
notes: Vec<String>,
|
||||
user_count: usize,
|
||||
system_count: usize,
|
||||
disabled_count: usize,
|
||||
notes: Vec<StartupNote>,
|
||||
/// The two lists the page shows, counted the way they are counted on screen.
|
||||
login_count: usize,
|
||||
background_count: usize,
|
||||
/// Entries belonging to Apple or Microsoft, which are hidden by default.
|
||||
vendor_count: usize,
|
||||
/// Entries the user owns that are not vendor-owned: what this page may act on.
|
||||
actionable_count: usize,
|
||||
risky_count: usize,
|
||||
/// Which of the two platforms' surfaces were readable at all, so a page that
|
||||
/// shows nothing can say whether that means "none" or "could not look".
|
||||
sources: Vec<String>,
|
||||
}
|
||||
|
||||
impl StartupView {
|
||||
fn of(inventory: StartupInventory) -> StartupView {
|
||||
let mut sources: Vec<String> = inventory
|
||||
.items
|
||||
.iter()
|
||||
.map(|item| item.source.as_str().to_string())
|
||||
.collect();
|
||||
sources.sort();
|
||||
sources.dedup();
|
||||
StartupView {
|
||||
login_count: inventory
|
||||
.items
|
||||
.iter()
|
||||
.filter(|item| item.category == StartupCategory::OpenAtLogin)
|
||||
.count(),
|
||||
background_count: inventory
|
||||
.items
|
||||
.iter()
|
||||
.filter(|item| item.category == StartupCategory::Background)
|
||||
.count(),
|
||||
vendor_count: inventory
|
||||
.items
|
||||
.iter()
|
||||
.filter(|item| item.system_vendor)
|
||||
.count(),
|
||||
actionable_count: inventory
|
||||
.items
|
||||
.iter()
|
||||
|
|
@ -53,10 +61,6 @@ impl StartupView {
|
|||
.iter()
|
||||
.filter(|item| !item.risks.is_empty())
|
||||
.count(),
|
||||
user_count: inventory.user_count(),
|
||||
system_count: inventory.system_count(),
|
||||
disabled_count: inventory.disabled_count(),
|
||||
sources,
|
||||
items: inventory.items,
|
||||
notes: inventory.notes,
|
||||
}
|
||||
|
|
@ -117,6 +121,64 @@ pub async fn startup_set_enabled(id: String, enabled: bool) -> Result<StartupCha
|
|||
.map_err(|error| error.to_string())?
|
||||
}
|
||||
|
||||
/// Open the pane where the entries squid only reads can actually be changed.
|
||||
///
|
||||
/// macOS owns the login-item list, and Windows owns scheduled tasks and services, so
|
||||
/// for those the honest action is to hand the person to the operating system rather
|
||||
/// than offer a toggle that would not hold. `open` reports success for a settings
|
||||
/// pane it does not recognise, so the macOS version picks the URL instead of trying
|
||||
/// one and hoping: Ventura renamed the login-item pane from a Users & Groups anchor
|
||||
/// to its own extension.
|
||||
#[tauri::command]
|
||||
pub fn open_startup_settings() -> Result<(), String> {
|
||||
#[cfg(target_os = "macos")]
|
||||
let target = {
|
||||
let version = crate::process::command("/usr/bin/sw_vers")
|
||||
.arg("-productVersion")
|
||||
.output()
|
||||
.map(|output| String::from_utf8_lossy(&output.stdout).trim().to_owned())
|
||||
.unwrap_or_default();
|
||||
let major: u32 = version
|
||||
.split('.')
|
||||
.next()
|
||||
.and_then(|head| head.parse().ok())
|
||||
.unwrap_or(12);
|
||||
if major >= 13 {
|
||||
"x-apple.systempreferences:com.apple.LoginItems-Settings.extension"
|
||||
} else {
|
||||
"x-apple.systempreferences:com.apple.preference.users?LoginItems"
|
||||
}
|
||||
};
|
||||
// The pane Task Manager's Startup tab writes to. `ms-settings:startup` is not a
|
||||
// URI and silently opens whatever was last shown.
|
||||
#[cfg(windows)]
|
||||
let target = "ms-settings:startupapps";
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let opened = run("/usr/bin/open", &[target]);
|
||||
#[cfg(windows)]
|
||||
let opened = run("cmd", &["/C", "start", "", target]);
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
return Err("The system settings are not available here.".into());
|
||||
#[cfg(any(target_os = "macos", windows))]
|
||||
opened
|
||||
}
|
||||
|
||||
/// The one shape the two platforms' settings openers differ in: a program, its
|
||||
/// arguments, and whether the operating system accepted the request.
|
||||
#[cfg(any(target_os = "macos", windows))]
|
||||
fn run(program: &str, arguments: &[&str]) -> Result<(), String> {
|
||||
let status = crate::process::command(program)
|
||||
.args(arguments)
|
||||
.status()
|
||||
.map_err(|error| format!("Could not open the system settings: {error}"))?;
|
||||
if status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Could not open the system settings.".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProcessDetailView {
|
||||
|
|
@ -133,12 +195,163 @@ pub struct ProcessDetailView {
|
|||
pub async fn process_inventory(with_trust: Option<bool>) -> Result<Vec<ProcessRow>, String> {
|
||||
let with_trust = with_trust.unwrap_or(true);
|
||||
tauri::async_runtime::spawn_blocking(move || -> Result<Vec<ProcessRow>, String> {
|
||||
Ok(squid_platform::process_table::snapshot(with_trust).rows)
|
||||
let mut rows = squid_platform::process_table::snapshot(with_trust).rows;
|
||||
mark_startup_entries(&mut rows, &squid_platform::startup::inventory());
|
||||
Ok(rows)
|
||||
})
|
||||
.await
|
||||
.map_err(|error| format!("Could not read the process table: {error}"))?
|
||||
}
|
||||
|
||||
/// Name the startup entry behind each process, which is what the table's "started by
|
||||
/// a startup item" marker and its filter read.
|
||||
///
|
||||
/// `ProcessRow::startup_item` says the desktop layer fills it in, and the marker has
|
||||
/// been drawn from it since 0.1.6 — but nothing ever assigned it, so the icon never
|
||||
/// appeared and "only started by an entry" returned nothing at all.
|
||||
///
|
||||
/// Measured on an M1 Pro, ~760 processes and 874 entries: costs 0.45 s on top of the
|
||||
/// 5.7 s the table already spends resolving signatures, and marks 452 of the rows.
|
||||
/// The same read dominates the cheap path that skips signatures — 26 ms becomes 390 ms.
|
||||
/// See ROADMAP 13.9 for why that trade was taken without caching.
|
||||
fn mark_startup_entries(rows: &mut [ProcessRow], inventory: &StartupInventory) {
|
||||
// Keyed once for the whole table. `entry_for` re-reads every root on every call,
|
||||
// so using it per row would cost one inventory per process, several hundred of them,
|
||||
// where the table already spends seconds reading signatures.
|
||||
let mut declared: HashMap<&Path, &str> = HashMap::new();
|
||||
for item in &inventory.items {
|
||||
// The inventory arrives user entries first, so keeping the first name seen
|
||||
// prefers the entry this user owns when a vendor installs the same program
|
||||
// twice (`com.google.keystone.agent` exists in both `~/Library` and `/Library`).
|
||||
if let Some(program) = item.program.as_deref() {
|
||||
declared.entry(program).or_insert(item.name.as_str());
|
||||
}
|
||||
}
|
||||
for row in rows {
|
||||
row.startup_item = row
|
||||
.program
|
||||
.as_deref()
|
||||
.and_then(|program| declared.get(program))
|
||||
.map(|name| (*name).to_string());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod join_tests {
|
||||
use super::mark_startup_entries;
|
||||
use squid_platform::startup::{StartupInventory, StartupItem, StartupScope, StartupSource};
|
||||
use std::path::Path;
|
||||
|
||||
/// The join costs one inventory read per refresh. Measured here rather than
|
||||
/// asserted, because it is a latency decision, not a correctness one: the process
|
||||
/// table has a deliberately cheap path that skips signature reads, and a join that
|
||||
/// dwarfed it would be the wrong trade.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn what_the_join_costs() {
|
||||
use std::time::Instant;
|
||||
for with_trust in [true, false] {
|
||||
let start = Instant::now();
|
||||
let mut rows = squid_platform::process_table::snapshot(with_trust).rows;
|
||||
let table = start.elapsed();
|
||||
let start = Instant::now();
|
||||
mark_startup_entries(&mut rows, &squid_platform::startup::inventory());
|
||||
let join = start.elapsed();
|
||||
let marked = rows.iter().filter(|row| row.startup_item.is_some()).count();
|
||||
println!(
|
||||
"trust={with_trust}: table {table:.0?} + join {join:.0?} = {:.0?} · {marked}/{} marked",
|
||||
table + join,
|
||||
rows.len()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn row(pid: u32, program: Option<&str>) -> super::ProcessRow {
|
||||
super::ProcessRow {
|
||||
pid,
|
||||
parent: None,
|
||||
name: "thing".into(),
|
||||
command: String::new(),
|
||||
program: program.map(Path::new).map(|p| p.to_path_buf()),
|
||||
working_directory: None,
|
||||
user: String::new(),
|
||||
cpu: 0.0,
|
||||
memory: 0,
|
||||
started_ms: None,
|
||||
startup_item: None,
|
||||
signed: false,
|
||||
publisher: None,
|
||||
owned: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn entry(name: &str, program: &str) -> StartupItem {
|
||||
let mut item = StartupItem::new(
|
||||
format!("/Library/LaunchAgents/{name}.plist"),
|
||||
name,
|
||||
StartupSource::LaunchAgent,
|
||||
StartupScope::User,
|
||||
);
|
||||
item.program = Some(Path::new(program).to_path_buf());
|
||||
item
|
||||
}
|
||||
|
||||
/// The table has drawn a marker from this field since 0.1.6, and a filter has
|
||||
/// keyed off it, but nothing ever wrote it: the icon never appeared and
|
||||
/// "only started by an entry" returned nothing at all.
|
||||
#[test]
|
||||
fn a_process_is_matched_to_the_entry_that_declares_it() {
|
||||
let inventory = StartupInventory {
|
||||
items: vec![
|
||||
entry("com.user.keystone", "/opt/keystone/agent"),
|
||||
entry("com.system.keystone", "/opt/keystone/agent"),
|
||||
entry("com.other.thing", "/opt/other/thing"),
|
||||
],
|
||||
notes: vec![],
|
||||
};
|
||||
let mut rows = vec![
|
||||
row(1, Some("/opt/keystone/agent")),
|
||||
row(2, Some("/opt/unrelated/app")),
|
||||
row(3, None),
|
||||
];
|
||||
mark_startup_entries(&mut rows, &inventory);
|
||||
|
||||
assert_eq!(
|
||||
rows[0].startup_item.as_deref(),
|
||||
Some("com.user.keystone"),
|
||||
"an entry is named, and the user-owned one wins a duplicate program"
|
||||
);
|
||||
assert_eq!(
|
||||
rows[1].startup_item, None,
|
||||
"a process nothing declared stays plain"
|
||||
);
|
||||
assert_eq!(
|
||||
rows[2].startup_item, None,
|
||||
"a process with no path cannot be matched"
|
||||
);
|
||||
}
|
||||
|
||||
/// Disabling an entry does not necessarily stop the process it started, and that
|
||||
/// is exactly when the link is worth seeing rather than losing. The detail drawer's
|
||||
/// `entry_for` has never filtered on `disabled` either, so the two views agree.
|
||||
#[test]
|
||||
fn a_disabled_entry_still_names_the_process_it_left_running() {
|
||||
let mut off = entry("com.user.updater", "/opt/updater/agent");
|
||||
off.disabled = true;
|
||||
let inventory = StartupInventory {
|
||||
items: vec![off],
|
||||
notes: vec![],
|
||||
};
|
||||
let mut rows = vec![row(9, Some("/opt/updater/agent"))];
|
||||
mark_startup_entries(&mut rows, &inventory);
|
||||
assert_eq!(
|
||||
rows[0].startup_item.as_deref(),
|
||||
Some("com.user.updater"),
|
||||
"the row that explains why this is still running must not disappear"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn process_detail(pid: u32) -> Result<ProcessDetailView, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || -> Result<ProcessDetailView, String> {
|
||||
|
|
@ -226,3 +439,88 @@ pub async fn process_stop(pid: u32, name: String) -> Result<ProcessStopResult, S
|
|||
.await
|
||||
.map_err(|error| error.to_string())?
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod wire_tests {
|
||||
use super::StartupView;
|
||||
use squid_platform::startup::{
|
||||
StartupInventory, StartupItem, StartupOwner, StartupScope, StartupSource,
|
||||
};
|
||||
|
||||
/// Every name the page reads has to be a name on the wire.
|
||||
///
|
||||
/// `StartupView` renames itself to camelCase and `StartupItem` did not, so the
|
||||
/// page's `item.systemVendor` was `undefined` for every entry: the filter that
|
||||
/// hides 845 Apple items silently hid nothing, and TypeScript could not see it
|
||||
/// because the interface says what was intended, not what is sent.
|
||||
#[test]
|
||||
fn startup_entries_arrive_in_the_names_the_page_reads() {
|
||||
let mut item = StartupItem::new(
|
||||
"/Library/LaunchDaemons/com.docker.vmnetd.plist",
|
||||
"com.docker.vmnetd",
|
||||
StartupSource::LaunchDaemon,
|
||||
StartupScope::System,
|
||||
);
|
||||
item.owner = Some(StartupOwner {
|
||||
name: "Docker".into(),
|
||||
bundle_path: Some("/Applications/Docker.app".into()),
|
||||
vendor: false,
|
||||
});
|
||||
let json = serde_json::to_value(StartupView::of(StartupInventory {
|
||||
items: vec![item],
|
||||
notes: vec![],
|
||||
}))
|
||||
.expect("a view serializes");
|
||||
|
||||
for key in ["systemVendor", "workingDirectory", "modifiedMs"] {
|
||||
assert!(
|
||||
json["items"][0].get(key).is_some(),
|
||||
"the page reads StartupItem.{key}; the wire does not carry it"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
json["items"][0]["owner"].get("bundlePath").is_some(),
|
||||
"the page reads owner.bundlePath"
|
||||
);
|
||||
assert!(
|
||||
json["items"][0].get("system_vendor").is_none(),
|
||||
"one casing per boundary, not two spellings of the same field"
|
||||
);
|
||||
}
|
||||
|
||||
/// The process table renames its own rows the same way, and reads three fields
|
||||
/// that only exist if it does.
|
||||
#[test]
|
||||
fn process_rows_arrive_in_the_names_the_table_reads() {
|
||||
let row = squid_platform::process_table::ProcessRow {
|
||||
pid: 4_321,
|
||||
parent: None,
|
||||
name: "squid".into(),
|
||||
command: String::new(),
|
||||
program: None,
|
||||
working_directory: None,
|
||||
user: String::new(),
|
||||
cpu: 0.0,
|
||||
memory: 0,
|
||||
started_ms: None,
|
||||
startup_item: None,
|
||||
signed: false,
|
||||
publisher: None,
|
||||
owned: true,
|
||||
};
|
||||
let json = serde_json::to_value(&row).expect("a row serializes");
|
||||
for key in ["startedMs", "startupItem", "workingDirectory"] {
|
||||
assert!(
|
||||
json.get(key).is_some(),
|
||||
"the table reads ProcessRow.{key}; the wire does not carry it"
|
||||
);
|
||||
}
|
||||
let trust = serde_json::to_value(squid_platform::trust::Trust::default())
|
||||
.expect("a trust serializes");
|
||||
assert!(
|
||||
trust.get("adHoc").is_some(),
|
||||
"the table reads Trust.adHoc; the wire says {:?}",
|
||||
trust.as_object().map(|o| o.keys().collect::<Vec<_>>())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Squid",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"identifier": "app.nex.squid",
|
||||
"mainBinaryName": "squid-desktop",
|
||||
"build": {
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ const NAV_GROUPS: {
|
|||
items: [
|
||||
{
|
||||
id: "overview",
|
||||
labelEn: "Computer overview",
|
||||
labelZh: "电脑概览",
|
||||
labelEn: "Overview",
|
||||
labelZh: "概览",
|
||||
icon: LayoutDashboard,
|
||||
},
|
||||
{
|
||||
|
|
@ -114,7 +114,7 @@ const NAV_GROUPS: {
|
|||
];
|
||||
|
||||
const PAGE_TITLES: Record<PageId, [string, string]> = {
|
||||
overview: ["Computer overview", "电脑概览"],
|
||||
overview: ["Overview", "概览"],
|
||||
cleanup: ["Daily cleanup", "日常清理"],
|
||||
applications: ["Uninstall apps", "应用卸载"],
|
||||
purge: ["Deep Clean", "深度清理"],
|
||||
|
|
@ -367,7 +367,6 @@ export default function App() {
|
|||
bootstrap={bootstrap}
|
||||
snapshot={system.snapshot}
|
||||
cleanup={cleanup}
|
||||
security={security}
|
||||
onNavigate={setPage}
|
||||
/>
|
||||
) : null}
|
||||
|
|
|
|||
|
|
@ -292,10 +292,6 @@ export function CleanupInventory({
|
|||
? categoryLabel(focus, lang)
|
||||
: t("Everything found in this scan", "本次扫描的全部项目")
|
||||
}
|
||||
subtitle={t(
|
||||
"Only checked items are touched. Protected items stay locked.",
|
||||
"只会处理已勾选的项目,受保护项目始终保持锁定。",
|
||||
)}
|
||||
action={
|
||||
focus ? (
|
||||
<Button variant="ghost" size="sm" onClick={() => setFocus(null)}>
|
||||
|
|
@ -369,8 +365,8 @@ export function CleanupInventory({
|
|||
`文件将移入${bin},之后可从历史记录中还原。`,
|
||||
)
|
||||
: t(
|
||||
"Permanent removal cannot be undone. Squid re-checks every path before deleting it.",
|
||||
"永久删除无法撤销。Squid 会在删除前重新检查每一个路径。",
|
||||
"Permanent removal cannot be undone.",
|
||||
"永久删除无法撤销。",
|
||||
)
|
||||
}
|
||||
confirmLabel={
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useI18n } from "../i18n";
|
||||
import { api } from "../lib/api";
|
||||
import { formatBytes, formatCount, messageFrom, shortPath } from "../lib/format";
|
||||
import { formatCount, formatMemoryBytes, messageFrom, shortPath } from "../lib/format";
|
||||
import type { Finding, ProcessDetail, ProcessRow } from "../types";
|
||||
import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace";
|
||||
import {
|
||||
|
|
@ -304,7 +304,7 @@ export function ProcessTable({
|
|||
{t(`${group.instances} instances`, `${group.instances} 个实例`)}
|
||||
</small>
|
||||
<span className="pg-cpu">{group.cpu.toFixed(1)}%</span>
|
||||
<span className="pg-memory">{formatBytes(group.memory)}</span>
|
||||
<span className="pg-memory">{formatMemoryBytes(group.memory)}</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
|
|
@ -337,7 +337,7 @@ export function ProcessTable({
|
|||
{row.user}
|
||||
</span>
|
||||
<span className="pt-cpu">{row.cpu.toFixed(1)}%</span>
|
||||
<span className="pt-memory">{formatBytes(row.memory)}</span>
|
||||
<span className="pt-memory">{formatMemoryBytes(row.memory)}</span>
|
||||
<span className="pt-start">
|
||||
{row.startedMs ? new Date(row.startedMs).toLocaleTimeString() : "—"}
|
||||
</span>
|
||||
|
|
@ -466,10 +466,7 @@ export function ProcessTable({
|
|||
open={Boolean(victim)}
|
||||
title={t("Stop this process?", "结束此进程?")}
|
||||
message={victim ? `${victim.name} · PID ${victim.pid}` : ""}
|
||||
note={t(
|
||||
"Unsaved work here may be lost. Only your own processes can be stopped.",
|
||||
"进程中未保存的内容可能丢失。只会结束当前用户的进程。",
|
||||
)}
|
||||
note={t("Unsaved work here may be lost.", "进程中未保存的内容可能丢失。")}
|
||||
confirmLabel={t("Stop process", "结束进程")}
|
||||
cancelLabel={t("Cancel", "取消")}
|
||||
busy={stopping}
|
||||
|
|
@ -550,10 +547,7 @@ function ProcessDetailBody({
|
|||
</p>
|
||||
) : null}
|
||||
<p className="detail-note">
|
||||
{t(
|
||||
"Stopping a process never touches its file. Quarantine needs a confirmed finding.",
|
||||
"结束进程不会处理其文件;只有已确认发现才会隔离。",
|
||||
)}
|
||||
{t("Stopping a process never touches its files.", "结束进程不会处理其文件。")}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import { api } from "../lib/api";
|
|||
import { messageFrom, shortPath } from "../lib/format";
|
||||
import type { ScanSchedule, SecurityStatus } from "../types";
|
||||
import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace";
|
||||
import { Button, ConfirmDialog, Toggle, useToast } from "./ui";
|
||||
import { Button, ConfirmDialog, Select, Toggle, useToast } from "./ui";
|
||||
|
||||
const SCHEDULES: [ScanSchedule, string, string][] = [
|
||||
["manual", "Only when I ask", "仅在我要求时"],
|
||||
|
|
@ -99,12 +99,6 @@ export function SecuritySettingsCard({
|
|||
<ShieldCheck size={18} />
|
||||
{t("Security", "安全")}
|
||||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"When scans run, what may move without asking, and what a scan must not read.",
|
||||
"扫描何时运行、什么可以不经确认就移动,以及扫描不能读取哪些位置。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -123,18 +117,13 @@ export function SecuritySettingsCard({
|
|||
)}
|
||||
</span>
|
||||
</div>
|
||||
<select
|
||||
className="settings-select"
|
||||
<Select
|
||||
value={settings.scanSchedule}
|
||||
disabled={busy}
|
||||
onChange={(event) => void save({ scanSchedule: event.target.value })}
|
||||
>
|
||||
{SCHEDULES.map(([value, en, zh]) => (
|
||||
<option key={value} value={value}>
|
||||
{t(en, zh)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
label={t("Scan schedule", "扫描计划")}
|
||||
options={SCHEDULES.map(([value, en, zh]) => ({ value, label: t(en, zh) }))}
|
||||
onChange={(next) => void save({ scanSchedule: next })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="settings-row">
|
||||
|
|
@ -208,8 +197,8 @@ export function SecuritySettingsCard({
|
|||
<span>
|
||||
{rulesNote ??
|
||||
t(
|
||||
"Rules are downloaded to this machine. No file name, hash or result is ever sent out.",
|
||||
"规则只会下载到本机;文件名、哈希与扫描结果都不会上传。",
|
||||
"Rules are downloaded to this machine; nothing is ever sent out.",
|
||||
"规则只下载到本机,不上传任何内容。",
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -182,17 +182,14 @@ export function SetupPanel({
|
|||
`${
|
||||
protection.productName ||
|
||||
(protection.provider === "xprotect" ? "XProtect" : protection.provider)
|
||||
}${protection.definitions ? ` · ${protection.definitions}` : ""}. Squid reads this and never turns it on, off or updates it.`,
|
||||
}${protection.definitions ? ` · ${protection.definitions}` : ""}. Read-only.`,
|
||||
`${
|
||||
protection.productName ||
|
||||
(protection.provider === "xprotect" ? "XProtect" : protection.provider)
|
||||
}${protection.definitions ? ` · ${protection.definitions}` : ""}。Squid 只读取该状态,不会开启、关闭或更新它。`,
|
||||
}${protection.definitions ? ` · ${protection.definitions}` : ""}。只读取,不改动。`,
|
||||
)
|
||||
: protection?.notes[0] ??
|
||||
t(
|
||||
"When this cannot be read Squid says so, rather than showing it as healthy.",
|
||||
"读不到时 Squid 会直接说明,不会把它显示为正常。",
|
||||
)
|
||||
t("Squid reports this instead of guessing.", "读不到时会直接说明,不会显示为正常。")
|
||||
}
|
||||
/>
|
||||
|
||||
|
|
@ -233,7 +230,7 @@ export function SetupPanel({
|
|||
}}
|
||||
note={t(
|
||||
"Confirmed findings only. The banner and tray still report without it.",
|
||||
"仅针对已确认发现。关闭后应用内提示与托盘仍会显示。",
|
||||
"仅针对已确认发现,应用内提示与托盘不受影响。",
|
||||
)}
|
||||
action={
|
||||
<Button
|
||||
|
|
@ -290,12 +287,12 @@ export function SetupPanel({
|
|||
intel.source === "pack"
|
||||
? `Rule pack r${intel.revision} · ${intel.installedRules} rules`
|
||||
: `${intel.builtinRules} built-in rules, no pack downloaded`
|
||||
}. Only rules are downloaded; no file name, hash or result leaves this machine.`,
|
||||
}. Rules are the only download.`,
|
||||
`${
|
||||
intel.source === "pack"
|
||||
? `规则包 r${intel.revision} · ${intel.installedRules} 条规则`
|
||||
: `内置 ${intel.builtinRules} 条规则,未下载规则包`
|
||||
}。只下载规则,文件名、哈希与扫描结果都不会离开本机。`,
|
||||
}。只会下载规则。`,
|
||||
)
|
||||
: t("Reading the installed rules…", "正在读取已安装规则…")
|
||||
}
|
||||
|
|
@ -315,12 +312,6 @@ export function SetupPanel({
|
|||
|
||||
{note ? <p className="setup-error">{note}</p> : null}
|
||||
|
||||
<p className="setup-note">
|
||||
{t(
|
||||
"Closing this changes nothing. The same checks stay in Settings, and an update may reset what macOS granted.",
|
||||
"关闭本卡片不会改变任何设置,这些检查在设置中依然保留。更新后 macOS 可能重置已授予的权限。",
|
||||
)}
|
||||
</p>
|
||||
|
||||
<footer className="setup-foot">
|
||||
<div className="setup-actions-secondary">
|
||||
|
|
|
|||
|
|
@ -51,12 +51,6 @@ export function UpdatePanel({
|
|||
<Sparkles size={18} />
|
||||
{t("Software updates", "软件更新")}
|
||||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"Check for a new version, then download and verify it before installing.",
|
||||
"发现新版本后,下载并自动校验,确认无误再安装。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
|
|
@ -197,12 +191,7 @@ export function UpdatePanel({
|
|||
<div className="settings-row">
|
||||
<div>
|
||||
<strong>{t("Check for updates daily", "每天自动检查更新")}</strong>
|
||||
<span>
|
||||
{t(
|
||||
"Checks at most once a day when Squid starts.",
|
||||
"启动 Squid 时每天最多检查一次。",
|
||||
)}
|
||||
</span>
|
||||
<span>{t("At most once a day, when Squid starts.", "每天最多一次,在启动时进行。")}</span>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={autoCheck}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,14 @@ export interface CategoryMeta {
|
|||
tone: Tone;
|
||||
}
|
||||
|
||||
export type Tone = "primary" | "success" | "warning" | "danger" | "neutral";
|
||||
export type Tone =
|
||||
| "primary"
|
||||
| "success"
|
||||
| "warning"
|
||||
| "danger"
|
||||
| "neutral"
|
||||
| "info"
|
||||
| "violet";
|
||||
|
||||
export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
||||
"system-junk": {
|
||||
|
|
@ -148,7 +155,7 @@ export function PageHeader({
|
|||
}: {
|
||||
eyebrow?: string;
|
||||
title: string;
|
||||
description: string;
|
||||
description?: string;
|
||||
actions?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
|
|
@ -156,7 +163,7 @@ export function PageHeader({
|
|||
<div>
|
||||
{eyebrow ? <div className="page-eyebrow">{eyebrow}</div> : null}
|
||||
<h1>{title}</h1>
|
||||
<p>{description}</p>
|
||||
{description ? <p>{description}</p> : null}
|
||||
</div>
|
||||
{actions ? <div className="page-header-actions">{actions}</div> : null}
|
||||
</header>
|
||||
|
|
@ -256,6 +263,125 @@ export function Checkbox({
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of choices that opens as one of ours.
|
||||
*
|
||||
* The native `<select>` is not used anywhere: its popup is drawn by the
|
||||
* operating system, so it ignores this app's type scale and colours and looks
|
||||
* like a different program. The trigger keeps the box the native control had —
|
||||
* same height, border and type scale — and only the popup is new, drawn with the
|
||||
* shell a panel uses, so the two agree in every theme.
|
||||
*/
|
||||
export function Select<T extends string | number>({
|
||||
value,
|
||||
options,
|
||||
onChange,
|
||||
label,
|
||||
disabled = false,
|
||||
align = "end",
|
||||
}: {
|
||||
value: T;
|
||||
options: { value: T; label: string }[];
|
||||
onChange: (next: T) => void;
|
||||
label: string;
|
||||
disabled?: boolean;
|
||||
align?: "start" | "end";
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [active, setActive] = useState(0);
|
||||
const root = useRef<HTMLDivElement>(null);
|
||||
const trigger = useRef<HTMLButtonElement>(null);
|
||||
const current = options.findIndex((option) => option.value === value);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const onPointer = (event: PointerEvent) => {
|
||||
if (!root.current?.contains(event.target as Node)) setOpen(false);
|
||||
};
|
||||
document.addEventListener("pointerdown", onPointer);
|
||||
return () => document.removeEventListener("pointerdown", onPointer);
|
||||
}, [open]);
|
||||
|
||||
const choose = (index: number) => {
|
||||
const option = options[index];
|
||||
if (option) onChange(option.value);
|
||||
setOpen(false);
|
||||
trigger.current?.focus();
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="select"
|
||||
ref={root}
|
||||
onKeyDown={(event) => {
|
||||
if (!open) {
|
||||
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
setActive(current < 0 ? 0 : current);
|
||||
setOpen(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.key === "Escape") {
|
||||
setOpen(false);
|
||||
trigger.current?.focus();
|
||||
} else if (event.key === "ArrowDown") {
|
||||
event.preventDefault();
|
||||
setActive((index) => (index + 1) % options.length);
|
||||
} else if (event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
setActive((index) => (index - 1 + options.length) % options.length);
|
||||
} else if (event.key === "Enter" || event.key === " ") {
|
||||
event.preventDefault();
|
||||
choose(active);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<button
|
||||
ref={trigger}
|
||||
type="button"
|
||||
className="select-trigger"
|
||||
aria-haspopup="listbox"
|
||||
aria-expanded={open}
|
||||
aria-label={label}
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
setActive(current < 0 ? 0 : current);
|
||||
setOpen((open) => !open);
|
||||
}}
|
||||
>
|
||||
<span>{current < 0 ? label : options[current].label}</span>
|
||||
<ChevronDown size={14} className={open ? "is-open" : ""} />
|
||||
</button>
|
||||
{open ? (
|
||||
<ul
|
||||
className={`select-menu is-${align}`}
|
||||
role="listbox"
|
||||
aria-label={label}
|
||||
>
|
||||
{options.map((option, index) => (
|
||||
<li key={String(option.value)}>
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
aria-selected={option.value === value}
|
||||
className={`${index === active ? "is-active" : ""} ${
|
||||
option.value === value ? "is-current" : ""
|
||||
}`}
|
||||
onMouseEnter={() => setActive(index)}
|
||||
onClick={() => choose(index)}
|
||||
>
|
||||
{option.label}
|
||||
{option.value === value ? <Check size={13} strokeWidth={2.5} /> : null}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ProgressCard({
|
||||
progress,
|
||||
title,
|
||||
|
|
@ -562,14 +688,14 @@ export function EmptyState({
|
|||
}: {
|
||||
icon: ReactNode;
|
||||
title: string;
|
||||
description: string;
|
||||
description?: string;
|
||||
action?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="empty-state">
|
||||
<div className="empty-icon">{icon}</div>
|
||||
<h2>{title}</h2>
|
||||
<p>{description}</p>
|
||||
{description ? <p>{description}</p> : null}
|
||||
{action}
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ export const api = {
|
|||
purgeDelete: (jobId: string, scanId: string, selected: number[], mode: DeleteMode) =>
|
||||
invoke<DeleteResult>("purge_delete", { jobId, scanId, selected, mode }),
|
||||
appsScan: (jobId: string) => invoke<AppsResult>("apps_scan", { jobId }),
|
||||
appIcon: (appKey: string) => invoke<string | null>("app_icon", { appKey }),
|
||||
appPlan: (jobId: string, appKey: string) => invoke<PlanResult>("app_plan", { jobId, appKey }),
|
||||
appUninstall: (jobId: string, planId: string, selected: number[], mode: DeleteMode) =>
|
||||
invoke<DeleteResult>("app_uninstall", { jobId, planId, selected, mode }),
|
||||
|
|
@ -118,6 +119,7 @@ export const api = {
|
|||
startupItems: () => invoke<StartupView>("startup_items"),
|
||||
startupSetEnabled: (id: string, enabled: boolean) =>
|
||||
invoke<StartupChange>("startup_set_enabled", { id, enabled }),
|
||||
openStartupSettings: () => invoke<void>("open_startup_settings"),
|
||||
processInventory: (withTrust = true) =>
|
||||
invoke<ProcessRow[]>("process_inventory", { withTrust }),
|
||||
processDetail: (pid: number) => invoke<ProcessDetail>("process_detail", { pid }),
|
||||
|
|
|
|||
|
|
@ -12,6 +12,21 @@ export function formatBytes(value: number, fractionDigits = 1): string {
|
|||
return `${remaining.toFixed(digits)} ${units[unit]}`;
|
||||
}
|
||||
|
||||
/** RAM is sold in binary units, so 16 GB should not read as 17.2 GB. */
|
||||
export function formatMemoryBytes(value: number, fractionDigits = 1): string {
|
||||
if (!Number.isFinite(value) || value <= 0) return "0 B";
|
||||
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
||||
let remaining = value;
|
||||
let unit = 0;
|
||||
while (remaining >= 1024 && unit < units.length - 1) {
|
||||
remaining /= 1024;
|
||||
unit += 1;
|
||||
}
|
||||
if (unit === 0) return `${Math.round(remaining)} B`;
|
||||
const digits = remaining >= 100 ? 0 : fractionDigits;
|
||||
return `${remaining.toFixed(digits)} ${units[unit]}`;
|
||||
}
|
||||
|
||||
export function formatBytesExact(value: number): string {
|
||||
if (value <= 0) return "0 B";
|
||||
const formatted = formatBytes(value, 2);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ import {
|
|||
ShieldCheck,
|
||||
Trash2,
|
||||
} from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useI18n } from "../i18n";
|
||||
import { api } from "../lib/api";
|
||||
import { formatBytes, formatCount, shortPath } from "../lib/format";
|
||||
import type { AppInfo, DeleteMode } from "../types";
|
||||
import type { AppsWorkspace } from "../hooks/useAppsWorkspace";
|
||||
|
|
@ -27,6 +28,55 @@ import {
|
|||
useToast,
|
||||
} from "../components/ui";
|
||||
|
||||
const iconCache = new Map<string, string | null>();
|
||||
const iconRequests = new Map<string, Promise<string | null>>();
|
||||
|
||||
function loadAppIcon(app: AppInfo): Promise<string | null> {
|
||||
const key = app.bundle_id || app.path;
|
||||
if (iconCache.has(key)) return Promise.resolve(iconCache.get(key) ?? null);
|
||||
const existing = iconRequests.get(key);
|
||||
if (existing) return existing;
|
||||
const request = api
|
||||
.appIcon(key)
|
||||
.catch(() => null)
|
||||
.then((icon) => {
|
||||
iconCache.set(key, icon);
|
||||
iconRequests.delete(key);
|
||||
return icon;
|
||||
});
|
||||
iconRequests.set(key, request);
|
||||
return request;
|
||||
}
|
||||
|
||||
function AppGlyph({ app, large = false }: { app: AppInfo; large?: boolean }) {
|
||||
const key = app.bundle_id || app.path;
|
||||
const [icon, setIcon] = useState<string | null>(() => iconCache.get(key) ?? null);
|
||||
|
||||
useEffect(() => {
|
||||
if (iconCache.has(key)) {
|
||||
setIcon(iconCache.get(key) ?? null);
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
void loadAppIcon(app).then((next) => {
|
||||
if (!cancelled) setIcon(next);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [app, key]);
|
||||
|
||||
const letter = app.name.trim().slice(0, 1).toUpperCase() || "?";
|
||||
return (
|
||||
<span
|
||||
className={`app-glyph ${large ? "is-large" : ""} ${icon ? "has-icon" : ""}`}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{icon ? <img src={icon} alt="" /> : letter}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function AppRow({
|
||||
app,
|
||||
selected,
|
||||
|
|
@ -37,12 +87,9 @@ function AppRow({
|
|||
onSelect: () => void;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
const letter = app.name.trim().slice(0, 1).toUpperCase() || "?";
|
||||
return (
|
||||
<button className={`app-row ${selected ? "is-selected" : ""}`} onClick={onSelect}>
|
||||
<span className="app-glyph" aria-hidden="true">
|
||||
{letter}
|
||||
</span>
|
||||
<AppGlyph app={app} />
|
||||
<span className="app-row-copy">
|
||||
<span className="app-row-title">
|
||||
<strong>{app.name}</strong>
|
||||
|
|
@ -203,9 +250,7 @@ export function ApplicationsPage({
|
|||
) : workspace.plan ? (
|
||||
<>
|
||||
<div className="plan-head">
|
||||
<span className="app-glyph is-large">
|
||||
{workspace.plan.app.name.slice(0, 1).toUpperCase()}
|
||||
</span>
|
||||
<AppGlyph app={workspace.plan.app} large />
|
||||
<div>
|
||||
<span className="plan-kicker">{t("Removal plan", "卸载方案")}</span>
|
||||
<h2>{workspace.plan.app.name}</h2>
|
||||
|
|
@ -303,12 +348,6 @@ export function ApplicationsPage({
|
|||
<ShieldCheck size={26} />
|
||||
</span>
|
||||
<h2>{t("Choose an application", "选择一个应用")}</h2>
|
||||
<p>
|
||||
{t(
|
||||
"Squid will map its caches, settings and support files before offering to remove anything.",
|
||||
"Squid 会先整理应用的缓存、设置与支持文件,再让您决定是否移除。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</aside>
|
||||
|
|
@ -319,10 +358,6 @@ export function ApplicationsPage({
|
|||
<EmptyState
|
||||
icon={<AppWindow size={29} />}
|
||||
title={t("See what is installed", "查看已安装的应用")}
|
||||
description={t(
|
||||
"Scan your applications to remove an app completely, including files that would otherwise stay behind.",
|
||||
"扫描应用后可连同原本会遗留的文件一起移除。",
|
||||
)}
|
||||
action={
|
||||
<Button
|
||||
variant="primary"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { ScanSearch, Sparkles } from "lucide-react";
|
||||
import { useI18n } from "../i18n";
|
||||
import { formatBytes } from "../lib/format";
|
||||
import type { DeleteMode } from "../types";
|
||||
import type { ScanWorkspace } from "../hooks/useScanWorkspace";
|
||||
import { CleanupInventory } from "../components/CleanupView";
|
||||
|
|
@ -19,7 +18,6 @@ export function CleanupPage({
|
|||
return (
|
||||
<div className="page">
|
||||
<PageHeader
|
||||
eyebrow={t("Cleanup", "清理")}
|
||||
title={t("Clutter, without the guesswork.", "清理垃圾,不靠猜。")}
|
||||
description={t(
|
||||
"Rebuildable caches, old logs and other safe-to-remove files — always reviewed before deletion.",
|
||||
|
|
@ -53,10 +51,6 @@ export function CleanupPage({
|
|||
<EmptyState
|
||||
icon={<Sparkles size={28} />}
|
||||
title={t("Ready when you are", "随时可以开始")}
|
||||
description={t(
|
||||
"Squid checks known cache and log locations, measures what can be reclaimed, and locks anything it cannot remove safely.",
|
||||
"Squid 会检查已知缓存与日志位置,统计可释放空间,并锁定任何无法安全删除的项目。",
|
||||
)}
|
||||
action={
|
||||
<Button
|
||||
variant="primary"
|
||||
|
|
@ -69,16 +63,6 @@ export function CleanupPage({
|
|||
/>
|
||||
) : null}
|
||||
|
||||
{workspace.result && workspace.selectedTotal > 0 ? (
|
||||
<p className="page-footnote">
|
||||
<span>
|
||||
{t(
|
||||
`${formatBytes(workspace.selectedTotal)} selected. Nothing is removed until you confirm.`,
|
||||
`已选择 ${formatBytes(workspace.selectedTotal)},在您确认前不会删除任何内容。`,
|
||||
)}
|
||||
</span>
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ export function HistoryPage() {
|
|||
return (
|
||||
<div className="page history-page">
|
||||
<PageHeader
|
||||
eyebrow={t("History", "历史记录")}
|
||||
title={t("Every change, on the record.", "每一次改动,都有记录。")}
|
||||
description={t(
|
||||
"Review past cleanups and put files back from the Trash when you change your mind.",
|
||||
|
|
@ -140,10 +139,6 @@ export function HistoryPage() {
|
|||
<EmptyState
|
||||
icon={<History size={28} />}
|
||||
title={t("No cleanups yet", "还没有清理记录")}
|
||||
description={t(
|
||||
"Each confirmed cleanup will appear here with its size, result and restore option.",
|
||||
"每次确认的清理都会记录在这里,并提供大小、结果与还原选项。",
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<div className="history-list">
|
||||
|
|
|
|||
|
|
@ -1,117 +1,37 @@
|
|||
import {
|
||||
AlertTriangle,
|
||||
AppWindow,
|
||||
ArrowRight,
|
||||
Boxes,
|
||||
CheckCircle2,
|
||||
ChevronRight,
|
||||
CircleGauge,
|
||||
Cpu,
|
||||
HardDrive,
|
||||
Laptop,
|
||||
MemoryStick,
|
||||
Microchip,
|
||||
Monitor,
|
||||
ScanSearch,
|
||||
ShieldCheck,
|
||||
ShieldQuestion,
|
||||
Sparkles,
|
||||
WandSparkles,
|
||||
} from "lucide-react";
|
||||
import { useI18n } from "../i18n";
|
||||
import { formatBytes, formatCount, percent } from "../lib/format";
|
||||
import type { Bootstrap, SystemSnapshot } from "../types";
|
||||
import {
|
||||
formatBytes,
|
||||
formatCount,
|
||||
formatMemoryBytes,
|
||||
percent,
|
||||
} from "../lib/format";
|
||||
import type { Bootstrap, PageId, SystemSnapshot, Volume } from "../types";
|
||||
import type { ScanWorkspace } from "../hooks/useScanWorkspace";
|
||||
import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace";
|
||||
import type { PageId } from "../types";
|
||||
import { CategorySummary } from "../components/CleanupView";
|
||||
import {
|
||||
Button,
|
||||
Gauge,
|
||||
PageHeader,
|
||||
ProgressCard,
|
||||
SectionTitle,
|
||||
UsageBar,
|
||||
} from "../components/ui";
|
||||
|
||||
/**
|
||||
* The security strip: what protects the machine, and whether anything is waiting.
|
||||
*
|
||||
* It says "not scanned yet" rather than showing a green tick. The whole point of
|
||||
* the roadmap's rule — never render an unknown as healthy — is that a strip which
|
||||
* defaults to calm teaches people to trust a colour that has not earned it.
|
||||
*/
|
||||
function SecurityStrip({
|
||||
security,
|
||||
onNavigate,
|
||||
}: {
|
||||
security: SecurityWorkspace;
|
||||
onNavigate: (page: PageId) => void;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
const status = security.status;
|
||||
if (!status) {
|
||||
return (
|
||||
<section className="security-strip tone-neutral">
|
||||
<span className="metric-icon">
|
||||
<ShieldQuestion size={18} />
|
||||
</span>
|
||||
<span className="quick-copy">
|
||||
<strong>{t("Reading this machine's protection…", "正在读取本机防护状态…")}</strong>
|
||||
</span>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
const scan = status.scan;
|
||||
const alarmed = status.confirmed > 0;
|
||||
const tone = alarmed ? "danger" : scan ? (scan.coverageComplete ? "success" : "warning") : "neutral";
|
||||
const headline = alarmed
|
||||
? t(
|
||||
`${status.confirmed} confirmed finding${status.confirmed === 1 ? "" : "s"} need a decision`,
|
||||
`有 ${status.confirmed} 项已确认发现需要处理`,
|
||||
)
|
||||
: !scan
|
||||
? t("No scan of this machine yet", "尚未进行过扫描")
|
||||
: !scan.coverageComplete
|
||||
? t("Nothing found — but coverage was limited", "未发现威胁,但覆盖范围受限")
|
||||
: t("Nothing outstanding from the last scan", "上次扫描没有待处理项");
|
||||
// One line, in the order someone asks about it: what guards the machine now,
|
||||
// what squid last looked at, and whether it could look at everything.
|
||||
const provider = !status.protection.known
|
||||
? t("protection unknown", "防护状态未知")
|
||||
: status.protection.provider === "xprotect"
|
||||
? "XProtect"
|
||||
: status.protection.productName || "Antivirus";
|
||||
const detail = scan
|
||||
? t(
|
||||
`${provider} · ${formatCount(scan.examined)} files checked · ${
|
||||
scan.coverageComplete ? "full coverage" : "coverage limited"
|
||||
}`,
|
||||
`${provider} · 已检查 ${formatCount(scan.examined)} 个文件 · ${
|
||||
scan.coverageComplete ? "覆盖完整" : "覆盖受限"
|
||||
}`,
|
||||
)
|
||||
: t(
|
||||
`${provider} · quick scan covers login items, apps and downloads`,
|
||||
`${provider} · 快速扫描覆盖登录项、应用与下载目录`,
|
||||
);
|
||||
|
||||
return (
|
||||
<section className={`security-strip tone-${tone}`}>
|
||||
<span className="metric-icon">
|
||||
{alarmed ? <AlertTriangle size={18} /> : scan ? <CheckCircle2 size={18} /> : <ShieldQuestion size={18} />}
|
||||
</span>
|
||||
<div className="quick-copy">
|
||||
<strong>{headline}</strong>
|
||||
<small>{detail}</small>
|
||||
</div>
|
||||
<Button
|
||||
variant={alarmed ? "danger" : "ghost"}
|
||||
size="sm"
|
||||
icon={<ArrowRight size={14} />}
|
||||
onClick={() => onNavigate("security")}
|
||||
>
|
||||
{alarmed ? t("Review findings", "查看发现") : t("Open security", "打开安全")}
|
||||
</Button>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function greeting(lang: "zh" | "en"): string {
|
||||
const hour = new Date().getHours();
|
||||
if (lang === "zh") {
|
||||
|
|
@ -125,17 +45,80 @@ function greeting(lang: "zh" | "en"): string {
|
|||
return "Good evening";
|
||||
}
|
||||
|
||||
function coreLabel(snapshot: SystemSnapshot | null, t: (en: string, zh: string) => string) {
|
||||
if (!snapshot) return t("Reading processor…", "正在读取处理器…");
|
||||
const { physical_cores: physical, logical_cores: logical } = snapshot.cpu;
|
||||
if (physical === logical) {
|
||||
return t(`${physical} cores`, `${physical} 核`);
|
||||
}
|
||||
return t(`${physical} cores / ${logical} threads`, `${physical} 核 / ${logical} 线程`);
|
||||
}
|
||||
|
||||
function machineRows(
|
||||
bootstrap: Bootstrap,
|
||||
snapshot: SystemSnapshot | null,
|
||||
volume: Volume | null,
|
||||
t: (en: string, zh: string) => string,
|
||||
) {
|
||||
const model = bootstrap.hardware.split(" · ")[0]?.trim() || bootstrap.hardware;
|
||||
const rows = [
|
||||
{
|
||||
key: "os",
|
||||
icon: Monitor,
|
||||
label: t("Operating system", "操作系统"),
|
||||
value: bootstrap.osVersion || bootstrap.osName,
|
||||
},
|
||||
{
|
||||
key: "model",
|
||||
icon: Laptop,
|
||||
label: t("Computer", "本机型号"),
|
||||
value: model,
|
||||
},
|
||||
{
|
||||
key: "cpu",
|
||||
icon: Cpu,
|
||||
label: t("Processor", "处理器"),
|
||||
value: snapshot
|
||||
? snapshot.cpu.brand || t("Unknown processor", "未知处理器")
|
||||
: t("Reading processor…", "正在读取处理器…"),
|
||||
},
|
||||
{
|
||||
key: "memory",
|
||||
icon: MemoryStick,
|
||||
label: t("Memory", "内存"),
|
||||
value: snapshot
|
||||
? formatMemoryBytes(snapshot.memory.total)
|
||||
: t("Reading memory…", "正在读取内存…"),
|
||||
},
|
||||
{
|
||||
key: "disk",
|
||||
icon: HardDrive,
|
||||
label: t("Primary disk", "主硬盘"),
|
||||
value: volume
|
||||
? `${volume.name || volume.mount_point} · ${formatBytes(volume.total, 0)} · ${volume.filesystem.toUpperCase()}`
|
||||
: t("Reading disks…", "正在读取磁盘…"),
|
||||
},
|
||||
];
|
||||
if (snapshot?.host.gpu) {
|
||||
rows.push({
|
||||
key: "gpu",
|
||||
icon: Microchip,
|
||||
label: t("Graphics", "显卡"),
|
||||
value: snapshot.host.gpu,
|
||||
});
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
export function OverviewPage({
|
||||
bootstrap,
|
||||
snapshot,
|
||||
cleanup,
|
||||
security,
|
||||
onNavigate,
|
||||
}: {
|
||||
bootstrap: Bootstrap;
|
||||
snapshot: SystemSnapshot | null;
|
||||
cleanup: ScanWorkspace;
|
||||
security: SecurityWorkspace;
|
||||
onNavigate: (page: PageId) => void;
|
||||
}) {
|
||||
const { t, lang } = useI18n();
|
||||
|
|
@ -151,6 +134,11 @@ export function OverviewPage({
|
|||
.filter((item) => !item.lock)
|
||||
.reduce((sum, item) => sum + item.onDisk, 0)
|
||||
: 0;
|
||||
const visibleVolumes = (snapshot?.volumes ?? []).slice(0, 2);
|
||||
const startScan = () => {
|
||||
if (cleanup.result) onNavigate("cleanup");
|
||||
else void cleanup.runScan();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="page overview-page">
|
||||
|
|
@ -158,38 +146,26 @@ export function OverviewPage({
|
|||
eyebrow={`${greeting(lang)} · ${bootstrap.osName}`}
|
||||
title={t("Your computer, at its best.", "让电脑始终保持在最佳状态。")}
|
||||
description={t(
|
||||
"Cleaning and security are two different scans here — one frees space, the other checks for threats.",
|
||||
"清理与安全是两种不同的扫描:一个释放空间,另一个检查威胁。",
|
||||
"One safe scan tidies clutter, space and everyday performance.",
|
||||
"一次安全扫描,整理垃圾、空间与日常性能。",
|
||||
)}
|
||||
actions={
|
||||
<Button
|
||||
variant="primary"
|
||||
size="lg"
|
||||
icon={<Sparkles size={17} />}
|
||||
onClick={() => {
|
||||
if (cleanup.result) onNavigate("cleanup");
|
||||
else void cleanup.runScan();
|
||||
}}
|
||||
onClick={startScan}
|
||||
disabled={cleanup.scanning}
|
||||
>
|
||||
{cleanup.result
|
||||
? t("Review cleanup scan", "查看清理结果")
|
||||
: t("Cleanup scan", "清理扫描")}
|
||||
{cleanup.scanning
|
||||
? t("Scanning…", "扫描中…")
|
||||
: cleanup.result
|
||||
? t("Review smart scan", "查看智能扫描")
|
||||
: t("Smart scan", "智能扫描")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
{security.scanning ? (
|
||||
<ProgressCard
|
||||
progress={security.progress}
|
||||
title={t("Scanning for malware", "正在扫描恶意软件")}
|
||||
compact
|
||||
onCancel={() => void security.cancel()}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<SecurityStrip security={security} onNavigate={onNavigate} />
|
||||
|
||||
<section className="overview-hero">
|
||||
<div className="overview-hero-copy">
|
||||
<div className="hero-kicker">
|
||||
|
|
@ -219,35 +195,19 @@ export function OverviewPage({
|
|||
<Button
|
||||
variant="primary"
|
||||
icon={cleanup.result ? <ArrowRight size={16} /> : <ScanSearch size={16} />}
|
||||
onClick={() => {
|
||||
if (cleanup.result) onNavigate("cleanup");
|
||||
else void cleanup.runScan();
|
||||
}}
|
||||
onClick={startScan}
|
||||
disabled={cleanup.scanning}
|
||||
>
|
||||
{cleanup.result
|
||||
? t("Choose what to clean", "选择清理项目")
|
||||
: t("Start a cleanup scan", "开始清理扫描")}
|
||||
: t("Start smart scan", "开始智能扫描")}
|
||||
</Button>
|
||||
{/* Two scans, two names, one screen. Merging them would let a user
|
||||
believe the clutter sweep also looked for threats, and it does
|
||||
not; this is the line the roadmap drew on purpose. */}
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon={<ShieldCheck size={16} />}
|
||||
onClick={() => void security.start("quick")}
|
||||
disabled={security.scanning}
|
||||
>
|
||||
{security.scanning
|
||||
? t("Security scan…", "安全扫描中…")
|
||||
: t("Quick security scan", "安全快速扫描")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
icon={<CircleGauge size={16} />}
|
||||
onClick={() => onNavigate("system")}
|
||||
>
|
||||
{t("Live system", "实时监控")}
|
||||
{t("Live monitor", "实时监控")}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="hero-assurances">
|
||||
|
|
@ -257,25 +217,23 @@ export function OverviewPage({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="overview-gauge-wrap">
|
||||
<div className="gauge-halo" />
|
||||
<Gauge value={usedPercent} size={226} stroke={16} tone={usedPercent > 85 ? "danger" : "primary"}>
|
||||
<span className="gauge-caption">{t("Disk in use", "磁盘已用")}</span>
|
||||
<strong className="gauge-number">{Math.round(usedPercent)}%</strong>
|
||||
<span className="gauge-sub">
|
||||
{volume
|
||||
? t(
|
||||
`${formatBytes(volume.free)} free`,
|
||||
`剩余 ${formatBytes(volume.free)}`,
|
||||
)
|
||||
: t("Reading volume…", "正在读取磁盘…")}
|
||||
</span>
|
||||
</Gauge>
|
||||
<div className="hero-device">
|
||||
<HardDrive size={14} />
|
||||
<span>{bootstrap.hardware}</span>
|
||||
<aside className="overview-machine">
|
||||
<span className="machine-title">{t("This machine", "本机配置")}</span>
|
||||
<div className="machine-list">
|
||||
{machineRows(bootstrap, snapshot, volume, t).map((row) => {
|
||||
const Icon = row.icon;
|
||||
return (
|
||||
<div className="machine-row" key={row.key}>
|
||||
<span className="machine-icon">
|
||||
<Icon size={15} />
|
||||
</span>
|
||||
<span className="machine-label">{row.label}</span>
|
||||
<strong title={row.value}>{row.value}</strong>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
{cleanup.scanning ? (
|
||||
|
|
@ -286,14 +244,118 @@ export function OverviewPage({
|
|||
/>
|
||||
) : null}
|
||||
|
||||
<section className="overview-metrics">
|
||||
<article className="metric-panel">
|
||||
<div className="metric-panel-head">
|
||||
<span className="metric-icon tone-primary">
|
||||
<Cpu size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<strong>{t("Processor", "处理器")}</strong>
|
||||
<span>{coreLabel(snapshot, t)}</span>
|
||||
</div>
|
||||
<b>{Math.round(snapshot?.cpu.total ?? 0)}%</b>
|
||||
</div>
|
||||
<UsageBar used={snapshot?.cpu.total ?? 0} total={100} tone="primary" />
|
||||
<small>
|
||||
{snapshot?.cpu.brand || t("Processor details unavailable", "暂无处理器信息")}
|
||||
</small>
|
||||
</article>
|
||||
|
||||
<article className="metric-panel">
|
||||
<div className="metric-panel-head">
|
||||
<span className="metric-icon tone-violet">
|
||||
<MemoryStick size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<strong>{t("Memory", "内存")}</strong>
|
||||
<span>
|
||||
{snapshot
|
||||
? `${formatMemoryBytes(snapshot.memory.used)} / ${formatMemoryBytes(
|
||||
snapshot.memory.total,
|
||||
)}`
|
||||
: t("Sampling…", "正在采样…")}
|
||||
</span>
|
||||
</div>
|
||||
<b>{Math.round(memoryPercent)}%</b>
|
||||
</div>
|
||||
<UsageBar used={memoryPercent} total={100} tone="violet" />
|
||||
<small>
|
||||
{snapshot?.memory.compressed !== null &&
|
||||
snapshot?.memory.compressed !== undefined
|
||||
? t(
|
||||
`Compressed ${formatMemoryBytes(snapshot.memory.compressed)} · Wired ${formatMemoryBytes(
|
||||
snapshot.memory.wired ?? 0,
|
||||
)}`,
|
||||
`压缩 ${formatMemoryBytes(snapshot.memory.compressed)} · 固定 ${formatMemoryBytes(
|
||||
snapshot.memory.wired ?? 0,
|
||||
)}`,
|
||||
)
|
||||
: snapshot
|
||||
? t(
|
||||
`${formatCount(snapshot.processes)} processes running`,
|
||||
`${formatCount(snapshot.processes)} 个进程正在运行`,
|
||||
)
|
||||
: t("Reading activity", "正在读取活动")}
|
||||
</small>
|
||||
</article>
|
||||
|
||||
<article className="metric-panel overview-storage-card">
|
||||
<div className="metric-panel-head">
|
||||
<span className="metric-icon tone-success">
|
||||
<HardDrive size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<strong>{t("Storage", "存储空间")}</strong>
|
||||
<span>
|
||||
{snapshot
|
||||
? t(
|
||||
`${formatCount(snapshot.volumes.length)} partitions`,
|
||||
`${formatCount(snapshot.volumes.length)} 个分区`,
|
||||
)
|
||||
: t("Reading volume…", "正在读取磁盘…")}
|
||||
</span>
|
||||
</div>
|
||||
<b>{Math.round(usedPercent)}%</b>
|
||||
</div>
|
||||
{visibleVolumes.length > 0 ? (
|
||||
<div className="storage-volume-list">
|
||||
{visibleVolumes.map((candidate) => {
|
||||
const candidateUsed = candidate.total - candidate.free;
|
||||
const candidatePercent = percent(candidateUsed, candidate.total);
|
||||
return (
|
||||
<div className="storage-volume" key={candidate.mount_point}>
|
||||
<div className="storage-volume-head">
|
||||
<strong>
|
||||
{candidate.name || candidate.mount_point}
|
||||
{candidate.is_root ? ` · ${t("System", "系统")}` : ""}
|
||||
</strong>
|
||||
<span>
|
||||
{t(
|
||||
`Total ${formatBytes(candidate.total)} · ${formatBytes(candidate.free)} free`,
|
||||
`总 ${formatBytes(candidate.total)} · 可用 ${formatBytes(candidate.free)}`,
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<UsageBar
|
||||
used={candidateUsed}
|
||||
total={candidate.total}
|
||||
tone={candidatePercent > 88 ? "danger" : "success"}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<UsageBar used={0} total={100} tone="success" />
|
||||
)}
|
||||
</article>
|
||||
</section>
|
||||
|
||||
{cleanup.result && !cleanup.scanning ? (
|
||||
<section className="overview-found">
|
||||
<SectionTitle
|
||||
title={t("What the scan found", "扫描发现")}
|
||||
subtitle={t(
|
||||
"Uncheck anything you want to keep.",
|
||||
"不想清理的项目可以随时取消勾选。",
|
||||
)}
|
||||
action={
|
||||
<Button variant="ghost" size="sm" onClick={() => onNavigate("cleanup")}>
|
||||
{t("Open cleanup", "打开清理")}
|
||||
|
|
@ -316,17 +378,7 @@ export function OverviewPage({
|
|||
subtitle={t("The right tool for the next five minutes.", "用几分钟完成最常用的事。")}
|
||||
/>
|
||||
<div className="quick-grid">
|
||||
<button className="quick-card tone-primary" onClick={() => onNavigate("security")}>
|
||||
<span className="quick-icon">
|
||||
<ShieldCheck size={22} />
|
||||
</span>
|
||||
<span className="quick-copy">
|
||||
<strong>{t("Security", "安全")}</strong>
|
||||
<small>{t("Scan, review findings, quarantine", "扫描、查看发现、隔离")}</small>
|
||||
</span>
|
||||
<ChevronRight size={17} />
|
||||
</button>
|
||||
<button className="quick-card tone-primary" onClick={() => onNavigate("applications")}>
|
||||
<button className="quick-card tone-info" onClick={() => onNavigate("applications")}>
|
||||
<span className="quick-icon">
|
||||
<AppWindow size={22} />
|
||||
</span>
|
||||
|
|
@ -336,7 +388,7 @@ export function OverviewPage({
|
|||
</span>
|
||||
<ChevronRight size={17} />
|
||||
</button>
|
||||
<button className="quick-card tone-neutral" onClick={() => onNavigate("storage")}>
|
||||
<button className="quick-card tone-violet" onClick={() => onNavigate("storage")}>
|
||||
<span className="quick-icon">
|
||||
<Boxes size={22} />
|
||||
</span>
|
||||
|
|
@ -346,7 +398,7 @@ export function OverviewPage({
|
|||
</span>
|
||||
<ChevronRight size={17} />
|
||||
</button>
|
||||
<button className="quick-card tone-primary" onClick={() => onNavigate("purge")}>
|
||||
<button className="quick-card tone-violet" onClick={() => onNavigate("purge")}>
|
||||
<span className="quick-icon">
|
||||
<Sparkles size={22} />
|
||||
</span>
|
||||
|
|
@ -358,82 +410,6 @@ export function OverviewPage({
|
|||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="overview-metrics">
|
||||
<div className="metric-panel">
|
||||
<div className="metric-panel-head">
|
||||
<span className="metric-icon tone-primary">
|
||||
<CircleGauge size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<strong>{t("Processor", "处理器")}</strong>
|
||||
<span>
|
||||
{snapshot
|
||||
? `${snapshot.cpu.logical_cores} ${t("cores", "核心")}`
|
||||
: t("Sampling…", "正在采样…")}
|
||||
</span>
|
||||
</div>
|
||||
<b>{Math.round(snapshot?.cpu.total ?? 0)}%</b>
|
||||
</div>
|
||||
<UsageBar used={snapshot?.cpu.total ?? 0} total={100} tone="primary" />
|
||||
<small>
|
||||
{snapshot?.cpu.brand || t("Processor details unavailable", "暂无处理器信息")}
|
||||
</small>
|
||||
</div>
|
||||
<div className="metric-panel">
|
||||
<div className="metric-panel-head">
|
||||
<span className="metric-icon tone-neutral">
|
||||
<Boxes size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<strong>{t("Memory", "内存")}</strong>
|
||||
<span>
|
||||
{snapshot
|
||||
? `${formatBytes(snapshot.memory.used)} / ${formatBytes(
|
||||
snapshot.memory.total,
|
||||
)}`
|
||||
: t("Sampling…", "正在采样…")}
|
||||
</span>
|
||||
</div>
|
||||
<b>{Math.round(memoryPercent)}%</b>
|
||||
</div>
|
||||
<UsageBar used={memoryPercent} total={100} tone="primary" />
|
||||
<small>
|
||||
{snapshot
|
||||
? t(
|
||||
`${formatCount(snapshot.processes)} processes running`,
|
||||
`${formatCount(snapshot.processes)} 个进程正在运行`,
|
||||
)
|
||||
: t("Reading activity", "正在读取活动")}
|
||||
</small>
|
||||
</div>
|
||||
<div className="metric-panel">
|
||||
<div className="metric-panel-head">
|
||||
<span
|
||||
className={`metric-icon ${
|
||||
usedPercent > 85 ? "tone-warning" : "tone-success"
|
||||
}`}
|
||||
>
|
||||
<HardDrive size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<strong>{t("Storage", "存储空间")}</strong>
|
||||
<span>
|
||||
{volume
|
||||
? `${formatBytes(volume.free)} ${t("available", "可用")}`
|
||||
: t("Reading volume…", "正在读取磁盘…")}
|
||||
</span>
|
||||
</div>
|
||||
<b>{Math.round(usedPercent)}%</b>
|
||||
</div>
|
||||
<UsageBar
|
||||
used={usedPercent}
|
||||
total={100}
|
||||
tone={usedPercent > 85 ? "danger" : "success"}
|
||||
/>
|
||||
<small>{volume?.mount_point || bootstrap.configPath}</small>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ export function PurgePage({
|
|||
return (
|
||||
<div className="page">
|
||||
<PageHeader
|
||||
eyebrow={t("Deep Clean", "深度清理")}
|
||||
title={t("Find the space normal cleaning misses.", "找到普通清理遗漏的空间。")}
|
||||
description={t(
|
||||
"Search projects for rebuildable build folders and dependency caches. Git history and source files are never selected.",
|
||||
|
|
@ -69,12 +68,6 @@ export function PurgePage({
|
|||
)}
|
||||
rows={3}
|
||||
/>
|
||||
<span className="field-help">
|
||||
{t(
|
||||
"Squid uses these as search roots, not as delete targets.",
|
||||
"这些路径只用于查找,不会作为删除目标。",
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="deep-option-side">
|
||||
<label className="field-label" htmlFor="purge-age">
|
||||
|
|
|
|||
|
|
@ -134,7 +134,6 @@ export function SecurityPage({
|
|||
return (
|
||||
<div className="page is-stacked">
|
||||
<PageHeader
|
||||
eyebrow={t("Security", "安全")}
|
||||
title={t("Checking this machine…", "正在检查这台电脑…")}
|
||||
description={t(
|
||||
"Reading what protects the machine and what ran at the last login.",
|
||||
|
|
@ -149,7 +148,6 @@ export function SecurityPage({
|
|||
return (
|
||||
<div className="page is-stacked">
|
||||
<PageHeader
|
||||
eyebrow={t("Security", "安全")}
|
||||
title={
|
||||
scan
|
||||
? t("The last scan, and what to do about it.", "上次扫描的结果,以及下一步。")
|
||||
|
|
@ -216,11 +214,6 @@ export function SecurityPage({
|
|||
<section className="panel">
|
||||
<SectionTitle
|
||||
title={t("Findings", "发现")}
|
||||
subtitle={
|
||||
scan
|
||||
? undefined
|
||||
: t("Nothing has been scanned on this machine yet.", "这台电脑还没有扫描记录。")
|
||||
}
|
||||
action={
|
||||
scan ? (
|
||||
<div className="chip-row" role="tablist">
|
||||
|
|
@ -252,10 +245,6 @@ export function SecurityPage({
|
|||
<EmptyState
|
||||
icon={<ShieldQuestion size={26} />}
|
||||
title={t("No scan yet", "尚未扫描")}
|
||||
description={t(
|
||||
"A quick scan covers login items, applications, browser extensions and downloads.",
|
||||
"快速扫描会检查登录项、应用程序、浏览器扩展与下载目录。",
|
||||
)}
|
||||
/>
|
||||
) : findings.length === 0 ? (
|
||||
<EmptyState
|
||||
|
|
@ -268,8 +257,8 @@ export function SecurityPage({
|
|||
description={
|
||||
scan.coverageComplete
|
||||
? t(
|
||||
"This is not a promise about files a scan never opened — the coverage card lists those.",
|
||||
"这不代表未打开的文件也是安全的——未检查范围见上方覆盖说明。",
|
||||
"Files the scan never opened are listed in the coverage card above.",
|
||||
"未检查的范围见上方覆盖说明。",
|
||||
)
|
||||
: t(
|
||||
"Part of this scan could not be read. See the coverage card above.",
|
||||
|
|
@ -725,7 +714,6 @@ function FindingRow({
|
|||
return (
|
||||
<li className={`item-row is-${meta.tone} ${finding.quarantined ? "is-handled" : ""}`}>
|
||||
<button className="item-main" onClick={onOpen}>
|
||||
<span className={`level-dot is-${meta.tone}`} />
|
||||
<span className="item-copy">
|
||||
<strong>{finding.name}</strong>
|
||||
<small title={finding.displayPath ?? undefined}>
|
||||
|
|
@ -926,7 +914,6 @@ function ActivityCard({
|
|||
<section className="panel">
|
||||
<SectionTitle
|
||||
title={t("Recent security activity", "最近的安全活动")}
|
||||
subtitle={t("Scans, quarantines and startup changes.", "本机的扫描、隔离与启动项修改。")}
|
||||
/>
|
||||
<ul className="activity-list">
|
||||
{activity.slice(0, 10).map((entry, index) => (
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import {
|
||||
AppWindow,
|
||||
Check,
|
||||
FileCog,
|
||||
FolderClock,
|
||||
|
|
@ -34,6 +33,7 @@ import {
|
|||
Button,
|
||||
InlineError,
|
||||
PageHeader,
|
||||
Select,
|
||||
Toggle,
|
||||
useToast,
|
||||
} from "../components/ui";
|
||||
|
|
@ -176,7 +176,6 @@ export function SettingsPage({
|
|||
return (
|
||||
<div className="page settings-page">
|
||||
<PageHeader
|
||||
eyebrow={t("Settings", "设置")}
|
||||
title={t("Make Squid yours.", "按您的方式使用 Squid。")}
|
||||
description={t(
|
||||
"Language, deletion behaviour, protected locations and updates all live here.",
|
||||
|
|
@ -193,12 +192,6 @@ export function SettingsPage({
|
|||
<Languages size={18} />
|
||||
{t("Language & appearance", "语言与外观")}
|
||||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"The current system language is selected by default.",
|
||||
"默认选择当前系统语言。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="language-picker">
|
||||
|
|
@ -229,12 +222,6 @@ export function SettingsPage({
|
|||
<LockKeyhole size={18} />
|
||||
{t("System permissions", "系统权限")}
|
||||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"Squid works without this access; protected app data is simply skipped.",
|
||||
"未授权时 Squid 仍可正常工作,只会跳过受保护的 App 数据。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="permission-check-row">
|
||||
|
|
@ -304,12 +291,6 @@ export function SettingsPage({
|
|||
<Power size={18} />
|
||||
{t("Startup", "启动")}
|
||||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"Choose whether Squid starts automatically after you sign in.",
|
||||
"选择登录电脑后是否自动启动 Squid。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="settings-row is-first">
|
||||
|
|
@ -317,8 +298,8 @@ export function SettingsPage({
|
|||
<strong>{t("Launch Squid at login", "登录时启动 Squid")}</strong>
|
||||
<span>
|
||||
{t(
|
||||
"Only Squid itself. To manage what else starts at login, use the Startup items page.",
|
||||
"只针对 Squid 本身。要管理其他登录时启动的程序,请前往启动项页面。",
|
||||
"Only Squid itself; other apps are managed under Startup items.",
|
||||
"仅 Squid 自身,其他程序请到启动项页面管理。",
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -342,12 +323,6 @@ export function SettingsPage({
|
|||
<Trash2 size={18} />
|
||||
{t("Deletion safety", "删除安全")}
|
||||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"This is the default shown in every confirmation. You can still choose per cleanup.",
|
||||
"这是每次确认时的默认选项,单次清理仍可另行选择。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="delete-mode-cards">
|
||||
|
|
@ -411,24 +386,13 @@ export function SettingsPage({
|
|||
<div className="settings-row">
|
||||
<div>
|
||||
<strong>{t("History records to keep", "保留历史记录数量")}</strong>
|
||||
<span>
|
||||
{t(
|
||||
"Older cleanup records are pruned after this many sessions.",
|
||||
"超过此数量后,较早的清理记录会被移除。",
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<select
|
||||
className="settings-select"
|
||||
<Select
|
||||
value={settings.historyKeep}
|
||||
onChange={(event) => void save({ historyKeep: Number(event.target.value) })}
|
||||
>
|
||||
{[20, 60, 100, 200, 500].map((value) => (
|
||||
<option value={value} key={value}>
|
||||
{value}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
label={t("History records to keep", "保留历史记录数量")}
|
||||
options={[20, 60, 100, 200, 500].map((value) => ({ value, label: String(value) }))}
|
||||
onChange={(next) => void save({ historyKeep: next })}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
@ -441,8 +405,8 @@ export function SettingsPage({
|
|||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"Squid never deletes anything inside these folders, even if a cleanup rule matches. This list does not stop the malware scan from reporting a finding inside them.",
|
||||
"即使清理规则匹配,Squid 也绝不会删除这些文件夹中的内容。该列表不会阻止恶意软件扫描在其中报告发现。",
|
||||
"Never deleted here, even when a cleanup rule matches. The malware scan still reports inside them.",
|
||||
"这里的内容绝不会被删除。恶意软件扫描仍会检查其中的发现。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -572,16 +536,6 @@ export function SettingsPage({
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer className="settings-footer">
|
||||
<AppWindow size={15} />
|
||||
<span>
|
||||
{t(
|
||||
"Squid keeps scans, policy checks and cleanup history on this computer.",
|
||||
"Squid 的扫描、安全策略校验与清理历史均在这台电脑上完成。",
|
||||
)}
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
AlertTriangle,
|
||||
ChevronDown,
|
||||
ChevronRight,
|
||||
ExternalLink,
|
||||
FileSearch,
|
||||
|
|
@ -7,27 +8,32 @@ import {
|
|||
Lock,
|
||||
RefreshCw,
|
||||
Search,
|
||||
Settings2,
|
||||
ShieldAlert,
|
||||
ToggleLeft,
|
||||
ToggleRight,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useI18n } from "../i18n";
|
||||
import { api } from "../lib/api";
|
||||
import { formatDate, messageFrom, shortPath } from "../lib/format";
|
||||
import type { StartupItem, StartupRisk, StartupSource } from "../types";
|
||||
import { formatDate, formatCount, messageFrom, shortPath } from "../lib/format";
|
||||
import type {
|
||||
StartupCategory,
|
||||
StartupItem,
|
||||
StartupLock,
|
||||
StartupRisk,
|
||||
StartupSource,
|
||||
} from "../types";
|
||||
import type { SecurityWorkspace } from "../hooks/useSecurityWorkspace";
|
||||
import type { StartupWorkspace } from "../hooks/useStartupWorkspace";
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
ConfirmDialog,
|
||||
EmptyState,
|
||||
InlineError,
|
||||
Modal,
|
||||
PageHeader,
|
||||
SectionTitle,
|
||||
Select,
|
||||
Toggle,
|
||||
useToast,
|
||||
} from "../components/ui";
|
||||
|
|
@ -46,28 +52,46 @@ const RISK_LABEL: Record<StartupRisk, [string, string]> = {
|
|||
"missing-target": ["Target is gone", "目标已不存在"],
|
||||
"in-temp-dir": ["Runs from a temp folder", "位于临时目录"],
|
||||
unsigned: ["No usable signature", "无可用签名"],
|
||||
"signature-unreadable": ["Signature could not be read", "无法读取签名"],
|
||||
"script-interpreter": ["Started through a script", "经由脚本启动"],
|
||||
"recently-created": ["Created recently", "最近创建"],
|
||||
"recently-created": ["Added recently", "最近添加"],
|
||||
"hidden-entry": ["Hidden entry", "隐藏条目"],
|
||||
"hidden-home-directory": ["Runs from a dot-folder", "位于隐藏目录"],
|
||||
};
|
||||
|
||||
type ScopeFilter = "all" | "user" | "system";
|
||||
const LOCK_LABEL: Record<StartupLock, [string, string]> = {
|
||||
"operating-system": ["Part of the operating system", "系统自带条目"],
|
||||
"needs-authorisation": ["Needs an administrator", "需要管理员权限"],
|
||||
"not-writable": ["Not writable by this user", "当前用户不可写"],
|
||||
"managed-by-system-settings": ["Managed in System Settings", "由系统设置管理"],
|
||||
"not-managed": ["Read-only in this release", "本版本只读"],
|
||||
};
|
||||
|
||||
type Tab = StartupCategory;
|
||||
type Scope = "all" | "user" | "system";
|
||||
|
||||
/// Where to reveal an entry: the program it runs if that exists, otherwise the
|
||||
/// plist, key or task file that declares it. A login item whose target is gone can
|
||||
/// still be shown by its declaration.
|
||||
///
|
||||
/// An id is only a place when it looks like one. macOS login items are named rather
|
||||
/// than filed, and their `login-item://` id is a key, not a path to open.
|
||||
function revealTarget(item: StartupItem): string | null {
|
||||
return item.program ?? (item.id.includes("/") || item.id.includes("\\") ? item.id : null);
|
||||
if (item.program) return item.program;
|
||||
return /^[\\/]|[A-Za-z]:[\\/]/.test(item.id) ? item.id : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup items: what the machine has been told to run by itself.
|
||||
*
|
||||
* A risk label here means "look at this", never "this is malware" — the page says
|
||||
* so because the alternative is a wall of orange next to entries the operating
|
||||
* system owns. System items are hidden by default and read-only wherever squid
|
||||
* has no business writing without an authorisation it does not have.
|
||||
* Read the way the operating system reads it. macOS shows two lists — what opens
|
||||
* when you log in, and what may keep running behind it — and files each entry under
|
||||
* the application that installed it. A flat list of 870 launchd labels asks the user
|
||||
* to do the grouping squid can do from paths alone.
|
||||
*
|
||||
* A risk label means "look at this", never "this is malware"; the alternative is a
|
||||
* wall of orange beside entries the operating system owns, which is why those are
|
||||
* hidden until asked for.
|
||||
*/
|
||||
export function StartupPage({
|
||||
startup,
|
||||
|
|
@ -84,17 +108,14 @@ export function StartupPage({
|
|||
}) {
|
||||
const { t, lang } = useI18n();
|
||||
const { push } = useToast();
|
||||
const [scope, setScope] = useState<ScopeFilter>("user");
|
||||
const [source, setSource] = useState<StartupSource | "all">("all");
|
||||
const [disabledOnly, setDisabledOnly] = useState(false);
|
||||
const [riskyOnly, setRiskyOnly] = useState(false);
|
||||
const [tab, setTab] = useState<Tab>("open-at-login");
|
||||
const [scope, setScope] = useState<Scope>("all");
|
||||
const [showVendor, setShowVendor] = useState(false);
|
||||
const [riskyOnly, setRiskyOnly] = useState(false);
|
||||
const [query, setQuery] = useState(initialQuery ?? "");
|
||||
const [open, setOpen] = useState<Set<string>>(new Set());
|
||||
const [detail, setDetail] = useState<StartupItem | null>(null);
|
||||
const [pending, setPending] = useState<{ item: StartupItem; enabled: boolean } | null>(null);
|
||||
const [selectMode, setSelectMode] = useState(false);
|
||||
const [selected, setSelected] = useState<Set<string>>(new Set());
|
||||
const [batch, setBatch] = useState(false);
|
||||
|
||||
/**
|
||||
* One file, scanned now, and the user is taken to the page that shows the
|
||||
|
|
@ -110,23 +131,88 @@ export function StartupPage({
|
|||
}
|
||||
};
|
||||
|
||||
const items = useMemo(() => {
|
||||
/** Everything but the search, so the counts beside the tabs are what clicking shows. */
|
||||
const listed = useMemo(() => {
|
||||
const all = startup.view?.items ?? [];
|
||||
const needle = query.trim().toLowerCase();
|
||||
return all.filter((item) => {
|
||||
if (!showVendor && item.systemVendor) return false;
|
||||
if (scope !== "all" && item.scope !== scope) return false;
|
||||
if (source !== "all" && item.source !== source) return false;
|
||||
if (disabledOnly && !item.disabled) return false;
|
||||
if (riskyOnly && item.risks.length === 0) return false;
|
||||
if (!needle) return true;
|
||||
return (
|
||||
item.name.toLowerCase().includes(needle) ||
|
||||
item.command.toLowerCase().includes(needle) ||
|
||||
(item.program ?? "").toLowerCase().includes(needle)
|
||||
);
|
||||
return true;
|
||||
});
|
||||
}, [disabledOnly, query, scope, showVendor, source, startup.view]);
|
||||
}, [riskyOnly, scope, showVendor, startup.view]);
|
||||
|
||||
const groups = useMemo(() => {
|
||||
const needle = query.trim().toLowerCase();
|
||||
const matching = needle
|
||||
? listed.filter(
|
||||
(item) =>
|
||||
item.name.toLowerCase().includes(needle) ||
|
||||
item.command.toLowerCase().includes(needle) ||
|
||||
(item.program ?? "").toLowerCase().includes(needle) ||
|
||||
(item.owner?.name ?? "").toLowerCase().includes(needle),
|
||||
)
|
||||
: listed;
|
||||
const byOwner = new Map<string, StartupItem[]>();
|
||||
for (const item of matching.filter((entry) => entry.category === tab)) {
|
||||
const key = item.owner?.name ?? "";
|
||||
byOwner.set(key, [...(byOwner.get(key) ?? []), item]);
|
||||
}
|
||||
return [...byOwner.entries()]
|
||||
.map(([name, items]) => ({
|
||||
key: name || "—",
|
||||
name,
|
||||
items: items.sort(
|
||||
(a, b) => Number(a.systemVendor) - Number(b.systemVendor) || a.name.localeCompare(b.name),
|
||||
),
|
||||
}))
|
||||
.sort(
|
||||
(a, b) =>
|
||||
Number(a.key === "—") - Number(b.key === "—") ||
|
||||
a.name.localeCompare(b.name, "zh", { sensitivity: "base" }),
|
||||
);
|
||||
}, [listed, query, tab]);
|
||||
|
||||
const counts = {
|
||||
"open-at-login": listed.filter((item) => item.category === "open-at-login").length,
|
||||
background: listed.filter((item) => item.category === "background").length,
|
||||
};
|
||||
const shown = groups.reduce((total, group) => total + group.items.length, 0);
|
||||
const searching = query.trim().length > 0;
|
||||
|
||||
// Coming from a process row means coming with a question: "is this one of mine,
|
||||
// and where is it declared?" So the handed-over path becomes the search, vendor
|
||||
// items stop being hidden, and whichever list holds it is opened.
|
||||
//
|
||||
// Applied once per handover. The inventory is re-read whenever the page opens and
|
||||
// after every change, and an effect that keyed on it alone would restore this
|
||||
// search and clear the filters the person has set since.
|
||||
const handed = useRef<string | null>(null);
|
||||
useEffect(() => {
|
||||
if (!initialQuery || handed.current === initialQuery) return;
|
||||
setQuery(initialQuery);
|
||||
setShowVendor(true);
|
||||
setScope("all");
|
||||
const match = startup.view?.items.find(
|
||||
(item) => item.program === initialQuery || item.command === initialQuery,
|
||||
);
|
||||
if (match) setTab(match.category);
|
||||
// Until the inventory has arrived the tab is still a guess, so the handover
|
||||
// stays open and runs again when the list it needs is finally there.
|
||||
if (startup.view) handed.current = initialQuery;
|
||||
}, [initialQuery, startup.view]);
|
||||
|
||||
/**
|
||||
* Login items belong to macOS, which refuses to let another process write them, so
|
||||
* the honest action beside a read-only row is the door to the pane that can.
|
||||
*/
|
||||
const openSettings = async () => {
|
||||
try {
|
||||
await api.openStartupSettings();
|
||||
} catch (reason) {
|
||||
push(messageFrom(reason), "danger");
|
||||
}
|
||||
};
|
||||
|
||||
const change = async (item: StartupItem, enabled: boolean) => {
|
||||
try {
|
||||
|
|
@ -138,144 +224,68 @@ export function StartupPage({
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* One entry at a time is the rule, and it exists for a reason: a plist that
|
||||
* fails to reload, a task the vendor re-arms on next launch, and a login item
|
||||
* that belongs to an update helper all need to be visible as themselves. "All
|
||||
* user items" is offered rather than "everything", so the worst case a batch
|
||||
* can do is bounded by what the current user owns.
|
||||
*/
|
||||
const toggleSelection = (item: StartupItem) => {
|
||||
setSelected((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(item.id)) next.delete(item.id);
|
||||
else next.add(item.id);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const actionable = useMemo(
|
||||
() => new Set(items.filter((item) => item.modifiable && !item.systemVendor).map((item) => item.id)),
|
||||
[items],
|
||||
);
|
||||
const allSelected = actionable.size > 0 && [...actionable].every((id) => selected.has(id));
|
||||
|
||||
const runBatch = async (enabled: boolean) => {
|
||||
const ids = [...selected].filter((id) => actionable.has(id));
|
||||
setBatch(true);
|
||||
let done = 0;
|
||||
const failures: string[] = [];
|
||||
for (const id of ids) {
|
||||
const item = startup.view?.items.find((candidate) => candidate.id === id);
|
||||
if (!item || item.disabled === !enabled) continue;
|
||||
try {
|
||||
await startup.setEnabled(item, enabled);
|
||||
done += 1;
|
||||
} catch (reason) {
|
||||
failures.push(`${item.name}: ${messageFrom(reason)}`);
|
||||
}
|
||||
}
|
||||
setBatch(false);
|
||||
setSelected(new Set());
|
||||
setSelectMode(false);
|
||||
push(
|
||||
failures.length
|
||||
? t(
|
||||
`${done} changed · ${failures.length} refused: ${failures[0]}`,
|
||||
`已修改 ${done} 项 · ${failures.length} 项被拒绝:${failures[0]}`,
|
||||
)
|
||||
: t(
|
||||
`${done} startup items are now ${enabled ? "on" : "off"}.`,
|
||||
`${done} 个启动项已${enabled ? "启用" : "停用"}。`,
|
||||
),
|
||||
failures.length ? "danger" : "success",
|
||||
);
|
||||
};
|
||||
|
||||
// Coming from a process row means coming with a question: "is this one of
|
||||
// mine, and where is it declared?" So the handed-over path becomes the search,
|
||||
// and the vendor items the process might belong to stop being hidden.
|
||||
useEffect(() => {
|
||||
if (!initialQuery) return;
|
||||
setQuery(initialQuery);
|
||||
setShowVendor(true);
|
||||
setScope("all");
|
||||
setSource("all");
|
||||
}, [initialQuery]);
|
||||
|
||||
const view = startup.view;
|
||||
return (
|
||||
<div className="page is-stacked">
|
||||
<PageHeader
|
||||
eyebrow={t("Startup items", "启动项")}
|
||||
title={t("What your machine starts by itself.", "你的电脑自己会启动什么。")}
|
||||
description={t(
|
||||
"A risk label means worth a look, never malicious.",
|
||||
"风险标记只代表值得检查,不代表恶意。",
|
||||
"Grouped by the app that installed each entry. A risk label means worth a look.",
|
||||
"按安装该条目的应用分组。风险标记只代表值得检查。",
|
||||
)}
|
||||
actions={
|
||||
<>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon={<Settings2 size={15} />}
|
||||
onClick={() => setSelectMode((current) => !current)}
|
||||
>
|
||||
{selectMode
|
||||
? t("Done selecting", "完成选择")
|
||||
: t("Select user items", "选择用户项目")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon={<RefreshCw size={15} />}
|
||||
onClick={() => void startup.refresh()}
|
||||
disabled={startup.loading}
|
||||
>
|
||||
{t("Read again", "重新读取")}
|
||||
</Button>
|
||||
</>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon={<RefreshCw size={15} />}
|
||||
onClick={() => void startup.refresh()}
|
||||
disabled={startup.loading}
|
||||
>
|
||||
{t("Read again", "重新读取")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
{startup.error ? <InlineError message={startup.error} /> : null}
|
||||
|
||||
{view ? (
|
||||
<div className="stat-grid">
|
||||
<div className="stat">
|
||||
<strong>{view.userCount}</strong>
|
||||
<span>{t("for your user", "属于当前用户")}</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<strong>{view.systemCount}</strong>
|
||||
<span>{t("system-wide", "系统级")}</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<strong>{view.disabledCount}</strong>
|
||||
<span>{t("turned off", "已停用")}</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<strong>{view.actionableCount}</strong>
|
||||
<span>{t("squid may change", "Squid 可修改")}</span>
|
||||
</div>
|
||||
<div className="stat is-warning">
|
||||
<strong>{view.riskyCount}</strong>
|
||||
<span>{t("worth a look", "值得检查")}</span>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{view?.notes.length ? (
|
||||
<div className="notice">
|
||||
{view.notes.map((note) => (
|
||||
<span key={note}>
|
||||
<span key={`${note.kind}-${note.subject}`}>
|
||||
<AlertTriangle size={13} />
|
||||
{note}
|
||||
{note.kind === "login-items-unavailable"
|
||||
? t(
|
||||
"macOS has not let Squid read the login items.",
|
||||
"macOS 尚未允许 Squid 读取登录项。",
|
||||
)
|
||||
: t("This folder could not be listed:", "以下目录无法读取:")}{" "}
|
||||
{note.kind === "unreadable-root" ? note.subject : null}
|
||||
{note.detail ? ` — ${note.detail}` : ""}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="chip-row page-tabs" role="tablist">
|
||||
{(
|
||||
[
|
||||
["open-at-login", t("Login items", "登录项")],
|
||||
["background", t("Background", "后台程序")],
|
||||
] as [Tab, string][]
|
||||
).map(([key, label]) => (
|
||||
<button
|
||||
key={key}
|
||||
role="tab"
|
||||
aria-selected={tab === key}
|
||||
className={`filter-chip ${tab === key ? "is-active" : ""}`}
|
||||
onClick={() => setTab(key)}
|
||||
>
|
||||
{label}
|
||||
<b>{counts[key]}</b>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<section className="panel">
|
||||
<label className="search-field">
|
||||
<Search size={14} />
|
||||
|
|
@ -286,131 +296,107 @@ export function StartupPage({
|
|||
/>
|
||||
</label>
|
||||
<div className="chip-row">
|
||||
{(
|
||||
[
|
||||
["user", t("My user", "当前用户")],
|
||||
["system", t("System", "系统")],
|
||||
["all", t("All scopes", "全部范围")],
|
||||
] as [ScopeFilter, string][]
|
||||
).map(([key, label]) => (
|
||||
<button
|
||||
key={key}
|
||||
className={`filter-chip ${scope === key ? "is-active" : ""}`}
|
||||
onClick={() => setScope(key)}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
<select
|
||||
className="settings-select"
|
||||
value={source}
|
||||
onChange={(event) => setSource(event.target.value as StartupSource | "all")}
|
||||
>
|
||||
<option value="all">{t("Every kind", "所有类型")}</option>
|
||||
{(Object.keys(SOURCE_LABEL) as StartupSource[]).map((key) => (
|
||||
<option key={key} value={key}>
|
||||
{lang === "zh" ? SOURCE_LABEL[key][1] : SOURCE_LABEL[key][0]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button
|
||||
className={`filter-chip ${disabledOnly ? "is-active" : ""}`}
|
||||
onClick={() => setDisabledOnly((current) => !current)}
|
||||
>
|
||||
{t("Turned off", "已停用")}
|
||||
</button>
|
||||
<Select
|
||||
value={scope}
|
||||
align="start"
|
||||
label={t("Scope", "范围")}
|
||||
onChange={setScope}
|
||||
options={[
|
||||
{ value: "all", label: t("All scopes", "全部范围") },
|
||||
{ value: "user", label: t("My user", "当前用户") },
|
||||
{ value: "system", label: t("System", "系统") },
|
||||
]}
|
||||
/>
|
||||
<button
|
||||
className={`filter-chip ${riskyOnly ? "is-active" : ""}`}
|
||||
onClick={() => setRiskyOnly((current) => !current)}
|
||||
>
|
||||
{t("Risky only", "仅看需注意")}
|
||||
{t("Worth a look", "值得检查")}
|
||||
</button>
|
||||
<button
|
||||
className={`filter-chip ${showVendor ? "is-active" : ""}`}
|
||||
onClick={() => setShowVendor((current) => !current)}
|
||||
>
|
||||
{t("Show Apple / Microsoft items", "显示系统条目")}
|
||||
{t("Operating system items", "系统自带条目")}
|
||||
<b>{formatCount((view?.items ?? []).filter((item) => item.systemVendor).length)}</b>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{selectMode ? (
|
||||
<div className="startup-batch">
|
||||
<label className="startup-batch-all">
|
||||
<Checkbox
|
||||
checked={allSelected}
|
||||
indeterminate={selected.size > 0 && !allSelected}
|
||||
onChange={() =>
|
||||
setSelected(allSelected ? new Set() : new Set(actionable))
|
||||
}
|
||||
label={t("Select all shown user items", "全选当前显示的用户项目")}
|
||||
/>
|
||||
<span>
|
||||
{t(
|
||||
`${selected.size} of ${actionable.size} changeable items shown`,
|
||||
`已选 ${selected.size} / 可修改 ${actionable.size} 项`,
|
||||
)}
|
||||
</span>
|
||||
</label>
|
||||
<div className="startup-batch-actions">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
disabled={batch || selected.size === 0}
|
||||
onClick={() => void runBatch(true)}
|
||||
>
|
||||
{t("Enable selected", "启用所选")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="danger"
|
||||
disabled={batch || selected.size === 0}
|
||||
onClick={() => void runBatch(false)}
|
||||
>
|
||||
{t("Disable selected", "停用所选")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<SectionTitle
|
||||
title={t("Startup entries", "启动条目")}
|
||||
subtitle={t(
|
||||
`${items.length} shown${
|
||||
view ? ` of ${view.items.length} read from this machine` : ""
|
||||
}. Disabling keeps the original file or value so it can be put back.`,
|
||||
`当前显示 ${items.length} 项${
|
||||
view ? `,本机共读取 ${view.items.length} 项` : ""
|
||||
}。停用会保留原始文件或注册表值,可随时恢复。`,
|
||||
)}
|
||||
/>
|
||||
|
||||
{items.length === 0 ? (
|
||||
{shown === 0 ? (
|
||||
<EmptyState
|
||||
icon={<ToggleLeft size={26} />}
|
||||
title={t("Nothing matches these filters", "没有符合筛选条件的条目")}
|
||||
title={
|
||||
searching || riskyOnly
|
||||
? t("Nothing matches", "没有符合条件的条目")
|
||||
: tab === "open-at-login"
|
||||
? t("Nothing opens when you log in", "登录时不会打开任何东西")
|
||||
: t("No background entries are shown", "没有显示后台条目")
|
||||
}
|
||||
description={t(
|
||||
"System-wide entries stay hidden until you show them above.",
|
||||
"系统级条目需要在上方手动显示。",
|
||||
"Operating system entries stay hidden until you show them above.",
|
||||
"系统自带条目需要在上方手动显示。",
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<ul className="item-list">
|
||||
{items.map((item) => (
|
||||
<StartupRow
|
||||
key={item.id}
|
||||
item={item}
|
||||
lang={lang}
|
||||
busy={startup.busy || batch}
|
||||
selectMode={selectMode}
|
||||
selected={selected.has(item.id)}
|
||||
selectable={actionable.has(item.id)}
|
||||
onToggleSelected={() => toggleSelection(item)}
|
||||
onOpen={() => setDetail(item)}
|
||||
onAsk={(enabled) => setPending({ item, enabled })}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
<section className="panel">
|
||||
<SectionTitle
|
||||
title={
|
||||
tab === "open-at-login"
|
||||
? t("Opens at login", "登录时打开")
|
||||
: t("Runs in the background", "在后台运行")
|
||||
}
|
||||
subtitle={t(
|
||||
"Disabling keeps the original file or value so it can be put back.",
|
||||
"停用会保留原始文件或注册表值,可随时恢复。",
|
||||
)}
|
||||
action={
|
||||
tab === "open-at-login" ? (
|
||||
<button className="text-button" onClick={() => void openSettings()}>
|
||||
<ExternalLink size={13} />
|
||||
{t("Open System Settings", "打开系统设置")}
|
||||
</button>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
{tab === "open-at-login" && !searching ? (
|
||||
<ul className="item-list">
|
||||
{groups.flatMap((group) => group.items).map((item) => (
|
||||
<StartupRow
|
||||
key={item.id}
|
||||
item={item}
|
||||
lang={lang}
|
||||
busy={startup.busy}
|
||||
showSource={false}
|
||||
onOpen={setDetail}
|
||||
onAsk={(next) => setPending({ item, enabled: next })}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<ul className="group-list">
|
||||
{groups.map((group) => (
|
||||
<StartupGroup
|
||||
key={group.key}
|
||||
group={group}
|
||||
expanded={searching || open.has(group.key)}
|
||||
busy={startup.busy}
|
||||
lang={lang}
|
||||
onToggle={() =>
|
||||
setOpen((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(group.key)) next.delete(group.key);
|
||||
else next.add(group.key);
|
||||
return next;
|
||||
})
|
||||
}
|
||||
onOpen={setDetail}
|
||||
onAsk={(item, enabled) => setPending({ item, enabled })}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
|
||||
<Modal
|
||||
|
|
@ -421,9 +407,7 @@ export function StartupPage({
|
|||
subtitle={
|
||||
detail
|
||||
? `${lang === "zh" ? SOURCE_LABEL[detail.source][1] : SOURCE_LABEL[detail.source][0]} · ${
|
||||
detail.scope === "user"
|
||||
? t("your user", "当前用户")
|
||||
: t("system", "系统")
|
||||
detail.scope === "user" ? t("your user", "当前用户") : t("system", "系统")
|
||||
}`
|
||||
: undefined
|
||||
}
|
||||
|
|
@ -485,10 +469,6 @@ export function StartupPage({
|
|||
confirmLabel={pending?.enabled ? t("Enable", "启用") : t("Disable", "停用")}
|
||||
cancelLabel={t("Cancel", "取消")}
|
||||
message={pending?.item.name ?? ""}
|
||||
note={t(
|
||||
"The original is kept, so this can be undone here.",
|
||||
"Squid 会保留原始值,可在此页面恢复。",
|
||||
)}
|
||||
onConfirm={() => pending && void change(pending.item, pending.enabled)}
|
||||
onClose={() => setPending(null)}
|
||||
>
|
||||
|
|
@ -508,78 +488,138 @@ export function StartupPage({
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* One application and the entries it installed. Login items are shown flat, the way
|
||||
* System Settings shows them, because there are usually only a few; background
|
||||
* entries are folded under their application because a machine has twenty or more.
|
||||
*/
|
||||
function StartupGroup({
|
||||
group,
|
||||
expanded,
|
||||
busy,
|
||||
lang,
|
||||
onToggle,
|
||||
onOpen,
|
||||
onAsk,
|
||||
}: {
|
||||
group: { key: string; name: string; items: StartupItem[] };
|
||||
expanded: boolean;
|
||||
busy: boolean;
|
||||
lang: "zh" | "en";
|
||||
onToggle: () => void;
|
||||
onOpen: (item: StartupItem) => void;
|
||||
onAsk: (item: StartupItem, enabled: boolean) => void;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
const risky = group.items.filter((item) => item.risks.length > 0).length;
|
||||
const off = group.items.filter((item) => item.disabled).length;
|
||||
const bundle = group.items.find((item) => item.owner?.bundlePath)?.owner?.bundlePath;
|
||||
const signed = group.items.some((item) => item.signed);
|
||||
return (
|
||||
<li>
|
||||
<button className="group-head" onClick={onToggle} aria-expanded={expanded}>
|
||||
<span className="item-copy">
|
||||
<strong>
|
||||
{group.name || t("Not attributed to an app", "未归属到具体应用")}
|
||||
</strong>
|
||||
<small title={bundle ?? undefined}>
|
||||
{bundle
|
||||
? shortPath(bundle, 64)
|
||||
: lang === "zh"
|
||||
? SOURCE_LABEL[group.items[0].source][1]
|
||||
: SOURCE_LABEL[group.items[0].source][0]}
|
||||
</small>
|
||||
</span>
|
||||
<span className="group-meta">
|
||||
{off > 0 ? (
|
||||
<span className="status-chip is-neutral">{t(`${off} off`, `${off} 项已停用`)}</span>
|
||||
) : null}
|
||||
{risky > 0 ? (
|
||||
<span className="status-chip is-warning">
|
||||
<ShieldAlert size={11} />
|
||||
{t(`${risky} worth a look`, `${risky} 项值得检查`)}
|
||||
</span>
|
||||
) : null}
|
||||
{signed ? (
|
||||
<span className="status-chip is-success">{t("signed", "已签名")}</span>
|
||||
) : null}
|
||||
<span className="group-count">{formatCount(group.items.length)}</span>
|
||||
</span>
|
||||
<ChevronDown size={15} className={`group-arrow ${expanded ? "is-open" : ""}`} />
|
||||
</button>
|
||||
{expanded ? (
|
||||
<ul className="item-list is-nested">
|
||||
{group.items.map((item) => (
|
||||
<StartupRow
|
||||
key={item.id}
|
||||
item={item}
|
||||
lang={lang}
|
||||
busy={busy}
|
||||
showSource
|
||||
onOpen={onOpen}
|
||||
onAsk={(enabled) => onAsk(item, enabled)}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function StartupRow({
|
||||
item,
|
||||
lang,
|
||||
busy,
|
||||
selectMode,
|
||||
selected,
|
||||
selectable,
|
||||
onToggleSelected,
|
||||
showSource,
|
||||
onOpen,
|
||||
onAsk,
|
||||
}: {
|
||||
item: StartupItem;
|
||||
lang: "zh" | "en";
|
||||
busy: boolean;
|
||||
selectMode: boolean;
|
||||
selected: boolean;
|
||||
selectable: boolean;
|
||||
onToggleSelected: () => void;
|
||||
onOpen: () => void;
|
||||
/** Where every row in sight comes from the same place, naming it again says nothing. */
|
||||
showSource: boolean;
|
||||
onOpen: (item: StartupItem) => void;
|
||||
onAsk: (enabled: boolean) => void;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
const target = item.program ?? item.command;
|
||||
return (
|
||||
<li className={`item-row ${item.disabled ? "is-off" : ""} ${item.risks.length ? "is-risky" : ""}`}>
|
||||
{selectMode ? (
|
||||
<Checkbox
|
||||
checked={selected}
|
||||
disabled={!selectable}
|
||||
onChange={onToggleSelected}
|
||||
label={t("Select startup item", "选择启动项")}
|
||||
/>
|
||||
) : null}
|
||||
<button className="item-main" onClick={onOpen}>
|
||||
<button className="item-main" onClick={() => onOpen(item)}>
|
||||
<span className="item-copy">
|
||||
<strong>{item.name}</strong>
|
||||
<small title={target}>{shortPath(target, 76)}</small>
|
||||
{target ? <small title={target}>{shortPath(target, 76)}</small> : null}
|
||||
</span>
|
||||
<span className="startup-meta">
|
||||
<span className="startup-source">{lang === "zh" ? SOURCE_LABEL[item.source][1] : SOURCE_LABEL[item.source][0]}</span>
|
||||
<span className={`status-chip is-${item.scope === "user" ? "info" : "neutral"}`}>
|
||||
{item.scope === "user" ? t("user", "用户") : t("system", "系统")}
|
||||
{item.risks.map((risk) => (
|
||||
<span key={risk} className="status-chip is-warning">
|
||||
<ShieldAlert size={11} />
|
||||
{t(RISK_LABEL[risk][0], RISK_LABEL[risk][1])}
|
||||
</span>
|
||||
{item.publisher ? (
|
||||
<span className="status-chip is-success">
|
||||
{t("signed", "已签名")} · {item.publisher}
|
||||
</span>
|
||||
) : item.signed ? null : (
|
||||
<span className="status-chip is-neutral">{t("unsigned", "未签名")}</span>
|
||||
)}
|
||||
{item.risks.map((risk) => (
|
||||
<span key={risk} className="risk-chip" title={t(RISK_LABEL[risk][0], RISK_LABEL[risk][1])}>
|
||||
<ShieldAlert size={11} />
|
||||
{t(RISK_LABEL[risk][0], RISK_LABEL[risk][1])}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
))}
|
||||
{showSource ? (
|
||||
<span className="startup-source">
|
||||
{lang === "zh" ? SOURCE_LABEL[item.source][1] : SOURCE_LABEL[item.source][0]}
|
||||
</span>
|
||||
) : null}
|
||||
{item.scope === "user" ? null : (
|
||||
<span className="status-chip is-neutral">{t("system", "系统")}</span>
|
||||
)}
|
||||
</button>
|
||||
{item.modifiable ? (
|
||||
<Toggle
|
||||
checked={!item.disabled}
|
||||
disabled={busy}
|
||||
label={t("Toggle startup item", "切换启动项")}
|
||||
onChange={(next) => onAsk(next)}
|
||||
onChange={onAsk}
|
||||
/>
|
||||
) : (
|
||||
<span className="muted-note" title={item.readonlyReason ?? undefined}>
|
||||
<span className="muted-note">
|
||||
<Lock size={14} />
|
||||
{item.readonlyReason ?? t("read-only", "只读")}
|
||||
{item.lock ? t(LOCK_LABEL[item.lock][0], LOCK_LABEL[item.lock][1]) : t("read-only", "只读")}
|
||||
</span>
|
||||
)}
|
||||
<button className="icon-button" title={t("Details", "详情")} onClick={onOpen}>
|
||||
<button className="icon-button" title={t("Details", "详情")} onClick={() => onOpen(item)}>
|
||||
<ChevronRight size={16} />
|
||||
</button>
|
||||
</li>
|
||||
|
|
@ -599,18 +639,24 @@ function StartupDetail({
|
|||
}) {
|
||||
const { t } = useI18n();
|
||||
const rows: [string, string][] = [];
|
||||
if (item.owner) rows.push([t("Application", "所属应用"), item.owner.name]);
|
||||
if (item.workingDirectory) rows.push([t("Working directory", "工作目录"), item.workingDirectory]);
|
||||
if (item.program) rows.push([t("Program", "程序"), item.program]);
|
||||
rows.push([t("Entry", "声明位置"), item.id]);
|
||||
if (item.modifiedMs)
|
||||
rows.push([t("Modified", "修改时间"), formatDate(new Date(item.modifiedMs).toISOString(), lang)]);
|
||||
rows.push([
|
||||
t("Modified", "修改时间"),
|
||||
formatDate(new Date(item.modifiedMs).toISOString(), lang),
|
||||
]);
|
||||
rows.push([
|
||||
t("Signature", "签名"),
|
||||
item.publisher
|
||||
? item.publisher
|
||||
: item.signed
|
||||
? t("Signed, vendor unknown", "已签名,发布者未知")
|
||||
: t("No usable signature", "无可用签名"),
|
||||
: item.risks.includes("signature-unreadable")
|
||||
? t("Could not be read by this user", "当前用户无法读取")
|
||||
: t("No usable signature", "无可用签名"),
|
||||
]);
|
||||
return (
|
||||
<div className="item-detail">
|
||||
|
|
@ -639,11 +685,12 @@ function StartupDetail({
|
|||
{!item.modifiable ? (
|
||||
<p className="detail-note">
|
||||
<Lock size={13} />
|
||||
{item.readonlyReason ??
|
||||
t(
|
||||
"Squid installs no privileged helper, so system-wide entries stay read-only.",
|
||||
"Squid 不安装特权 helper,系统级条目保持只读。",
|
||||
)}
|
||||
{item.lock
|
||||
? t(LOCK_LABEL[item.lock][0], LOCK_LABEL[item.lock][1])
|
||||
: t(
|
||||
"Squid installs no privileged helper, so system-wide entries stay read-only.",
|
||||
"Squid 不安装特权 helper,系统级条目保持只读。",
|
||||
)}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="detail-actions">
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ export function StoragePage({ bootstrap }: { bootstrap: Bootstrap }) {
|
|||
return (
|
||||
<div className="page storage-page">
|
||||
<PageHeader
|
||||
eyebrow={t("Storage", "存储空间")}
|
||||
title={t("See space clearly.", "看清每一寸空间。")}
|
||||
description={t(
|
||||
"Drill into folders, find the heavyweight files, and open anything in Finder.",
|
||||
|
|
@ -295,8 +294,8 @@ export function StoragePage({ bootstrap }: { bootstrap: Bootstrap }) {
|
|||
<SectionTitle
|
||||
title={t("Largest files", "最大文件")}
|
||||
subtitle={t(
|
||||
"Files over 1 MB in the current folder, largest first.",
|
||||
"当前文件夹中大于 1 MB 的文件,按大小排序。",
|
||||
"Over 1 MB in the current folder, largest first.",
|
||||
"当前文件夹中大于 1 MB 的文件,从大到小。",
|
||||
)}
|
||||
action={
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { api } from "../lib/api";
|
|||
import {
|
||||
formatBytes,
|
||||
formatCount,
|
||||
formatMemoryBytes,
|
||||
formatRate,
|
||||
formatUptime,
|
||||
messageFrom,
|
||||
|
|
@ -88,7 +89,6 @@ export function SystemPage({
|
|||
return (
|
||||
<div className="page system-page">
|
||||
<PageHeader
|
||||
eyebrow={t("Real-time monitor", "实时监控")}
|
||||
title={t("The pulse of your machine.", "掌握设备的每一次呼吸。")}
|
||||
description={t(
|
||||
"Live processor, memory, disk and network activity, sampled locally every couple of seconds.",
|
||||
|
|
@ -193,7 +193,7 @@ export function SystemPage({
|
|||
<strong>{t("Memory", "内存")}</strong>
|
||||
<span>
|
||||
{snapshot
|
||||
? `${formatBytes(snapshot.memory.used)} / ${formatBytes(
|
||||
? `${formatMemoryBytes(snapshot.memory.used)} / ${formatMemoryBytes(
|
||||
snapshot.memory.total,
|
||||
)}`
|
||||
: t("Reading memory…", "正在读取内存…")}
|
||||
|
|
@ -209,19 +209,20 @@ export function SystemPage({
|
|||
>
|
||||
<strong className="gauge-number is-small">{Math.round(memoryPercent)}%</strong>
|
||||
<span className="gauge-sub">
|
||||
{snapshot ? formatBytes(snapshot.memory.available) : "—"} {t("free", "可用")}
|
||||
{snapshot ? formatMemoryBytes(snapshot.memory.available) : "—"}{" "}
|
||||
{t("available", "可用")}
|
||||
</span>
|
||||
</Gauge>
|
||||
<div className="memory-split">
|
||||
<div>
|
||||
<span>{t("Used", "已用")}</span>
|
||||
<strong>{formatBytes(snapshot?.memory.used ?? 0)}</strong>
|
||||
<strong>{formatMemoryBytes(snapshot?.memory.used ?? 0)}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>{t("Swap", "交换")}</span>
|
||||
<strong>
|
||||
{formatBytes(snapshot?.memory.swap_used ?? 0)}
|
||||
<small> / {formatBytes(snapshot?.memory.swap_total ?? 0)}</small>
|
||||
{formatMemoryBytes(snapshot?.memory.swap_used ?? 0)}
|
||||
<small> / {formatMemoryBytes(snapshot?.memory.swap_total ?? 0)}</small>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -322,7 +323,6 @@ export function SystemPage({
|
|||
<section className="process-panel">
|
||||
<SectionTitle
|
||||
title={t("Top processes", "高占用进程")}
|
||||
subtitle={t("Sorted by processor usage.", "按处理器占用排序。")}
|
||||
action={
|
||||
<Button variant="ghost" size="sm" onClick={() => setTab("processes")}>
|
||||
{t("View all processes", "查看全部进程")}
|
||||
|
|
@ -345,7 +345,7 @@ export function SystemPage({
|
|||
<small>PID {process.pid}</small>
|
||||
</span>
|
||||
<span className="process-cpu">{process.cpu.toFixed(1)}%</span>
|
||||
<span className="process-memory">{formatBytes(process.memory)}</span>
|
||||
<span className="process-memory">{formatMemoryBytes(process.memory)}</span>
|
||||
<button
|
||||
className="process-stop"
|
||||
title={t("Stop process", "结束进程")}
|
||||
|
|
|
|||
516
src/styles.css
516
src/styles.css
|
|
@ -23,6 +23,14 @@
|
|||
--nex-warning-strong: #8c6c40;
|
||||
--nex-warning-soft: #fff8e9;
|
||||
--nex-warning-rgb: 169, 119, 41;
|
||||
--nex-info: #4d94cf;
|
||||
--nex-info-strong: #3377b2;
|
||||
--nex-info-soft: #edf7ff;
|
||||
--nex-info-rgb: 77, 148, 207;
|
||||
--nex-violet: #8068d9;
|
||||
--nex-violet-strong: #6650c0;
|
||||
--nex-violet-soft: #f1eeff;
|
||||
--nex-violet-rgb: 128, 104, 217;
|
||||
--nex-danger: #c85a62;
|
||||
--nex-danger-strong: #a64048;
|
||||
--nex-danger-soft: #ffedef;
|
||||
|
|
@ -193,6 +201,18 @@ select:focus-visible,
|
|||
--tone-soft: rgba(125, 98, 86, 0.1);
|
||||
}
|
||||
|
||||
.tone-info {
|
||||
--tone: var(--nex-info);
|
||||
--tone-deep: var(--nex-info-strong);
|
||||
--tone-soft: var(--nex-info-soft);
|
||||
}
|
||||
|
||||
.tone-violet {
|
||||
--tone: var(--nex-violet);
|
||||
--tone-deep: var(--nex-violet-strong);
|
||||
--tone-soft: var(--nex-violet-soft);
|
||||
}
|
||||
|
||||
.spin {
|
||||
animation: spin 0.9s linear infinite;
|
||||
}
|
||||
|
|
@ -902,13 +922,6 @@ select:focus-visible,
|
|||
letter-spacing: 0.025em;
|
||||
}
|
||||
|
||||
.field-help {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
color: var(--nex-muted-soft);
|
||||
font-size: var(--nex-text-3xs);
|
||||
line-height: var(--nex-leading-body);
|
||||
}
|
||||
|
||||
.metric-icon {
|
||||
display: inline-grid;
|
||||
|
|
@ -925,6 +938,11 @@ select:focus-visible,
|
|||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
/* A chip is one label. Without this a CJK label with no spaces wraps to one
|
||||
glyph per line inside a row, which is what a `flex` row does to an inline item
|
||||
narrow enough to shrink. */
|
||||
flex: 0 0 auto;
|
||||
white-space: nowrap;
|
||||
padding: 3px 7px;
|
||||
border-radius: 20px;
|
||||
color: var(--nex-muted);
|
||||
|
|
@ -970,7 +988,7 @@ select:focus-visible,
|
|||
.overview-hero {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.72fr);
|
||||
grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
|
||||
min-height: 302px;
|
||||
overflow: hidden;
|
||||
padding: 31px 33px;
|
||||
|
|
@ -1016,6 +1034,7 @@ select:focus-visible,
|
|||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.hero-kicker {
|
||||
|
|
@ -1081,6 +1100,65 @@ select:focus-visible,
|
|||
content: "";
|
||||
}
|
||||
|
||||
.overview-machine {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding: 12px 0 12px 28px;
|
||||
border-left: 1px solid rgba(var(--nex-primary-rgb), 0.1);
|
||||
}
|
||||
|
||||
.machine-title {
|
||||
margin-bottom: 11px;
|
||||
color: var(--nex-ink);
|
||||
font-size: var(--nex-text-2xs);
|
||||
font-weight: var(--nex-weight-semibold);
|
||||
}
|
||||
|
||||
.machine-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.machine-row {
|
||||
display: grid;
|
||||
grid-template-columns: 24px 74px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.machine-icon {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 7px;
|
||||
color: var(--nex-primary-strong);
|
||||
background: rgba(255, 255, 255, 0.54);
|
||||
box-shadow: inset 0 0 0 1px rgba(var(--nex-primary-rgb), 0.08);
|
||||
}
|
||||
|
||||
.machine-label {
|
||||
color: var(--nex-muted);
|
||||
font-size: var(--nex-text-3xs);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.machine-row strong {
|
||||
overflow: hidden;
|
||||
color: var(--nex-ink);
|
||||
font-size: var(--nex-text-3xs);
|
||||
font-weight: var(--nex-weight-semibold);
|
||||
line-height: 1.45;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.overview-gauge-wrap {
|
||||
position: relative;
|
||||
display: flex;
|
||||
|
|
@ -1270,6 +1348,12 @@ select:focus-visible,
|
|||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.overview-metrics .metric-panel {
|
||||
display: flex;
|
||||
min-height: 145px;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.metric-panel {
|
||||
padding: 15px;
|
||||
border: 1px solid var(--nex-line);
|
||||
|
|
@ -1327,6 +1411,61 @@ select:focus-visible,
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.overview-metrics .metric-panel > small {
|
||||
margin-top: auto;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.overview-storage-card .metric-panel-head {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.storage-volume-list {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 9px;
|
||||
}
|
||||
|
||||
.storage-volume {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.storage-volume-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.storage-volume-head strong {
|
||||
flex: 0 0 auto;
|
||||
color: var(--nex-ink);
|
||||
font-size: var(--nex-text-3xs);
|
||||
font-weight: var(--nex-weight-semibold);
|
||||
}
|
||||
|
||||
.storage-volume-head span {
|
||||
overflow: hidden;
|
||||
color: var(--nex-muted-soft);
|
||||
font-size: var(--nex-text-3xs);
|
||||
text-align: right;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.storage-volume .usage-bar {
|
||||
height: 4px;
|
||||
}
|
||||
|
||||
.overview-page .page-eyebrow {
|
||||
color: #6f839a;
|
||||
}
|
||||
|
||||
/* Category cards */
|
||||
|
||||
.category-grid {
|
||||
|
|
@ -1853,12 +1992,6 @@ select:focus-visible,
|
|||
gap: 4px;
|
||||
}
|
||||
|
||||
.page-footnote {
|
||||
margin: 16px 0 0;
|
||||
color: var(--nex-muted);
|
||||
font-size: var(--nex-text-3xs);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Empty states */
|
||||
|
||||
|
|
@ -2169,6 +2302,20 @@ select:focus-visible,
|
|||
box-shadow: 0 5px 13px rgba(142, 71, 40, 0.13);
|
||||
font-size: var(--nex-text-sm);
|
||||
font-weight: var(--nex-weight-heavy);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-glyph.has-icon {
|
||||
border-color: var(--nex-line);
|
||||
background: rgba(255, 255, 255, 0.82);
|
||||
box-shadow: 0 4px 12px rgba(89, 51, 34, 0.08);
|
||||
}
|
||||
|
||||
.app-glyph img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.app-glyph.is-large {
|
||||
|
|
@ -3691,7 +3838,19 @@ select:focus-visible,
|
|||
line-height: var(--nex-leading-body);
|
||||
}
|
||||
|
||||
.settings-select {
|
||||
/* The app's own select. The box keeps the size, border and type scale the native
|
||||
control had, so replacing a `<select>` does not move a layout; only the popup
|
||||
is new, and it is drawn with the same shell as a panel. */
|
||||
.select {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.select-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-width: 86px;
|
||||
height: 31px;
|
||||
padding: 0 9px;
|
||||
|
|
@ -3700,6 +3859,88 @@ select:focus-visible,
|
|||
color: var(--nex-ink);
|
||||
background: var(--nex-paper);
|
||||
font-size: var(--nex-text-3xs);
|
||||
transition: border-color 0.14s ease;
|
||||
}
|
||||
|
||||
.select-trigger:hover:not(:disabled) {
|
||||
border-color: rgba(var(--nex-primary-rgb), 0.4);
|
||||
}
|
||||
|
||||
.select-trigger:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.select-trigger span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.select-trigger svg {
|
||||
flex: 0 0 auto;
|
||||
color: var(--nex-muted-soft);
|
||||
transition: transform 0.14s ease;
|
||||
}
|
||||
|
||||
.select-trigger svg.is-open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.select-menu {
|
||||
position: absolute;
|
||||
top: calc(100% + 5px);
|
||||
z-index: 30;
|
||||
display: grid;
|
||||
gap: 1px;
|
||||
min-width: 100%;
|
||||
max-height: 288px;
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
list-style: none;
|
||||
border: 1px solid var(--nex-line);
|
||||
border-radius: 11px;
|
||||
background: var(--nex-paper);
|
||||
box-shadow: var(--shadow-float);
|
||||
}
|
||||
|
||||
.select-menu.is-start {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.select-menu.is-end {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.select-menu button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
padding: 6px 8px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
color: var(--nex-ink);
|
||||
background: none;
|
||||
font-size: var(--nex-text-3xs);
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.select-menu button.is-active {
|
||||
background: var(--nex-primary-tint);
|
||||
}
|
||||
|
||||
.select-menu button.is-current {
|
||||
color: var(--nex-primary-strong);
|
||||
font-weight: var(--nex-weight-semibold);
|
||||
}
|
||||
|
||||
.select-menu svg {
|
||||
flex: 0 0 auto;
|
||||
color: var(--nex-primary);
|
||||
}
|
||||
|
||||
.whitelist-add {
|
||||
|
|
@ -3822,16 +4063,6 @@ select:focus-visible,
|
|||
font-weight: var(--nex-weight-semibold);
|
||||
}
|
||||
|
||||
.settings-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 13px;
|
||||
color: var(--nex-muted-soft);
|
||||
font-size: var(--nex-text-3xs);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Update panel */
|
||||
|
||||
|
|
@ -4246,12 +4477,6 @@ select:focus-visible,
|
|||
line-height: var(--nex-leading-body);
|
||||
}
|
||||
|
||||
.setup-note {
|
||||
margin: 14px 1px 0;
|
||||
color: var(--nex-muted-soft);
|
||||
font-size: var(--nex-text-3xs);
|
||||
line-height: var(--nex-leading-body);
|
||||
}
|
||||
|
||||
.setup-foot {
|
||||
display: flex;
|
||||
|
|
@ -4705,7 +4930,7 @@ select:focus-visible,
|
|||
}
|
||||
|
||||
.overview-hero {
|
||||
grid-template-columns: minmax(0, 1.2fr) 250px;
|
||||
grid-template-columns: minmax(0, 1fr) 330px;
|
||||
padding: 27px;
|
||||
}
|
||||
|
||||
|
|
@ -4738,7 +4963,7 @@ select:focus-visible,
|
|||
}
|
||||
|
||||
.overview-hero {
|
||||
grid-template-columns: minmax(0, 1fr) 218px;
|
||||
grid-template-columns: minmax(0, 1fr) 285px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
|
|
@ -4746,8 +4971,17 @@ select:focus-visible,
|
|||
font-size: var(--nex-text-hero);
|
||||
}
|
||||
|
||||
.overview-gauge-wrap .gauge {
|
||||
transform: scale(0.86);
|
||||
.overview-hero-copy {
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
.overview-machine {
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
.machine-row {
|
||||
grid-template-columns: 22px 66px minmax(0, 1fr);
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.quick-grid,
|
||||
|
|
@ -5136,10 +5370,12 @@ select:focus-visible,
|
|||
}
|
||||
|
||||
/* One row for everything that can be opened: a finding, a startup item, a
|
||||
quarantined file. The tone class is the only difference between them. */
|
||||
quarantined file. Flat rows divided by one hairline, the way every older list
|
||||
in the app is built — no card per entry, no rounded corners, no indicator bar.
|
||||
A tone tints the text of a row, never its edge. */
|
||||
.item-list {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
|
|
@ -5149,24 +5385,33 @@ select:focus-visible,
|
|||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--nex-line);
|
||||
border-radius: var(--radius-md);
|
||||
background: rgba(255, 255, 255, 0.62);
|
||||
min-height: 44px;
|
||||
padding: 7px 10px;
|
||||
border-bottom: 1px solid var(--nex-line);
|
||||
background: transparent;
|
||||
transition: background 0.14s ease;
|
||||
}
|
||||
|
||||
.item-row.is-danger {
|
||||
border-left: 3px solid var(--nex-danger);
|
||||
.item-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.item-row.is-warning,
|
||||
.item-row.is-risky {
|
||||
border-left: 3px solid var(--nex-warning);
|
||||
.item-row:hover {
|
||||
background: var(--nex-cream);
|
||||
}
|
||||
|
||||
.item-row.is-danger .item-copy strong {
|
||||
color: var(--nex-danger-strong);
|
||||
}
|
||||
|
||||
.item-row.is-warning .item-copy strong,
|
||||
.item-row.is-risky .item-copy strong {
|
||||
color: var(--nex-warning-strong);
|
||||
}
|
||||
|
||||
.item-row.is-handled,
|
||||
.item-row.is-off {
|
||||
opacity: 0.62;
|
||||
opacity: 0.64;
|
||||
}
|
||||
|
||||
/* The whole row is one button, which is why the reset is here rather than in a
|
||||
|
|
@ -5226,22 +5471,6 @@ select:focus-visible,
|
|||
gap: 6px;
|
||||
}
|
||||
|
||||
.level-dot {
|
||||
flex: 0 0 8px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--nex-muted-soft);
|
||||
}
|
||||
|
||||
.level-dot.is-danger {
|
||||
background: var(--nex-danger);
|
||||
}
|
||||
|
||||
.level-dot.is-warning {
|
||||
background: var(--nex-warning);
|
||||
}
|
||||
|
||||
/* Detail drawer body, shared by findings, startup items and processes. */
|
||||
.item-detail {
|
||||
display: grid;
|
||||
|
|
@ -5284,23 +5513,27 @@ select:focus-visible,
|
|||
|
||||
.evidence-list {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* One hairline per row, like every other list: the evidence is a table of facts,
|
||||
not a stack of cards. */
|
||||
.evidence-list li {
|
||||
display: grid;
|
||||
grid-template-columns: 108px 1fr;
|
||||
gap: 10px;
|
||||
padding: 9px 11px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--nex-cream);
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid var(--nex-line);
|
||||
font-size: var(--nex-text-2xs);
|
||||
line-height: var(--nex-leading-body);
|
||||
}
|
||||
|
||||
.evidence-list li:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.evidence-key {
|
||||
color: var(--nex-primary-strong);
|
||||
font-family: var(--nex-font-mono);
|
||||
|
|
@ -5469,44 +5702,10 @@ select:focus-visible,
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.stat {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
padding: 13px 15px;
|
||||
border: 1px solid var(--nex-line);
|
||||
border-radius: var(--radius-lg);
|
||||
background: rgba(255, 255, 255, 0.73);
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
|
||||
.stat strong {
|
||||
font-size: var(--nex-text-xl);
|
||||
font-weight: var(--nex-weight-bold);
|
||||
}
|
||||
|
||||
.stat span {
|
||||
color: var(--nex-muted);
|
||||
font-size: var(--nex-text-3xs);
|
||||
}
|
||||
|
||||
.stat.is-warning {
|
||||
border-color: rgba(var(--nex-warning-rgb), 0.26);
|
||||
background: var(--nex-warning-soft);
|
||||
}
|
||||
|
||||
.startup-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
max-width: 46%;
|
||||
}
|
||||
|
||||
/* Where the entry is declared: LaunchAgent, Run, a login item. quieter than the
|
||||
name it qualifies, because most rows are the kind the user never touches. */
|
||||
|
|
@ -5517,18 +5716,6 @@ select:focus-visible,
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.risk-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 2px 7px;
|
||||
border-radius: 999px;
|
||||
background: rgba(var(--nex-warning-rgb), 0.14);
|
||||
color: var(--nex-warning-strong);
|
||||
font-size: var(--nex-text-3xs);
|
||||
font-weight: var(--nex-weight-medium);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.muted-note {
|
||||
display: inline-flex;
|
||||
|
|
@ -5539,28 +5726,72 @@ select:focus-visible,
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.startup-batch {
|
||||
/* Startup groups: one application and the entries it installed. The head is the
|
||||
same flat, hairline-separated row as everything else it contains, and the rows
|
||||
under it are ordinary `.item-row`s that have only been indented. */
|
||||
.group-list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid rgba(var(--nex-primary-rgb), 0.24);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--nex-primary-tint);
|
||||
flex-direction: column;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.startup-batch-all {
|
||||
.group-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
padding: 7px 10px;
|
||||
border-bottom: 1px solid var(--nex-line);
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
transition: background 0.14s ease;
|
||||
}
|
||||
|
||||
.group-head:hover {
|
||||
background: var(--nex-cream);
|
||||
}
|
||||
|
||||
.group-head > .item-copy strong {
|
||||
font-size: var(--nex-text-xs);
|
||||
}
|
||||
|
||||
.group-meta {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.group-count {
|
||||
min-width: 22px;
|
||||
color: var(--nex-muted);
|
||||
font-size: var(--nex-text-2xs);
|
||||
font-size: var(--nex-text-3xs);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.startup-batch-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
.group-arrow {
|
||||
flex: 0 0 auto;
|
||||
color: var(--nex-muted-soft);
|
||||
transition: transform 0.14s ease;
|
||||
}
|
||||
|
||||
.group-arrow.is-open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
/* Nested rather than boxed: the rows belong to the group above them, which a card
|
||||
around each one would deny. */
|
||||
.item-list.is-nested .item-row {
|
||||
padding-left: 28px;
|
||||
background: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.item-list.is-nested .item-row:last-child {
|
||||
border-bottom: 1px solid var(--nex-line);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- process table */
|
||||
|
|
@ -5604,7 +5835,6 @@ select:focus-visible,
|
|||
|
||||
.ptable.pt-rows {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
|
|
@ -5615,11 +5845,14 @@ select:focus-visible,
|
|||
.ptable.pt-rows li {
|
||||
min-height: 38px;
|
||||
padding: 5px 11px;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.ptable.pt-rows li:nth-child(odd) {
|
||||
background: rgba(255, 255, 255, 0.55);
|
||||
.ptable.pt-rows li:not(:last-child) {
|
||||
border-bottom: 1px solid var(--nex-line);
|
||||
}
|
||||
|
||||
.ptable.pt-rows li:hover {
|
||||
background: var(--nex-cream);
|
||||
}
|
||||
|
||||
.ptable.pt-rows li.is-flagged {
|
||||
|
|
@ -5703,8 +5936,15 @@ select:focus-visible,
|
|||
/* Grouped by application: the group header is a row of the same shape, so the
|
||||
columns line up with the rows it opens. */
|
||||
.process-grouped {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.process-grouped > li:not(:last-child) > .process-group-head {
|
||||
border-bottom: 1px solid var(--nex-line);
|
||||
}
|
||||
|
||||
.process-group-head {
|
||||
|
|
@ -5714,13 +5954,11 @@ select:focus-visible,
|
|||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 9px 11px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: rgba(255, 255, 255, 0.55);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.process-group-head:hover {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
background: var(--nex-cream);
|
||||
}
|
||||
|
||||
.process-group-head strong {
|
||||
|
|
@ -5804,8 +6042,4 @@ select:focus-visible,
|
|||
.item-row {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.startup-meta {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
36
src/types.ts
36
src/types.ts
|
|
@ -116,6 +116,7 @@ export interface AppInfo {
|
|||
name: string;
|
||||
bundle_id: string | null;
|
||||
path: string;
|
||||
icon_source: string | null;
|
||||
version: string | null;
|
||||
size: number;
|
||||
source: string;
|
||||
|
|
@ -212,6 +213,7 @@ export interface SystemSnapshot {
|
|||
os_name: string;
|
||||
os_version: string;
|
||||
hardware: string;
|
||||
gpu: string;
|
||||
hostname: string;
|
||||
user: string;
|
||||
arch: string;
|
||||
|
|
@ -440,10 +442,31 @@ export type StartupRisk =
|
|||
| "missing-target"
|
||||
| "in-temp-dir"
|
||||
| "unsigned"
|
||||
| "signature-unreadable"
|
||||
| "script-interpreter"
|
||||
| "recently-created"
|
||||
| "hidden-entry"
|
||||
| "hidden-home-directory";
|
||||
export type StartupCategory = "open-at-login" | "background";
|
||||
/** Something squid has to admit it could not read; the page says it in its own language. */
|
||||
export interface StartupNote {
|
||||
kind: "unreadable-root" | "login-items-unavailable";
|
||||
subject: string;
|
||||
detail: string;
|
||||
}
|
||||
export type StartupLock =
|
||||
| "operating-system"
|
||||
| "needs-authorisation"
|
||||
| "not-writable"
|
||||
| "managed-by-system-settings"
|
||||
| "not-managed";
|
||||
|
||||
/** The application an entry belongs to, as both operating systems group them. */
|
||||
export interface StartupOwner {
|
||||
name: string;
|
||||
bundlePath: string | null;
|
||||
vendor: boolean;
|
||||
}
|
||||
|
||||
export interface StartupItem {
|
||||
id: string;
|
||||
|
|
@ -458,21 +481,22 @@ export interface StartupItem {
|
|||
systemVendor: boolean;
|
||||
disabled: boolean;
|
||||
modifiable: boolean;
|
||||
readonlyReason: string | null;
|
||||
lock: StartupLock | null;
|
||||
hidden: boolean;
|
||||
modifiedMs: number | null;
|
||||
risks: StartupRisk[];
|
||||
category: StartupCategory;
|
||||
owner: StartupOwner | null;
|
||||
}
|
||||
|
||||
export interface StartupView {
|
||||
items: StartupItem[];
|
||||
notes: string[];
|
||||
userCount: number;
|
||||
systemCount: number;
|
||||
disabledCount: number;
|
||||
notes: StartupNote[];
|
||||
loginCount: number;
|
||||
backgroundCount: number;
|
||||
vendorCount: number;
|
||||
actionableCount: number;
|
||||
riskyCount: number;
|
||||
sources: string[];
|
||||
}
|
||||
|
||||
export interface StartupChange {
|
||||
|
|
|
|||
Loading…
Reference in New Issue