Repository navigation
Architecture
zipax-bot edited this page Aug 11, 2026
·
2 revisions
┌─────────────────────────────────────────────────┐
│ 前端(React + TypeScript) │
│ src/ · hooks/ · components/ · store/ · styles │
└──────────────────────┬──────────────────────────┘
│ Tauri IPC (invoke)
┌──────────────────────▼──────────────────────────┐
│ Tauri 外壳 zipax-app(src-tauri) │
│ lib.rs · commands · autostart · tray · watcher │
│ gs_install · app_window · file_commands ... │
└──────────────────────┬──────────────────────────┘
│ Rust 函数调用
┌──────────────────────▼──────────────────────────┐
│ zipax-core(共享压缩核心) │
│ compress/ · plan/ · config/ · format/ · utils │
└─────────────────────────────────────────────────┘
▲ ▲
│ │
┌───────┴───────┐ ┌───────┴────────┐
│ zipax-cli │ │ 文件系统/外部 │
│ (命令行) │ │ Ghostscript等 │
└───────────────┘ └────────────────┘
-
zipax-cross/Cargo.toml— workspace 根,resolver = "2",统一版本与依赖 -
crates/zipax-core— 压缩引擎(无平台依赖,桌面端与 CLI 共用) -
crates/zipax-cli— 命令行入口(测试与自动化) -
src-tauri— Tauri 桌面应用(crate 名zipax-app)
| 模块 | 职责 |
|---|---|
compress/ |
各格式压缩实现:jpeg.rs png.rs webp.rs avif.rs heic.rs pdf.rs image_pdf.rs
|
plan.rs |
压缩规划(plan_compression → CompressionPlan),预判体积/目标大小 |
config.rs |
配置解析:CompressionMode、OutputFormat、QualityLevel、ResizeOptions
|
format.rs |
格式识别(ImageKind) |
error.rs |
错误类型(Error / Result) |
image_io.rs |
图像读写封装 |
process.rs |
多文件批处理 |
utils.rs |
工具函数 |
commands.rs 已拆分为聚焦模块:
| 模块 | 职责 |
|---|---|
commands.rs |
核心压缩命令(compress_file / compress_batch / plan_compression / get_app_info) |
autostart.rs |
开机自启动读写(含 Windows 注册表路径修复) |
tray_commands.rs |
托盘菜单状态(关闭到托盘、自动更新、自动压缩开关) |
watch_commands.rs |
文件夹监控(watch_folder / stop_all_watchers) |
file_commands.rs |
文件操作(save_temp_image / copy_file) |
gs_install.rs |
Ghostscript 一键安装(跨平台) |
compression_options.rs |
压缩选项转换 |
compression_runtime.rs |
压缩运行时(并发队列) |
state.rs |
Tauri 托管状态(AppBehaviorState / TrayMenuState / WatcherState) |
watcher.rs |
notify 封装 |
app_window.rs |
主窗口配置(无边框、透明、自适应尺寸) |
.invoke_handler(tauri::generate_handler![
commands::compress_file,
commands::compress_batch,
commands::plan_compression,
commands::get_app_info,
autostart::set_autostart_enabled,
autostart::get_autostart_enabled,
gs_install::install_ghostscript,
tray_commands::set_close_to_tray_enabled,
tray_commands::get_close_to_tray_enabled,
tray_commands::set_tray_status,
watch_commands::watch_folder,
watch_commands::stop_all_watchers,
file_commands::save_temp_image,
file_commands::copy_file,
])-
单实例:
tauri-plugin-single-instance,重复启动时唤起主窗口 - 托盘:TrayIcon + 菜单(打开 / 统计 / 自动更新开关 / 自动压缩开关 / 退出)
-
关闭到托盘:
close_to_tray为 true 时拦截关闭事件并隐藏窗口 -
macOS:使用
macos-private-api与ActivationPolicy::Accessory,激活策略切换 -
窗口:无边框 + 透明背景(
decorations: false、transparent: true),页面加载完成后按内容自适应尺寸 -
自动更新:
tauri-plugin-updater,端点为 GitHub Release 的latest.json
src/
├── main.tsx / App.tsx # 入口与路由
├── i18n.ts # 中英文国际化
├── store/ # Zustand(types / app / utils)
├── hooks/ # useAutoWindowSize、useManualCompressionActions、
│ # useAutomationRules、useUpdateCheck、useAppEffects ...
├── components/ # ManualCompression、AutomationView、GeneralView、
│ # WorkflowView、WindowFrame、UpdatePrompt、ui/ ...
├── lib/ # tauri.ts(命令封装)、update.ts、format.ts、utils.ts
└── styles/ # base / components / manual / automation / settings /
# config / motion / window / about
Language / 语言:
- 简体中文 · English
- Home
- Tech-Stack
- Architecture
- Compression-Engine
- Features
- Build-and-Release
- CLI-Usage
- Ghostscript-Install
- Release-History
- Docs-Index
- Home-EN
- Tech-Stack-EN
- Architecture-EN
- Compression-Engine-EN
- Features-EN
- Build-and-Release-EN
- CLI-Usage-EN
- Ghostscript-Install-EN
- Release-History-EN
- Docs-Index-EN