Skip to content

Commit d4b5a56

Browse files
committed
feat: mirror
1 parent 495b787 commit d4b5a56

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

guide/install.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,24 @@ Commit 时间: 2025-02-12 04:38:33 +0800
6060
curl -fsSL https://cjbind.zxilly.dev/install.sh | bash
6161
```
6262

63+
可以使用镜像源加速下载:
64+
65+
```shell
66+
curl -fsSL https://cjbind.zxilly.dev/install.sh | bash -s -- --mirror
67+
```
68+
6369
#### Windows
6470

6571
```powershell
6672
irm https://cjbind.zxilly.dev/install.ps1 | iex
6773
```
6874

75+
可以使用镜像源加速下载:
76+
77+
```powershell
78+
irm https://cjbind.zxilly.dev/install.ps1 | iex -args "--mirror"
79+
```
80+
6981
## 源码安装
7082

7183
你可以查看 `cjbind` 源码中包含的 `DEVELOPMENT.md` 文件,里面包含了如何在本地构建 `cjbind` 和拉取依赖的详细步骤。

public/install.ps1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
$OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
22

3+
# 检查是否使用镜像
4+
$UseMirror = $false
5+
foreach ($arg in $args) {
6+
if ($arg -eq "--mirror" -or $arg -eq "-m") {
7+
$UseMirror = $true
8+
break
9+
}
10+
}
11+
312
Write-Host "`n=== 开始安装 cjbind ===" -ForegroundColor Cyan
413

514
try {
@@ -30,18 +39,25 @@ try {
3039
Write-Host " √ 目录创建成功" -ForegroundColor Green
3140
}
3241
else {
33-
Write-Host " ! 目录已存在,跳过创建" -ForegroundColor Yellow
42+
Write-Host " ! 目录已存在,跳过创建" -ForegroundColor Yellow
3443
}
3544
}
3645
catch {
3746
Write-Host "错误:目录创建失败 - $_" -ForegroundColor Red
3847
exit 1
3948
}
4049

41-
$downloadUrl = "https://github.com/cjbind/cjbind/releases/download/$latestTag/cjbind-windows-x64.exe"
50+
if ($UseMirror) {
51+
$downloadUrl = "https://gitcode.com/Cangjie-TPC/cjbind/releases/download/$latestTag/cjbind-windows-x64.exe"
52+
$mirrorStatus = ""
53+
} else {
54+
$downloadUrl = "https://github.com/cjbind/cjbind/releases/download/$latestTag/cjbind-windows-x64.exe"
55+
$mirrorStatus = ""
56+
}
4257
$destination = "$targetDir\cjbind.exe"
4358
try {
4459
Write-Host "[3/3] 正在下载程序文件..." -ForegroundColor Cyan
60+
Write-Host " 使用镜像:$mirrorStatus" -ForegroundColor Yellow
4561
Write-Host " 下载地址:$downloadUrl"
4662
Write-Host " 保存路径:$destination`n"
4763

public/install.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/bin/bash
22
set -eo pipefail
33

4+
# 检查是否使用镜像源
5+
USE_MIRROR=false
6+
for arg in "$@"; do
7+
if [ "$arg" = "--mirror" ] || [ "$arg" = "-m" ]; then
8+
USE_MIRROR=true
9+
break
10+
fi
11+
done
12+
413
if [ -t 1 ]; then
514
RED=$(printf '\033[31m')
615
GREEN=$(printf '\033[32m')
@@ -58,7 +67,13 @@ mkdir -p "$TARGET_DIR" || error "无法创建目录: $TARGET_DIR"
5867
success "目录已创建: ${TARGET_DIR/#$HOME/~}"
5968

6069
step 4 "下载程序文件"
61-
DOWNLOAD_URL="https://github.com/cjbind/cjbind/releases/download/$LATEST_TAG/$FILENAME"
70+
if [ "$USE_MIRROR" = true ]; then
71+
DOWNLOAD_URL="https://gitcode.com/Cangjie-TPC/cjbind/releases/download/$LATEST_TAG/$FILENAME"
72+
echo " 使用镜像: ${YELLOW}${RESET}"
73+
else
74+
DOWNLOAD_URL="https://github.com/cjbind/cjbind/releases/download/$LATEST_TAG/$FILENAME"
75+
echo " 使用镜像: ${YELLOW}${RESET}"
76+
fi
6277
echo " 源地址: ${CYAN}${DOWNLOAD_URL}${RESET}"
6378
echo " 目标路径: ${CYAN}${TARGET_DIR/#$HOME/~}/cjbind${RESET}"
6479

0 commit comments

Comments
 (0)