优化mac打包模式,buid.sh一键打包脚本兼容MacOS
This commit is contained in:
53
build.sh
53
build.sh
@@ -12,10 +12,32 @@ app_list=(
|
||||
"flomo 浮墨 flomoapp.com"
|
||||
"weread 微信阅读 weread.qq.com"
|
||||
)
|
||||
# total package number
|
||||
export index=1
|
||||
export total=4
|
||||
|
||||
old_name="weread"
|
||||
old_zh_name="微信阅读"
|
||||
old_url="weread.qq.com"
|
||||
package_prefix="com.tw93"
|
||||
|
||||
if [[ "$OSTYPE" =~ ^linux ]]; then
|
||||
echo "==============="
|
||||
echo "Build for Linux"
|
||||
echo "==============="
|
||||
# for linux, package name may be com.xxx.xxx
|
||||
echo "rename package name"
|
||||
export desktop_file="src-tauri/assets/${package_prefix}.weread.desktop"
|
||||
mv "src-tauri/assets/weread.desktop" ${desktop_file}
|
||||
sed -i "s/\"productName\": \"weread\"/\"productName\": \"${package_prefix}.weread\"" ${desktop_file}
|
||||
fi
|
||||
|
||||
if [[ "$OSTYPE" =~ ^darwin ]]; then
|
||||
echo "==============="
|
||||
echo "Build for MacOS"
|
||||
echo "==============="
|
||||
fi
|
||||
|
||||
for app_info in "${app_list[@]}"; do
|
||||
array=($app_info)
|
||||
package_name=${array[0]}
|
||||
@@ -23,24 +45,37 @@ for app_info in "${app_list[@]}"; do
|
||||
url=${array[2]}
|
||||
echo "update package name and url"
|
||||
# replace package info
|
||||
sed -i "s/${old_url}/${url}/g" src-tauri/tauri.conf.json
|
||||
sed -i "s/${old_name}/${package_name}/g" src-tauri/tauri.conf.json
|
||||
|
||||
if [[ "$OSTYPE" =~ ^linux ]]; then
|
||||
sed -i "s/${old_url}/${url}/g" src-tauri/tauri.conf.json
|
||||
sed -i "s/${old_name}/${package_name}/g" src-tauri/tauri.conf.json
|
||||
fi
|
||||
|
||||
if [[ "$OSTYPE" =~ ^darwin ]]; then
|
||||
sed -i '' "s|${old_url}|${url}|g" src-tauri/tauri.conf.json
|
||||
sed -i '' "s|${old_name}|${package_name}|g" src-tauri/tauri.conf.json
|
||||
fi
|
||||
|
||||
echo "update ico with 32x32 pictue"
|
||||
cp "src-tauri/png/${package_name}_32.png" "src-tauri/icons/icon.ico"
|
||||
|
||||
echo "update desktop"
|
||||
mv "src-tauri/assets/com-tw93-${old_name}.desktop" "src-tauri/assets/com-tw93-${package_name}.desktop"
|
||||
sed -i "s/${old_zh_name}/${package_zh_name}/g" "src-tauri/assets/com-tw93-${package_name}.desktop"
|
||||
sed -i "s/${old_name}/${package_name}/g" "src-tauri/assets/com-tw93-${package_name}.desktop"
|
||||
if [[ "$OSTYPE" =~ ^linux ]]; then
|
||||
echo "update desktop"
|
||||
old_desktop="src-tauri/assets/${package_prefix}.${old_name}.desktop"
|
||||
new_desktop="src-tauri/assets/${package_prefix}.${old_name}.desktop"
|
||||
mv ${old_desktop} ${new_desktop}
|
||||
sed -i "s/${old_zh_name}/${package_zh_name}/g" ${new_desktop}
|
||||
sed -i "s/${old_name}/${package_name}/g" ${new_desktop}
|
||||
fi
|
||||
|
||||
# update package info
|
||||
old_zh_name=${package_zh_name}
|
||||
old_name=${package_name}
|
||||
old_url=${url}
|
||||
|
||||
echo "build deb/appImage package for Linux x86-64"
|
||||
echo "package name is ${package_name}"
|
||||
npm run build:linux
|
||||
echo "building package ${index}/${total}"
|
||||
echo "package name is ${package_name} (${package_zh_name})"
|
||||
npm run tauri build
|
||||
echo "package build success!"
|
||||
index=$(($index+1))
|
||||
done
|
||||
@@ -1,9 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Categories=Office
|
||||
Exec=com-tw93-weread
|
||||
Icon=com-tw93-weread
|
||||
Name=com-tw93-weread
|
||||
Exec=weread
|
||||
Icon=weread
|
||||
Name=weread
|
||||
Name[zh_CN]=微信阅读
|
||||
StartupNotify=true
|
||||
Terminal=false
|
||||
@@ -2,6 +2,10 @@
|
||||
#![windows_subsystem = "windows"]
|
||||
extern crate image;
|
||||
use tauri_utils::config::{Config, WindowConfig};
|
||||
#[cfg(target_os = "macos")]
|
||||
use wry::application::platform::macos::WindowBuilderExtMacOS;
|
||||
#[cfg(target_os = "windows")]
|
||||
use wry::application::platform::windows::WindowBuilderExtWindows;
|
||||
|
||||
#[cfg(target_os="macos")]
|
||||
use wry::{
|
||||
@@ -46,18 +50,30 @@ fn main() -> wry::Result<()> {
|
||||
#[cfg(target_os = "macos")]
|
||||
let mut menu_bar_menu = Menu::new();
|
||||
#[cfg(target_os = "macos")]
|
||||
let mut first_menu = Menu::new()
|
||||
.add_native_item(MenuItem::Hide)
|
||||
.add_native_item(MenuItem::EnterFullScreen)
|
||||
.add_native_item(MenuItem::Minimize)
|
||||
.add_native_item(MenuItem::Separator)
|
||||
.add_native_item(MenuItem::Copy)
|
||||
.add_native_item(MenuItem::Cut)
|
||||
.add_native_item(MenuItem::Paste)
|
||||
.add_native_item(MenuItem::Undo)
|
||||
.add_native_item(MenuItem::Redo)
|
||||
.add_native_item(MenuItem::SelectAll)
|
||||
.add_native_item(MenuItem::Separator);
|
||||
let mut first_menu = Menu::new();
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Hide);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::EnterFullScreen);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Minimize);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Separator);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Copy);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Cut);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Paste);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Undo);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Redo);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::SelectAll);
|
||||
#[cfg(target_os = "macos")]
|
||||
first_menu.add_native_item(MenuItem::Separator);
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let close_item = first_menu.add_item(
|
||||
MenuItemAttributes::new("CloseWindow")
|
||||
@@ -69,7 +85,7 @@ fn main() -> wry::Result<()> {
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
menu_bar_menu.add_submenu("App", true, first_menu);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let WindowConfig {
|
||||
url,
|
||||
width,
|
||||
@@ -78,6 +94,25 @@ fn main() -> wry::Result<()> {
|
||||
fullscreen,
|
||||
..
|
||||
} = get_windows_config().unwrap_or(WindowConfig::default());
|
||||
#[cfg(target_os = "windows")]
|
||||
let WindowConfig {
|
||||
url,
|
||||
width,
|
||||
height,
|
||||
resizable,
|
||||
fullscreen,
|
||||
..
|
||||
} = get_windows_config().unwrap_or(WindowConfig::default());
|
||||
#[cfg(target_os = "macos")]
|
||||
let WindowConfig {
|
||||
url,
|
||||
width,
|
||||
height,
|
||||
resizable,
|
||||
transparent,
|
||||
fullscreen,
|
||||
..
|
||||
} = get_windows_config().unwrap_or(WindowConfig::default());
|
||||
let event_loop = EventLoop::new();
|
||||
|
||||
let common_window = WindowBuilder::new()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"package": {
|
||||
"productName": "com.tw93.weread",
|
||||
"productName": "weread",
|
||||
"version": "0.2.0"
|
||||
},
|
||||
"tauri": {
|
||||
@@ -39,7 +39,7 @@
|
||||
"librsvg2-dev"
|
||||
],
|
||||
"files": {
|
||||
"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"
|
||||
"/usr/share/applications/weread.desktop": "assets/weread.desktop"
|
||||
}
|
||||
},
|
||||
"externalBin": [],
|
||||
|
||||
Reference in New Issue
Block a user