From 0ee65e58fb721fd617baaa4cdb8aed3f2b79bd56 Mon Sep 17 00:00:00 2001 From: zqm Date: Wed, 6 May 2026 15:29:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E9=BB=98=E8=AE=A4=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=8E=A7=E5=88=B6=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Windows/CS/Framework4.0/Updater/build.rs | 16 +++++++++++++--- Windows/CS/Framework4.0/Updater/src/main.rs | 12 +++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Windows/CS/Framework4.0/Updater/build.rs b/Windows/CS/Framework4.0/Updater/build.rs index 9ed447a..ee342b8 100644 --- a/Windows/CS/Framework4.0/Updater/build.rs +++ b/Windows/CS/Framework4.0/Updater/build.rs @@ -3,13 +3,23 @@ use winresource::VersionInfo; extern crate winresource; fn main() { + let version_str = "1.0.0.2"; + let mut res = winresource::WindowsResource::new(); // 字符串表(文件属性对话框显示的值) - res.set("FileVersion", "1.0.0.1"); - res.set("ProductVersion", "1.0.0.1"); + res.set("FileVersion", version_str); + res.set("ProductVersion", version_str); + + // 从字符串自动解析版本号到二进制结构 + let mut parts = version_str.split('.'); + let major: u64 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0); + let minor: u64 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0); + let patch: u64 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0); + let pre: u64 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0); + // 二进制结构(VERSIONINFO 的 FILEVERSION / PRODUCTVERSION) // 格式: Major<<48 | Minor<<32 | Patch<<16 | Pre - let ver: u64 = (1u64 << 48) | (0 << 32) | (0 << 16) | 1; + let ver: u64 = (major << 48) | (minor << 32) | (patch << 16) | pre; res.set_version_info(VersionInfo::FILEVERSION, ver); res.set_version_info(VersionInfo::PRODUCTVERSION, ver); res.compile().unwrap(); diff --git a/Windows/CS/Framework4.0/Updater/src/main.rs b/Windows/CS/Framework4.0/Updater/src/main.rs index c7e7161..92ff5c1 100644 --- a/Windows/CS/Framework4.0/Updater/src/main.rs +++ b/Windows/CS/Framework4.0/Updater/src/main.rs @@ -1,3 +1,5 @@ +#![windows_subsystem = "windows"] + use rand::Rng; use std::collections::{HashMap, HashSet}; use std::sync::{Arc, Mutex}; @@ -2708,17 +2710,13 @@ async fn main() { // 加载 Updater 自身配置(debug_mode) let config = load_updater_config(); - // 非 debug 模式下释放控制台,后台静默运行 - if !config.debug_mode { + // debug 模式下分配控制台窗口 + if config.debug_mode { #[cfg(windows)] { use windows::Win32::System::Console; - use windows::Win32::Foundation::HWND; unsafe { - let console = Console::GetConsoleWindow(); - if console != HWND::default() { - let _ = Console::FreeConsole(); - } + let _ = Console::AllocConsole(); } } }