feat: add Windows PowerShell port (clash.ps1 + install.ps1)

- clash.ps1: 1:1 port of macOS clash script to PowerShell 7
  - TUN-only mode, auto UAC elevation via Start-Process -Verb RunAs
  - Subcommands: start/stop/restart/reload/status/link/open/edit/
    log/cleanup/doctor/verge-off/help + interactive menu
  - win_adapt_config: strip Linux-only fields, stack system→gvisor
  - wintun adapter + route cleanup for network recovery
  - ANSI colors (pwsh 7 + Windows Terminal)
  - 5-path mihomo binary detection (Get-Command→scoop→~/Mihomo→LOCALAPPDATA→ProgramFiles)

- install.ps1: one-command Windows deploy
  - Detect pwsh 7, download mihomo v1.19.15 + wintun.dll 0.14.1
  - Architecture-aware (amd64/arm64)
  - Deploy clash.ps1 to PATH

- README.md: add Windows section
- .gitignore: add wintun.dll, *.exe
This commit is contained in:
2026-08-10 17:11:22 +08:00
parent cdfbcec6b7
commit 061b2bb46e
4 changed files with 1035 additions and 15 deletions
+50 -15
View File
@@ -1,8 +1,10 @@
# Clash — macOS 代理管理脚本
# Clash — Mihomo 内核管理脚本
一份 YAML 配置同时在 OpenWRT macOS 上使用,启动时自动适配 macOS
一份 YAML 配置同时在 OpenWRT / macOS / Windows 上使用,启动时自动适配平台
## 使用
## macOS
### 使用
| 命令 | 说明 |
|------|------|
@@ -15,17 +17,7 @@
| `clash link` | 源文件路径 |
| `clash cleanup` | 网络修复 |
## 目录
```
Clash/
├── clash # 管理脚本
└── install.sh # 部署脚本
~/Mihomo/ ← 放 YAML 配置文件
```
## 新电脑部署
### 部署
```bash
git clone git@github.com:lukeopen/Clash.git
@@ -34,6 +26,49 @@ cp /path/to/config.yaml ~/Mihomo/
clash start
```
## 依赖
### 依赖
- Homebrew + `brew install mihomo`
## Windows
### 使用
| 命令 | 说明 |
|------|------|
| `clash.ps1` | 交互菜单 |
| `clash.ps1 start` | 启动 (TUN 模式) |
| `clash.ps1 stop` | 停止 |
| `clash.ps1 restart` | 重启 |
| `clash.ps1 reload` | 热重载 |
| `clash.ps1 status` | 状态 |
| `clash.ps1 link` | 源文件路径 |
| `clash.ps1 cleanup` | 网络修复 |
### 部署
```powershell
git clone https://github.com/lukeopen/Clash.git
cd Clash
pwsh install.ps1
# 把 .yaml 配置文件放入 ~/Mihomo/
clash.ps1 start
```
### 要求
- Windows 11 + PowerShell 7 (`winget install Microsoft.PowerShell`)
- TUN 模式需要管理员权限(UAC 关闭时自动提权无感)
### 目录结构
```
Clash/
├── clash # macOS 管理脚本
├── install.sh # macOS 部署脚本
├── clash.ps1 # Windows 管理脚本
└── install.ps1 # Windows 部署脚本
~/Mihomo/ ← 放 YAML 配置文件
~/.config/mihomo/ ← 运行时数据(config.yaml / pid / log / ui
```