diff --git a/next-env.d.ts b/next-env.d.ts
index c4b7818..9edff1c 100644
--- a/next-env.d.ts
+++ b/next-env.d.ts
@@ -1,6 +1,6 @@
///
///
-import "./.next/dev/types/routes.d.ts";
+import "./.next/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
diff --git a/src-tauri/src/cmds.rs b/src-tauri/src/cmds.rs
index 8db4a3e..cb3ae5e 100644
--- a/src-tauri/src/cmds.rs
+++ b/src-tauri/src/cmds.rs
@@ -1,19 +1,19 @@
use crate::steam;
-use crate::tool::*;
use crate::tool::updater::{check_update, download_update, install_update, UpdateInfo};
+use crate::tool::*;
use crate::vdf::preset;
use crate::vdf::preset::VideoConfig;
use crate::wrap_err;
use anyhow::Result;
-use std::fs::File;
+use serde::{Deserialize, Serialize};
use std::fs;
-use std::path::Path;
+use std::fs::File;
use std::io::{BufRead, BufReader};
+use std::path::Path;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, OnceLock};
use tauri::path::BaseDirectory;
use tauri::Manager;
-use serde::{Deserialize, Serialize};
// use tauri_plugin_shell::ShellExt;
@@ -23,7 +23,9 @@ use serde::{Deserialize, Serialize};
static DOWNLOAD_CANCELLED: OnceLock> = OnceLock::new();
fn get_download_cancelled() -> Arc {
- DOWNLOAD_CANCELLED.get_or_init(|| Arc::new(AtomicBool::new(false))).clone()
+ DOWNLOAD_CANCELLED
+ .get_or_init(|| Arc::new(AtomicBool::new(false)))
+ .clone()
}
#[tauri::command]
@@ -127,7 +129,9 @@ pub fn start_watch_cs2_video(
steam_dir: String,
steam_id32: u32,
) -> Result<(), String> {
- wrap_err!(steam::watch::start_watch_cs2_video(app, steam_dir, steam_id32))
+ wrap_err!(steam::watch::start_watch_cs2_video(
+ app, steam_dir, steam_id32
+ ))
}
#[tauri::command]
@@ -169,16 +173,16 @@ pub fn check_path(path: &str) -> Result {
#[tauri::command]
pub fn check_steam_dir_valid(steam_dir: &str) -> Result {
use std::path::Path;
-
+
let path = Path::new(steam_dir);
if !path.exists() {
return Ok(false);
}
-
+
// 检查是否存在 steam.exe 或 config 目录(至少有一个即可)
let steam_exe = path.join("steam.exe");
let config_dir = path.join("config");
-
+
Ok(steam_exe.exists() || config_dir.exists())
}
@@ -201,14 +205,14 @@ pub async fn analyze_replay(app: tauri::AppHandle, path: &str) -> Result Result {
#[tauri::command]
pub fn read_vprof_report(console_log_path: &str) -> Result {
let path = Path::new(console_log_path);
-
+
if !path.exists() {
return Err("console.log 文件不存在".to_string());
}
let file = File::open(path).map_err(|e| format!("无法打开文件: {}", e))?;
let reader = BufReader::new(file);
-
+
let mut vprof_lines = Vec::new();
let mut in_vprof_section = false;
let mut empty_line_count = 0;
-
+
for line_result in reader.lines() {
let line = line_result.map_err(|e| format!("读取行错误: {}", e))?;
-
+
// 检测 [VProf] 标记
if line.contains("[VProf]") {
in_vprof_section = true;
@@ -300,11 +304,11 @@ pub fn read_vprof_report(console_log_path: &str) -> Result {
}
}
}
-
+
if vprof_lines.is_empty() {
return Err("未找到 [VProf] 报告".to_string());
}
-
+
Ok(vprof_lines.join("\n"))
}
@@ -321,34 +325,22 @@ pub async fn check_app_update(
let current_version = app.package_info().version.to_string();
let use_mirror = use_mirror.unwrap_or(false);
let include_prerelease = include_prerelease.unwrap_or(false);
-
- // println!("[检查更新命令] 当前应用版本: {}", current_version);
- // println!("[检查更新命令] 使用镜像: {}", use_mirror);
- // println!("[检查更新命令] 包含预发布版本: {}", include_prerelease);
- // if let Some(ref ep) = endpoint {
- // println!("[检查更新命令] 自定义端点: {}", ep);
- // }
-
+
// 从环境变量获取 GitHub 仓库信息,如果没有则使用默认值
const DEFAULT_GITHUB_REPO: &str = "plsgo/cstb";
let github_repo_str = std::env::var("GITHUB_REPO").ok();
let github_repo = github_repo_str.as_deref().unwrap_or(DEFAULT_GITHUB_REPO);
- // println!("[检查更新命令] GitHub 仓库: {}", github_repo);
-
- let result = wrap_err!(check_update(
- endpoint.as_deref(),
- ¤t_version,
- use_mirror,
- Some(github_repo),
- include_prerelease
- ).await)?;
-
- // if result.is_some() {
- // println!("[检查更新命令] ✓ 返回更新信息");
- // } else {
- // println!("[检查更新命令] ✗ 无更新可用");
- // }
-
+ let result = wrap_err!(
+ check_update(
+ endpoint.as_deref(),
+ ¤t_version,
+ use_mirror,
+ Some(github_repo),
+ include_prerelease
+ )
+ .await
+ )?;
+
Ok(result)
}
@@ -361,7 +353,7 @@ pub async fn download_app_update(
// 重置取消标志
let cancelled = get_download_cancelled();
cancelled.store(false, Ordering::Relaxed);
-
+
let path = wrap_err!(download_update(&app, &download_url, cancelled).await)?;
Ok(path.to_string_lossy().to_string())
}
@@ -385,7 +377,7 @@ pub fn install_app_update(installer_path: String) -> Result<(), String> {
#[cfg(target_os = "windows")]
pub async fn get_computer_info() -> Result {
use tokio::process::Command;
-
+
// 异步执行 PowerShell 命令获取计算机信息并转换为 JSON
let output = Command::new("powershell")
.args(&[
@@ -396,24 +388,24 @@ pub async fn get_computer_info() -> Result {
.output()
.await
.map_err(|e| format!("执行 PowerShell 命令失败: {}", e))?;
-
+
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
return Err(format!("PowerShell 命令执行失败: {}", stderr));
}
-
+
// 处理 PowerShell 输出,移除 BOM 和空白字符
let stdout = String::from_utf8_lossy(&output.stdout);
let cleaned = stdout.trim().trim_start_matches('\u{feff}'); // 移除 BOM
-
+
// 如果输出为空,返回空对象
if cleaned.is_empty() {
return Ok(serde_json::json!({}));
}
-
+
let mut json: serde_json::Value = serde_json::from_str(cleaned)
.map_err(|e| format!("解析 JSON 失败: {},原始输出: {}", e, cleaned))?;
-
+
// 对于 Windows 11,优先使用 OSDisplayVersion 获取版本代码(如 25H2)
// 如果 OSDisplayVersion 存在且包含版本代码,提取它
if let Some(os_display_version) = json.get("OSDisplayVersion").and_then(|v| v.as_str()) {
@@ -428,7 +420,7 @@ pub async fn get_computer_info() -> Result {
}
}
}
-
+
// 如果没有从 OSDisplayVersion 获取到版本代码,尝试从注册表获取 ReleaseId
if !json.get("ReleaseId").and_then(|v| v.as_str()).is_some() {
let release_id_output = Command::new("powershell")
@@ -439,17 +431,19 @@ pub async fn get_computer_info() -> Result {
])
.output()
.await;
-
+
if let Ok(release_output) = release_id_output {
if release_output.status.success() {
- let release_str = String::from_utf8_lossy(&release_output.stdout).trim().to_string();
+ let release_str = String::from_utf8_lossy(&release_output.stdout)
+ .trim()
+ .to_string();
if !release_str.is_empty() {
json["ReleaseId"] = serde_json::Value::String(release_str);
}
}
}
}
-
+
Ok(json)
}
@@ -488,12 +482,12 @@ fn format_bytes(bytes: u64) -> String {
#[tauri::command]
pub fn get_gpu_info() -> Result