Release Squid 0.1.5 with language and startup controls
parent
20c20128e1
commit
6d9db8b700
|
|
@ -64,3 +64,5 @@ __pycache__/
|
|||
!release/0.1.3/Squid-Setup-0.1.3-win-x64.exe
|
||||
!release/0.1.4/Squid-0.1.4-macOS-universal.dmg
|
||||
!release/0.1.4/Squid-Setup-0.1.4-win-x64.exe
|
||||
!release/0.1.5/Squid-0.1.5-macOS-universal.dmg
|
||||
!release/0.1.5/Squid-Setup-0.1.5-win-x64.exe
|
||||
|
|
|
|||
|
|
@ -967,7 +967,7 @@ checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"
|
|||
|
||||
[[package]]
|
||||
name = "squid-cli"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -986,7 +986,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-core"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -1005,7 +1005,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-engine"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -1025,7 +1025,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-platform"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"libc",
|
||||
|
|
@ -1042,7 +1042,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-rules"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"globset",
|
||||
"serde",
|
||||
|
|
@ -1054,7 +1054,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-stats"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
|
@ -1066,7 +1066,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-tui"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ members = ["crates/*"]
|
|||
exclude = ["src-tauri"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
edition = "2021"
|
||||
rust-version = "1.80"
|
||||
license = "GPL-3.0-only"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,283 @@
|
|||
# Squid
|
||||
|
||||
[简体中文](README.zh-CN.md) · [Bilingual home](README.md)
|
||||
|
||||
**Give your computer a bath.**
|
||||
|
||||
Squid is a local system-care app for macOS and Windows. It cleans rebuildable caches and system junk, uninstalls apps with their leftovers, removes project build artefacts, maps disk usage, and shows live system health.
|
||||
|
||||
The desktop app, CLI, and TUI share one Rust scan-and-delete engine. Cleaning rules, safety boundaries, the deletion ledger, and settings live in one place. Squid requires no cloud service and no root access.
|
||||
|
||||
## Product surfaces
|
||||
|
||||
| Surface | Stack | Binary |
|
||||
| --- | --- | --- |
|
||||
| Desktop app | Tauri 2 + React 19 + TypeScript + Vite 6 | `squid-desktop` |
|
||||
| CLI | Rust + clap | `squid` |
|
||||
| TUI | Rust + ratatui + crossterm | `squid state` |
|
||||
|
||||
The desktop app supports macOS 12+ and Windows 10/11 x64. The CLI and TUI share the same Rust workspace.
|
||||
|
||||
## Features
|
||||
|
||||
| Feature | Description |
|
||||
| --- | --- |
|
||||
| Computer 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 |
|
||||
| Storage | Measures folders level by level, with the largest children and files |
|
||||
| Real-time monitor | Samples CPU, memory, network, disk, battery, volumes, and high-usage processes every two seconds; processes can be ended after confirmation |
|
||||
| History and undo | Every real deletion is recorded in a local ledger; items still in Trash or the Recycle Bin can be restored |
|
||||
| System updates | Checks, verifies, downloads, and installs new versions from the release channel |
|
||||
|
||||
Language settings offer only Simplified Chinese and English, with the current system language selected by default. A manual choice is saved as the interface language for this computer.
|
||||
|
||||
## Desktop app
|
||||
|
||||
### Sidebar
|
||||
|
||||
- **Maintenance**: Computer overview, Daily cleanup, Uninstall apps, Deep Clean
|
||||
- **Insights**: Storage, Real-time monitor
|
||||
- **Bottom**: History, Settings
|
||||
|
||||
Use `⌘1`–`⌘8` on macOS or `Ctrl+1`–`Ctrl+8` on Windows to switch pages.
|
||||
|
||||
### Menu bar / tray
|
||||
|
||||
Closing the main window only hides it; Squid keeps running. The tray menu offers:
|
||||
|
||||
- Open Squid
|
||||
- Daily cleanup
|
||||
- Uninstall apps
|
||||
- Deep Clean
|
||||
- Quit Squid
|
||||
|
||||
The tray follows the active interface language. Reopening the app, double-clicking the app icon, or triggering the single-instance handler restores and focuses the main window. Only **Quit Squid** ends the process.
|
||||
|
||||
### Software updates
|
||||
|
||||
- The system information panel always shows the current OS version, architecture, and Squid version.
|
||||
- Version changes, release notes, and actions appear only when a newer version exists; there is no duplicate "up to date" message.
|
||||
- After a verified download, install and restart, or use the neutral outlined **Discard** button that matches Shift to remove the downloaded file.
|
||||
- Automatic checks are enabled by default and run at most once per day.
|
||||
- Installers must match the manifest's size and SHA256. Builds with a release public key also verify the manifest's Ed25519 signature.
|
||||
|
||||
### Permissions and privacy
|
||||
|
||||
- On first launch, Squid shows an optional Full Disk Access check once. It does not force the macOS permission prompt and never blocks startup.
|
||||
- **Settings → System permissions** provides a status check and a shortcut to **System Settings → Privacy & Security → Full Disk Access**.
|
||||
- Without Full Disk Access, TCC-protected locations are skipped and every other feature remains available.
|
||||
- Storage analysis and Deep Clean read only user-selected or configured folders; file contents are never uploaded.
|
||||
- The app makes no network requests other than update checks and installer downloads.
|
||||
|
||||
### Launch at login
|
||||
|
||||
**Settings → Startup** includes a launch-at-login switch. When enabled, Squid starts automatically after the current user signs in and keeps its tray entry available. The setting is user-level and requires no administrator access.
|
||||
|
||||
See [`docs/DESKTOP.md`](docs/DESKTOP.md) for details.
|
||||
|
||||
## Quick start
|
||||
|
||||
### Desktop development
|
||||
|
||||
Requirements:
|
||||
|
||||
- Node.js 20+ and pnpm
|
||||
- Stable Rust
|
||||
- macOS: Xcode Command Line Tools
|
||||
- Windows: MSVC Build Tools and WebView2 Runtime
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
pnpm desktop:dev
|
||||
```
|
||||
|
||||
A plain Vite page cannot call Tauri commands. Use `pnpm desktop:dev` when testing scans, deletion, system data, or updates.
|
||||
|
||||
### CLI / TUI
|
||||
|
||||
```bash
|
||||
cargo install --path crates/squid-cli
|
||||
# or
|
||||
cargo build --release -p squid-cli
|
||||
|
||||
squid state # TUI
|
||||
squid status # system snapshot
|
||||
squid clean --dry-run # preview cleanable items
|
||||
squid uninstall --list # installed apps
|
||||
squid purge ~/code # project build artefacts
|
||||
squid analyze ~/Library/Caches # storage analysis
|
||||
squid history # deletion ledger
|
||||
squid undo # restore the latest Trash session
|
||||
```
|
||||
|
||||
Common commands:
|
||||
|
||||
| Command | Purpose |
|
||||
| --- | --- |
|
||||
| `clean` | Clean caches, logs, browser and developer junk, crash reports, and Trash by rule |
|
||||
| `uninstall [NAME]` | Locate an app and build an app-plus-leftovers uninstall plan |
|
||||
| `purge [PATHS…]` | Remove project build folders, disk images, installers, and stale downloads |
|
||||
| `state` | Open the TUI with cleanup, uninstall, deep clean, storage, system, and history panels |
|
||||
| `status` | Print a CPU, memory, network, disk, battery, and process snapshot |
|
||||
| `analyze [PATH]` | Print a directory-size tree and the largest files |
|
||||
| `history` / `undo [ID]` | Review history or restore a Trash session |
|
||||
| `whitelist add\|list\|remove` | Maintain protected paths that are never selected |
|
||||
| `rules` | List active rules |
|
||||
| `doctor` | Check permissions, configuration, history, and effective paths |
|
||||
|
||||
Every delete command supports `--dry-run`; non-interactive environments require `-y/--yes`. Run `squid <command> --help` for complete options.
|
||||
|
||||
## Architecture
|
||||
|
||||
```text
|
||||
crates/
|
||||
├── squid-core models, paths, safety policy, settings, deletion ledger, progress, cancellation
|
||||
├── squid-platform macOS / Linux / Windows adapters: apps, leftovers, volumes, Trash, processes
|
||||
├── squid-rules TOML rule engine: expansion, anchors, protection, age, and risk flags
|
||||
├── squid-stats sysinfo sampling, trends, battery, network, and disk activity
|
||||
├── squid-engine clean / uninstall / purge / analyze and the single deletion path
|
||||
├── squid-tui ratatui terminal interface
|
||||
└── squid-cli clap command-line entry point
|
||||
|
||||
src/ React desktop interface
|
||||
src-tauri/ Tauri shell, commands, tray, permission checks, and updater
|
||||
scripts/ development, verification, and dual-platform release scripts
|
||||
docs/ architecture, design, desktop, and release specifications
|
||||
```
|
||||
|
||||
`src-tauri` is separate from the root Cargo workspace, but depends directly on `squid-core`, `squid-platform`, `squid-stats`, and `squid-engine`. The desktop app does not maintain a second cleanup implementation.
|
||||
|
||||
See [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for architecture details and [`docs/DESIGN.md`](docs/DESIGN.md) for the shared Nex color, typography, component, and language rules.
|
||||
|
||||
## Safety model
|
||||
|
||||
1. **Index-based deletion**: the desktop UI can only submit indexes from a scan, never arbitrary paths.
|
||||
2. **Revalidation before execution**: the Rust layer rebuilds each item and rechecks ownership, safety anchors, protected locations, the whitelist, and lock state.
|
||||
3. **Trash by default**: deletion mode defaults to `trash`; files are removed directly only when permanent deletion is explicitly selected.
|
||||
4. **Hard boundaries**: system roots, `/usr`, `/System`, `/Applications`, and similar locations cannot be recursively deleted. Symlinks are never followed.
|
||||
5. **Rule brakes**: rules support `protect`, `min_age_days`, `skip_if_running`, and `risky`.
|
||||
6. **Ledger and undo**: real deletions are recorded in a local JSON ledger; files still in Trash can be restored.
|
||||
7. **Process protection**: the process is sampled again before termination; Squid itself, PID 1, and critical system processes are refused.
|
||||
|
||||
The GUI and CLI use the same `squid-engine::delete` path, so behavior, locks, and audit results stay consistent.
|
||||
|
||||
## Data and configuration
|
||||
|
||||
| Purpose | macOS | Windows |
|
||||
| --- | --- | --- |
|
||||
| Configuration and rules | `~/Library/Application Support/squid/` | `%APPDATA%\squid\` |
|
||||
| History ledger | `~/Library/Application Support/squid/history/` | `%APPDATA%\squid\history\` |
|
||||
| Delete destination | `~/.Trash` or permanent deletion | Recycle Bin or permanent deletion |
|
||||
|
||||
Linux uses XDG directories. The desktop app and CLI/TUI share configuration and history, so a cleanup from either surface is visible in the other.
|
||||
|
||||
Common configuration:
|
||||
|
||||
```toml
|
||||
delete_mode = "trash"
|
||||
history_keep = 60
|
||||
purge_min_age_days = 7
|
||||
purge_max_entries = 200000
|
||||
show_allocated = true
|
||||
# Empty or omitted means "follow system"; set "en" or "zh" to override
|
||||
language = ""
|
||||
whitelist = ["~/Library/Caches/ImportantApp"]
|
||||
disabled_rules = ["user-trash"]
|
||||
purge_roots = ["~/code", "~/Projects", "~/Desktop"]
|
||||
```
|
||||
|
||||
Main environment variables:
|
||||
|
||||
| Variable | Purpose |
|
||||
| --- | --- |
|
||||
| `SQUID_CONFIG_DIR` | Override the configuration directory |
|
||||
| `SQUID_STATE_DIR` | Override the state and history directory |
|
||||
| `SQUID_LANG` | Force the CLI/TUI language to `zh` or `en` |
|
||||
| `SQUID_UPDATE_URL` | Override the desktop update manifest URL for staging |
|
||||
| `SQUID_TRUECOLOR` / `NO_COLOR` | Control TUI color |
|
||||
| `SQUID_SYMBOL_CELLS` / `SQUID_CONSOLE_TRACE` | Diagnose Windows console character width and layout |
|
||||
|
||||
`SQUID_LANG` is a CLI override. The desktop app's default language comes from the system and can be changed in the app.
|
||||
|
||||
## Development and verification
|
||||
|
||||
Frontend:
|
||||
|
||||
```bash
|
||||
pnpm check
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Rust workspace:
|
||||
|
||||
```bash
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --workspace --all-targets -- -D warnings
|
||||
cargo test --workspace --no-fail-fast
|
||||
```
|
||||
|
||||
Tauri:
|
||||
|
||||
```bash
|
||||
cargo fmt --manifest-path src-tauri/Cargo.toml -- --check
|
||||
cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings
|
||||
cargo test --manifest-path src-tauri/Cargo.toml --lib
|
||||
```
|
||||
|
||||
The TUI uses a real-pty smoke test; Windows consoles also have a capture, replay, and frame-check test:
|
||||
|
||||
```bash
|
||||
python3 -m pip install --user pyte
|
||||
python3 scripts/tui_smoke.py
|
||||
python3 scripts/tui-frame-check.py --selftest
|
||||
```
|
||||
|
||||
CI runs workspace tests, an MSVC target cross-check, the desktop frontend build, and the Tauri Rust check.
|
||||
|
||||
## Build and release
|
||||
|
||||
Keep the version identical in all four places:
|
||||
|
||||
- `Cargo.toml` workspace version
|
||||
- `src-tauri/Cargo.toml`
|
||||
- `src-tauri/tauri.conf.json`
|
||||
- `package.json`
|
||||
|
||||
Build installers:
|
||||
|
||||
```bash
|
||||
scripts/build-macos-release.sh
|
||||
scripts/build-windows-release.sh
|
||||
```
|
||||
|
||||
Artifacts:
|
||||
|
||||
```text
|
||||
artifacts/Squid-<version>-macOS-universal.dmg
|
||||
artifacts/Squid-Setup-<version>-win-x64.exe
|
||||
artifacts/SHA256SUMS.txt
|
||||
```
|
||||
|
||||
Publish to the update channel:
|
||||
|
||||
```bash
|
||||
scripts/publish-release.sh --notes /path/to/release-notes.md
|
||||
```
|
||||
|
||||
The publish script rebuilds the `releases` branch with `squid-update.json`, both installers, and an optional `squid-update.sig`. The manifest records exact size and SHA256, which the client verifies again after download.
|
||||
|
||||
See [`docs/RELEASE.md`](docs/RELEASE.md) for the full release, signing, and manifest process.
|
||||
|
||||
## Platform status
|
||||
|
||||
| Platform | Status |
|
||||
| --- | --- |
|
||||
| macOS | Full desktop and CLI/TUI support; universal DMG |
|
||||
| Windows x64 | Desktop and CLI/TUI support; NSIS installer |
|
||||
| Linux | Platform layer and basic CLI/TUI support; built-in rules and desktop installers are not yet provided |
|
||||
|
||||
## License
|
||||
|
||||
Squid is licensed under **GNU General Public License v3.0 only** (`GPL-3.0-only`). See [`LICENSE`](LICENSE).
|
||||
280
README.md
280
README.md
|
|
@ -1,279 +1,49 @@
|
|||
# Squid
|
||||
|
||||
**给你的电脑洗个澡。**
|
||||
**给你的电脑洗个澡。** · **Give your computer a bath.**
|
||||
|
||||
Squid 是面向 macOS 与 Windows 的本地系统维护工具:清理可重建的缓存与系统垃圾、卸载应用并处理残留、清理项目构建产物、分析磁盘占用,以及实时查看系统状态。
|
||||
[简体中文](README.zh-CN.md) · [English](README.en.md)
|
||||
|
||||
桌面端、命令行与 TUI 共用同一套 Rust 扫描和删除引擎。清理规则、安全边界、删除账本与配置只维护一份,不依赖云端服务,也不需要 root。
|
||||
Squid is a local system-care app for macOS and Windows. It cleans rebuildable caches and system junk, uninstalls apps with their leftovers, removes project build artefacts, maps disk usage, and monitors live system health.
|
||||
|
||||
## 产品组成
|
||||
Squid 是面向 macOS 与 Windows 的本地系统维护工具。桌面端、CLI 与 TUI 共用同一套 Rust 扫描和删除引擎,不依赖云端服务,也不需要 root。
|
||||
|
||||
| 入口 | 技术栈 | 二进制 |
|
||||
| --- | --- | --- |
|
||||
| 桌面应用 | Tauri 2 + React 19 + TypeScript + Vite 6 | `squid-desktop` |
|
||||
| 命令行 | Rust + clap | `squid` |
|
||||
| 终端界面 | Rust + ratatui + crossterm | `squid state` |
|
||||
## Highlights / 功能
|
||||
|
||||
桌面端支持 macOS 12+ 与 Windows 10/11 x64;CLI/TUI 使用同一个 Rust workspace。
|
||||
- **Daily cleanup / 日常清理** — 38 macOS rules and 30 Windows rules for caches, logs, crash reports, developer data, and Trash.
|
||||
- **Uninstall apps / 应用卸载** — One plan for the app and its preferences, caches, containers, or AppData leftovers.
|
||||
- **Deep Clean / 深度清理** — Rebuildable build output, disk images, installers, and stale downloads with project-age protection.
|
||||
- **Storage & monitor / 存储与监控** — Folder-level disk analysis, live CPU, memory, network, disk, battery, and process views.
|
||||
- **History & updates / 历史与更新** — Restorable Trash sessions and a size- and SHA256-verified update channel.
|
||||
|
||||
## 功能
|
||||
The interface follows the system language by default and can be switched to Simplified Chinese or English in Settings.
|
||||
|
||||
| 功能 | 说明 |
|
||||
| --- | --- |
|
||||
| 电脑概览 | 磁盘健康、常用操作入口与 CPU、内存、存储摘要 |
|
||||
| 日常清理 | macOS 38 条 / Windows 30 条内置规则,覆盖应用与浏览器缓存、日志、崩溃报告、开发缓存与废纸篓等 |
|
||||
| 应用卸载 | 按名称定位应用,把应用本体与偏好、缓存、容器或 AppData 残留组成同一个卸载计划 |
|
||||
| 深度清理 | 查找 `node_modules` 等可重建构建产物、磁盘镜像、安装包和陈旧下载,并保护近期仍在使用的项目 |
|
||||
| 存储空间 | 逐层测量目录、查看最大子项与最大文件 |
|
||||
| 实时监控 | 每两秒采样 CPU、内存、网络、磁盘、电池、卷和高占用进程,可确认后结束进程 |
|
||||
| 历史与撤销 | 每次真实删除写入本地账本;仍在废纸篓或回收站中的内容可以还原 |
|
||||
| 系统更新 | 从发布分支检查、校验、下载并安装新版本 |
|
||||
界面默认跟随系统语言,可在设置中切换简体中文或 English。
|
||||
|
||||
界面支持中文和英文,跟随 Squid 的语言设置与系统语言。
|
||||
|
||||
## 桌面应用
|
||||
|
||||
### 左侧菜单
|
||||
|
||||
- **维护**:电脑概览、日常清理、应用卸载、深度清理
|
||||
- **洞察**:存储空间、实时监控
|
||||
- **底部**:历史记录、设置
|
||||
|
||||
`⌘1`–`⌘8`(macOS)或 `Ctrl+1`–`Ctrl+8`(Windows)可以直接切换页面。
|
||||
|
||||
### 常驻托盘
|
||||
|
||||
关闭主窗口只会隐藏窗口,Squid 进程继续运行。托盘菜单提供:
|
||||
|
||||
- 打开 Squid
|
||||
- 日常清理
|
||||
- 应用卸载
|
||||
- 深度清理
|
||||
- 退出 Squid
|
||||
|
||||
再次打开应用、双击应用图标或通过单实例唤起时,会恢复并聚焦主窗口。只有选择“退出 Squid”才会结束进程。
|
||||
|
||||
### 软件更新
|
||||
|
||||
- 设置中的系统信息面板始终显示当前系统版本、架构与 Squid 版本。
|
||||
- 只有检测到更高版本时,才显示版本变化和更新说明;已经是最新版本时不显示额外提示。
|
||||
- 自动检查默认开启,每天最多检查一次。
|
||||
- 安装包必须通过 SHA256 与文件大小校验;带发布公钥的构建还会校验清单的 Ed25519 签名。
|
||||
|
||||
### 权限与隐私
|
||||
|
||||
- 首次启动会显示一次可选的全盘访问检查,不会强制弹出 macOS 权限窗口,也不会阻止应用启动。
|
||||
- “设置 → 系统权限”提供权限状态检查和打开“系统设置 → 隐私与安全性 → 全盘访问”的入口。
|
||||
- 没有全盘访问时,受 TCC 保护的位置会被跳过,其余功能仍然可用。
|
||||
- 存储分析与深度清理只在用户选择或配置目录后读取;文件内容不会上传。
|
||||
- 除更新检查和安装包下载外,应用不发起网络请求。
|
||||
|
||||
完整说明见 [`docs/DESKTOP.md`](docs/DESKTOP.md)。
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 桌面端开发
|
||||
|
||||
环境要求:
|
||||
|
||||
- Node.js 20+ 与 pnpm
|
||||
- Rust stable
|
||||
- macOS:Xcode Command Line Tools
|
||||
- Windows:MSVC Build Tools 与 WebView2 Runtime
|
||||
## Start / 开始
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
pnpm desktop:dev
|
||||
```
|
||||
|
||||
仅运行 Vite 页面时无法调用 Tauri 命令;需要验证扫描、删除、系统数据或更新流程时请使用 `pnpm desktop:dev`。
|
||||
|
||||
### CLI / TUI
|
||||
CLI / TUI:
|
||||
|
||||
```bash
|
||||
cargo install --path crates/squid-cli
|
||||
# 或
|
||||
cargo build --release -p squid-cli
|
||||
|
||||
squid state # TUI
|
||||
squid status # 系统快照
|
||||
squid clean --dry-run # 预览可清理内容
|
||||
squid uninstall --list # 已安装应用
|
||||
squid purge ~/code # 深度清理项目构建产物
|
||||
squid analyze ~/Library/Caches # 存储分析
|
||||
squid history # 历史账本
|
||||
squid undo # 还原最近一次废纸篓会话
|
||||
squid state
|
||||
squid clean --dry-run
|
||||
```
|
||||
|
||||
常用命令:
|
||||
## Documentation / 文档
|
||||
|
||||
| 命令 | 作用 |
|
||||
| --- | --- |
|
||||
| `clean` | 按规则清理缓存、日志、浏览器与开发者垃圾、崩溃报告和废纸篓 |
|
||||
| `uninstall [NAME]` | 定位应用并生成“本体 + 残留”卸载计划 |
|
||||
| `purge [PATHS…]` | 清理项目构建目录、磁盘镜像、安装包与陈旧下载 |
|
||||
| `state` | 打开包含清理、卸载、深度清理、存储、系统和历史面板的 TUI |
|
||||
| `status` | 输出 CPU、内存、网络、磁盘、电池与进程快照 |
|
||||
| `analyze [PATH]` | 输出目录体积树与最大文件 |
|
||||
| `history` / `undo [ID]` | 查看历史或还原废纸篓会话 |
|
||||
| `whitelist add\|list\|remove` | 维护永不选中的保护路径 |
|
||||
| `rules` | 列出当前生效的规则 |
|
||||
| `doctor` | 检查权限、配置、历史文件和生效路径 |
|
||||
- [中文完整说明](README.zh-CN.md)
|
||||
- [Full English guide](README.en.md)
|
||||
- [Architecture / 架构](docs/ARCHITECTURE.md)
|
||||
- [Nex design standard / 设计规范](docs/DESIGN.md)
|
||||
- [Desktop / 桌面端](docs/DESKTOP.md)
|
||||
- [Release and updates / 发布与更新](docs/RELEASE.md)
|
||||
|
||||
所有删除命令都支持 `--dry-run`;非交互环境必须使用 `-y/--yes`。完整参数请运行 `squid <command> --help`。
|
||||
## License / 许可证
|
||||
|
||||
## 架构
|
||||
|
||||
```text
|
||||
crates/
|
||||
├── squid-core 模型、路径、安全策略、设置、删除账本、进度与取消
|
||||
├── squid-platform macOS / Linux / Windows 平台适配:应用、残留、卷、回收站、进程
|
||||
├── squid-rules TOML 规则引擎:模式展开、锚点、保护、年龄与风险标记
|
||||
├── squid-stats sysinfo 采样、趋势、电池、网络与磁盘活动
|
||||
├── squid-engine clean / uninstall / purge / analyze 与唯一删除通道
|
||||
├── squid-tui ratatui 终端界面
|
||||
└── squid-cli clap 命令行入口
|
||||
|
||||
src/ React 桌面界面
|
||||
src-tauri/ Tauri 壳、命令适配、托盘、权限检查与更新器
|
||||
scripts/ 开发、验证与双平台发布脚本
|
||||
docs/ 架构、设计、桌面与发布规范
|
||||
```
|
||||
|
||||
核心依赖方向:
|
||||
|
||||
```text
|
||||
squid-core → squid-platform → squid-rules → squid-stats → squid-engine → squid-tui → squid-cli
|
||||
```
|
||||
|
||||
`src-tauri` 独立于根 Cargo workspace,但直接依赖 `squid-core`、`squid-platform`、`squid-stats` 与 `squid-engine`,桌面端不维护第二套清理实现。
|
||||
|
||||
更多设计见 [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md);Nex 系列统一颜色、字体和组件常量见 [`docs/DESIGN.md`](docs/DESIGN.md)。
|
||||
|
||||
## 安全模型
|
||||
|
||||
1. **索引式删除**:桌面界面只能提交扫描结果中的索引,不能提交任意待删除路径。
|
||||
2. **执行前复验**:Rust 层重新构造扫描条目,并检查路径所有权、安全锚点、保护列表、白名单与锁定状态。
|
||||
3. **默认进废纸篓**:删除模式默认是 `trash`;只有显式选择永久删除才直接移除。
|
||||
4. **硬性禁区**:系统根目录、`/usr`、`/System`、`/Applications` 等位置不能被递归删除;符号链接不会被跟随。
|
||||
5. **规则刹车**:规则支持 `protect`、`min_age_days`、`skip_if_running` 与 `risky` 标记。
|
||||
6. **账本与撤销**:真实删除记录到本地 JSON 账本,仍在废纸篓中的文件可以还原。
|
||||
7. **进程保护**:结束进程前重新采样并核对名称,拒绝 Squid 自身、系统首进程和关键系统进程。
|
||||
|
||||
GUI 和 CLI 使用同一个 `squid-engine::delete` 通道,因此行为、锁定和审计结果一致。
|
||||
|
||||
## 数据与配置
|
||||
|
||||
| 用途 | macOS | Windows |
|
||||
| --- | --- | --- |
|
||||
| 配置与规则 | `~/Library/Application Support/squid/` | `%APPDATA%\squid\` |
|
||||
| 历史账本 | `~/Library/Application Support/squid/history/` | `%APPDATA%\squid\history\` |
|
||||
| 删除去向 | `~/.Trash` 或永久删除 | 回收站或永久删除 |
|
||||
|
||||
Linux 使用 XDG 目录。桌面端与 CLI/TUI 共用配置和历史,因此任一端产生的清理记录都能在另一端查看。
|
||||
|
||||
常用配置:
|
||||
|
||||
```toml
|
||||
delete_mode = "trash"
|
||||
history_keep = 60
|
||||
purge_min_age_days = 7
|
||||
purge_max_entries = 200000
|
||||
show_allocated = true
|
||||
language = "zh" # en | zh
|
||||
whitelist = ["~/Library/Caches/ImportantApp"]
|
||||
disabled_rules = ["user-trash"]
|
||||
purge_roots = ["~/code", "~/Projects", "~/Desktop"]
|
||||
```
|
||||
|
||||
主要环境变量:
|
||||
|
||||
| 变量 | 作用 |
|
||||
| --- | --- |
|
||||
| `SQUID_CONFIG_DIR` | 覆盖配置目录 |
|
||||
| `SQUID_STATE_DIR` | 覆盖状态与历史目录 |
|
||||
| `SQUID_LANG` | 强制 `zh` 或 `en` |
|
||||
| `SQUID_UPDATE_URL` | 覆盖桌面端更新清单地址,适合测试发布通道 |
|
||||
| `SQUID_TRUECOLOR` / `NO_COLOR` | 控制 TUI 颜色 |
|
||||
| `SQUID_SYMBOL_CELLS` / `SQUID_CONSOLE_TRACE` | 排查 Windows 控制台字符宽度与排版 |
|
||||
|
||||
## 开发与验证
|
||||
|
||||
前端:
|
||||
|
||||
```bash
|
||||
pnpm check
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Rust workspace:
|
||||
|
||||
```bash
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --workspace --all-targets -- -D warnings
|
||||
cargo test --workspace
|
||||
```
|
||||
|
||||
Tauri:
|
||||
|
||||
```bash
|
||||
cargo fmt --manifest-path src-tauri/Cargo.toml -- --check
|
||||
cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings
|
||||
cargo test --manifest-path src-tauri/Cargo.toml --lib
|
||||
```
|
||||
|
||||
TUI 使用真实 pty 冒烟测试;Windows 控制台另有“抓帧、复放、量框”验证:
|
||||
|
||||
```bash
|
||||
python3 -m pip install --user pyte
|
||||
python3 scripts/tui_smoke.py
|
||||
python3 scripts/tui-frame-check.py --selftest
|
||||
```
|
||||
|
||||
CI 同时执行 workspace 测试、MSVC 目标交叉检查、桌面前端构建和 Tauri Rust 检查。
|
||||
|
||||
## 打包与发布
|
||||
|
||||
版本必须同时写入以下四处:
|
||||
|
||||
- `Cargo.toml` workspace 版本
|
||||
- `src-tauri/Cargo.toml`
|
||||
- `src-tauri/tauri.conf.json`
|
||||
- `package.json`
|
||||
|
||||
构建安装包:
|
||||
|
||||
```bash
|
||||
scripts/build-macos-release.sh
|
||||
scripts/build-windows-release.sh
|
||||
```
|
||||
|
||||
产物:
|
||||
|
||||
```text
|
||||
artifacts/Squid-<version>-macOS-universal.dmg
|
||||
artifacts/Squid-Setup-<version>-win-x64.exe
|
||||
artifacts/SHA256SUMS.txt
|
||||
```
|
||||
|
||||
发布到更新通道:
|
||||
|
||||
```bash
|
||||
scripts/publish-release.sh --notes /path/to/release-notes.md
|
||||
```
|
||||
|
||||
发布脚本会重建 `releases` 分支,写入 `squid-update.json`、两个安装包和可选的 `squid-update.sig`。清单包含精确大小与 SHA256,客户端下载后再次校验。
|
||||
|
||||
完整发布流程、签名和清单格式见 [`docs/RELEASE.md`](docs/RELEASE.md)。
|
||||
|
||||
## 平台状态
|
||||
|
||||
| 平台 | 状态 |
|
||||
| --- | --- |
|
||||
| macOS | 桌面端与 CLI/TUI 完整支持,发布通用 DMG |
|
||||
| Windows x64 | 桌面端与 CLI/TUI 支持,发布 NSIS 安装包 |
|
||||
| Linux | 平台层与 CLI/TUI 基础实现;尚未提供内置 Linux 规则和桌面安装包 |
|
||||
|
||||
## 许可证
|
||||
|
||||
Squid 使用 **GNU General Public License v3.0 only**(`GPL-3.0-only`)。完整条款见 [`LICENSE`](LICENSE)。
|
||||
**GNU General Public License v3.0 only** (`GPL-3.0-only`). See [`LICENSE`](LICENSE).
|
||||
|
|
|
|||
|
|
@ -0,0 +1,283 @@
|
|||
# Squid
|
||||
|
||||
[English](README.en.md) · [返回双语首页](README.md)
|
||||
|
||||
**给你的电脑洗个澡。**
|
||||
|
||||
Squid 是面向 macOS 与 Windows 的本地系统维护工具:清理可重建的缓存与系统垃圾、卸载应用并处理残留、清理项目构建产物、分析磁盘占用,以及实时查看系统状态。
|
||||
|
||||
桌面端、命令行与 TUI 共用同一套 Rust 扫描和删除引擎。清理规则、安全边界、删除账本与配置只维护一份,不依赖云端服务,也不需要 root。
|
||||
|
||||
## 产品组成
|
||||
|
||||
| 入口 | 技术栈 | 二进制 |
|
||||
| --- | --- | --- |
|
||||
| 桌面应用 | Tauri 2 + React 19 + TypeScript + Vite 6 | `squid-desktop` |
|
||||
| 命令行 | Rust + clap | `squid` |
|
||||
| 终端界面 | Rust + ratatui + crossterm | `squid state` |
|
||||
|
||||
桌面端支持 macOS 12+ 与 Windows 10/11 x64;CLI/TUI 使用同一个 Rust workspace。
|
||||
|
||||
## 功能
|
||||
|
||||
| 功能 | 说明 |
|
||||
| --- | --- |
|
||||
| 电脑概览 | 磁盘健康、常用操作入口与 CPU、内存、存储摘要 |
|
||||
| 日常清理 | macOS 38 条 / Windows 30 条内置规则,覆盖应用与浏览器缓存、日志、崩溃报告、开发缓存与废纸篓等 |
|
||||
| 应用卸载 | 按名称定位应用,把应用本体与偏好、缓存、容器或 AppData 残留组成同一个卸载计划 |
|
||||
| 深度清理 | 查找 `node_modules` 等可重建构建产物、磁盘镜像、安装包和陈旧下载,并保护近期仍在使用的项目 |
|
||||
| 存储空间 | 逐层测量目录、查看最大子项与最大文件 |
|
||||
| 实时监控 | 每两秒采样 CPU、内存、网络、磁盘、电池、卷和高占用进程,可确认后结束进程 |
|
||||
| 历史与撤销 | 每次真实删除写入本地账本;仍在废纸篓或回收站中的内容可以还原 |
|
||||
| 系统更新 | 从发布分支检查、校验、下载并安装新版本 |
|
||||
|
||||
语言设置只提供简体中文与 English 两项,首次使用时默认选中当前系统语言。手动选择会保存为该电脑上的界面语言。
|
||||
|
||||
## 桌面应用
|
||||
|
||||
### 左侧菜单
|
||||
|
||||
- **维护**:电脑概览、日常清理、应用卸载、深度清理
|
||||
- **洞察**:存储空间、实时监控
|
||||
- **底部**:历史记录、设置
|
||||
|
||||
`⌘1`–`⌘8`(macOS)或 `Ctrl+1`–`Ctrl+8`(Windows)可以直接切换页面。
|
||||
|
||||
### 常驻托盘
|
||||
|
||||
关闭主窗口只会隐藏窗口,Squid 进程继续运行。托盘菜单提供:
|
||||
|
||||
- 打开 Squid
|
||||
- 日常清理
|
||||
- 应用卸载
|
||||
- 深度清理
|
||||
- 退出 Squid
|
||||
|
||||
托盘菜单跟随当前界面语言。再次打开应用、双击应用图标或通过单实例唤起时,会恢复并聚焦主窗口。只有选择“退出 Squid”才会结束进程。
|
||||
|
||||
### 软件更新
|
||||
|
||||
- 设置中的系统信息面板始终显示当前系统版本、架构与 Squid 版本。
|
||||
- 只有检测到更高版本时,才显示版本变化、更新说明和操作按钮;已经是最新版本时不显示额外提示。
|
||||
- 下载完成后可安装并重启,或用与 Shift 一致的中性描边“放弃”按钮清除已下载文件。
|
||||
- 自动检查默认开启,每天最多检查一次。
|
||||
- 安装包必须通过 SHA256 与文件大小校验;带发布公钥的构建还会校验清单的 Ed25519 签名。
|
||||
|
||||
### 权限与隐私
|
||||
|
||||
- 首次启动会显示一次可选的全盘访问检查,不会强制弹出 macOS 权限窗口,也不会阻止应用启动。
|
||||
- “设置 → 系统权限”提供权限状态检查和打开“系统设置 → 隐私与安全性 → 全盘访问”的入口。
|
||||
- 没有全盘访问时,受 TCC 保护的位置会被跳过,其余功能仍然可用。
|
||||
- 存储分析与深度清理只在用户选择或配置目录后读取;文件内容不会上传。
|
||||
- 除更新检查和安装包下载外,应用不发起网络请求。
|
||||
|
||||
### 开机自启
|
||||
|
||||
“设置 → 启动”提供开机自启开关。启用后 Squid 会在当前用户登录时自动启动并保留托盘入口;该设置只写入当前用户级启动项,不需要管理员权限。
|
||||
|
||||
完整说明见 [`docs/DESKTOP.md`](docs/DESKTOP.md)。
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 桌面端开发
|
||||
|
||||
环境要求:
|
||||
|
||||
- Node.js 20+ 与 pnpm
|
||||
- Rust stable
|
||||
- macOS:Xcode Command Line Tools
|
||||
- Windows:MSVC Build Tools 与 WebView2 Runtime
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
pnpm desktop:dev
|
||||
```
|
||||
|
||||
仅运行 Vite 页面时无法调用 Tauri 命令;需要验证扫描、删除、系统数据或更新流程时请使用 `pnpm desktop:dev`。
|
||||
|
||||
### CLI / TUI
|
||||
|
||||
```bash
|
||||
cargo install --path crates/squid-cli
|
||||
# 或
|
||||
cargo build --release -p squid-cli
|
||||
|
||||
squid state # TUI
|
||||
squid status # 系统快照
|
||||
squid clean --dry-run # 预览可清理内容
|
||||
squid uninstall --list # 已安装应用
|
||||
squid purge ~/code # 深度清理项目构建产物
|
||||
squid analyze ~/Library/Caches # 存储分析
|
||||
squid history # 历史账本
|
||||
squid undo # 还原最近一次废纸篓会话
|
||||
```
|
||||
|
||||
常用命令:
|
||||
|
||||
| 命令 | 作用 |
|
||||
| --- | --- |
|
||||
| `clean` | 按规则清理缓存、日志、浏览器与开发者垃圾、崩溃报告和废纸篓 |
|
||||
| `uninstall [NAME]` | 定位应用并生成“本体 + 残留”卸载计划 |
|
||||
| `purge [PATHS…]` | 清理项目构建目录、磁盘镜像、安装包与陈旧下载 |
|
||||
| `state` | 打开包含清理、卸载、深度清理、存储、系统和历史面板的 TUI |
|
||||
| `status` | 输出 CPU、内存、网络、磁盘、电池与进程快照 |
|
||||
| `analyze [PATH]` | 输出目录体积树与最大文件 |
|
||||
| `history` / `undo [ID]` | 查看历史或还原废纸篓会话 |
|
||||
| `whitelist add\|list\|remove` | 维护永不选中的保护路径 |
|
||||
| `rules` | 列出当前生效的规则 |
|
||||
| `doctor` | 检查权限、配置、历史文件和生效路径 |
|
||||
|
||||
所有删除命令都支持 `--dry-run`;非交互环境必须使用 `-y/--yes`。完整参数请运行 `squid <command> --help`。
|
||||
|
||||
## 架构
|
||||
|
||||
```text
|
||||
crates/
|
||||
├── squid-core 模型、路径、安全策略、设置、删除账本、进度与取消
|
||||
├── squid-platform macOS / Linux / Windows 平台适配:应用、残留、卷、回收站、进程
|
||||
├── squid-rules TOML 规则引擎:模式展开、锚点、保护、年龄与风险标记
|
||||
├── squid-stats sysinfo 采样、趋势、电池、网络与磁盘活动
|
||||
├── squid-engine clean / uninstall / purge / analyze 与唯一删除通道
|
||||
├── squid-tui ratatui 终端界面
|
||||
└── squid-cli clap 命令行入口
|
||||
|
||||
src/ React 桌面界面
|
||||
src-tauri/ Tauri 壳、命令适配、托盘、权限检查与更新器
|
||||
scripts/ 开发、验证与双平台发布脚本
|
||||
docs/ 架构、设计、桌面与发布规范
|
||||
```
|
||||
|
||||
`src-tauri` 独立于根 Cargo workspace,但直接依赖 `squid-core`、`squid-platform`、`squid-stats` 与 `squid-engine`,桌面端不维护第二套清理实现。
|
||||
|
||||
更多设计见 [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md);Nex 系列统一颜色、字体、组件和语言规范见 [`docs/DESIGN.md`](docs/DESIGN.md)。
|
||||
|
||||
## 安全模型
|
||||
|
||||
1. **索引式删除**:桌面界面只能提交扫描结果中的索引,不能提交任意待删除路径。
|
||||
2. **执行前复验**:Rust 层重新构造扫描条目,并检查路径所有权、安全锚点、保护列表、白名单与锁定状态。
|
||||
3. **默认进废纸篓**:删除模式默认是 `trash`;只有显式选择永久删除才直接移除。
|
||||
4. **硬性禁区**:系统根目录、`/usr`、`/System`、`/Applications` 等位置不能被递归删除;符号链接不会被跟随。
|
||||
5. **规则刹车**:规则支持 `protect`、`min_age_days`、`skip_if_running` 与 `risky` 标记。
|
||||
6. **账本与撤销**:真实删除记录到本地 JSON 账本,仍在废纸篓中的文件可以还原。
|
||||
7. **进程保护**:结束进程前重新采样并核对名称,拒绝 Squid 自身、系统首进程和关键系统进程。
|
||||
|
||||
GUI 和 CLI 使用同一个 `squid-engine::delete` 通道,因此行为、锁定和审计结果一致。
|
||||
|
||||
## 数据与配置
|
||||
|
||||
| 用途 | macOS | Windows |
|
||||
| --- | --- | --- |
|
||||
| 配置与规则 | `~/Library/Application Support/squid/` | `%APPDATA%\squid\` |
|
||||
| 历史账本 | `~/Library/Application Support/squid/history/` | `%APPDATA%\squid\history\` |
|
||||
| 删除去向 | `~/.Trash` 或永久删除 | 回收站或永久删除 |
|
||||
|
||||
Linux 使用 XDG 目录。桌面端与 CLI/TUI 共用配置和历史,因此任一端产生的清理记录都能在另一端查看。
|
||||
|
||||
常用配置:
|
||||
|
||||
```toml
|
||||
delete_mode = "trash"
|
||||
history_keep = 60
|
||||
purge_min_age_days = 7
|
||||
purge_max_entries = 200000
|
||||
show_allocated = true
|
||||
# language 留空或删除表示跟随系统;也可手动设为 "en" 或 "zh"
|
||||
language = ""
|
||||
whitelist = ["~/Library/Caches/ImportantApp"]
|
||||
disabled_rules = ["user-trash"]
|
||||
purge_roots = ["~/code", "~/Projects", "~/Desktop"]
|
||||
```
|
||||
|
||||
主要环境变量:
|
||||
|
||||
| 变量 | 作用 |
|
||||
| --- | --- |
|
||||
| `SQUID_CONFIG_DIR` | 覆盖配置目录 |
|
||||
| `SQUID_STATE_DIR` | 覆盖状态与历史目录 |
|
||||
| `SQUID_LANG` | 强制 CLI/TUI 使用 `zh` 或 `en` |
|
||||
| `SQUID_UPDATE_URL` | 覆盖桌面端更新清单地址,适合测试发布通道 |
|
||||
| `SQUID_TRUECOLOR` / `NO_COLOR` | 控制 TUI 颜色 |
|
||||
| `SQUID_SYMBOL_CELLS` / `SQUID_CONSOLE_TRACE` | 排查 Windows 控制台字符宽度与排版 |
|
||||
|
||||
`SQUID_LANG` 是命令行覆盖项;桌面界面的默认语言来自系统设置,并可在应用内修改。
|
||||
|
||||
## 开发与验证
|
||||
|
||||
前端:
|
||||
|
||||
```bash
|
||||
pnpm check
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Rust workspace:
|
||||
|
||||
```bash
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --workspace --all-targets -- -D warnings
|
||||
cargo test --workspace --no-fail-fast
|
||||
```
|
||||
|
||||
Tauri:
|
||||
|
||||
```bash
|
||||
cargo fmt --manifest-path src-tauri/Cargo.toml -- --check
|
||||
cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings
|
||||
cargo test --manifest-path src-tauri/Cargo.toml --lib
|
||||
```
|
||||
|
||||
TUI 使用真实 pty 冒烟测试;Windows 控制台另有“抓帧、复放、量框”验证:
|
||||
|
||||
```bash
|
||||
python3 -m pip install --user pyte
|
||||
python3 scripts/tui_smoke.py
|
||||
python3 scripts/tui-frame-check.py --selftest
|
||||
```
|
||||
|
||||
CI 同时执行 workspace 测试、MSVC 目标交叉检查、桌面前端构建和 Tauri Rust 检查。
|
||||
|
||||
## 打包与发布
|
||||
|
||||
版本必须同时写入以下四处:
|
||||
|
||||
- `Cargo.toml` workspace 版本
|
||||
- `src-tauri/Cargo.toml`
|
||||
- `src-tauri/tauri.conf.json`
|
||||
- `package.json`
|
||||
|
||||
构建安装包:
|
||||
|
||||
```bash
|
||||
scripts/build-macos-release.sh
|
||||
scripts/build-windows-release.sh
|
||||
```
|
||||
|
||||
产物:
|
||||
|
||||
```text
|
||||
artifacts/Squid-<version>-macOS-universal.dmg
|
||||
artifacts/Squid-Setup-<version>-win-x64.exe
|
||||
artifacts/SHA256SUMS.txt
|
||||
```
|
||||
|
||||
发布到更新通道:
|
||||
|
||||
```bash
|
||||
scripts/publish-release.sh --notes /path/to/release-notes.md
|
||||
```
|
||||
|
||||
发布脚本会重建 `releases` 分支,写入 `squid-update.json`、两个安装包和可选的 `squid-update.sig`。清单包含精确大小与 SHA256,客户端下载后再次校验。
|
||||
|
||||
完整发布流程、签名和清单格式见 [`docs/RELEASE.md`](docs/RELEASE.md)。
|
||||
|
||||
## 平台状态
|
||||
|
||||
| 平台 | 状态 |
|
||||
| --- | --- |
|
||||
| macOS | 桌面端与 CLI/TUI 完整支持,发布通用 DMG |
|
||||
| Windows x64 | 桌面端与 CLI/TUI 支持,发布 NSIS 安装包 |
|
||||
| Linux | 平台层与 CLI/TUI 基础实现;尚未提供内置 Linux 规则和桌面安装包 |
|
||||
|
||||
## 许可证
|
||||
|
||||
Squid 使用 **GNU General Public License v3.0 only**(`GPL-3.0-only`)。完整条款见 [`LICENSE`](LICENSE)。
|
||||
|
|
@ -23,6 +23,7 @@ rayon.workspace = true
|
|||
[target.'cfg(windows)'.dependencies]
|
||||
windows = { version = "0.58", features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_Globalization",
|
||||
"Win32_Security",
|
||||
"Win32_Storage_FileSystem",
|
||||
"Win32_System_Com",
|
||||
|
|
|
|||
|
|
@ -338,13 +338,34 @@ fn system_locale() -> Option<Locale> {
|
|||
None
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(target_os = "windows")]
|
||||
fn system_locale() -> Option<Locale> {
|
||||
// Linux and Windows describe the language through the environment only,
|
||||
// and step 3 of `detect` has already read every bit of it.
|
||||
use windows::Win32::Globalization::GetUserDefaultUILanguage;
|
||||
|
||||
// The environment is not a reliable proxy for the Windows display
|
||||
// language: Explorer and the Store may run under a different UI locale.
|
||||
let langid = unsafe { GetUserDefaultUILanguage() };
|
||||
Some(locale_from_langid(langid))
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
fn system_locale() -> Option<Locale> {
|
||||
// Linux describes the language through the environment, already read by
|
||||
// step 3 of `detect`.
|
||||
None
|
||||
}
|
||||
|
||||
/// Windows LANGIDs pack a primary language in the low ten bits.
|
||||
#[cfg(any(target_os = "windows", test))]
|
||||
fn locale_from_langid(langid: u16) -> Locale {
|
||||
const PRIMARY_CHINESE: u16 = 0x04;
|
||||
if langid & 0x03ff == PRIMARY_CHINESE {
|
||||
Locale::Zh
|
||||
} else {
|
||||
Locale::En
|
||||
}
|
||||
}
|
||||
|
||||
/// Convenience for reports that want the "freed" number in display units.
|
||||
pub fn display_size(settings: &Settings, logical: Bytes, allocated: Bytes) -> Bytes {
|
||||
if settings.show_allocated && !allocated.is_zero() {
|
||||
|
|
@ -454,6 +475,16 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_langid_uses_the_primary_language() {
|
||||
assert_eq!(locale_from_langid(0x0004), Locale::Zh);
|
||||
assert_eq!(locale_from_langid(0x0804), Locale::Zh, "zh-CN");
|
||||
assert_eq!(locale_from_langid(0x0404), Locale::Zh, "zh-TW");
|
||||
assert_eq!(locale_from_langid(0x0409), Locale::En, "en-US");
|
||||
assert_eq!(locale_from_langid(0x0809), Locale::En, "en-GB");
|
||||
assert_eq!(locale_from_langid(0x0411), Locale::En, "ja-JP fallback");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn squid_lang_beats_the_desktop_locale() {
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Nex 应用视觉规范
|
||||
|
||||
版本:1.0
|
||||
版本:1.1
|
||||
状态:Nex 系列应用统一标准
|
||||
基准实现:`nex_shift` 的主色系
|
||||
|
||||
|
|
@ -12,7 +12,8 @@ Squid 以及后续 Nex 应用不得再各自定义蓝色或其它颜色的主操
|
|||
- 主操作、选中态、焦点环和进度使用 Nex 主色。
|
||||
- 页面底色、卡片和正文使用暖中性色,不使用冷蓝色底。
|
||||
- 绿色、红色、黄色只表达成功、危险和警告,不作为品牌主色。
|
||||
- 分类色可以保留各自的语义色,但不得替代主操作色。
|
||||
- 图表、分类和装饰只使用主色、暖中性色或成功/警告/危险状态色。
|
||||
- 不引入蓝色、紫色、青色、粉色等第二品牌色;状态色也不得用于装饰。
|
||||
- 新界面必须引用 `src/styles.css` 中的 `--nex-*` 常量,不写新的主色十六进制值。
|
||||
|
||||
## 2. 品牌常量
|
||||
|
|
@ -39,6 +40,19 @@ Squid 以及后续 Nex 应用不得再各自定义蓝色或其它颜色的主操
|
|||
主色高亮需要透明度时使用 `rgba(var(--nex-primary-rgb), α)`,其中
|
||||
`--nex-primary-rgb` 为 `242, 106, 51`。
|
||||
|
||||
### 状态色
|
||||
|
||||
| 常量 | 值 | 用途 |
|
||||
| --- | --- | --- |
|
||||
| `--nex-success` / `-strong` / `-soft` | `#17865F` / `#126D4C` / `#E7F8F1` | 完成、安全、已授权 |
|
||||
| `--nex-warning` / `-strong` / `-soft` | `#A97729` / `#8C6C40` / `#FFF8E9` | 警告、需要注意 |
|
||||
| `--nex-danger` / `-strong` / `-soft` | `#C85A62` / `#A64048` / `#FFEDEF` | 错误、危险操作 |
|
||||
|
||||
对应的 `--nex-success-rgb`、`--nex-warning-rgb`、`--nex-danger-rgb`
|
||||
用于状态色透明度。组件通过 `.tone-primary`、`.tone-success`、
|
||||
`.tone-warning`、`.tone-danger`、`.tone-neutral` 五种语义色调取色,
|
||||
不新增分类专用色调。
|
||||
|
||||
## 3. 图标渐变
|
||||
|
||||
应用图标的品牌渐变沿用 Shift:
|
||||
|
|
@ -47,7 +61,8 @@ Squid 以及后续 Nex 应用不得再各自定义蓝色或其它颜色的主操
|
|||
- 中段 `#FF6B35`
|
||||
- 终点 `#C66BFF`
|
||||
|
||||
图标主体的描边和阴影必须使用暖色,不得保留旧版蓝色。
|
||||
图标主体允许保留应用图标自身的暖橙渐变与粉色高光;它们属于图标资产,
|
||||
不得扩展为界面装饰色。图标主体的描边和阴影必须使用暖色,不得保留旧版蓝色。
|
||||
|
||||
### 侧栏品牌锁定
|
||||
|
||||
|
|
@ -95,18 +110,26 @@ Squid 以及后续 Nex 应用不得再各自定义蓝色或其它颜色的主操
|
|||
- 正文不使用纯黑;标题使用 `--nex-ink-strong`。
|
||||
- 更新面板面向使用者,只展示当前系统版本、版本状态、更新说明、进度与操作;
|
||||
更新地址、安装包文件名和哈希留在后端校验流程中,不进入常规界面。
|
||||
- 下载完成后的“放弃”使用中性描边按钮:34px 高、9px 圆角、暖白半透明表面、
|
||||
`--nex-ink` 文字;悬停仅切换主色描边与白色表面,与 Shift 保持一致。
|
||||
- 软件更新不再重复显示“已是最新版本”;当前版本只在系统信息面板中展示,
|
||||
只有发现更新包时才展开版本变化与操作区。
|
||||
|
||||
## 6. 旧变量兼容
|
||||
## 6. 语言与本地化
|
||||
|
||||
现有组件仍引用 `--blue`、`--blue-deep`、`--blue-soft`。这三个变量已经
|
||||
分别别名为 `--nex-primary`、`--nex-primary-strong`、`--nex-primary-soft`,
|
||||
因此不会再渲染蓝色。新增代码应直接使用 `--nex-*` 常量;迁移旧组件时
|
||||
可以逐步移除 `--blue-*` 别名,但不得改回独立颜色值。
|
||||
- 首次启动默认跟随系统语言:macOS 读取 `AppleLocale` / `AppleLanguages`,
|
||||
Windows 读取 `GetUserDefaultUILanguage`,Linux 读取标准 locale 环境变量。
|
||||
- 设置中只提供“简体中文”和“English”两个语言选项;尚未手动选择时,选中项反映当前系统语言。
|
||||
- 手动选择语言会写入 `config.toml` 的 `language`,后续启动继续使用该选择。
|
||||
- 托盘菜单与主界面使用同一语言,并在切换后立即刷新。
|
||||
- 当前支持中文与英文,其他系统语言回退到英文。
|
||||
|
||||
## 7. 验收
|
||||
|
||||
- 全应用不出现蓝色主按钮、蓝色选中态或蓝色焦点环。
|
||||
- 全应用不出现蓝色、紫色、青色或粉色界面装饰;品牌色只有橙色。
|
||||
- 状态色只用于成功、警告和危险,不作为卡片或图表的分类装饰色。
|
||||
- 页面底色为 `#F5EEE7`,面板为暖白,不使用冷蓝渐变。
|
||||
- Settings、首次启动权限卡和更新面板共享同一套主色。
|
||||
- 应用图标与界面使用同一组暖色品牌常量。
|
||||
- 正文和标签不小于 11px,标题使用统一字号阶梯,不出现 7–10px 的正文。
|
||||
- 默认语言与系统一致,切换语言后主界面和托盘同步更新。
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings
|
|||
| Storage | Measures a chosen folder, exposes the largest children, drills down, and finds the largest files |
|
||||
| Real-time monitor | Live CPU, memory, network, disk, battery, volume and process data; process termination asks for confirmation |
|
||||
| History | Lists cleanup sessions, shows the ledger, restores files that are still in Trash/Recycle Bin, and opens the bin |
|
||||
| Settings | Language, deletion mode, history retention, protected paths, local file locations, and software updates |
|
||||
| Settings | Chinese/English language selection that defaults to the system language, launch at login, deletion mode, history retention, protected paths, local file locations, and software updates |
|
||||
|
||||
`⌘1`–`⌘8` on macOS and `Ctrl+1`–`Ctrl+8` on Windows switch screens.
|
||||
|
||||
|
|
@ -60,7 +60,13 @@ cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings
|
|||
|
||||
Squid keeps running after its main window is closed. The tray menu can reopen
|
||||
the window and jump directly to Daily cleanup, Uninstall apps or Deep Clean.
|
||||
Use **Quit Squid** in the same menu to stop the background process.
|
||||
The tray follows the active interface language. Use **Quit Squid** in the same
|
||||
menu to stop the background process.
|
||||
|
||||
**Settings → Startup** registers the app for the current user only. macOS
|
||||
uses a user LaunchAgent, Windows uses the current-user Run key, and Linux uses
|
||||
an XDG autostart desktop entry. Enabling or disabling launch at login does not
|
||||
require administrator access.
|
||||
|
||||
## Safety boundary
|
||||
|
||||
|
|
@ -115,6 +121,8 @@ The update implementation mirrors `nex_shift`:
|
|||
bytes.
|
||||
- The application checks at most once a day when automatic checks are enabled;
|
||||
the last-check day lives in `updates.json`.
|
||||
- A verified download can be installed and restarted, or discarded with the
|
||||
neutral outlined action shared with `nex_shift`.
|
||||
- macOS mounts the DMG after exit and swaps `Squid.app` with rollback on failure.
|
||||
- Windows waits for `squid-desktop.exe` to exit, runs the same NSIS installer
|
||||
silently, then relaunches it from `%LOCALAPPDATA%\Programs\Squid`.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "squid-desktop",
|
||||
"private": true,
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --port 1420 --strictPort",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
Squid 0.1.5 - 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.5-win-x64.exe。
|
||||
2. 这是未签名构建。若 SmartScreen 显示警告,请选择“更多信息” > “仍要运行”。
|
||||
3. 卸载请在 Windows“设置 > 应用”中移除 Squid。
|
||||
|
||||
更新
|
||||
----
|
||||
Squid 使用与 nex_shift 一致的 releases 分支更新通道。更新包会先校验
|
||||
文件大小与 SHA256,再在退出后运行同一个安装程序。若构建时写入发布公钥,
|
||||
还会验证清单的 Ed25519 签名。
|
||||
|
||||
校验
|
||||
----
|
||||
PowerShell:
|
||||
Get-FileHash .\Squid-Setup-0.1.5-win-x64.exe -Algorithm SHA256
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Squid 0.1.5
|
||||
|
||||
- 语言默认跟随系统;macOS、Windows 与 Linux 分别读取对应的系统语言设置。
|
||||
- 语言设置只保留中文与 English 两项,默认选中当前系统语言;切换后托盘菜单同步更新。
|
||||
- 设置中新增开机自启开关,使用当前用户级启动项,无需管理员权限。
|
||||
- 软件更新下载完成后的「放弃」按钮改为与 Shift 一致的中性描边样式。
|
||||
- 统一 Nex 暖色设计语言:界面只使用橙色主色、暖中性色与成功/警告/危险状态色,移除蓝色、紫色、青色和粉色装饰。
|
||||
- README 提供双语首页以及完整的简体中文版和英文版。
|
||||
- macOS 与 Windows 同步发布 0.1.5。
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
57028b3872a9dbe965752b6451cc06fcec19d6d92b2e40710e5bbd49b2b60bd2 Squid-0.1.5-macOS-universal.dmg
|
||||
9e85eefc348e066f873f3b91c6202f0e906c166a0c50a8fec4de6db7dc1f907b Squid-Setup-0.1.5-win-x64.exe
|
||||
2048178675631a41f39961413d6865c462e5366ffeb890431c373cd7cb8440cb README-Windows-x64.txt
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"schema": 1,
|
||||
"version": "0.1.5",
|
||||
"date": "2026-11-05",
|
||||
"notes": "Squid 0.1.5\n\n- 语言默认跟随系统;macOS、Windows 与 Linux 分别读取对应的系统语言设置。\n- 语言设置只保留中文与 English 两项,默认选中当前系统语言;切换后托盘菜单同步更新。\n- 设置中新增开机自启开关,使用当前用户级启动项,无需管理员权限。\n- 软件更新下载完成后的「放弃」按钮改为与 Shift 一致的中性描边样式。\n- 统一 Nex 暖色设计语言:界面只使用橙色主色、暖中性色与成功/警告/危险状态色,移除蓝色、紫色、青色和粉色装饰。\n- README 提供双语首页以及完整的简体中文版和英文版。\n- macOS 与 Windows 同步发布 0.1.5。",
|
||||
"artifacts": {
|
||||
"macos": {
|
||||
"file": "Squid-0.1.5-macOS-universal.dmg",
|
||||
"sha256": "57028b3872a9dbe965752b6451cc06fcec19d6d92b2e40710e5bbd49b2b60bd2",
|
||||
"size": 10702261
|
||||
},
|
||||
"windows": {
|
||||
"file": "Squid-Setup-0.1.5-win-x64.exe",
|
||||
"sha256": "9e85eefc348e066f873f3b91c6202f0e906c166a0c50a8fec4de6db7dc1f907b",
|
||||
"size": 3354754
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3489,7 +3489,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-core"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -3508,10 +3508,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-desktop"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"dirs 6.0.0",
|
||||
"ed25519-dalek",
|
||||
"globset",
|
||||
"hex",
|
||||
|
|
@ -3532,7 +3533,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-engine"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -3552,7 +3553,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-platform"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"libc",
|
||||
|
|
@ -3569,7 +3570,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-rules"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"globset",
|
||||
"serde",
|
||||
|
|
@ -3581,7 +3582,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-stats"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "squid-desktop"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
description = "Squid — a CleanMyMac-inspired cleaner, uninstaller and system monitor."
|
||||
authors = ["squid contributors"]
|
||||
edition = "2021"
|
||||
|
|
@ -28,6 +28,7 @@ tauri = { version = "2.11", features = ["tray-icon", "image-png", "macos-private
|
|||
tauri-plugin-dialog = "2"
|
||||
tauri-plugin-opener = "2"
|
||||
tauri-plugin-single-instance = "2"
|
||||
dirs = "6"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
chrono = { version = "0.4", features = ["clock"] }
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ use squid_core::ledger::{self, Session};
|
|||
use squid_core::paths;
|
||||
use squid_core::progress::{CancelToken, Event, Progress};
|
||||
use squid_core::{
|
||||
AppInfo, Bytes, Category, CleanupItem, DeleteMode, ItemKind, LockReason, ScanReport, Settings,
|
||||
UninstallPlan,
|
||||
AppInfo, Bytes, Category, CleanupItem, DeleteMode, ItemKind, Locale, LockReason, ScanReport,
|
||||
Settings, UninstallPlan,
|
||||
};
|
||||
use squid_engine::analyze::{self, FileEntry, Node};
|
||||
use squid_engine::delete::{self, DeleteJob, DeleteOutcome};
|
||||
|
|
@ -316,6 +316,7 @@ pub struct SettingsView {
|
|||
purge_min_age_days: u64,
|
||||
show_allocated: bool,
|
||||
language: Option<String>,
|
||||
effective_language: String,
|
||||
history_keep: usize,
|
||||
setup_reviewed: bool,
|
||||
errors: Vec<String>,
|
||||
|
|
@ -330,6 +331,7 @@ impl SettingsView {
|
|||
purge_min_age_days: settings.purge_min_age_days,
|
||||
show_allocated: settings.show_allocated,
|
||||
language: settings.language.clone(),
|
||||
effective_language: Locale::detect(settings).code().into(),
|
||||
history_keep: settings.history_keep,
|
||||
setup_reviewed: settings.desktop_setup_reviewed,
|
||||
errors,
|
||||
|
|
@ -835,7 +837,7 @@ pub struct SettingsPatch {
|
|||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn settings_save(patch: SettingsPatch) -> Result<SettingsView, String> {
|
||||
pub async fn settings_save(app: AppHandle, patch: SettingsPatch) -> Result<SettingsView, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
let (mut settings, mut errors) = Settings::load();
|
||||
if let Some(mode) = patch.delete_mode {
|
||||
|
|
@ -860,6 +862,7 @@ pub async fn settings_save(patch: SettingsPatch) -> Result<SettingsView, String>
|
|||
settings
|
||||
.save()
|
||||
.map_err(|error| format!("Could not save settings: {error}"))?;
|
||||
crate::sync_tray(&app, Locale::detect(&settings));
|
||||
errors.retain(|error| !error.contains("config.toml"));
|
||||
Ok(SettingsView::from_settings(&settings, errors))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,249 @@
|
|||
//! User-level launch-at-login integration.
|
||||
//!
|
||||
//! Every platform writes only the current user's startup configuration. Failing
|
||||
//! to create or remove it is reported to Settings so the toggle can roll back.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
#[cfg(target_os = "windows")]
|
||||
use std::process::Command;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "windows",
|
||||
not(any(target_os = "macos", target_os = "windows"))
|
||||
))]
|
||||
const APP_NAME: &str = "Squid";
|
||||
|
||||
#[tauri::command]
|
||||
pub fn autostart_status() -> Result<bool, String> {
|
||||
status().map_err(|error| format!("Could not read launch-at-login state: {error}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn set_autostart(enabled: bool) -> Result<bool, String> {
|
||||
set(enabled).map_err(|error| format!("Could not update launch-at-login state: {error}"))
|
||||
}
|
||||
|
||||
fn set(enabled: bool) -> Result<bool, String> {
|
||||
if enabled {
|
||||
enable()?;
|
||||
} else {
|
||||
disable()?;
|
||||
}
|
||||
status()
|
||||
}
|
||||
|
||||
fn executable() -> Result<PathBuf, String> {
|
||||
std::env::current_exe().map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn registration_path() -> Result<PathBuf, String> {
|
||||
let home = dirs::home_dir().ok_or("The home directory is unavailable.")?;
|
||||
Ok(home
|
||||
.join("Library")
|
||||
.join("LaunchAgents")
|
||||
.join("app.nex.squid.plist"))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn status() -> Result<bool, String> {
|
||||
Ok(registration_path()?.is_file())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn enable() -> Result<(), String> {
|
||||
let path = registration_path()?;
|
||||
let parent = path
|
||||
.parent()
|
||||
.ok_or("The LaunchAgents directory is unavailable.")?;
|
||||
std::fs::create_dir_all(parent).map_err(|error| error.to_string())?;
|
||||
std::fs::write(&path, launch_agent_plist(&executable()?)).map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn disable() -> Result<(), String> {
|
||||
let path = registration_path()?;
|
||||
match std::fs::remove_file(path) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
|
||||
Err(error) => Err(error.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn launch_agent_plist(exe: &Path) -> String {
|
||||
let target = exe
|
||||
.ancestors()
|
||||
.find(|path| path.extension().is_some_and(|extension| extension == "app"))
|
||||
.unwrap_or(exe);
|
||||
let arguments = if target == exe {
|
||||
format!("<string>{}</string>", xml_escape(&target.to_string_lossy()))
|
||||
} else {
|
||||
format!(
|
||||
"<string>/usr/bin/open</string><string>{}</string>",
|
||||
xml_escape(&target.to_string_lossy())
|
||||
)
|
||||
};
|
||||
format!(
|
||||
r#"<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>app.nex.squid</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>{arguments}</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>LimitLoadToSessionType</key>
|
||||
<string>Aqua</string>
|
||||
</dict>
|
||||
</plist>
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn xml_escape(text: &str) -> String {
|
||||
text.replace('&', "&")
|
||||
.replace('<', "<")
|
||||
.replace('>', ">")
|
||||
.replace('"', """)
|
||||
.replace('\'', "'")
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
const RUN_KEY: &str = r"HKCU\Software\Microsoft\Windows\CurrentVersion\Run";
|
||||
#[cfg(target_os = "windows")]
|
||||
const RUN_VALUE: &str = APP_NAME;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn status() -> Result<bool, String> {
|
||||
let output = hidden_command("reg.exe")
|
||||
.args(["query", RUN_KEY, "/v", RUN_VALUE])
|
||||
.output()
|
||||
.map_err(|error| error.to_string())?;
|
||||
Ok(output.status.success())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn enable() -> Result<(), String> {
|
||||
let exe = executable()?;
|
||||
let value = format!("\"{}\"", exe.display());
|
||||
let output = hidden_command("reg.exe")
|
||||
.args([
|
||||
"add", RUN_KEY, "/v", RUN_VALUE, "/t", "REG_SZ", "/d", &value, "/f",
|
||||
])
|
||||
.output()
|
||||
.map_err(|error| error.to_string())?;
|
||||
command_result(output)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn disable() -> Result<(), String> {
|
||||
if !status()? {
|
||||
return Ok(());
|
||||
}
|
||||
let output = hidden_command("reg.exe")
|
||||
.args(["delete", RUN_KEY, "/v", RUN_VALUE, "/f"])
|
||||
.output()
|
||||
.map_err(|error| error.to_string())?;
|
||||
command_result(output)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn hidden_command(program: &str) -> Command {
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||
let mut command = Command::new(program);
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
command
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn command_result(output: std::process::Output) -> Result<(), String> {
|
||||
if output.status.success() {
|
||||
return Ok(());
|
||||
}
|
||||
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
|
||||
Err(if stderr.is_empty() {
|
||||
format!("reg.exe exited with {}", output.status)
|
||||
} else {
|
||||
stderr
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
fn registration_path() -> Result<PathBuf, String> {
|
||||
dirs::config_dir()
|
||||
.map(|directory| directory.join("autostart").join("squid.desktop"))
|
||||
.ok_or_else(|| "The user configuration directory is unavailable.".to_string())
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
fn status() -> Result<bool, String> {
|
||||
Ok(registration_path()?.is_file())
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
fn enable() -> Result<(), String> {
|
||||
let path = registration_path()?;
|
||||
let parent = path
|
||||
.parent()
|
||||
.ok_or("The autostart directory is unavailable.")?;
|
||||
std::fs::create_dir_all(parent).map_err(|error| error.to_string())?;
|
||||
std::fs::write(&path, desktop_entry(&executable()?)).map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
fn disable() -> Result<(), String> {
|
||||
let path = registration_path()?;
|
||||
match std::fs::remove_file(path) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
|
||||
Err(error) => Err(error.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
fn desktop_entry(exe: &Path) -> String {
|
||||
let executable = exe
|
||||
.to_string_lossy()
|
||||
.replace('\\', "\\\\")
|
||||
.replace('"', "\\\"")
|
||||
.replace('$', "\\$");
|
||||
format!(
|
||||
"[Desktop Entry]\n\
|
||||
Type=Application\n\
|
||||
Name={APP_NAME}\n\
|
||||
Comment=System care for your computer\n\
|
||||
Exec=\"{executable}\"\n\
|
||||
Terminal=false\n\
|
||||
X-GNOME-Autostart-enabled=true\n"
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[test]
|
||||
fn launch_agent_opens_the_app_bundle() {
|
||||
let plist = launch_agent_plist(Path::new(
|
||||
"/Applications/Squid & Tools.app/Contents/MacOS/squid-desktop",
|
||||
));
|
||||
assert!(plist.contains("<string>/usr/bin/open</string>"));
|
||||
assert!(plist.contains("/Applications/Squid & Tools.app"));
|
||||
assert!(plist.contains("<key>RunAtLoad</key>"));
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
#[test]
|
||||
fn desktop_entry_quotes_the_executable() {
|
||||
let entry = desktop_entry(Path::new("/home/me/Squid Tools/squid-desktop"));
|
||||
assert!(entry.contains("Exec=\"/home/me/Squid Tools/squid-desktop\""));
|
||||
assert!(entry.contains("X-GNOME-Autostart-enabled=true"));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
mod app;
|
||||
mod autostart;
|
||||
mod permissions;
|
||||
mod process;
|
||||
mod update;
|
||||
|
||||
use squid_core::{Locale, Settings};
|
||||
use tauri::{
|
||||
menu::{Menu, MenuItem, PredefinedMenuItem},
|
||||
tray::TrayIconBuilder,
|
||||
|
|
@ -25,15 +27,53 @@ fn navigate_to(app: &AppHandle, page: &'static str) {
|
|||
let _ = app.emit("squid://navigate", page);
|
||||
}
|
||||
|
||||
fn create_tray(app: &AppHandle) -> tauri::Result<()> {
|
||||
let open = MenuItem::with_id(app, "open", "打开 Squid", true, None::<&str>)?;
|
||||
let cleanup = MenuItem::with_id(app, "cleanup", "日常清理", true, None::<&str>)?;
|
||||
let apps = MenuItem::with_id(app, "applications", "应用卸载", true, None::<&str>)?;
|
||||
let purge = MenuItem::with_id(app, "purge", "深度清理", true, None::<&str>)?;
|
||||
let quit = MenuItem::with_id(app, "quit", "退出 Squid", true, None::<&str>)?;
|
||||
fn tray_text(locale: Locale, en: &'static str, zh: &'static str) -> &'static str {
|
||||
if locale == Locale::Zh {
|
||||
zh
|
||||
} else {
|
||||
en
|
||||
}
|
||||
}
|
||||
|
||||
fn tray_menu(app: &AppHandle, locale: Locale) -> tauri::Result<Menu<tauri::Wry>> {
|
||||
let open = MenuItem::with_id(
|
||||
app,
|
||||
"open",
|
||||
tray_text(locale, "Open Squid", "打开 Squid"),
|
||||
true,
|
||||
None::<&str>,
|
||||
)?;
|
||||
let cleanup = MenuItem::with_id(
|
||||
app,
|
||||
"cleanup",
|
||||
tray_text(locale, "Daily cleanup", "日常清理"),
|
||||
true,
|
||||
None::<&str>,
|
||||
)?;
|
||||
let apps = MenuItem::with_id(
|
||||
app,
|
||||
"applications",
|
||||
tray_text(locale, "Uninstall apps", "应用卸载"),
|
||||
true,
|
||||
None::<&str>,
|
||||
)?;
|
||||
let purge = MenuItem::with_id(
|
||||
app,
|
||||
"purge",
|
||||
tray_text(locale, "Deep Clean", "深度清理"),
|
||||
true,
|
||||
None::<&str>,
|
||||
)?;
|
||||
let quit = MenuItem::with_id(
|
||||
app,
|
||||
"quit",
|
||||
tray_text(locale, "Quit Squid", "退出 Squid"),
|
||||
true,
|
||||
None::<&str>,
|
||||
)?;
|
||||
let first_separator = PredefinedMenuItem::separator(app)?;
|
||||
let last_separator = PredefinedMenuItem::separator(app)?;
|
||||
let menu = Menu::with_items(
|
||||
Menu::with_items(
|
||||
app,
|
||||
&[
|
||||
&open,
|
||||
|
|
@ -44,7 +84,11 @@ fn create_tray(app: &AppHandle) -> tauri::Result<()> {
|
|||
&last_separator,
|
||||
&quit,
|
||||
],
|
||||
)?;
|
||||
)
|
||||
}
|
||||
|
||||
fn create_tray(app: &AppHandle, locale: Locale) -> tauri::Result<()> {
|
||||
let menu = tray_menu(app, locale)?;
|
||||
let icon = app
|
||||
.default_window_icon()
|
||||
.cloned()
|
||||
|
|
@ -67,6 +111,15 @@ fn create_tray(app: &AppHandle) -> tauri::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn sync_tray(app: &AppHandle, locale: Locale) {
|
||||
let Some(tray) = app.tray_by_id("squid-tray") else {
|
||||
return;
|
||||
};
|
||||
if let Ok(menu) = tray_menu(app, locale) {
|
||||
let _ = tray.set_menu(Some(menu));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let app = tauri::Builder::default()
|
||||
|
|
@ -102,6 +155,8 @@ pub fn run() {
|
|||
app::settings_save,
|
||||
app::whitelist_add,
|
||||
app::whitelist_remove,
|
||||
autostart::autostart_status,
|
||||
autostart::set_autostart,
|
||||
app::reveal_path,
|
||||
app::open_trash,
|
||||
permissions::permission_status,
|
||||
|
|
@ -114,7 +169,8 @@ pub fn run() {
|
|||
update::set_update_check_enabled,
|
||||
])
|
||||
.setup(|app| {
|
||||
create_tray(app.handle())?;
|
||||
let (settings, _) = Settings::load();
|
||||
create_tray(app.handle(), Locale::detect(&settings))?;
|
||||
update::spawn_startup_check(app.handle());
|
||||
Ok(())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Squid",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"identifier": "app.nex.squid",
|
||||
"mainBinaryName": "squid-desktop",
|
||||
"build": {
|
||||
|
|
|
|||
|
|
@ -230,11 +230,11 @@ export default function App() {
|
|||
|
||||
const changeLanguage = useCallback(
|
||||
async (nextLanguage: Language) => {
|
||||
setLang(nextLanguage);
|
||||
document.documentElement.lang = nextLanguage === "zh" ? "zh-CN" : "en";
|
||||
try {
|
||||
const next = await api.settingsSave({ language: nextLanguage });
|
||||
setSettings(next);
|
||||
setLang(next.effectiveLanguage);
|
||||
document.documentElement.lang = next.effectiveLanguage === "zh" ? "zh-CN" : "en";
|
||||
} catch (reason) {
|
||||
push(messageFrom(reason), "danger");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,8 @@ export function UpdatePanel({
|
|||
) : null}
|
||||
{verified && !flow.installing ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
variant="secondary"
|
||||
className="update-cancel"
|
||||
icon={<X size={14} />}
|
||||
onClick={() => void flow.clear()}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ export interface CategoryMeta {
|
|||
blurbEn: string;
|
||||
blurbZh: string;
|
||||
icon: typeof Boxes;
|
||||
tone: string;
|
||||
tone: Tone;
|
||||
}
|
||||
|
||||
export type Tone = "primary" | "success" | "warning" | "danger" | "neutral";
|
||||
|
||||
export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
||||
"system-junk": {
|
||||
en: "System junk",
|
||||
|
|
@ -45,7 +47,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Temporary files and system scratch data",
|
||||
blurbZh: "临时文件与系统缓存",
|
||||
icon: Trash2,
|
||||
tone: "blue",
|
||||
tone: "primary",
|
||||
},
|
||||
"app-caches": {
|
||||
en: "App caches",
|
||||
|
|
@ -53,7 +55,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Caches apps can rebuild",
|
||||
blurbZh: "应用可自动重建的缓存",
|
||||
icon: AppWindow,
|
||||
tone: "cyan",
|
||||
tone: "primary",
|
||||
},
|
||||
"browser-caches": {
|
||||
en: "Browser caches",
|
||||
|
|
@ -61,7 +63,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Web content and offline data",
|
||||
blurbZh: "网页内容与离线数据",
|
||||
icon: Globe2,
|
||||
tone: "violet",
|
||||
tone: "primary",
|
||||
},
|
||||
logs: {
|
||||
en: "Logs & reports",
|
||||
|
|
@ -69,7 +71,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Rotated logs and crash reports",
|
||||
blurbZh: "旧日志与崩溃报告",
|
||||
icon: FileWarning,
|
||||
tone: "orange",
|
||||
tone: "neutral",
|
||||
},
|
||||
developer: {
|
||||
en: "Developer files",
|
||||
|
|
@ -77,7 +79,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Simulators, archives and tool caches",
|
||||
blurbZh: "模拟器、归档与工具缓存",
|
||||
icon: Code2,
|
||||
tone: "indigo",
|
||||
tone: "neutral",
|
||||
},
|
||||
"project-artifacts": {
|
||||
en: "Build artefacts",
|
||||
|
|
@ -85,7 +87,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Regenerable project build folders",
|
||||
blurbZh: "可重新生成的构建目录",
|
||||
icon: PackageOpen,
|
||||
tone: "teal",
|
||||
tone: "primary",
|
||||
},
|
||||
trash: {
|
||||
en: "Trash",
|
||||
|
|
@ -93,7 +95,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Files waiting to be emptied",
|
||||
blurbZh: "等待清空的文件",
|
||||
icon: Trash2,
|
||||
tone: "slate",
|
||||
tone: "neutral",
|
||||
},
|
||||
"language-packs": {
|
||||
en: "Language packs",
|
||||
|
|
@ -101,7 +103,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Unused voice and localisation data",
|
||||
blurbZh: "未使用的语音与本地化数据",
|
||||
icon: Languages,
|
||||
tone: "pink",
|
||||
tone: "neutral",
|
||||
},
|
||||
leftovers: {
|
||||
en: "Leftovers",
|
||||
|
|
@ -109,7 +111,7 @@ export const CATEGORY_META: Record<Category, CategoryMeta> = {
|
|||
blurbEn: "Data left by removed applications",
|
||||
blurbZh: "已删除应用留下的数据",
|
||||
icon: Puzzle,
|
||||
tone: "amber",
|
||||
tone: "warning",
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -490,14 +492,14 @@ export function Gauge({
|
|||
value,
|
||||
size = 160,
|
||||
stroke = 12,
|
||||
tone = "blue",
|
||||
tone = "primary",
|
||||
children,
|
||||
label,
|
||||
}: {
|
||||
value: number;
|
||||
size?: number;
|
||||
stroke?: number;
|
||||
tone?: "blue" | "green" | "orange" | "violet" | "red";
|
||||
tone?: Tone;
|
||||
children?: ReactNode;
|
||||
label?: string;
|
||||
}) {
|
||||
|
|
@ -540,10 +542,10 @@ export function Gauge({
|
|||
|
||||
export function MetricBar({
|
||||
value,
|
||||
tone = "blue",
|
||||
tone = "primary",
|
||||
}: {
|
||||
value: number;
|
||||
tone?: "blue" | "green" | "orange" | "violet" | "red";
|
||||
tone?: Tone;
|
||||
}) {
|
||||
return (
|
||||
<div className={`metric-bar tone-${tone}`}>
|
||||
|
|
@ -810,11 +812,11 @@ export function PathRow({
|
|||
export function UsageBar({
|
||||
used,
|
||||
total,
|
||||
tone = "blue",
|
||||
tone = "primary",
|
||||
}: {
|
||||
used: number;
|
||||
total: number;
|
||||
tone?: "blue" | "green" | "orange" | "violet" | "red";
|
||||
tone?: Tone;
|
||||
}) {
|
||||
return (
|
||||
<div className={`usage-bar tone-${tone}`}>
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ export const api = {
|
|||
settingsSave: (patch: SettingsPatch) => invoke<SettingsView>("settings_save", { patch }),
|
||||
whitelistAdd: (path: string) => invoke<SettingsView>("whitelist_add", { path }),
|
||||
whitelistRemove: (pattern: string) => invoke<SettingsView>("whitelist_remove", { pattern }),
|
||||
autostartStatus: () => invoke<boolean>("autostart_status"),
|
||||
setAutostart: (enabled: boolean) => invoke<boolean>("set_autostart", { enabled }),
|
||||
revealPath: (path: string) => invoke<void>("reveal_path", { path }),
|
||||
openTrash: () => invoke<void>("open_trash"),
|
||||
permissionStatus: () => invoke<PermissionStatus>("permission_status"),
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export function OverviewPage({
|
|||
|
||||
<div className="overview-gauge-wrap">
|
||||
<div className="gauge-halo" />
|
||||
<Gauge value={usedPercent} size={226} stroke={16} tone={usedPercent > 85 ? "red" : "blue"}>
|
||||
<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">
|
||||
|
|
@ -202,7 +202,7 @@ export function OverviewPage({
|
|||
subtitle={t("The right tool for the next five minutes.", "用几分钟完成最常用的事。")}
|
||||
/>
|
||||
<div className="quick-grid">
|
||||
<button className="quick-card tone-cyan" onClick={() => onNavigate("applications")}>
|
||||
<button className="quick-card tone-primary" onClick={() => onNavigate("applications")}>
|
||||
<span className="quick-icon">
|
||||
<AppWindow size={22} />
|
||||
</span>
|
||||
|
|
@ -212,7 +212,7 @@ export function OverviewPage({
|
|||
</span>
|
||||
<ChevronRight size={17} />
|
||||
</button>
|
||||
<button className="quick-card tone-indigo" onClick={() => onNavigate("storage")}>
|
||||
<button className="quick-card tone-neutral" onClick={() => onNavigate("storage")}>
|
||||
<span className="quick-icon">
|
||||
<Boxes size={22} />
|
||||
</span>
|
||||
|
|
@ -222,7 +222,7 @@ export function OverviewPage({
|
|||
</span>
|
||||
<ChevronRight size={17} />
|
||||
</button>
|
||||
<button className="quick-card tone-violet" onClick={() => onNavigate("purge")}>
|
||||
<button className="quick-card tone-primary" onClick={() => onNavigate("purge")}>
|
||||
<span className="quick-icon">
|
||||
<Sparkles size={22} />
|
||||
</span>
|
||||
|
|
@ -238,7 +238,7 @@ export function OverviewPage({
|
|||
<section className="overview-metrics">
|
||||
<div className="metric-panel">
|
||||
<div className="metric-panel-head">
|
||||
<span className="metric-icon tone-blue">
|
||||
<span className="metric-icon tone-primary">
|
||||
<CircleGauge size={18} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -251,14 +251,14 @@ export function OverviewPage({
|
|||
</div>
|
||||
<b>{Math.round(snapshot?.cpu.total ?? 0)}%</b>
|
||||
</div>
|
||||
<UsageBar used={snapshot?.cpu.total ?? 0} total={100} tone="blue" />
|
||||
<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-violet">
|
||||
<span className="metric-icon tone-neutral">
|
||||
<Boxes size={18} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -273,7 +273,7 @@ export function OverviewPage({
|
|||
</div>
|
||||
<b>{Math.round(memoryPercent)}%</b>
|
||||
</div>
|
||||
<UsageBar used={memoryPercent} total={100} tone="violet" />
|
||||
<UsageBar used={memoryPercent} total={100} tone="primary" />
|
||||
<small>
|
||||
{snapshot
|
||||
? t(
|
||||
|
|
@ -285,7 +285,11 @@ export function OverviewPage({
|
|||
</div>
|
||||
<div className="metric-panel">
|
||||
<div className="metric-panel-head">
|
||||
<span className="metric-icon tone-green">
|
||||
<span
|
||||
className={`metric-icon ${
|
||||
usedPercent > 85 ? "tone-warning" : "tone-success"
|
||||
}`}
|
||||
>
|
||||
<HardDrive size={18} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -301,7 +305,7 @@ export function OverviewPage({
|
|||
<UsageBar
|
||||
used={usedPercent}
|
||||
total={100}
|
||||
tone={usedPercent > 85 ? "red" : "green"}
|
||||
tone={usedPercent > 85 ? "danger" : "success"}
|
||||
/>
|
||||
<small>{volume?.mount_point || bootstrap.configPath}</small>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
Languages,
|
||||
LockKeyhole,
|
||||
Plus,
|
||||
Power,
|
||||
RefreshCw,
|
||||
ShieldCheck,
|
||||
Trash2,
|
||||
|
|
@ -31,6 +32,7 @@ import {
|
|||
Button,
|
||||
InlineError,
|
||||
PageHeader,
|
||||
Toggle,
|
||||
useToast,
|
||||
} from "../components/ui";
|
||||
|
||||
|
|
@ -58,6 +60,8 @@ export function SettingsPage({
|
|||
const [error, setError] = useState<string | null>(null);
|
||||
const [permission, setPermission] = useState<PermissionStatus | null>(null);
|
||||
const [checkingPermission, setCheckingPermission] = useState(false);
|
||||
const [autostart, setAutostart] = useState<boolean | null>(null);
|
||||
const [savingAutostart, setSavingAutostart] = useState(false);
|
||||
|
||||
const checkPermissions = useCallback(async () => {
|
||||
setCheckingPermission(true);
|
||||
|
|
@ -78,6 +82,21 @@ export function SettingsPage({
|
|||
return () => window.removeEventListener("focus", onFocus);
|
||||
}, [bootstrap.platform, checkPermissions]);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
void api
|
||||
.autostartStatus()
|
||||
.then((enabled) => {
|
||||
if (!cancelled) setAutostart(enabled);
|
||||
})
|
||||
.catch((reason) => {
|
||||
if (!cancelled) setError(messageFrom(reason));
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const save = async (patch: Parameters<typeof api.settingsSave>[0]) => {
|
||||
setSaving(true);
|
||||
setError(null);
|
||||
|
|
@ -132,6 +151,24 @@ export function SettingsPage({
|
|||
await save({ deleteMode: mode });
|
||||
};
|
||||
|
||||
const setLaunchAtLogin = async (enabled: boolean) => {
|
||||
setSavingAutostart(true);
|
||||
setError(null);
|
||||
try {
|
||||
setAutostart(await api.setAutostart(enabled));
|
||||
push(
|
||||
enabled
|
||||
? t("Squid will launch when you sign in", "Squid 将在登录时自动启动")
|
||||
: t("Launch at login disabled", "已关闭开机自启"),
|
||||
"success",
|
||||
);
|
||||
} catch (reason) {
|
||||
setError(messageFrom(reason));
|
||||
} finally {
|
||||
setSavingAutostart(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="page settings-page">
|
||||
<PageHeader
|
||||
|
|
@ -152,7 +189,12 @@ export function SettingsPage({
|
|||
<Languages size={18} />
|
||||
{t("Language & appearance", "语言与外观")}
|
||||
</h2>
|
||||
<p>{t("The interface follows this setting on both platforms.", "两个平台的界面都会使用此设置。")}</p>
|
||||
<p>
|
||||
{t(
|
||||
"The current system language is selected by default.",
|
||||
"默认选择当前系统语言。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="language-picker">
|
||||
|
|
@ -251,6 +293,40 @@ export function SettingsPage({
|
|||
</section>
|
||||
) : null}
|
||||
|
||||
<section className="settings-section">
|
||||
<div className="settings-section-head">
|
||||
<div>
|
||||
<h2>
|
||||
<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">
|
||||
<div>
|
||||
<strong>{t("Launch at login", "开机自启")}</strong>
|
||||
<span>
|
||||
{t(
|
||||
"The app starts automatically and keeps the tray available.",
|
||||
"登录后自动启动,并保留托盘入口。",
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={autostart ?? false}
|
||||
onChange={(enabled) => void setLaunchAtLogin(enabled)}
|
||||
disabled={autostart === null || savingAutostart}
|
||||
label={t("Launch Squid at login", "登录时启动 Squid")}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="settings-section">
|
||||
<div className="settings-section-head">
|
||||
<div>
|
||||
|
|
@ -434,7 +510,7 @@ export function SettingsPage({
|
|||
</div>
|
||||
<div className="path-settings-list">
|
||||
<div className="path-setting-row">
|
||||
<span className="metric-icon tone-blue">
|
||||
<span className="metric-icon tone-primary">
|
||||
<FileCog size={17} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -454,7 +530,7 @@ export function SettingsPage({
|
|||
</Button>
|
||||
</div>
|
||||
<div className="path-setting-row">
|
||||
<span className="metric-icon tone-violet">
|
||||
<span className="metric-icon tone-neutral">
|
||||
<FolderClock size={17} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -474,7 +550,7 @@ export function SettingsPage({
|
|||
</Button>
|
||||
</div>
|
||||
<div className="path-setting-row">
|
||||
<span className="metric-icon tone-green">
|
||||
<span className="metric-icon tone-neutral">
|
||||
<HardDrive size={17} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import {
|
|||
SectionTitle,
|
||||
} from "../components/ui";
|
||||
|
||||
const BAR_TONES = ["blue", "violet", "cyan", "teal", "orange", "pink", "indigo", "slate"];
|
||||
const BAR_TONES = ["primary", "neutral"] as const;
|
||||
|
||||
function nodeSize(node: { allocated: number; logical: number }): number {
|
||||
return node.allocated || node.logical;
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ export function SystemPage({
|
|||
<div className="system-gauges">
|
||||
<section className="system-gauge-card">
|
||||
<div className="system-gauge-head">
|
||||
<span className="metric-icon tone-blue">
|
||||
<span className="metric-icon tone-primary">
|
||||
<Cpu size={18} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -108,7 +108,7 @@ export function SystemPage({
|
|||
value={snapshot?.cpu.total ?? 0}
|
||||
size={168}
|
||||
stroke={13}
|
||||
tone="blue"
|
||||
tone="primary"
|
||||
label={t("Processor usage", "处理器占用")}
|
||||
>
|
||||
<strong className="gauge-number is-small">
|
||||
|
|
@ -142,7 +142,7 @@ export function SystemPage({
|
|||
|
||||
<section className="system-gauge-card">
|
||||
<div className="system-gauge-head">
|
||||
<span className="metric-icon tone-violet">
|
||||
<span className="metric-icon tone-neutral">
|
||||
<Activity size={18} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -160,7 +160,7 @@ export function SystemPage({
|
|||
value={memoryPercent}
|
||||
size={168}
|
||||
stroke={13}
|
||||
tone="violet"
|
||||
tone="primary"
|
||||
label={t("Memory usage", "内存占用")}
|
||||
>
|
||||
<strong className="gauge-number is-small">{Math.round(memoryPercent)}%</strong>
|
||||
|
|
@ -185,7 +185,7 @@ export function SystemPage({
|
|||
|
||||
<section className="system-gauge-card system-activity-card">
|
||||
<div className="system-gauge-head">
|
||||
<span className="metric-icon tone-green">
|
||||
<span className="metric-icon tone-primary">
|
||||
<Network size={18} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -319,7 +319,7 @@ export function SystemPage({
|
|||
const use = percent(volume.total - volume.free, volume.total);
|
||||
return (
|
||||
<div className="volume-row" key={volume.mount_point}>
|
||||
<span className="metric-icon tone-blue">
|
||||
<span className="metric-icon tone-primary">
|
||||
<HardDrive size={17} />
|
||||
</span>
|
||||
<div>
|
||||
|
|
@ -331,7 +331,7 @@ export function SystemPage({
|
|||
<UsageBar
|
||||
used={volume.total - volume.free}
|
||||
total={volume.total}
|
||||
tone={use > 88 ? "red" : "blue"}
|
||||
tone={use > 88 ? "danger" : "primary"}
|
||||
/>
|
||||
</div>
|
||||
<b>{Math.round(use)}%</b>
|
||||
|
|
@ -363,7 +363,7 @@ export function SystemPage({
|
|||
snapshot?.network.interfaces ?? 0,
|
||||
)} 个网络接口`,
|
||||
)}
|
||||
<MetricBar value={snapshot?.disk.activity ?? 0} tone="green" />
|
||||
<MetricBar value={snapshot?.disk.activity ?? 0} tone="success" />
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
|
|
|
|||
533
src/styles.css
533
src/styles.css
File diff suppressed because it is too large
Load Diff
|
|
@ -83,6 +83,7 @@ export interface SettingsView {
|
|||
purgeMinAgeDays: number;
|
||||
showAllocated: boolean;
|
||||
language: string | null;
|
||||
effectiveLanguage: Language;
|
||||
historyKeep: number;
|
||||
setupReviewed: boolean;
|
||||
errors: string[];
|
||||
|
|
|
|||
Loading…
Reference in New Issue