版本修改
This commit is contained in:
88
Windows/CS/Framework4.0/BootLoader/Cargo.lock
generated
88
Windows/CS/Framework4.0/BootLoader/Cargo.lock
generated
@@ -8,7 +8,29 @@ version = "1.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"windows",
|
"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]]
|
[[package]]
|
||||||
@@ -83,6 +105,15 @@ dependencies = [
|
|||||||
"zmij",
|
"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]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.117"
|
version = "2.0.117"
|
||||||
@@ -96,19 +127,55 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.5.11"
|
version = "1.1.2+spec-1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee"
|
||||||
dependencies = [
|
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]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.24"
|
version = "1.0.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.56.0"
|
version = "0.56.0"
|
||||||
@@ -227,12 +294,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winres"
|
name = "winnow"
|
||||||
version = "0.1.12"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
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 = [
|
dependencies = [
|
||||||
"toml",
|
"toml",
|
||||||
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ edition = "2024"
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
windows = { version = "0.56", features = ["Win32_System_Console", "Win32_Foundation", "Win32_System_ProcessStatus", "Win32_System_Threading"] }
|
windows = { version = "0.56", features = ["Win32_System_Console", "Win32_Foundation", "Win32_System_ProcessStatus", "Win32_System_Threading"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
[build-dependencies]
|
||||||
winres = "0.1"
|
winresource = "0.1"
|
||||||
|
|||||||
@@ -1,32 +1,31 @@
|
|||||||
use winres::WindowsResource;
|
use winresource::VersionInfo;
|
||||||
|
|
||||||
|
extern crate winresource;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// 仅在 Windows 上处理资源文件
|
let mut res = winresource::WindowsResource::new();
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
let mut res = 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
|
// 格式: Major<<48 | Minor<<32 | Patch<<16 | Build
|
||||||
res.set_version_info(winres::VersionInfo::FILEVERSION, 0x0001_0000_0000_0000);
|
let major = 1u64;
|
||||||
res.set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x0001_0000_0000_0000);
|
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.2");
|
||||||
res.set("FileVersion", "1.0.0.1");
|
res.set("ProductVersion", "1.0.0.1");
|
||||||
res.set("ProductVersion", "1.0.0.1");
|
|
||||||
|
|
||||||
// 设置产品名和公司名
|
// VERSIONINFO 二进制字段
|
||||||
res.set("ProductName", "BootLoader");
|
res.set_version_info(VersionInfo::FILEVERSION, ver);
|
||||||
res.set("CompanyName", "JoyD");
|
res.set_version_info(VersionInfo::PRODUCTVERSION, ver);
|
||||||
res.set("FileDescription", "应用程序启动器");
|
|
||||||
res.set("LegalCopyright", "Copyright JoyD");
|
|
||||||
|
|
||||||
if let Err(e) = res.compile() {
|
// 产品信息
|
||||||
eprintln!("Failed to compile resource file: {}", e);
|
res.set("ProductName", "BootLoader");
|
||||||
std::process::exit(1);
|
res.set("CompanyName", "JoyD");
|
||||||
}
|
res.set("FileDescription", "应用程序启动器");
|
||||||
}
|
res.set("LegalCopyright", "Copyright JoyD");
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
res.compile().unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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":{}}
|
||||||
@@ -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"}
|
|
||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||||
//通过使用 "*",如下所示:
|
//通过使用 "*",如下所示:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.2.0")]
|
[assembly: AssemblyVersion("1.0.2.1")]
|
||||||
[assembly: AssemblyFileVersion("1.0.2.0")]
|
[assembly: AssemblyFileVersion("1.0.2.1")]
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace JoyD.Windows.CS.WebSocket
|
|||||||
private int _reconnectAttempts = 0;
|
private int _reconnectAttempts = 0;
|
||||||
private int _reconnectDelay = 1000;
|
private int _reconnectDelay = 1000;
|
||||||
private volatile bool _isReconnectScheduled = false;
|
private volatile bool _isReconnectScheduled = false;
|
||||||
|
private volatile bool _isConnecting = false;
|
||||||
|
|
||||||
// 事件
|
// 事件
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -106,6 +107,16 @@ namespace JoyD.Windows.CS.WebSocket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查是否正在连接中
|
||||||
|
if (_isConnecting)
|
||||||
|
{
|
||||||
|
Log("WebSocket正在连接中,跳过本次连接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置正在连接标志
|
||||||
|
_isConnecting = true;
|
||||||
|
|
||||||
ChangeStatus("connecting");
|
ChangeStatus("connecting");
|
||||||
Connecting?.Invoke(this, EventArgs.Empty);
|
Connecting?.Invoke(this, EventArgs.Empty);
|
||||||
|
|
||||||
@@ -157,6 +168,7 @@ namespace JoyD.Windows.CS.WebSocket
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
_isConnecting = false;
|
||||||
StopConnectTimeoutTimer();
|
StopConnectTimeoutTimer();
|
||||||
LogError("WebSocket连接失败: " + ex.Message);
|
LogError("WebSocket连接失败: " + ex.Message);
|
||||||
ChangeStatus("error");
|
ChangeStatus("error");
|
||||||
@@ -174,6 +186,7 @@ namespace JoyD.Windows.CS.WebSocket
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
|
_isConnecting = false;
|
||||||
CancelReconnect();
|
CancelReconnect();
|
||||||
StopHeartbeat();
|
StopHeartbeat();
|
||||||
StopConnectTimeoutTimer();
|
StopConnectTimeoutTimer();
|
||||||
@@ -192,7 +205,7 @@ namespace JoyD.Windows.CS.WebSocket
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Reconnect()
|
public void Reconnect()
|
||||||
{
|
{
|
||||||
if (_webSocket != null && _webSocket.ReadyState == WebSocketSharp.WebSocketState.Connecting)
|
if (_isConnecting || (_webSocket != null && _webSocket.ReadyState == WebSocketSharp.WebSocketState.Connecting))
|
||||||
{
|
{
|
||||||
Log("WebSocket正在连接中,跳过本次重连");
|
Log("WebSocket正在连接中,跳过本次重连");
|
||||||
return;
|
return;
|
||||||
@@ -309,6 +322,7 @@ namespace JoyD.Windows.CS.WebSocket
|
|||||||
// 私有方法
|
// 私有方法
|
||||||
private void WebSocket_OnOpen(object sender, EventArgs e)
|
private void WebSocket_OnOpen(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
_isConnecting = false;
|
||||||
StopConnectTimeoutTimer();
|
StopConnectTimeoutTimer();
|
||||||
ChangeStatus("connected");
|
ChangeStatus("connected");
|
||||||
_reconnectAttempts = 0;
|
_reconnectAttempts = 0;
|
||||||
@@ -347,6 +361,7 @@ namespace JoyD.Windows.CS.WebSocket
|
|||||||
|
|
||||||
private void WebSocket_OnClose(object sender, CloseEventArgs e)
|
private void WebSocket_OnClose(object sender, CloseEventArgs e)
|
||||||
{
|
{
|
||||||
|
_isConnecting = false;
|
||||||
StopConnectTimeoutTimer();
|
StopConnectTimeoutTimer();
|
||||||
StopHeartbeat();
|
StopHeartbeat();
|
||||||
Log("WebSocket连接关闭: " + e.Code + " " + e.Reason);
|
Log("WebSocket连接关闭: " + e.Code + " " + e.Reason);
|
||||||
@@ -366,6 +381,7 @@ namespace JoyD.Windows.CS.WebSocket
|
|||||||
|
|
||||||
private void WebSocket_OnError(object sender, ErrorEventArgs e)
|
private void WebSocket_OnError(object sender, ErrorEventArgs e)
|
||||||
{
|
{
|
||||||
|
_isConnecting = false;
|
||||||
StopConnectTimeoutTimer();
|
StopConnectTimeoutTimer();
|
||||||
StopHeartbeat();
|
StopHeartbeat();
|
||||||
LogError("WebSocket错误: " + e.Message);
|
LogError("WebSocket错误: " + e.Message);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use winresource::VersionInfo;
|
|||||||
extern crate winresource;
|
extern crate winresource;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let version_str = "1.0.0.2";
|
let version_str = "1.0.0.3";
|
||||||
|
|
||||||
let mut res = winresource::WindowsResource::new();
|
let mut res = winresource::WindowsResource::new();
|
||||||
// 字符串表(文件属性对话框显示的值)
|
// 字符串表(文件属性对话框显示的值)
|
||||||
|
|||||||
@@ -5,6 +5,19 @@ use std::collections::{HashMap, HashSet};
|
|||||||
use std::sync::{Arc, Mutex};
|
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 确保线程安全写入)
|
/// 日志文件(Mutex 确保线程安全写入)
|
||||||
static LOG_FILE: std::sync::Mutex<Option<std::fs::File>> = std::sync::Mutex::new(None);
|
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 {
|
macro_rules! log_print {
|
||||||
($($arg:tt)*) => {{
|
($($arg:tt)*) => {{
|
||||||
let msg = format!($($arg)*);
|
let msg = format!($($arg)*);
|
||||||
print!("{}\n", msg);
|
if is_debug_mode() {
|
||||||
std::io::stdout().flush().ok();
|
print!("{}\n", msg);
|
||||||
|
std::io::stdout().flush().ok();
|
||||||
|
}
|
||||||
if LOG_FILE.lock().unwrap().is_none() {
|
if LOG_FILE.lock().unwrap().is_none() {
|
||||||
init_log_file();
|
init_log_file();
|
||||||
}
|
}
|
||||||
@@ -66,11 +81,13 @@ macro_rules! log_print {
|
|||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 错误日志宏:同时输出到控制台stderr和文件(始终记录)
|
/// 错误日志宏:根据 debug 模式决定是否输出到控制台
|
||||||
macro_rules! log_eprintln {
|
macro_rules! log_eprintln {
|
||||||
($($arg:tt)*) => {{
|
($($arg:tt)*) => {{
|
||||||
let msg = format!($($arg)*);
|
let msg = format!($($arg)*);
|
||||||
eprintln!("{}", msg);
|
if is_debug_mode() {
|
||||||
|
eprintln!("{}", msg);
|
||||||
|
}
|
||||||
if LOG_FILE.lock().unwrap().is_none() {
|
if LOG_FILE.lock().unwrap().is_none() {
|
||||||
init_log_file();
|
init_log_file();
|
||||||
}
|
}
|
||||||
@@ -2710,6 +2727,9 @@ async fn main() {
|
|||||||
// 加载 Updater 自身配置(debug_mode)
|
// 加载 Updater 自身配置(debug_mode)
|
||||||
let config = load_updater_config();
|
let config = load_updater_config();
|
||||||
|
|
||||||
|
// 设置全局 debug 模式标志(必须在任何日志输出之前设置)
|
||||||
|
set_debug_mode(config.debug_mode);
|
||||||
|
|
||||||
// debug 模式下分配控制台窗口
|
// debug 模式下分配控制台窗口
|
||||||
if config.debug_mode {
|
if config.debug_mode {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|||||||
Reference in New Issue
Block a user