mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-03 04:57:36 +08:00
refactor: Simplify OS Detection and Download Process
- Streamline OS detection logic by removing detailed architecture checks - Reduce complexity in download URL generation - Remove verbose download verification steps - Simplify error handling during binary download
This commit is contained in:
parent
8afd5df4ea
commit
72c95e4b4f
@ -50,25 +50,12 @@ get_latest_version() {
|
|||||||
echo -e "${GREEN}✅ 找到最新版本: ${VERSION}${NC}"
|
echo -e "${GREEN}✅ 找到最新版本: ${VERSION}${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 檢測系統類型和架構
|
# 檢測系統類型
|
||||||
detect_os() {
|
detect_os() {
|
||||||
if [[ "$(uname)" == "Darwin" ]]; then
|
if [[ "$(uname)" == "Darwin" ]]; then
|
||||||
# 检测 macOS 架构
|
OS="mac"
|
||||||
ARCH=$(uname -m)
|
|
||||||
if [[ "$ARCH" == "arm64" ]]; then
|
|
||||||
OS="mac_arm64"
|
|
||||||
echo -e "${CYAN}ℹ️ 检测到 macOS ARM64 架构${NC}"
|
|
||||||
else
|
else
|
||||||
OS="mac_intel"
|
|
||||||
echo -e "${CYAN}ℹ️ 检测到 macOS Intel 架构${NC}"
|
|
||||||
fi
|
|
||||||
elif [[ "$(uname)" == "Linux" ]]; then
|
|
||||||
OS="linux"
|
OS="linux"
|
||||||
echo -e "${CYAN}ℹ️ 检测到 Linux 系统${NC}"
|
|
||||||
else
|
|
||||||
# 假设是 Windows
|
|
||||||
OS="windows"
|
|
||||||
echo -e "${CYAN}ℹ️ 检测到 Windows 系统${NC}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,51 +67,11 @@ install_cursor_free_vip() {
|
|||||||
local download_url="https://github.com/yeongpin/cursor-free-vip/releases/download/v${VERSION}/${binary_name}"
|
local download_url="https://github.com/yeongpin/cursor-free-vip/releases/download/v${VERSION}/${binary_name}"
|
||||||
|
|
||||||
echo -e "${CYAN}ℹ️ 正在下載到 ${downloads_dir}...${NC}"
|
echo -e "${CYAN}ℹ️ 正在下載到 ${downloads_dir}...${NC}"
|
||||||
echo -e "${CYAN}ℹ️ 下載鏈接: ${download_url}${NC}"
|
|
||||||
|
|
||||||
# 先检查文件是否存在
|
|
||||||
if curl --output /dev/null --silent --head --fail "$download_url"; then
|
|
||||||
echo -e "${GREEN}✅ 文件存在,开始下载...${NC}"
|
|
||||||
else
|
|
||||||
echo -e "${RED}❌ 下载链接不存在: ${download_url}${NC}"
|
|
||||||
echo -e "${YELLOW}⚠️ 尝试不带架构的版本...${NC}"
|
|
||||||
|
|
||||||
# 尝试不带架构的版本
|
|
||||||
if [[ "$OS" == "mac_arm64" || "$OS" == "mac_intel" ]]; then
|
|
||||||
OS="mac"
|
|
||||||
binary_name="CursorFreeVIP_${VERSION}_${OS}"
|
|
||||||
download_url="https://github.com/yeongpin/cursor-free-vip/releases/download/v${VERSION}/${binary_name}"
|
|
||||||
echo -e "${CYAN}ℹ️ 新下载链接: ${download_url}${NC}"
|
|
||||||
|
|
||||||
if ! curl --output /dev/null --silent --head --fail "$download_url"; then
|
|
||||||
echo -e "${RED}❌ 新下载链接也不存在${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 下载文件
|
|
||||||
if ! curl -L -o "${binary_path}" "$download_url"; then
|
if ! curl -L -o "${binary_path}" "$download_url"; then
|
||||||
echo -e "${RED}❌ 下載失敗${NC}"
|
echo -e "${RED}❌ 下載失敗${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 检查下载的文件大小
|
|
||||||
local file_size=$(stat -f%z "${binary_path}" 2>/dev/null || stat -c%s "${binary_path}" 2>/dev/null)
|
|
||||||
echo -e "${CYAN}ℹ️ 下載的文件大小: ${file_size} 字節${NC}"
|
|
||||||
|
|
||||||
# 如果文件太小,可能是错误信息
|
|
||||||
if [ "$file_size" -lt 1000 ]; then
|
|
||||||
echo -e "${YELLOW}⚠️ 警告: 下載的文件太小,可能不是有效的可執行文件${NC}"
|
|
||||||
echo -e "${YELLOW}⚠️ 文件內容:${NC}"
|
|
||||||
cat "${binary_path}"
|
|
||||||
echo ""
|
|
||||||
echo -e "${RED}❌ 下載失敗,請檢查版本號和操作系統是否正確${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${CYAN}ℹ️ 正在設置執行權限...${NC}"
|
echo -e "${CYAN}ℹ️ 正在設置執行權限...${NC}"
|
||||||
chmod +x "${binary_path}"
|
chmod +x "${binary_path}"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user