版本修改

This commit is contained in:
zqm
2026-05-07 09:17:23 +08:00
parent 0ee65e58fb
commit 4247b49791
9 changed files with 152 additions and 44 deletions

View File

@@ -8,7 +8,29 @@ version = "1.0.0"
dependencies = [
"serde_json",
"windows",
"winres",
"winresource",
]
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "hashbrown"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
[[package]]
name = "indexmap"
version = "2.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
@@ -83,6 +105,15 @@ dependencies = [
"zmij",
]
[[package]]
name = "serde_spanned"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
dependencies = [
"serde_core",
]
[[package]]
name = "syn"
version = "2.0.117"
@@ -96,19 +127,55 @@ dependencies = [
[[package]]
name = "toml"
version = "0.5.11"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee"
dependencies = [
"serde",
"indexmap",
"serde_core",
"serde_spanned",
"toml_datetime",
"toml_parser",
"toml_writer",
"winnow",
]
[[package]]
name = "toml_datetime"
version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"
dependencies = [
"serde_core",
]
[[package]]
name = "toml_parser"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526"
dependencies = [
"winnow",
]
[[package]]
name = "toml_writer"
version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db"
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "windows"
version = "0.56.0"
@@ -227,12 +294,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winres"
version = "0.1.12"
name = "winnow"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0"
[[package]]
name = "winresource"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0986a8b1d586b7d3e4fe3d9ea39fb451ae22869dcea4aa109d287a374d866087"
dependencies = [
"toml",
"version_check",
]
[[package]]

View File

@@ -7,5 +7,5 @@ edition = "2024"
serde_json = "1.0"
windows = { version = "0.56", features = ["Win32_System_Console", "Win32_Foundation", "Win32_System_ProcessStatus", "Win32_System_Threading"] }
[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
[build-dependencies]
winresource = "0.1"

View File

@@ -1,32 +1,31 @@
use winres::WindowsResource;
use winresource::VersionInfo;
extern crate winresource;
fn main() {
// 仅在 Windows 上处理资源文件
#[cfg(windows)]
{
let mut res = WindowsResource::new();
let mut res = winresource::WindowsResource::new();
// 编码方式高32位 = (major << 16 | minor)低32位 = (patch << 16 | build)
// 1.0.0.0 => major=1, minor=0, patch=0, build=0 => 0x0001_0000_0000_0000
res.set_version_info(winres::VersionInfo::FILEVERSION, 0x0001_0000_0000_0000);
res.set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x0001_0000_0000_0000);
// 版本定义(只改这一处)
// 格式: Major<<48 | Minor<<32 | Patch<<16 | Build
let major = 1u64;
let minor = 0u64;
let patch = 0u64;
let build = 2u64;
let ver: u64 = (major << 48) | (minor << 32) | (patch << 16) | build;
// 关键:显式设置字符串版本字段,与二进制版本保持一致
// 不设置的话PowerShell/.NET/Explorer 可能从不同字段读取,导致不一致
res.set("FileVersion", "1.0.0.1");
res.set("ProductVersion", "1.0.0.1");
// 字符串版本(文件版本和产品版本可独立设置)
res.set("FileVersion", "1.0.0.2");
res.set("ProductVersion", "1.0.0.1");
// 设置产品名和公司名
res.set("ProductName", "BootLoader");
res.set("CompanyName", "JoyD");
res.set("FileDescription", "应用程序启动器");
res.set("LegalCopyright", "Copyright JoyD");
// VERSIONINFO 二进制字段
res.set_version_info(VersionInfo::FILEVERSION, ver);
res.set_version_info(VersionInfo::PRODUCTVERSION, ver);
if let Err(e) = res.compile() {
eprintln!("Failed to compile resource file: {}", e);
std::process::exit(1);
}
}
// 产品信息
res.set("ProductName", "BootLoader");
res.set("CompanyName", "JoyD");
res.set("FileDescription", "应用程序启动器");
res.set("LegalCopyright", "Copyright JoyD");
println!("cargo:rerun-if-changed=build.rs");
res.compile().unwrap();
}

View File

@@ -1 +1 @@
{"rustc_fingerprint":17656983458485528297,"outputs":{"8372365128484698959":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\xyzqm\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"crt-static\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\xyzqm\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.94.1 (e408947bf 2026-03-25)\nbinary: rustc\ncommit-hash: e408947bfd200af42db322daf0fadfe7e26d3bd1\ncommit-date: 2026-03-25\nhost: x86_64-pc-windows-msvc\nrelease: 1.94.1\nLLVM version: 21.1.8\n","stderr":""}},"successes":{}}
{"rustc_fingerprint":17656983458485528297,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\xyzqm\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"8372365128484698959":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\xyzqm\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"crt-static\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.94.1 (e408947bf 2026-03-25)\nbinary: rustc\ncommit-hash: e408947bfd200af42db322daf0fadfe7e26d3bd1\ncommit-date: 2026-03-25\nhost: x86_64-pc-windows-msvc\nrelease: 1.94.1\nLLVM version: 21.1.8\n","stderr":""}},"successes":{}}

View File

