mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-02 04:37:35 +08:00
Merge pull request #800 from Dragonzhoulong/test-chrome-permissions-fix
fix: 修复 Chrome 用户数据目录权限问题
This commit is contained in:
commit
8e94fa4e46
@ -640,7 +640,9 @@
|
||||
"found_chrome_at": "找到 Chrome: {path}",
|
||||
"found_browser_user_data_dir": "找到 {browser} 用户数据目录: {path}",
|
||||
"select_profile": "选择要使用的 {browser} 配置文件:",
|
||||
"profile_list": "可用 {browser} 配置文件:"
|
||||
"profile_list": "可用 {browser} 配置文件:",
|
||||
"chrome_permissions_fixed": "已修复 Chrome 用户数据目录权限",
|
||||
"chrome_permissions_fix_failed": "修复 Chrome 权限失败: {error}"
|
||||
},
|
||||
"browser_profile": {
|
||||
"title": "浏览器配置文件选择",
|
||||
|
@ -483,6 +483,25 @@ class OAuthHandler:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.error_configuring_browser_options', error=str(e)) if self.translator else f'Error configuring browser options: {e}'}{Style.RESET_ALL}")
|
||||
raise
|
||||
|
||||
def _fix_chrome_permissions(self, user_data_dir):
|
||||
"""Fix permissions for Chrome user data directory"""
|
||||
try:
|
||||
if sys.platform == 'darwin': # macOS
|
||||
import subprocess
|
||||
import pwd
|
||||
|
||||
# Get current user
|
||||
current_user = pwd.getpwuid(os.getuid()).pw_name
|
||||
|
||||
# Fix permissions for Chrome directory
|
||||
chrome_dir = os.path.expanduser('~/Library/Application Support/Google/Chrome')
|
||||
if os.path.exists(chrome_dir):
|
||||
subprocess.run(['chmod', '-R', 'u+rwX', chrome_dir])
|
||||
subprocess.run(['chown', '-R', f'{current_user}:staff', chrome_dir])
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.chrome_permissions_fixed') if self.translator else 'Fixed Chrome user data directory permissions'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('oauth.chrome_permissions_fix_failed', error=str(e)) if self.translator else f'Failed to fix Chrome permissions: {str(e)}'}{Style.RESET_ALL}")
|
||||
|
||||
def handle_google_auth(self):
|
||||
"""Handle Google OAuth authentication"""
|
||||
try:
|
||||
@ -493,6 +512,9 @@ class OAuthHandler:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.browser_failed') if self.translator else 'Browser failed to initialize'}{Style.RESET_ALL}")
|
||||
return False, None
|
||||
|
||||
# Get user data directory for later use
|
||||
user_data_dir = self._get_user_data_directory()
|
||||
|
||||
# Navigate to auth URL
|
||||
try:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.navigating_to_authentication_page') if self.translator else 'Navigating to authentication page...'}{Style.RESET_ALL}")
|
||||
@ -556,6 +578,8 @@ class OAuthHandler:
|
||||
try:
|
||||
if self.browser:
|
||||
self.browser.quit()
|
||||
# Fix Chrome permissions after browser is closed
|
||||
self._fix_chrome_permissions(user_data_dir)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user