老板要求:开发 macOS 和 Linux 版。
一、代码跨平台化(原来只能编 Windows)
· Cargo.toml:clipboard-win / windows-sys 挪到 [target.'cfg(windows)'.dependencies];
非 Windows 加 arboard(macOS 走 NSPasteboard,Linux 走 X11/Wayland)
· main.rs:
- windows_subsystem 属性加目标平台判断(mac/Linux 没这个概念)
- 剪贴板三个命令按平台分文件级实现
- 「复制文件本身」在 mac/Linux 退化为复制路径文本(这两个平台剪贴板没有
通用的文件格式,要写 NSPasteboard / GTK 私有 target,代价不值)
- reveal_in_explorer:explorer / open -R / xdg-open
- open_external:explorer / open / xdg-open
· 修了重构时误删的 message_box 命令(构建时才暴露,已核对 19 个命令齐全)
二、打包配置
· tauri icon 生成三端图标集(.ico / .icns / 多尺寸 png)
· bundle.targets = "all":win→nsis,mac→app+dmg,linux→deb+rpm+appimage
· macOS minimumSystemVersion 10.15;linux.deb 依赖声明
三、发布链路升级成多平台
· publish.py 重写:自动扫描 target 下**存在的**产物,按平台归位,
清单**合并**写入(在 Windows 发版不会冲掉 mac 的条目)
· 官网页新增 macOS / Linux 下载卡,按 latest.json 里有没有该平台决定显隐,
避免指向不存在的文件
四、实测(Linux 版)
· 本机装 webkit2gtk-4.1 等依赖后原生构建成功
· deb 2.79MB、AppImage 103.62MB(AppImage 自带 webkit 运行时所以大)
· 已发布:latest.json 现在有 windows-x86_64 + linux-x86_64 两个平台
· 官网 Linux 卡已显示,macOS 卡等有产物再自动出现
五、macOS
· .github/workflows/build.yml:macos-latest(arm64 + intel)/ ubuntu / windows 矩阵出包
· 需要仓库 Secrets 配升级签名私钥(和可选的苹果开发者证书)
42 lines
1.1 KiB
TOML
42 lines
1.1 KiB
TOML
[package]
|
||
name = "xiaoyin-markdown"
|
||
version = "2.6.5"
|
||
description = "小银 Markdown —— 轻量本地 Markdown 编辑器"
|
||
edition = "2021"
|
||
|
||
[build-dependencies]
|
||
tauri-build = { version = "2", features = [] }
|
||
|
||
[dependencies]
|
||
tauri = { version = "2", features = [] }
|
||
tauri-plugin-dialog = "2"
|
||
tauri-plugin-single-instance = "2"
|
||
# 在线升级:官方 updater(minisign 签名校验)+ process(升级后重启)
|
||
tauri-plugin-updater = "2"
|
||
tauri-plugin-process = "2"
|
||
serde = { version = "1", features = ["derive"] }
|
||
chrono = "0.4"
|
||
serde_json = "1"
|
||
# —— 三端:平台专属依赖各归各的 ——
|
||
# Windows:剪贴板里放「文件本身」要靠 Win32 的 CF_HDROP
|
||
[target.'cfg(windows)'.dependencies]
|
||
clipboard-win = "5"
|
||
windows-sys = { version = "0.61", features = [
|
||
"Win32_Foundation",
|
||
"Win32_System_DataExchange",
|
||
"Win32_System_Memory",
|
||
"Win32_UI_Shell",
|
||
"Win32_UI_WindowsAndMessaging"
|
||
] }
|
||
|
||
# macOS / Linux:文本剪贴板用 arboard(macOS 走 NSPasteboard,Linux 走 X11/Wayland)
|
||
[target.'cfg(not(windows))'.dependencies]
|
||
arboard = "3"
|
||
|
||
[profile.release]
|
||
opt-level = "s"
|
||
lto = true
|
||
codegen-units = 1
|
||
strip = true
|
||
panic = "abort"
|