老板要求:开发 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)"
100 lines
2.2 KiB
JSON
100 lines
2.2 KiB
JSON
{
|
|
"$schema": "https://schema.tauri.app/config/2",
|
|
"productName": "XiaoyinMarkdown",
|
|
"version": "2.6.5",
|
|
"identifier": "com.xiaoyin.markdown",
|
|
"build": {
|
|
"frontendDist": "../src/renderer"
|
|
},
|
|
"app": {
|
|
"withGlobalTauri": true,
|
|
"windows": [
|
|
{
|
|
"label": "main",
|
|
"title": "未命名 — 小银 Markdown",
|
|
"width": 1380,
|
|
"height": 880,
|
|
"minWidth": 860,
|
|
"minHeight": 520,
|
|
"dragDropEnabled": true
|
|
}
|
|
],
|
|
"security": {
|
|
"csp": null
|
|
}
|
|
},
|
|
"bundle": {
|
|
"active": true,
|
|
"targets": "all",
|
|
"icon": [
|
|
"icons/32x32.png",
|
|
"icons/128x128.png",
|
|
"icons/128x128@2x.png",
|
|
"icons/icon.icns",
|
|
"icons/icon.ico"
|
|
],
|
|
"fileAssociations": [
|
|
{
|
|
"ext": [
|
|
"md",
|
|
"markdown",
|
|
"mdown",
|
|
"mkd",
|
|
"mdwn"
|
|
],
|
|
"name": "XiaoyinMarkdown.Document",
|
|
"description": "Markdown 文档 — 小银 Markdown",
|
|
"role": "Editor"
|
|
},
|
|
{
|
|
"ext": [
|
|
"txt"
|
|
],
|
|
"name": "XiaoyinMarkdown.Text",
|
|
"description": "文本文档 — 小银 Markdown",
|
|
"role": "Editor"
|
|
}
|
|
],
|
|
"windows": {
|
|
"webviewInstallMode": {
|
|
"type": "downloadBootstrapper"
|
|
},
|
|
"nsis": {
|
|
"installMode": "currentUser",
|
|
"languages": [
|
|
"SimpChinese"
|
|
],
|
|
"displayLanguageSelector": false,
|
|
"installerIcon": "icons/icon.ico",
|
|
"uninstallerIcon": "icons/icon.ico",
|
|
"installerHooks": "installer-hooks.nsh"
|
|
}
|
|
},
|
|
"createUpdaterArtifacts": true,
|
|
"linux": {
|
|
"deb": {
|
|
"depends": [
|
|
"libwebkit2gtk-4.1-0",
|
|
"libgtk-3-0"
|
|
]
|
|
},
|
|
"appimage": {
|
|
"bundleMediaFramework": false
|
|
}
|
|
},
|
|
"macOS": {
|
|
"minimumSystemVersion": "10.15"
|
|
}
|
|
},
|
|
"plugins": {
|
|
"updater": {
|
|
"endpoints": [
|
|
"https://md.wangjinding.com/update/latest.json"
|
|
],
|
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEVFMjMxQjcwNzlFMDhCNTgKUldSWWkrQjVjQnNqN3Ewazg0U1VTN2VHSmE5amRROEIzN2UrK2w4dlJ5R05rcGhTY0FuNUk3NUwK",
|
|
"windows": {
|
|
"installMode": "passive"
|
|
}
|
|
}
|
|
}
|
|
} |