feat: Enhance 福袋 template matching functionality
- Introduced a new configuration option to enable or disable 福袋 template matching, improving user control over the feature. - Updated command-line arguments to support enabling and disabling the 福袋 template matching feature. - Enhanced the GUI to include options for configuring 福袋 template matching settings. - Improved error handling and logging in various modules to support the new functionality. - Updated documentation to reflect changes in 福袋 template matching features and configuration options.
This commit is contained in:
1 parent
533943620c
commit
fe0098c591
18 files changed
+7263
-107
No files matched your search
+87
-9
@@ -897,6 +897,28 @@ class ProcRunner:
|
||||
fudai_find_max_attempts = 0
|
||||
if fudai_find_max_attempts > 0:
|
||||
cmd += ["--fudai-find-max-attempts", str(fudai_find_max_attempts)]
|
||||
|
||||
# OCR模式1开关(命令行优先)
|
||||
enable_ocr_mode1 = bool(_pick("enable_ocr_mode1", False))
|
||||
if enable_ocr_mode1:
|
||||
cmd.append("--enable-ocr-mode1")
|
||||
else:
|
||||
cmd.append("--disable-ocr-mode1")
|
||||
|
||||
# 福袋模板匹配开关(命令行优先)
|
||||
fudai_template_match_enabled = bool(_pick("fudai_template_match_enabled", False))
|
||||
if fudai_template_match_enabled:
|
||||
cmd.append("--fudai-template-enabled")
|
||||
else:
|
||||
cmd.append("--fudai-template-disabled")
|
||||
|
||||
# 福袋模板匹配阈值(命令行优先)
|
||||
try:
|
||||
fudai_template_match_threshold = float(_pick("fudai_template_match_threshold", 0.7) or 0.7)
|
||||
if 0.0 <= fudai_template_match_threshold <= 1.0:
|
||||
cmd += ["--fudai-template-threshold", str(fudai_template_match_threshold)]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._start_process(cmd)
|
||||
|
||||
@@ -1033,10 +1055,21 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if not rel_path:
|
||||
rel_path = "index.html"
|
||||
safe = os.path.normpath(rel_path).replace("\\", "/")
|
||||
if safe.startswith("../") or safe.startswith("..\\"):
|
||||
# 安全检查:防止路径遍历攻击
|
||||
if safe.startswith("../") or safe.startswith("..\\") or ".." in safe:
|
||||
self.send_error(HTTPStatus.FORBIDDEN)
|
||||
return
|
||||
full = os.path.join(WEBUI_DIR, safe)
|
||||
# 额外安全检查:确保文件在 WEBUI_DIR 目录内
|
||||
try:
|
||||
full_real = os.path.realpath(full)
|
||||
webui_real = os.path.realpath(WEBUI_DIR)
|
||||
if not full_real.startswith(webui_real + os.sep) and full_real != webui_real:
|
||||
self.send_error(HTTPStatus.FORBIDDEN)
|
||||
return
|
||||
except Exception:
|
||||
self.send_error(HTTPStatus.FORBIDDEN)
|
||||
return
|
||||
if not os.path.isfile(full):
|
||||
self.send_error(HTTPStatus.NOT_FOUND)
|
||||
return
|
||||
@@ -1052,14 +1085,35 @@ class Handler(BaseHTTPRequestHandler):
|
||||
".svg": "image/svg+xml; charset=utf-8",
|
||||
}.get(ext, "application/octet-stream")
|
||||
|
||||
with open(full, "rb") as f:
|
||||
data = f.read()
|
||||
self.send_response(HTTPStatus.OK)
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Length", str(len(data)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
self.end_headers()
|
||||
self.wfile.write(data)
|
||||
try:
|
||||
with open(full, "rb") as f:
|
||||
data = f.read()
|
||||
# 对于静态资源,使用适当的缓存策略
|
||||
cache_control = "no-store" if ext in (".html", ".js") else "public, max-age=3600"
|
||||
self.send_response(HTTPStatus.OK)
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Length", str(len(data)))
|
||||
self.send_header("Cache-Control", cache_control)
|
||||
# 添加 ETag 支持(简单实现:基于文件大小和修改时间)
|
||||
try:
|
||||
stat = os.stat(full)
|
||||
etag = f'"{stat.st_size}-{int(stat.st_mtime)}"'
|
||||
self.send_header("ETag", etag)
|
||||
# 检查 If-None-Match 头,支持 304 Not Modified
|
||||
if_none_match = self.headers.get("If-None-Match", "")
|
||||
if if_none_match == etag:
|
||||
self.send_response(HTTPStatus.NOT_MODIFIED)
|
||||
self.end_headers()
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
self.end_headers()
|
||||
self.wfile.write(data)
|
||||
except FileNotFoundError:
|
||||
self.send_error(HTTPStatus.NOT_FOUND)
|
||||
except Exception as e:
|
||||
print(f"[WEB_GUI] Error serving static file {rel_path}: {e}")
|
||||
self.send_error(HTTPStatus.INTERNAL_SERVER_ERROR)
|
||||
|
||||
def do_GET(self):
|
||||
u = urlparse(self.path)
|
||||
@@ -1210,7 +1264,14 @@ class Handler(BaseHTTPRequestHandler):
|
||||
"min_participants",
|
||||
"max_participants",
|
||||
"skip_if_countdown_lt_seconds",
|
||||
"skip_if_countdown_gt_seconds",
|
||||
"reset_after_swipes",
|
||||
"fudai_find_max_attempts",
|
||||
"fudai_quiet_start_hour",
|
||||
"fudai_quiet_end_hour",
|
||||
"high_value_fudai_join_ahead_seconds",
|
||||
"high_value_fudai_max_swipe_back",
|
||||
"high_value_fudai_max_reservations",
|
||||
"yanghao_like_icon_x",
|
||||
"yanghao_like_icon_y",
|
||||
"yanghao_fav_icon_x",
|
||||
@@ -1238,6 +1299,16 @@ class Handler(BaseHTTPRequestHandler):
|
||||
"yanghao_fav_prob",
|
||||
"yanghao_comment_prob",
|
||||
"yanghao_icon_match_threshold",
|
||||
"fudai_template_match_threshold",
|
||||
"lucky_draw_red_ratio_threshold",
|
||||
"live_room_match_threshold",
|
||||
"stage_diag_max_time",
|
||||
"stage_diag_max_step_time",
|
||||
"fudai_icon_retry_delay_seconds",
|
||||
"fudai_icon_max_wait_seconds",
|
||||
"reservation_back_swipe_delay",
|
||||
"reservation_preempt_min_value",
|
||||
"high_value_fudai_threshold_yuan",
|
||||
}
|
||||
bool_keys = {
|
||||
"auto_join_fansclub",
|
||||
@@ -1245,6 +1316,13 @@ class Handler(BaseHTTPRequestHandler):
|
||||
"yanghao_enable_actions",
|
||||
"yanghao_enabled",
|
||||
"yanghao_step_screenshot",
|
||||
"enable_ocr_mode1",
|
||||
"fudai_template_match_enabled",
|
||||
"fudai_quiet_hours_enabled",
|
||||
"high_value_fudai_enabled",
|
||||
"high_value_room_revisit_enabled",
|
||||
"high_value_room_revisit_only_current_run",
|
||||
"reservation_back_verify_enabled",
|
||||
}
|
||||
list_str_keys = {
|
||||
"contains_want",
|
||||
|
||||
Reference in new issue
Block a user