feat: 支持linux; 支持配置代理
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
DOMAIN='xxxxx.me'
|
||||
TEMP_MAIL='xxxxxx'
|
||||
TEMP_MAIL='xxxxxx'
|
||||
BROWSER_USER_AGENT='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.92 Safari/537.36'
|
||||
BROWSER_PROXY='http://127.0.0.1:2080'
|
||||
BROWSER_HEADLESS='True'
|
||||
|
||||
@@ -2,6 +2,9 @@ from DrissionPage import ChromiumOptions, Chromium
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
class BrowserManager:
|
||||
@@ -24,12 +27,16 @@ class BrowserManager:
|
||||
logging.warning(f"警告: {e}")
|
||||
|
||||
co.set_user_agent(
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.92 Safari/537.36"
|
||||
os.getenv('BROWSER_USER_AGENT', "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.92 Safari/537.36")
|
||||
)
|
||||
co.set_pref("credentials_enable_service", False)
|
||||
co.set_argument("--hide-crash-restore-bubble")
|
||||
proxy = os.getenv('BROWSER_PROXY')
|
||||
if proxy:
|
||||
co.set_proxy(proxy)
|
||||
|
||||
co.auto_port()
|
||||
co.headless(True) # 生产环境使用无头模式
|
||||
co.headless(os.getenv('BROWSER_HEADLESS', 'True').lower() == 'true') # 生产环境使用无头模式
|
||||
|
||||
# Mac 系统特殊处理
|
||||
if sys.platform == "darwin":
|
||||
|
||||
6
build.py
6
build.py
@@ -89,9 +89,9 @@ def build():
|
||||
system = platform.system().lower()
|
||||
spec_file = os.path.join("CursorKeepAlive.spec")
|
||||
|
||||
if system not in ["darwin", "windows"]:
|
||||
print(f"\033[91mUnsupported operating system: {system}\033[0m")
|
||||
return
|
||||
# if system not in ["darwin", "windows"]:
|
||||
# print(f"\033[91mUnsupported operating system: {system}\033[0m")
|
||||
# return
|
||||
|
||||
output_dir = f"dist/{system if system != 'darwin' else 'mac'}"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sqlite3
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
class CursorAuthManager:
|
||||
@@ -7,14 +8,23 @@ class CursorAuthManager:
|
||||
|
||||
def __init__(self):
|
||||
# 判断操作系统
|
||||
if os.name == "nt": # Windows
|
||||
if sys.platform == "win32": # Windows
|
||||
appdata = os.getenv("APPDATA")
|
||||
if appdata is None:
|
||||
raise EnvironmentError("APPDATA 环境变量未设置")
|
||||
self.db_path = os.path.join(
|
||||
os.getenv("APPDATA"), "Cursor", "User", "globalStorage", "state.vscdb"
|
||||
appdata, "Cursor", "User", "globalStorage", "state.vscdb"
|
||||
)
|
||||
else: # macOS
|
||||
self.db_path = os.path.expanduser(
|
||||
elif sys.platform == "darwin": # macOS
|
||||
self.db_path = os.path.abspath(os.path.expanduser(
|
||||
"~/Library/Application Support/Cursor/User/globalStorage/state.vscdb"
|
||||
)
|
||||
))
|
||||
elif sys.platform == "linux" : # Linux 和其他类Unix系统
|
||||
self.db_path = os.path.abspath(os.path.expanduser(
|
||||
"~/.config/Cursor/User/globalStorage/state.vscdb"
|
||||
))
|
||||
else:
|
||||
raise NotImplementedError(f"不支持的操作系统: {sys.platform}")
|
||||
|
||||
def update_auth(self, email=None, access_token=None, refresh_token=None):
|
||||
"""
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import uuid
|
||||
import hashlib
|
||||
@@ -22,15 +23,24 @@ EMOJI = {
|
||||
class MachineIDResetter:
|
||||
def __init__(self):
|
||||
# 判断操作系统
|
||||
if os.name == "nt": # Windows
|
||||
if sys.platform == "win32": # Windows
|
||||
appdata = os.getenv("APPDATA")
|
||||
if appdata is None:
|
||||
raise EnvironmentError("APPDATA 环境变量未设置")
|
||||
self.db_path = os.path.join(
|
||||
os.getenv("APPDATA"), "Cursor", "User", "globalStorage", "storage.json"
|
||||
appdata, "Cursor", "User", "globalStorage", "storage.json"
|
||||
)
|
||||
else: # macOS
|
||||
self.db_path = os.path.expanduser(
|
||||
elif sys.platform == "darwin": # macOS
|
||||
self.db_path = os.path.abspath(os.path.expanduser(
|
||||
"~/Library/Application Support/Cursor/User/globalStorage/storage.json"
|
||||
)
|
||||
|
||||
))
|
||||
elif sys.platform == "linux": # Linux 和其他类Unix系统
|
||||
self.db_path = os.path.abspath(os.path.expanduser(
|
||||
"~/.config/Cursor/User/globalStorage/storage.json"
|
||||
))
|
||||
else:
|
||||
raise NotImplementedError(f"不支持的操作系统: {sys.platform}")
|
||||
|
||||
def generate_new_ids(self):
|
||||
"""生成新的机器ID"""
|
||||
# 生成新的UUID
|
||||
|
||||
Reference in New Issue
Block a user