@@ -1 +0,0 @@
{"rustc_vv":"rustc 1.94.1 (e408947bf 2026-03-25)\nbinary: rustc\ncommit-hash: e408947bfd200af42db322daf0fadfe7e26d3bd1\ncommit-date: 2026-03-25\nhost: x86_64-pc-windows-msvc\nrelease: 1.94.1\nLLVM version: 21.1.8\n"}

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyVersion("1.0.2.1")]
[assembly: AssemblyFileVersion("1.0.2.1")]

View File

@@ -22,6 +22,7 @@ namespace JoyD.Windows.CS.WebSocket
private int _reconnectAttempts = 0;
private int _reconnectDelay = 1000;
private volatile bool _isReconnectScheduled = false;
private volatile bool _isConnecting = false;
// 事件
/// <summary>
@@ -106,6 +107,16 @@ namespace JoyD.Windows.CS.WebSocket
return;
}
// 检查是否正在连接中
if (_isConnecting)
{
Log("WebSocket正在连接中跳过本次连接");
return;
}
// 设置正在连接标志
_isConnecting = true;
ChangeStatus("connecting");
Connecting?.Invoke(this, EventArgs.Empty);
@@ -157,6 +168,7 @@ namespace JoyD.Windows.CS.WebSocket
}
catch (Exception ex)
{
_isConnecting = false;
StopConnectTimeoutTimer();
LogError("WebSocket连接失败: " + ex.Message);
ChangeStatus("error");
@@ -174,6 +186,7 @@ namespace JoyD.Windows.CS.WebSocket
/// </summary>
public void Disconnect()
{
_isConnecting = false;
CancelReconnect();
StopHeartbeat();
StopConnectTimeoutTimer();
@@ -192,7 +205,7 @@ namespace JoyD.Windows.CS.WebSocket
/// </summary>
public void Reconnect()
{
if (_webSocket != null && _webSocket.ReadyState == WebSocketSharp.WebSocketState.Connecting)
if (_isConnecting || (_webSocket != null && _webSocket.ReadyState == WebSocketSharp.WebSocketState.Connecting))
{
Log("WebSocket正在连接中跳过本次重连");
return;
@@ -309,6 +322,7 @@ namespace JoyD.Windows.CS.WebSocket
// 私有方法
private void WebSocket_OnOpen(object sender, EventArgs e)
{
_isConnecting = false;
StopConnectTimeoutTimer();
ChangeStatus("connected");
_reconnectAttempts = 0;
@@ -347,6 +361,7 @@ namespace JoyD.Windows.CS.WebSocket
private void WebSocket_OnClose(object sender, CloseEventArgs e)
{
_isConnecting = false;
StopConnectTimeoutTimer();
StopHeartbeat();
Log("WebSocket连接关闭: " + e.Code + " " + e.Reason);
@@ -366,6 +381,7 @@ namespace JoyD.Windows.CS.WebSocket
private void WebSocket_OnError(object sender, ErrorEventArgs e)
{
_isConnecting = false;
StopConnectTimeoutTimer();
StopHeartbeat();
LogError("WebSocket错误: " + e.Message);

View File

@@ -3,7 +3,7 @@ use winresource::VersionInfo;
extern crate winresource;
fn main() {
let version_str = "1.0.0.2";
let version_str = "1.0.0.3";
let mut res = winresource::WindowsResource::new();
// 字符串表(文件属性对话框显示的值)

View File

@@ -5,6 +5,19 @@ use std::collections::{HashMap, HashSet};
use std::sync::{Arc, Mutex};
// ===================== 日志模块 =====================
/// 是否为 debug 模式(控制控制台输出)
static DEBUG_MODE: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
/// 设置 debug 模式标志
fn set_debug_mode(debug: bool) {
DEBUG_MODE.store(debug, std::sync::atomic::Ordering::SeqCst);
}
/// 获取 debug 模式标志
fn is_debug_mode() -> bool {
DEBUG_MODE.load(std::sync::atomic::Ordering::SeqCst)
}
/// 日志文件Mutex 确保线程安全写入)
static LOG_FILE: std::sync::Mutex<Option<std::fs::File>> = std::sync::Mutex::new(None);
@@ -49,12 +62,14 @@ fn init_log_file() {
}
}
/// 日志宏:同时输出到控制台和文件
/// 日志宏:根据 debug 模式决定是否输出到控制台
macro_rules! log_print {
($($arg:tt)*) => {{
let msg = format!($($arg)*);
print!("{}\n", msg);
std::io::stdout().flush().ok();
if is_debug_mode() {
print!("{}\n", msg);
std::io::stdout().flush().ok();
}
if LOG_FILE.lock().unwrap().is_none() {
init_log_file();
}
@@ -66,11 +81,13 @@ macro_rules! log_print {
}};
}
/// 错误日志宏:同时输出到控制台stderr和文件始终记录
/// 错误日志宏:根据 debug 模式决定是否输出到控制台
macro_rules! log_eprintln {
($($arg:tt)*) => {{
let msg = format!($($arg)*);
eprintln!("{}", msg);
if is_debug_mode() {
eprintln!("{}", msg);
}
if LOG_FILE.lock().unwrap().is_none() {
init_log_file();
}
@@ -2710,6 +2727,9 @@ async fn main() {
// 加载 Updater 自身配置debug_mode
let config = load_updater_config();
// 设置全局 debug 模式标志(必须在任何日志输出之前设置)
set_debug_mode(config.debug_mode);
// debug 模式下分配控制台窗口
if config.debug_mode {
#[cfg(windows)]