Browse Source

安装选择的版本

黄中银 2 weeks ago
parent
commit
e4aa12c93b
2 changed files with 26 additions and 17 deletions
  1. 20 16
      build-win.bat
  2. 6 1
      src/App.vue

+ 20 - 16
build-win.bat

@@ -1,15 +1,19 @@
 @echo off
 @echo off
 chcp 65001 >nul 2>&1
 chcp 65001 >nul 2>&1
 
 
+:: 切换到脚本所在目录
+cd /d "%~dp0"
+
+:: 启用 ANSI 转义序列支持 (Windows 10+)
+:: 设置 ESC 变量为真正的 ESC 字符 (ASCII 27)
+for /f %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
+
 :: ============================================
 :: ============================================
 :: Claude AI Installer Windows 构建脚本
 :: Claude AI Installer Windows 构建脚本
 :: Build script for Windows using Tauri
 :: Build script for Windows using Tauri
 :: 此脚本作为 scripts/build.js 的简单入口
 :: 此脚本作为 scripts/build.js 的简单入口
 :: ============================================
 :: ============================================
 
 
-:: 切换到脚本所在目录
-cd /d "%~dp0"
-
 :: 检查是否请求帮助
 :: 检查是否请求帮助
 if /i "%~1"=="--help" goto :show_help
 if /i "%~1"=="--help" goto :show_help
 if /i "%~1"=="-h" goto :show_help
 if /i "%~1"=="-h" goto :show_help
@@ -24,43 +28,43 @@ echo.
 :: 检查 Rust 是否安装
 :: 检查 Rust 是否安装
 where rustc >nul 2>&1
 where rustc >nul 2>&1
 if errorlevel 1 (
 if errorlevel 1 (
-    echo   [91mx[0m 未找到 Rust,请先安装 Rust
-    echo   [94mi[0m 访问: https://rustup.rs/
+    echo   %ESC%[91mx%ESC%[0m 未找到 Rust,请先安装 Rust
+    echo   %ESC%[94mi%ESC%[0m 访问: https://rustup.rs/
     pause
     pause
     exit /b 1
     exit /b 1
 )
 )
 
 
 :: 显示 Rust 版本
 :: 显示 Rust 版本
-for /f "tokens=*" %%i in ('rustc --version') do echo   [92m√[0m Rust: %%i
+for /f "tokens=*" %%i in ('rustc --version') do echo   %ESC%[92m√%ESC%[0m Rust: %%i
 
 
 :: 检查 Node.js
 :: 检查 Node.js
 where node >nul 2>&1
 where node >nul 2>&1
 if errorlevel 1 (
 if errorlevel 1 (
-    echo   [91mx[0m 未找到 Node.js,请先安装 Node.js
+    echo   %ESC%[91mx%ESC%[0m 未找到 Node.js,请先安装 Node.js
     pause
     pause
     exit /b 1
     exit /b 1
 )
 )
 
 
 :: 显示 Node.js 版本
 :: 显示 Node.js 版本
-for /f "tokens=*" %%i in ('node --version') do echo   [92m√[0m Node.js: %%i
+for /f "tokens=*" %%i in ('node --version') do echo   %ESC%[92m√%ESC%[0m Node.js: %%i
 
 
 :: 设置 Tauri 签名密钥环境变量
 :: 设置 Tauri 签名密钥环境变量
 if exist ".keys\tauri-signing.key" (
 if exist ".keys\tauri-signing.key" (
-    echo   [92m√[0m 找到签名密钥
+    echo   %ESC%[92m√%ESC%[0m 找到签名密钥
     for /f "usebackq delims=" %%i in (".keys\tauri-signing.key") do set "TAURI_SIGNING_PRIVATE_KEY=%%i"
     for /f "usebackq delims=" %%i in (".keys\tauri-signing.key") do set "TAURI_SIGNING_PRIVATE_KEY=%%i"
     set "TAURI_SIGNING_PRIVATE_KEY_PASSWORD="
     set "TAURI_SIGNING_PRIVATE_KEY_PASSWORD="
 ) else (
 ) else (
-    echo   [93m![0m 未找到签名密钥 (.keys\tauri-signing.key)
-    echo   [94mi[0m 更新功能将不可用,构建将继续...
+    echo   %ESC%[93m!%ESC%[0m 未找到签名密钥 (.keys\tauri-signing.key)
+    echo   %ESC%[94mi%ESC%[0m 更新功能将不可用,构建将继续...
 )
 )
 
 
 :: 检查 node_modules
 :: 检查 node_modules
 if not exist "node_modules" (
 if not exist "node_modules" (
     echo.
     echo.
-    echo   [93m![0m 未找到 node_modules,正在安装依赖...
+    echo   %ESC%[93m!%ESC%[0m 未找到 node_modules,正在安装依赖...
     call npm install
     call npm install
     if errorlevel 1 (
     if errorlevel 1 (
-        echo   [91mx[0m 安装依赖失败
+        echo   %ESC%[91mx%ESC%[0m 安装依赖失败
         pause
         pause
         exit /b 1
         exit /b 1
     )
     )
@@ -80,14 +84,14 @@ goto :parse_args
 
 
 :run_build
 :run_build
 echo.
 echo.
-echo   [96m^> 调用 Node.js 构建脚本...[0m
-echo   [94mi[0m 执行: node scripts/build.js %NODE_ARGS%
+echo   %ESC%[96m^> 调用 Node.js 构建脚本...%ESC%[0m
+echo   %ESC%[94mi%ESC%[0m 执行: node scripts/build.js %NODE_ARGS%
 echo.
 echo.
 
 
 call node scripts/build.js %NODE_ARGS%
 call node scripts/build.js %NODE_ARGS%
 if errorlevel 1 (
 if errorlevel 1 (
     echo.
     echo.
-    echo   [91mx[0m 构建失败!
+    echo   %ESC%[91mx%ESC%[0m 构建失败!
     echo.
     echo.
     pause
     pause
     exit /b 1
     exit /b 1

+ 6 - 1
src/App.vue

@@ -57,8 +57,13 @@ async function handleInstall(software: SoftwareType, installOptions?: { customPa
   // 只有 nodejs, vscode, git 需要版本选择
   // 只有 nodejs, vscode, git 需要版本选择
   const versionedSoftware = software as 'nodejs' | 'vscode' | 'git'
   const versionedSoftware = software as 'nodejs' | 'vscode' | 'git'
   const hasVersion = software === 'nodejs' || software === 'vscode' || software === 'git'
   const hasVersion = software === 'nodejs' || software === 'vscode' || software === 'git'
+  const selectedVersion = hasVersion ? versionsStore.selectedVersions[versionedSoftware] : undefined
   const options: Record<string, string | undefined> = {
   const options: Record<string, string | undefined> = {
-    version: hasVersion ? versionsStore.selectedVersions[versionedSoftware] : undefined
+    version: selectedVersion,
+    // 后端对不同软件使用不同的版本字段名
+    nodejsVersion: software === 'nodejs' ? selectedVersion : undefined,
+    gitVersion: software === 'git' ? selectedVersion : undefined,
+    vscodeVersion: software === 'vscode' ? selectedVersion : undefined
   }
   }
   // 添加自定义安装路径(根据软件类型使用不同的参数名)
   // 添加自定义安装路径(根据软件类型使用不同的参数名)
   if (installOptions?.customPath) {
   if (installOptions?.customPath) {