Files
admin 0593ff7e62
nginx serve /uploads direct (audio speed) / patch-nginx (push) Failing after 1m34s
数字我 Digital Me:全量入库(大文件走 Git LFS)
2026-10-10 16:24:43 +08:00

80 lines
2.4 KiB
PowerShell
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
param(
[Parameter(Mandatory = $true)]
[string]$ProjectPath,
[Parameter(Mandatory = $true)]
[string]$ProjectName
)
$ErrorActionPreference = 'Stop'
$claudeExe = 'C:\Users\ZHIU\.local\bin\claude.exe'
[Console]::InputEncoding = [System.Text.UTF8Encoding]::new($false)
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
$host.UI.RawUI.WindowTitle = "Claude Code - $ProjectName"
Clear-Host
Write-Host '========================================' -ForegroundColor DarkCyan
Write-Host " Claude Code:$ProjectName" -ForegroundColor Cyan
Write-Host '========================================' -ForegroundColor DarkCyan
Write-Host "项目目录:$ProjectPath"
Write-Host ''
if (-not (Test-Path -LiteralPath $claudeExe)) {
Write-Host '没有找到 Claude Code 程序。' -ForegroundColor Red
Read-Host '按回车关闭窗口'
exit 1
}
if (-not (Test-Path -LiteralPath $ProjectPath -PathType Container)) {
Write-Host '项目目录不存在。' -ForegroundColor Red
Read-Host '按回车关闭窗口'
exit 1
}
function Test-ClaudeLogin {
try {
$statusText = & $claudeExe auth status 2>$null | Out-String
$status = $statusText | ConvertFrom-Json
return [bool]$status.loggedIn
}
catch {
return $false
}
}
if (-not (Test-ClaudeLogin)) {
Write-Host '当前尚未登录 Claude。现在开始登录。' -ForegroundColor Yellow
Write-Host '请按屏幕提示操作;如果浏览器打开,请在浏览器中完成登录。'
Write-Host ''
& $claudeExe auth login
if (-not (Test-ClaudeLogin)) {
Write-Host ''
Write-Host '登录没有完成,Claude 聊天尚未启动。' -ForegroundColor Red
Write-Host '如果看到“所在地区不可用”,说明当前网络无法登录 Claude。'
Read-Host '按回车关闭窗口'
exit 1
}
}
Set-Location -LiteralPath $ProjectPath
Clear-Host
Write-Host "已进入项目:$ProjectName" -ForegroundColor Green
Write-Host '现在可以直接输入中文,例如:请先阅读这个项目并告诉我现在做到哪里。'
Write-Host '退出 Claude:输入 /exit,或按 Ctrl+C。'
Write-Host ''
& $claudeExe
$exitCode = $LASTEXITCODE
Write-Host ''
if ($exitCode -eq 0) {
Write-Host 'Claude 会话已结束。' -ForegroundColor Yellow
}
else {
Write-Host "Claude 已退出,错误代码:$exitCode" -ForegroundColor Red
}
Read-Host '按回车关闭窗口'
exit $exitCode