优化界面布局:移除协议配置,将线程数量与注册数量放在一起
This commit is contained in:
@@ -30,19 +30,11 @@ class SteamRegistrationGUI:
|
||||
top_frame = ttk.Frame(main_frame)
|
||||
top_frame.pack(fill="x", side="top", padx=5, pady=5)
|
||||
|
||||
# 创建配置框架
|
||||
config_frame = ttk.LabelFrame(top_frame, text="基本配置")
|
||||
config_frame.pack(fill="x", padx=5, pady=5)
|
||||
|
||||
# 加载默认配置
|
||||
self.script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
self.config_path = os.path.join(self.script_dir, 'config.json')
|
||||
self.config = self._load_config()
|
||||
|
||||
# 创建配置输入框
|
||||
self.config_vars = {}
|
||||
self._create_config_widgets(config_frame)
|
||||
|
||||
# 创建验证码配置框架
|
||||
captcha_frame = ttk.LabelFrame(top_frame, text="验证码配置")
|
||||
captcha_frame.pack(fill="x", padx=5, pady=5)
|
||||
@@ -84,14 +76,25 @@ class SteamRegistrationGUI:
|
||||
("微软Graph", "graph")
|
||||
]
|
||||
|
||||
# 注册数量设置
|
||||
reg_count_frame = ttk.Frame(email_option_frame)
|
||||
reg_count_frame.pack(fill="x", padx=5, pady=5)
|
||||
# 注册数量和线程数量设置
|
||||
count_frame = ttk.Frame(email_option_frame)
|
||||
count_frame.pack(fill="x", padx=5, pady=5)
|
||||
|
||||
ttk.Label(reg_count_frame, text="注册数量:").grid(row=0, column=0, padx=5, pady=2, sticky="e")
|
||||
# 注册数量设置
|
||||
ttk.Label(count_frame, text="注册数量:").grid(row=0, column=0, padx=5, pady=2, sticky="e")
|
||||
self.reg_count_var = tk.StringVar(value="10")
|
||||
ttk.Entry(reg_count_frame, textvariable=self.reg_count_var, width=10).grid(row=0, column=1, padx=5, pady=2, sticky="w")
|
||||
ttk.Label(reg_count_frame, text="(0表示不限制)").grid(row=0, column=2, padx=5, pady=2, sticky="w")
|
||||
ttk.Entry(count_frame, textvariable=self.reg_count_var, width=10).grid(row=0, column=1, padx=5, pady=2, sticky="w")
|
||||
ttk.Label(count_frame, text="(0表示不限制)").grid(row=0, column=2, padx=5, pady=2, sticky="w")
|
||||
|
||||
# 线程数量设置
|
||||
ttk.Label(count_frame, text="线程数量:").grid(row=1, column=0, padx=5, pady=2, sticky="e")
|
||||
self.thread_count_var = tk.StringVar(value=str(self.config.get("executornum", "1")))
|
||||
ttk.Entry(count_frame, textvariable=self.thread_count_var, width=10).grid(row=1, column=1, padx=5, pady=2, sticky="w")
|
||||
|
||||
# 邮箱协议相关配置(隐藏但保留功能)
|
||||
self.protocol_var = tk.StringVar(value=str(self.config.get("protocol", "IMAP")))
|
||||
self.ssl_var = tk.StringVar(value=str(self.config.get("ssl", "True")))
|
||||
self.email_url_var = tk.StringVar(value=str(self.config.get("email_url", "mail.evnmail.com")))
|
||||
|
||||
# 邮箱来源选择
|
||||
email_source_frame = ttk.Frame(email_option_frame)
|
||||
@@ -264,28 +267,6 @@ class SteamRegistrationGUI:
|
||||
except Exception as e:
|
||||
messagebox.showerror("错误", f"加载配置文件失败: {str(e)}")
|
||||
return {}
|
||||
|
||||
def _create_config_widgets(self, parent):
|
||||
"""创建配置输入控件"""
|
||||
config_items = [
|
||||
("protocol", "协议类型:", ["GRAPH", "IMAP", "POP3", "IMAP_OAUTH", "POP3_OAUTH"]),
|
||||
("ssl", "启用SSL:", ["True", "False"]),
|
||||
("email_url", "邮箱服务器:", None),
|
||||
("executornum", "线程数量:", None)
|
||||
]
|
||||
|
||||
for i, (key, label, options) in enumerate(config_items):
|
||||
ttk.Label(parent, text=label, width=10).grid(row=i, column=0, padx=5, pady=2, sticky="e")
|
||||
|
||||
if options:
|
||||
var = tk.StringVar(value=str(self.config.get(key, "")))
|
||||
widget = ttk.Combobox(parent, textvariable=var, values=options, width=50)
|
||||
else:
|
||||
var = tk.StringVar(value=str(self.config.get(key, "")))
|
||||
widget = ttk.Entry(parent, textvariable=var, width=50)
|
||||
|
||||
widget.grid(row=i, column=1, padx=5, pady=2, sticky="ew")
|
||||
self.config_vars[key] = var
|
||||
|
||||
def _create_captcha_widgets(self, parent):
|
||||
"""创建验证码配置输入控件"""
|
||||
@@ -391,14 +372,16 @@ class SteamRegistrationGUI:
|
||||
"""保存配置"""
|
||||
try:
|
||||
config = {}
|
||||
# 保存原有配置
|
||||
for key, var in self.config_vars.items():
|
||||
value = var.get()
|
||||
if key == "executornum":
|
||||
value = int(value)
|
||||
elif key == "ssl":
|
||||
value = value.lower() == "true"
|
||||
config[key] = value
|
||||
# 保存邮箱协议配置(保留这些字段)
|
||||
config['protocol'] = self.protocol_var.get()
|
||||
config['ssl'] = self.ssl_var.get().lower() == "true"
|
||||
config['email_url'] = self.email_url_var.get()
|
||||
|
||||
# 保存线程数量
|
||||
try:
|
||||
config['executornum'] = int(self.thread_count_var.get())
|
||||
except ValueError:
|
||||
config['executornum'] = 1
|
||||
|
||||
# 保存验证码配置
|
||||
for key, var in self.captcha_vars.items():
|
||||
@@ -432,11 +415,15 @@ class SteamRegistrationGUI:
|
||||
messagebox.showerror("错误", "代理文件不存在")
|
||||
return False
|
||||
|
||||
# 验证基本配置
|
||||
for key, var in self.config_vars.items():
|
||||
if not var.get().strip():
|
||||
messagebox.showerror("错误", f"请填写 {key} 配置项")
|
||||
# 验证线程数量
|
||||
try:
|
||||
thread_count = int(self.thread_count_var.get())
|
||||
if thread_count <= 0:
|
||||
messagebox.showerror("错误", "线程数量必须大于0")
|
||||
return False
|
||||
except ValueError:
|
||||
messagebox.showerror("错误", "线程数量必须是整数")
|
||||
return False
|
||||
|
||||
# 验证验证码配置
|
||||
required_captcha_keys = ["pyno_user_token"]
|
||||
|
||||
Reference in New Issue
Block a user