diff --git a/ClaudeCode/setup-claude-code.ps1 b/ClaudeCode/setup-claude-code.ps1 index 779f75c..7983d46 100644 --- a/ClaudeCode/setup-claude-code.ps1 +++ b/ClaudeCode/setup-claude-code.ps1 @@ -1,4 +1,4 @@ -# Claude Code Configuration Script for XCodeCLI (Windows) +# Claude Code Configuration Script for XCodeCLI (Windows) # This script configures Claude Code to use your XCodeCLI instance # Run with: powershell -ExecutionPolicy Bypass -File setup-claude-code.ps1 -ApiKey YOUR_KEY # Or via one-liner: & { $key='YOUR_KEY'; iwr -useb https://api.xcodecli.com/setup-claude-code.ps1 | iex } @@ -13,6 +13,20 @@ param( # Check for pre-set variables from one-liner command (use different names to avoid conflict) if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key } +# ========== UTF-8 编码兼容 ========== +# 确保中文字符在各种 PowerShell 环境中正确显示 +# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex +try { + if ($Host.Name -eq 'ConsoleHost') { + [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + [Console]::InputEncoding = [System.Text.Encoding]::UTF8 + } + $OutputEncoding = [System.Text.Encoding]::UTF8 + if ($env:OS -eq 'Windows_NT') { + & cmd /c "chcp 65001 >nul" 2>&1 | Out-Null + } +} catch { } + # Configuration $DefaultBaseUrl = "https://api2.xcodecli.com" $ClaudeConfigDir = "$env:USERPROFILE\.claude" diff --git a/GeminiCLI/setup-gemini.ps1 b/GeminiCLI/setup-gemini.ps1 index ea585e3..c148465 100644 --- a/GeminiCLI/setup-gemini.ps1 +++ b/GeminiCLI/setup-gemini.ps1 @@ -1,4 +1,4 @@ -# Gemini CLI Configuration Script for XCodeCLI (Windows) +# Gemini CLI Configuration Script for XCodeCLI (Windows) # This script configures Gemini CLI to use your XCodeCLI instance # Automatically tests multiple API endpoints and selects the working one # Run with: powershell -ExecutionPolicy Bypass -File setup-gemini.ps1 -ApiKey YOUR_KEY @@ -13,6 +13,20 @@ param( # Check for pre-set variables from one-liner command if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key } +# ========== UTF-8 编码兼容 ========== +# 确保中文字符在各种 PowerShell 环境中正确显示 +# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex +try { + if ($Host.Name -eq 'ConsoleHost') { + [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + [Console]::InputEncoding = [System.Text.Encoding]::UTF8 + } + $OutputEncoding = [System.Text.Encoding]::UTF8 + if ($env:OS -eq 'Windows_NT') { + & cmd /c "chcp 65001 >nul" 2>&1 | Out-Null + } +} catch { } + # Configuration $DefaultBaseUrl = "https://api2.xcodecli.com" $GeminiConfigDir = "$env:USERPROFILE\.gemini" diff --git a/codex/setup-codex.ps1 b/codex/setup-codex.ps1 index 610ec5f..a1ced7f 100644 --- a/codex/setup-codex.ps1 +++ b/codex/setup-codex.ps1 @@ -1,4 +1,4 @@ -# Codex Configuration Script for XCodeCLI (Windows) +# Codex Configuration Script for XCodeCLI (Windows) # This script configures Codex to use your XCodeCLI instance # Automatically tests multiple API endpoints and selects the working one # Run with: powershell -ExecutionPolicy Bypass -File setup-codex.ps1 -ApiKey YOUR_KEY @@ -13,6 +13,20 @@ param( # Check for pre-set variables from one-liner command if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key } +# ========== UTF-8 编码兼容 ========== +# 确保中文字符在各种 PowerShell 环境中正确显示 +# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex +try { + if ($Host.Name -eq 'ConsoleHost') { + [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + [Console]::InputEncoding = [System.Text.Encoding]::UTF8 + } + $OutputEncoding = [System.Text.Encoding]::UTF8 + if ($env:OS -eq 'Windows_NT') { + & cmd /c "chcp 65001 >nul" 2>&1 | Out-Null + } +} catch { } + # Configuration $DefaultBaseUrl = "https://api2.xcodecli.com" $CodexConfigDir = "$env:USERPROFILE\.codex" diff --git a/setup-claude-code.ps1 b/setup-claude-code.ps1 index 779f75c..7983d46 100644 --- a/setup-claude-code.ps1 +++ b/setup-claude-code.ps1 @@ -1,4 +1,4 @@ -# Claude Code Configuration Script for XCodeCLI (Windows) +# Claude Code Configuration Script for XCodeCLI (Windows) # This script configures Claude Code to use your XCodeCLI instance # Run with: powershell -ExecutionPolicy Bypass -File setup-claude-code.ps1 -ApiKey YOUR_KEY # Or via one-liner: & { $key='YOUR_KEY'; iwr -useb https://api.xcodecli.com/setup-claude-code.ps1 | iex } @@ -13,6 +13,20 @@ param( # Check for pre-set variables from one-liner command (use different names to avoid conflict) if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key } +# ========== UTF-8 编码兼容 ========== +# 确保中文字符在各种 PowerShell 环境中正确显示 +# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex +try { + if ($Host.Name -eq 'ConsoleHost') { + [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + [Console]::InputEncoding = [System.Text.Encoding]::UTF8 + } + $OutputEncoding = [System.Text.Encoding]::UTF8 + if ($env:OS -eq 'Windows_NT') { + & cmd /c "chcp 65001 >nul" 2>&1 | Out-Null + } +} catch { } + # Configuration $DefaultBaseUrl = "https://api2.xcodecli.com" $ClaudeConfigDir = "$env:USERPROFILE\.claude" diff --git a/setup.ps1 b/setup.ps1 index ca97a93..59fa096 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -1,4 +1,4 @@ -# XCodeCLI Setup Launcher (Windows) +# XCodeCLI Setup Launcher (Windows) # 一站式安装和配置 Claude Code, Gemini CLI, Codex param( @@ -9,6 +9,23 @@ param( # 支持一行命令传入 API Key: $key='xxx'; iwr ... | iex if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key } +# ========== UTF-8 编码兼容 ========== +# 确保中文字符在各种 PowerShell 环境中正确显示 +# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex +try { + if ($Host.Name -eq 'ConsoleHost') { + [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + [Console]::InputEncoding = [System.Text.Encoding]::UTF8 + } + $OutputEncoding = [System.Text.Encoding]::UTF8 + # Windows 下同步控制台代码页为 UTF-8 + if ($env:OS -eq 'Windows_NT') { + & cmd /c "chcp 65001 >nul" 2>&1 | Out-Null + } +} catch { + # 静默处理 - ISE 等环境可能不支持 Console 类操作 +} + # ========== 颜色输出函数 ========== function Write-Info { param([string]$Message); Write-Host "[INFO]" -ForegroundColor Blue -NoNewline; Write-Host " $Message" } function Write-Success { param([string]$Message); Write-Host "[SUCCESS]" -ForegroundColor Green -NoNewline; Write-Host " $Message" }