Skip to content

Commit 21e7e06

Browse files
committed
feat: Windows
1 parent ae1aeb6 commit 21e7e06

File tree

6 files changed

+64
-42
lines changed

6 files changed

+64
-42
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name = "rs-wavelog-gate"
33
version = "0.1.0"
44
edition = "2024"
55

6+
[[bin]]
7+
name = "rs-wavelog-gate"
8+
path = "src/main.rs"
9+
10+
[build-dependencies]
11+
winres = "0.1"
12+
613
[dependencies]
714
config = "0.15.8"
815
serde = { version = "1.0.128", features = ["derive"] }

build.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#[cfg(windows)]
2+
fn main() {
3+
use std::io::Write;
4+
5+
let mut res = winres::WindowsResource::new();
6+
7+
// 设置应用程序信息
8+
res.set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x00010000);
9+
res.set_version_info(winres::VersionInfo::FILEVERSION, 0x00010000);
10+
11+
// 设置图标(如果有的话)
12+
// res.set_icon("icon.ico");
13+
14+
// 编译资源
15+
if let Err(e) = res.compile() {
16+
eprintln!("Warning: Failed to compile Windows resources: {}", e);
17+
// 不要让构建失败,只是警告
18+
}
19+
}
20+
21+
#[cfg(not(windows))]
22+
fn main() {
23+
// 在非Windows平台上什么都不做
24+
}

src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
2+
13
mod qso;
24
mod settings;
35
mod wavelog;
@@ -202,6 +204,12 @@ fn main() -> iced::Result {
202204
width: 600.0,
203205
height: 200.0,
204206
},
207+
min_size: Some(iced::Size {
208+
width: 400.0,
209+
height: 150.0,
210+
}),
211+
resizable: true,
212+
decorations: true,
205213
..Default::default()
206214
})
207215
.run_with(RustWavelogGateApp::new)

src/udp.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@ impl UdpListener {
2222
let sock = UdpSocket::bind(&addr).await
2323
.map_err(|e| UdpListenerError::BindError(addr.clone(), e))?;
2424

25-
let mut buf = [0; 1024];
25+
let mut buf = [0; 4096]; // 增大缓冲区大小以处理更大的ADIF数据
2626

2727
loop {
2828
match sock.recv_from(&mut buf).await {
2929
Ok((len, _src)) => {
30-
return Ok(buf[..len].to_vec());
30+
if len > 0 {
31+
return Ok(buf[..len].to_vec());
32+
}
3133
}
3234
Err(e) => {
3335
// 记录错误但继续监听
3436
eprintln!("UDP receive error: {}", e);
3537
// 添加小延迟避免过度占用CPU
36-
tokio::time::sleep(Duration::from_millis(10)).await;
38+
tokio::time::sleep(Duration::from_millis(100)).await;
3739
}
3840
}
3941
}

0 commit comments

Comments
 (0)