Skip to content

Commit 2f48adc

Browse files
committed
Prepare 1.0.1 rc2
1 parent 84bc304 commit 2f48adc

7 files changed

Lines changed: 37 additions & 15 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fileshare",
3-
"version": "1.0.1-rc.1",
3+
"version": "1.0.1-rc.2",
44
"private": true,
55
"type": "module",
66
"scripts": {

scripts/create-macos-dmg.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ mkdir -p "$(dirname "$output_path")"
3131
cp -R "$app_path" "$staging_dir/FileShare.app"
3232
cp "$repair_tool" "$staging_dir/损坏修复"
3333
chmod +x "$staging_dir/损坏修复"
34+
ln -s /Applications "$staging_dir/Applications"
3435

3536
hdiutil create \
3637
-volname "FileShare" \

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fileshare"
3-
version = "1.0.1-rc.1"
3+
version = "1.0.1-rc.2"
44
description = "LAN file sharing desktop app"
55
authors = ["FileShare"]
66
edition = "2021"

src-tauri/src/main.rs

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{path::PathBuf, sync::Mutex};
66
use tauri::{
77
image::Image,
88
menu::{Menu, MenuItem},
9-
tray::{TrayIcon, TrayIconBuilder},
9+
tray::{MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent},
1010
AppHandle, Emitter, Manager, RunEvent, WindowEvent, Wry,
1111
};
1212
#[cfg(target_os = "macos")]
@@ -176,12 +176,22 @@ fn setup_tray(app: &mut tauri::App) -> tauri::Result<()> {
176176
let show = MenuItem::with_id(app, TRAY_SHOW_ID, "显示窗口", true, None::<&str>)?;
177177
let quit = MenuItem::with_id(app, TRAY_QUIT_ID, "退出", true, None::<&str>)?;
178178
let menu = Menu::with_items(app, &[&show, &toggle_share, &check_update, &quit])?;
179-
let icon = tray_icon().or_else(|| app.default_window_icon().cloned());
179+
let icon = platform_tray_icon().or_else(|| app.default_window_icon().cloned());
180180

181181
let mut tray = TrayIconBuilder::new()
182182
.menu(&menu)
183183
.tooltip("FileShare")
184-
.show_menu_on_left_click(true)
184+
.show_menu_on_left_click(false)
185+
.on_tray_icon_event(|tray, event| {
186+
if let TrayIconEvent::Click {
187+
button: MouseButton::Left,
188+
button_state: MouseButtonState::Up,
189+
..
190+
} = event
191+
{
192+
show_main_window(tray.app_handle());
193+
}
194+
})
185195
.on_menu_event(|app, event| match event.id().as_ref() {
186196
TRAY_TOGGLE_SHARE_ID => {
187197
let app = app.clone();
@@ -236,6 +246,18 @@ fn tray_icon() -> Option<Image<'static>> {
236246
.map(Image::to_owned)
237247
}
238248

249+
#[cfg(target_os = "windows")]
250+
fn platform_tray_icon() -> Option<Image<'static>> {
251+
Image::from_bytes(include_bytes!("../icons/32x32.png"))
252+
.ok()
253+
.map(Image::to_owned)
254+
}
255+
256+
#[cfg(not(target_os = "windows"))]
257+
fn platform_tray_icon() -> Option<Image<'static>> {
258+
tray_icon()
259+
}
260+
239261
fn inactive_tray_icon() -> Option<Image<'static>> {
240262
tray_icon().map(|icon| {
241263
let rgba = icon
@@ -246,7 +268,7 @@ fn inactive_tray_icon() -> Option<Image<'static>> {
246268
pixel[0],
247269
pixel[1],
248270
pixel[2],
249-
((pixel[3] as f32) * 0.38).round() as u8,
271+
((pixel[3] as f32) * 0.70).round() as u8,
250272
]
251273
})
252274
.collect::<Vec<_>>();
@@ -363,11 +385,10 @@ fn set_tray_share_running(app: &AppHandle, running: bool) {
363385
} else {
364386
"启动分享"
365387
});
366-
let icon = if running {
367-
tray_icon()
368-
} else {
369-
inactive_tray_icon()
370-
};
388+
#[cfg(target_os = "macos")]
389+
let icon = if running { tray_icon() } else { inactive_tray_icon() };
390+
#[cfg(not(target_os = "macos"))]
391+
let icon = platform_tray_icon();
371392
let _ = tray.set_icon(icon);
372393
#[cfg(target_os = "macos")]
373394
{

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "FileShare",
4-
"version": "1.0.1-rc.1",
4+
"version": "1.0.1-rc.2",
55
"identifier": "com.fileshare.desktop",
66
"build": {
77
"beforeDevCommand": "",

0 commit comments

Comments
 (0)