feat(platform): 三端支持 —— Windows / Linux 已出包,macOS 走 Actions

老板要求:开发 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 配升级签名私钥(和可选的苹果开发者证书)
TXT
echo "  ✅ $(git log --oneline -1)"
This commit is contained in:
Jidekin committed 2026-11-20 11:28:05 +08:00
1 parent 6aa1689574
commit 7d8e95f348
61 files changed
+633 -109

No files matched your search

+169
View File
@@ -47,6 +47,26 @@ version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
[[package]]
name = "arboard"
version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917"
dependencies = [
"clipboard-win",
"image",
"log",
"objc2",
"objc2-app-kit",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-foundation",
"parking_lot",
"percent-encoding",
"windows-sys 0.61.2",
"x11rb",
]
[[package]]
name = "async-broadcast"
version = "0.7.2"
@@ -358,6 +378,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "byteorder-lite"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
version = "1.12.2"
@@ -643,6 +669,12 @@ version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
[[package]]
name = "crunchy"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-common"
version = "0.1.7"
@@ -1042,6 +1074,12 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
[[package]]
name = "fax"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a"
[[package]]
name = "fdeflate"
version = "0.3.7"
@@ -1329,6 +1367,16 @@ dependencies = [
"version_check",
]
[[package]]
name = "gethostname"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
dependencies = [
"rustix",
"windows-link",
]
[[package]]
name = "getrandom"
version = "0.2.17"
@@ -1513,6 +1561,17 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "half"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
dependencies = [
"cfg-if",
"crunchy",
"zerocopy",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
@@ -1822,6 +1881,20 @@ dependencies = [
"icu_properties",
]
[[package]]
name = "image"
version = "0.25.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104"
dependencies = [
"bytemuck",
"byteorder-lite",
"moxcms",
"num-traits",
"png",
"tiff",
]
[[package]]
name = "indexmap"
version = "1.9.3"
@@ -2229,6 +2302,16 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "moxcms"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
dependencies = [
"num-traits",
"pxfm",
]
[[package]]
name = "muda"
version = "0.20.0"
@@ -2355,6 +2438,7 @@ dependencies = [
"block2",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-foundation",
"objc2-quartz-core",
]
@@ -2913,6 +2997,18 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "pxfm"
version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea"
[[package]]
name = "quick-error"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "quick-xml"
version = "0.42.0"
@@ -4282,6 +4378,20 @@ dependencies = [
"syn 3.0.10",
]
[[package]]
name = "tiff"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52"
dependencies = [
"fax",
"flate2",
"half",
"quick-error",
"weezl",
"zune-jpeg",
]
[[package]]
name = "time"
version = "0.3.55"
@@ -4929,6 +5039,12 @@ dependencies = [
"windows-core",
]
[[package]]
name = "weezl"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
[[package]]
name = "winapi"
version = "0.3.9"
@@ -5358,6 +5474,23 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "x11rb"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414"
dependencies = [
"gethostname",
"rustix",
"x11rb-protocol",
]
[[package]]
name = "x11rb-protocol"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd"
[[package]]
name = "xattr"
version = "1.7.0"
@@ -5372,6 +5505,7 @@ dependencies = [
name = "xiaoyin-markdown"
version = "2.6.5"
dependencies = [
"arboard",
"chrono",
"clipboard-win",
"serde",
@@ -5478,6 +5612,26 @@ dependencies = [
"serde",
]
[[package]]
name = "zerocopy"
version = "0.8.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "zerofrom"
version = "0.1.8"
@@ -5582,6 +5736,21 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
[[package]]
name = "zune-core"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b"
[[package]]
name = "zune-jpeg"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
dependencies = [
"zune-core",
]
[[package]]
name = "zvariant"
version = "5.15.1"
+7
View File
@@ -17,6 +17,9 @@ 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",
@@ -26,6 +29,10 @@ windows-sys = { version = "0.61", features = [
"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
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1001 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

+108 -23
View File
@@ -1,5 +1,6 @@
// 小银 Markdown —— Tauri 2 后端
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
// 只在 Windows 上隐藏控制台窗口(macOS/Linux 没有这个概念)
#![cfg_attr(all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows")]
use serde::Serialize;
use std::fs;
@@ -254,9 +255,10 @@ fn read_dir(path: String) -> DirResult {
/* ---------------- 剪贴板 ---------------- */
/// Windows:把「文件本身」放进剪贴板(CF_HDROP),能直接粘到资源管理器 / 微信
#[cfg(windows)]
#[tauri::command]
fn copy_file_to_clipboard(path: String) -> Result<(), String> {
// 手写 CF_HDROP:DROPFILES 头 + 双 \0 结尾的 UTF-16 路径列表
use windows_sys::Win32::System::DataExchange::{CloseClipboard, EmptyClipboard, OpenClipboard, SetClipboardData};
use windows_sys::Win32::System::Memory::{GlobalAlloc, GlobalLock, GlobalUnlock, GMEM_MOVEABLE, GMEM_ZEROINIT};
use windows_sys::Win32::UI::Shell::DROPFILES;
@@ -273,10 +275,10 @@ fn copy_file_to_clipboard(path: String) -> Result<(), String> {
}
let mut wide: Vec<u16> = path.encode_utf16().collect();
wide.push(0); // 路径自身的 \0 终止符
wide.push(0);
let header_size = std::mem::size_of::<DROPFILES>();
let list_bytes = (wide.len() + 1) * 2; // +1 是列表级双 \0 结束符
let list_bytes = (wide.len() + 1) * 2;
let total = header_size + list_bytes;
let h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, total);
@@ -291,7 +293,7 @@ fn copy_file_to_clipboard(path: String) -> Result<(), String> {
}
let df = locked as *mut DROPFILES;
(*df).pFiles = header_size as u32;
(*df).fWide = 1; // UTF-16
(*df).fWide = 1;
let dst = (locked as *mut u8).add(header_size);
std::ptr::copy_nonoverlapping(wide.as_ptr() as *const u8, dst, wide.len() * 2);
GlobalUnlock(h);
@@ -305,18 +307,42 @@ fn copy_file_to_clipboard(path: String) -> Result<(), String> {
Ok(())
}
/// macOS / Linux:剪贴板没有跨平台的「文件」格式(要写 GTK/X11 私有 target),
/// 退化成把路径当文本复制 —— 粘到终端、编辑器、下载框里都还能用。
#[cfg(not(windows))]
#[tauri::command]
fn copy_file_to_clipboard(path: String) -> Result<(), String> {
write_clipboard_text(path)
}
#[cfg(windows)]
#[tauri::command]
fn read_clipboard_text() -> String {
use clipboard_win::formats;
use clipboard_win::get_clipboard;
get_clipboard(formats::Unicode).unwrap_or_default()
clipboard_win::get_clipboard(formats::Unicode).unwrap_or_default()
}
#[cfg(not(windows))]
#[tauri::command]
fn read_clipboard_text() -> String {
arboard::Clipboard::new()
.and_then(|mut c| c.get_text())
.unwrap_or_default()
}
#[cfg(windows)]
#[tauri::command]
fn write_clipboard_text(text: String) -> Result<(), String> {
use clipboard_win::formats;
use clipboard_win::set_clipboard;
set_clipboard(formats::Unicode, text).map_err(|e| e.to_string())
clipboard_win::set_clipboard(formats::Unicode, text).map_err(|e| e.to_string())
}
#[cfg(not(windows))]
#[tauri::command]
fn write_clipboard_text(text: String) -> Result<(), String> {
arboard::Clipboard::new()
.and_then(|mut c| c.set_text(text))
.map_err(|e| e.to_string())
}
/* ---------------- 系统 ---------------- */
@@ -324,18 +350,57 @@ fn write_clipboard_text(text: String) -> Result<(), String> {
#[tauri::command]
fn reveal_in_explorer(path: String) -> Result<(), String> {
let p = PathBuf::from(&path);
if p.is_file() {
std::process::Command::new("explorer")
.arg(format!("/select,{}", p.to_string_lossy()))
// Windows:资源管理器并选中该文件
#[cfg(windows)]
{
if p.is_file() {
std::process::Command::new("explorer")
.arg(format!("/select,{}", p.to_string_lossy()))
.spawn()
.map_err(|e| e.to_string())?;
} else {
std::process::Command::new("explorer")
.arg(&p)
.spawn()
.map_err(|e| e.to_string())?;
}
return Ok(());
}
// macOS:Finder 里选中(open -R)
#[cfg(target_os = "macos")]
{
let _ = &p;
if p.is_file() {
std::process::Command::new("open")
.arg("-R")
.arg(&p)
.spawn()
.map_err(|e| e.to_string())?;
} else {
std::process::Command::new("open")
.arg(&p)
.spawn()
.map_err(|e| e.to_string())?;
}
return Ok(());
}
// Linux:没有统一的「选中」接口,打开所在目录
#[cfg(all(unix, not(target_os = "macos")))]
{
let dir = if p.is_dir() {
p.clone()
} else {
p.parent().map(|x| x.to_path_buf()).unwrap_or(p.clone())
};
std::process::Command::new("xdg-open")
.arg(&dir)
.spawn()
.map_err(|e| e.to_string())?;
} else {
std::process::Command::new("explorer")
.arg(&p)
.spawn()
.map_err(|e| e.to_string())?;
return Ok(());
}
Ok(())
}
#[tauri::command]
@@ -343,11 +408,31 @@ fn open_external(url: String) -> Result<(), String> {
if !url.starts_with("http://") && !url.starts_with("https://") {
return Err("仅允许打开 http/https 链接".into());
}
std::process::Command::new("explorer")
.arg(&url)
.spawn()
.map_err(|e| e.to_string())?;
Ok(())
#[cfg(windows)]
{
std::process::Command::new("explorer")
.arg(&url)
.spawn()
.map_err(|e| e.to_string())?;
return Ok(());
}
#[cfg(target_os = "macos")]
{
std::process::Command::new("open")
.arg(&url)
.spawn()
.map_err(|e| e.to_string())?;
return Ok(());
}
#[cfg(all(unix, not(target_os = "macos")))]
{
std::process::Command::new("xdg-open")
.arg(&url)
.spawn()
.map_err(|e| e.to_string())?;
return Ok(());
}
}
#[tauri::command]
+20 -4
View File
@@ -25,10 +25,12 @@
},
"bundle": {
"active": true,
"targets": [
"nsis"
],
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"fileAssociations": [
@@ -68,7 +70,21 @@
"installerHooks": "installer-hooks.nsh"
}
},
"createUpdaterArtifacts": true
"createUpdaterArtifacts": true,
"linux": {
"deb": {
"depends": [
"libwebkit2gtk-4.1-0",
"libgtk-3-0"
]
},
"appimage": {
"bundleMediaFramework": false
}
},
"macOS": {
"minimumSystemVersion": "10.15"
}
},
"plugins": {
"updater": {