修复打包后文件展示问题
This commit is contained in:
@@ -316,7 +316,14 @@ fn find_standard_installations() -> Vec<ClaudeInstallation> {
|
||||
if let Ok(output) = Command::new("claude").arg("--version").output() {
|
||||
if output.status.success() {
|
||||
debug!("claude is available in PATH");
|
||||
let version = extract_version_from_output(&output.stdout);
|
||||
// Combine stdout and stderr for robust version extraction
|
||||
let mut combined: Vec<u8> = Vec::with_capacity(output.stdout.len() + output.stderr.len() + 1);
|
||||
combined.extend_from_slice(&output.stdout);
|
||||
if !output.stderr.is_empty() {
|
||||
combined.extend_from_slice(b"\n");
|
||||
combined.extend_from_slice(&output.stderr);
|
||||
}
|
||||
let version = extract_version_from_output(&combined);
|
||||
|
||||
installations.push(ClaudeInstallation {
|
||||
path: "claude".to_string(),
|
||||
@@ -335,7 +342,14 @@ fn get_claude_version(path: &str) -> Result<Option<String>, String> {
|
||||
match Command::new(path).arg("--version").output() {
|
||||
Ok(output) => {
|
||||
if output.status.success() {
|
||||
Ok(extract_version_from_output(&output.stdout))
|
||||
// Combine stdout and stderr for robust version extraction
|
||||
let mut combined: Vec<u8> = Vec::with_capacity(output.stdout.len() + output.stderr.len() + 1);
|
||||
combined.extend_from_slice(&output.stdout);
|
||||
if !output.stderr.is_empty() {
|
||||
combined.extend_from_slice(b"\n");
|
||||
combined.extend_from_slice(&output.stderr);
|
||||
}
|
||||
Ok(extract_version_from_output(&combined))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
@@ -586,9 +586,17 @@ pub async fn check_claude_version(app: AppHandle) -> Result<ClaudeVersionStatus,
|
||||
|
||||
// Use regex to directly extract version pattern (e.g., "1.0.41")
|
||||
let version_regex = regex::Regex::new(r"(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?)").ok();
|
||||
|
||||
|
||||
// Combine stdout and stderr for version extraction (some tools write version to stderr)
|
||||
let mut version_src = stdout.clone();
|
||||
if !stderr.is_empty() {
|
||||
version_src.push('\n');
|
||||
version_src.push_str(&stderr);
|
||||
}
|
||||
|
||||
let version = if let Some(regex) = version_regex {
|
||||
regex.captures(&stdout)
|
||||
regex
|
||||
.captures(&version_src)
|
||||
.and_then(|captures| captures.get(1))
|
||||
.map(|m| m.as_str().to_string())
|
||||
} else {
|
||||
@@ -603,7 +611,11 @@ pub async fn check_claude_version(app: AppHandle) -> Result<ClaudeVersionStatus,
|
||||
|
||||
// Check if the output matches the expected format
|
||||
// Expected format: "1.0.17 (Claude Code)" or similar
|
||||
let is_valid = stdout.contains("(Claude Code)") || stdout.contains("Claude Code");
|
||||
let is_valid =
|
||||
stdout.contains("(Claude Code)")
|
||||
|| stdout.contains("Claude Code")
|
||||
|| stderr.contains("(Claude Code)")
|
||||
|| stderr.contains("Claude Code");
|
||||
|
||||
Ok(ClaudeVersionStatus {
|
||||
is_installed: is_valid && output.status.success(),
|
||||
|
||||
@@ -78,16 +78,41 @@ use process::ProcessRegistryState;
|
||||
use file_watcher::FileWatcherState;
|
||||
use std::sync::Mutex;
|
||||
use tauri::Manager;
|
||||
use tauri::menu::{MenuBuilder, MenuItemBuilder};
|
||||
use tauri_plugin_log::{Target, TargetKind};
|
||||
|
||||
fn main() {
|
||||
// Initialize logger
|
||||
env_logger::init();
|
||||
|
||||
// Logging is initialized by tauri-plugin-log
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_clipboard_manager::init())
|
||||
.plugin(tauri_plugin_log::Builder::new()
|
||||
.level(log::LevelFilter::Debug)
|
||||
.targets([
|
||||
Target::new(TargetKind::LogDir { file_name: None }),
|
||||
Target::new(TargetKind::Stdout),
|
||||
])
|
||||
.build())
|
||||
// Add an app menu with DevTools toggle for packaged builds
|
||||
.menu(|app| {
|
||||
let toggle_devtools = MenuItemBuilder::new("Toggle DevTools")
|
||||
.id("toggle-devtools")
|
||||
.accelerator("CmdOrCtrl+Alt+I")
|
||||
.build(app)
|
||||
.unwrap();
|
||||
MenuBuilder::new(app)
|
||||
.item(&toggle_devtools)
|
||||
.build()
|
||||
})
|
||||
.on_menu_event(|app, event| {
|
||||
if event.id() == "toggle-devtools" {
|
||||
if let Some(win) = app.get_webview_window("main") {
|
||||
let _ = win.open_devtools();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setup(|app| {
|
||||
// Initialize agents database
|
||||
let conn = init_database(&app.handle()).expect("Failed to initialize agents database");
|
||||
@@ -178,6 +203,12 @@ fn main() {
|
||||
app.manage(UsageIndexState::default());
|
||||
app.manage(UsageCacheState::default());
|
||||
|
||||
// Optionally auto-open DevTools if env var is set (works in packaged builds)
|
||||
if std::env::var("TAURI_OPEN_DEVTOOLS").ok().as_deref() == Some("1") {
|
||||
if let Some(win) = app.get_webview_window("main") {
|
||||
let _ = win.open_devtools();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
|
||||
Reference in New Issue
Block a user