From 9221e90c81b43b796d8ad8be08b4fa65a55d24de Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 6 Dec 2025 04:21:28 +0800 Subject: Support windows - Simplify PowerShell wrapper function parameter handling - Change log filename format to use hyphens instead of colons - Correct Windows drive letter extraction logic to avoid compilation errors --- scripts/jv_cli.ps1 | 3 +-- src/bin/jvv.rs | 2 +- src/utils/globber.rs | 18 +++++++----------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/jv_cli.ps1 b/scripts/jv_cli.ps1 index 0325578..e8d3674 100644 --- a/scripts/jv_cli.ps1 +++ b/scripts/jv_cli.ps1 @@ -18,8 +18,7 @@ $env:JV_AUTO_UPDATE = "yes" ############### function jv { - param([string[]]$Arguments) - & (Get-Command jv -CommandType Application) @Arguments + & (Get-Command jv -CommandType Application) @args } function jvh { jv here @args } diff --git a/src/bin/jvv.rs b/src/bin/jvv.rs index f40ca97..3e32fa7 100644 --- a/src/bin/jvv.rs +++ b/src/bin/jvv.rs @@ -642,7 +642,7 @@ async fn jvv_service_listen(args: ListenArgs) { return; } let now = chrono::Local::now(); - let log_filename = format!("log_{}.txt", now.format("%Y.%m.%d-%H:%M:%S")); + let log_filename = format!("log_{}.txt", now.format("%Y-%m-%d-%H-%M-%S")); build_env_logger( logs_dir.join(log_filename), vault_cfg.server_config().logger_level(), diff --git a/src/utils/globber.rs b/src/utils/globber.rs index 0c3f471..dbb77ea 100644 --- a/src/utils/globber.rs +++ b/src/utils/globber.rs @@ -246,27 +246,23 @@ pub mod constants { } #[cfg(windows)] { - let current_drive = current_dir() - .unwrap_or_default() + let current_drive = current_dir .components() .find_map(|comp| { - if let std::path::Component::Prefix(prefix) = comp { - Some(prefix) + if let std::path::Component::Prefix(prefix_component) = comp { + Some(prefix_component) } else { None } }) - .and_then(|prefix| { - if let std::path::Prefix::Disk(drive_letter) - | std::path::Prefix::VerbatimDisk(drive_letter) = prefix - { + .and_then(|prefix_component| match prefix_component.kind() { + std::path::Prefix::Disk(drive_letter) + | std::path::Prefix::VerbatimDisk(drive_letter) => { Some((drive_letter as char).to_string()) - } else { - None } + _ => None, }) .unwrap_or_else(|| "C".to_string()); - ( PathBuf::from(format!("{}:{}", current_drive, ROOT_DIR_PREFIX)), remaining.to_string(), -- cgit