fix: 修复 Rust 编译错误并成功启动 Tauri 应用

- 修复 commands.rs 中的重复导入问题
- 清理未使用的导入
- 统一 Vite 和 Tauri 配置的端口为 3000
- 添加 Tauri 前端依赖包
- 应用已成功编译并运行
This commit is contained in:
farion1231
2025-08-23 21:00:50 +08:00
parent 88e69e844a
commit 29581b85d9
7 changed files with 5145 additions and 11 deletions

5136
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -15,13 +15,13 @@ name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"] crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies] [build-dependencies]
tauri-build = { version = "2.4.0" } tauri-build = { version = "2.4.0", features = [] }
[dependencies] [dependencies]
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
log = "0.4" log = "0.4"
tauri = { version = "2.8.2" } tauri = { version = "2.8.2", features = [] }
tauri-plugin-log = "2" tauri-plugin-log = "2"
tauri-plugin-store = "2" tauri-plugin-store = "2"
dirs = "5.0" dirs = "5.0"

View File

@@ -1,12 +1,11 @@
use std::collections::HashMap; use std::collections::HashMap;
use tauri::State; use tauri::State;
use serde_json::Value;
use crate::config::{ use crate::config::{
get_claude_config_status, import_current_config_as_default, get_claude_settings_path, import_current_config_as_default, get_claude_settings_path,
ConfigStatus, ConfigStatus,
}; };
use crate::provider::{Provider, ProviderManager}; use crate::provider::Provider;
use crate::store::AppState; use crate::store::AppState;
/// 获取所有供应商 /// 获取所有供应商
@@ -136,7 +135,7 @@ pub async fn import_default_config(
/// 获取 Claude Code 配置状态 /// 获取 Claude Code 配置状态
#[tauri::command] #[tauri::command]
pub async fn get_claude_config_status() -> Result<ConfigStatus, String> { pub async fn get_claude_config_status() -> Result<ConfigStatus, String> {
Ok(get_claude_config_status()) Ok(crate::config::get_claude_config_status())
} }
/// 获取 Claude Code 配置文件路径 /// 获取 Claude Code 配置文件路径

View File

@@ -1,6 +1,5 @@
use std::fs; use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::io::{self, Write};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;

View File

@@ -6,7 +6,7 @@ use uuid::Uuid;
use crate::config::{ use crate::config::{
copy_file, delete_file, get_provider_config_path, read_json_file, write_json_file, copy_file, delete_file, get_provider_config_path, read_json_file, write_json_file,
get_claude_settings_path, backup_config, sanitize_provider_name get_claude_settings_path, backup_config
}; };
/// 供应商结构体 /// 供应商结构体

View File

@@ -1,6 +1,6 @@
use std::sync::Mutex; use std::sync::Mutex;
use crate::config::{get_app_config_path, read_json_file, write_json_file}; use crate::config::get_app_config_path;
use crate::provider::{Provider, ProviderManager}; use crate::provider::ProviderManager;
/// 全局应用状态 /// 全局应用状态
pub struct AppState { pub struct AppState {

View File

@@ -5,7 +5,7 @@
"identifier": "com.ccswitch.app", "identifier": "com.ccswitch.app",
"build": { "build": {
"frontendDist": "../dist", "frontendDist": "../dist",
"devUrl": "http://localhost:5173", "devUrl": "http://localhost:3000",
"beforeDevCommand": "pnpm run dev:renderer", "beforeDevCommand": "pnpm run dev:renderer",
"beforeBuildCommand": "pnpm run build:renderer" "beforeBuildCommand": "pnpm run build:renderer"
}, },