mirror of
https://git.axenov.dev/mirrors/cursor-free-vip.git
synced 2026-01-03 01:09:08 +03:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3543615a69 | ||
|
|
24b0a5c09e | ||
|
|
5bbba05f69 | ||
|
|
72c95e4b4f | ||
|
|
8afd5df4ea | ||
|
|
a7a97b5621 | ||
|
|
e2e2ebc12e | ||
|
|
d131bccac0 |
@@ -1,5 +1,10 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v1.4.05
|
||||||
|
|
||||||
|
1. Fix: macOS Language Detection | 修復macOS語言檢測
|
||||||
|
|
||||||
|
|
||||||
## v1.4.04
|
## v1.4.04
|
||||||
|
|
||||||
1. Change Some Language Info to English | 更改一些語言信息為英文
|
1. Change Some Language Info to English | 更改一些語言信息為英文
|
||||||
|
|||||||
18
main.py
18
main.py
@@ -5,11 +5,15 @@ import sys
|
|||||||
import json
|
import json
|
||||||
from logo import print_logo
|
from logo import print_logo
|
||||||
from colorama import Fore, Style, init
|
from colorama import Fore, Style, init
|
||||||
import ctypes
|
|
||||||
from ctypes import windll
|
|
||||||
import locale
|
import locale
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
|
# 只在 Windows 系统上导入 windll
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
import ctypes
|
||||||
|
# 只在 Windows 上导入 windll
|
||||||
|
from ctypes import windll
|
||||||
|
|
||||||
# 初始化colorama
|
# 初始化colorama
|
||||||
init()
|
init()
|
||||||
|
|
||||||
@@ -29,8 +33,8 @@ EMOJI = {
|
|||||||
|
|
||||||
class Translator:
|
class Translator:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.current_language = self.detect_system_language() # Changed to use system language
|
|
||||||
self.translations = {}
|
self.translations = {}
|
||||||
|
self.current_language = self.detect_system_language() # 使用正确的方法名
|
||||||
self.fallback_language = 'en' # Fallback language if translation is missing
|
self.fallback_language = 'en' # Fallback language if translation is missing
|
||||||
self.load_translations()
|
self.load_translations()
|
||||||
|
|
||||||
@@ -51,8 +55,12 @@ class Translator:
|
|||||||
def _detect_windows_language(self):
|
def _detect_windows_language(self):
|
||||||
"""Detect language on Windows systems"""
|
"""Detect language on Windows systems"""
|
||||||
try:
|
try:
|
||||||
# Get the keyboard layout
|
# 确保我们在 Windows 上
|
||||||
user32 = ctypes.WinDLL('user32', use_last_error=True)
|
if platform.system() != 'Windows':
|
||||||
|
return 'en'
|
||||||
|
|
||||||
|
# 获取键盘布局
|
||||||
|
user32 = ctypes.windll.user32
|
||||||
hwnd = user32.GetForegroundWindow()
|
hwnd = user32.GetForegroundWindow()
|
||||||
threadid = user32.GetWindowThreadProcessId(hwnd, 0)
|
threadid = user32.GetWindowThreadProcessId(hwnd, 0)
|
||||||
layout_id = user32.GetKeyboardLayout(threadid) & 0xFFFF
|
layout_id = user32.GetKeyboardLayout(threadid) & 0xFFFF
|
||||||
|
|||||||
@@ -50,12 +50,25 @@ 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
|
||||||
OS="mac"
|
# 检测 macOS 架构
|
||||||
else
|
ARCH=$(uname -m)
|
||||||
|
if [[ "$ARCH" == "arm64" ]]; then
|
||||||
|
OS="mac_arm64"
|
||||||
|
echo -e "${CYAN}ℹ️ 检测到 macOS ARM64 架构${NC}"
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,11 +80,51 @@ 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}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user