chore: Remove obsolete scripts and enhance path configuration
- Deleted `check_md_files.py` and `fix_cursor_md_issue.py` as they are no longer needed. - Added new functions in `path_config.py` for better path management, including actions log and run_cli paths. - Updated various modules to utilize the new path configuration, ensuring consistency and maintainability across the project.
This commit is contained in:
1 parent
b9849b9f5a
commit
bdf9312bc9
58 files changed
+2472
-854
No files matched your search
+46
-10
@@ -8,6 +8,12 @@ import warnings
|
||||
from datetime import datetime
|
||||
from typing import Any, Callable
|
||||
|
||||
# 确保项目根目录在 Python 路径中(支持直接运行 gui/gui_app.py)
|
||||
_script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
_project_root = os.path.dirname(_script_dir)
|
||||
if _project_root not in sys.path:
|
||||
sys.path.insert(0, _project_root)
|
||||
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
# 抽离:ADB/配置/参数结构体到 gui_core.py(便于后续模块化)
|
||||
@@ -1570,9 +1576,9 @@ def main():
|
||||
# OCR区域配置:定义所有需要识别的区域(坐标基于1080x2400基准)
|
||||
OCR_REGIONS = [
|
||||
# (区域名称, (x1, y1, x2, y2), 描述)
|
||||
("福袋内容", (390, 1240, 980, 1470), "福袋内容详情"),
|
||||
("福袋内容", (389, 1273, 1000, 1534), "福袋内容详情"),
|
||||
("福袋倒计时", (390, 1470, 980, 1580), "福袋倒计时"),
|
||||
("福袋价值", (390, 1460, 1000, 1580), "奖品价值/价格"),
|
||||
("福袋价值", (390, 1440, 1000, 1580), "奖品价值/价格"),
|
||||
("抽奖结果", (380, 660, 720, 755), "抽奖结果弹窗"),
|
||||
("推荐页标签栏", (400, 140, 900, 200), "推荐/关注/直播标签"),
|
||||
("推荐页标签栏快速检测", (400, 140, 900, 200), "推荐页快速检测"),
|
||||
@@ -1620,9 +1626,13 @@ def main():
|
||||
root.after(0, log_msg("[截图] 截图成功,已保存到 pic/screenshot.png")) # type: ignore[arg-type]
|
||||
|
||||
# 读取截图以获取实际尺寸
|
||||
screenshot_path = os.path.join(
|
||||
os.path.dirname(__file__), "pic", "screenshot.png"
|
||||
)
|
||||
try:
|
||||
from path_config import get_screenshot_path
|
||||
screenshot_path = get_screenshot_path()
|
||||
except Exception:
|
||||
# 回退到旧路径(向后兼容)
|
||||
import path_config
|
||||
screenshot_path = path_config.get_screenshot_path()
|
||||
if not os.path.exists(screenshot_path):
|
||||
root.after(0, log_msg("[OCR] 截图文件不存在")) # type: ignore[arg-type]
|
||||
return
|
||||
@@ -1886,7 +1896,13 @@ def main():
|
||||
preview_top = ttk.Frame(preview_tab)
|
||||
preview_top.pack(fill=X, padx=10, pady=10)
|
||||
|
||||
images_dir = os.path.join(os.path.dirname(__file__), "pic")
|
||||
try:
|
||||
from path_config import get_pic_dir
|
||||
images_dir = get_pic_dir()
|
||||
except Exception:
|
||||
# 回退到旧路径(向后兼容)
|
||||
import path_config
|
||||
images_dir = path_config.get_pic_dir()
|
||||
|
||||
def scan_image_files():
|
||||
"""扫描pic文件夹及其子文件夹中的所有图片文件"""
|
||||
@@ -2905,7 +2921,13 @@ def main():
|
||||
pass
|
||||
|
||||
def refresh_reservations():
|
||||
path = os.path.join(os.path.dirname(__file__), "state", "reservations.json")
|
||||
try:
|
||||
from path_config import get_reservations_path
|
||||
path = get_reservations_path()
|
||||
except Exception:
|
||||
# 回退到旧路径(向后兼容)
|
||||
import path_config
|
||||
path = path_config.get_reservations_path()
|
||||
try:
|
||||
if os.path.exists(path):
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
@@ -3133,7 +3155,13 @@ def main():
|
||||
pass
|
||||
|
||||
def refresh_high_value_rooms():
|
||||
path = os.path.join(os.path.dirname(__file__), "state", "high_value_rooms.json")
|
||||
try:
|
||||
from path_config import get_high_value_rooms_path
|
||||
path = get_high_value_rooms_path()
|
||||
except Exception:
|
||||
# 回退到旧路径(向后兼容)
|
||||
import path_config
|
||||
path = path_config.get_high_value_rooms_path()
|
||||
try:
|
||||
if os.path.exists(path):
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
@@ -3173,7 +3201,9 @@ def main():
|
||||
path = get_actions_log_path()
|
||||
except Exception:
|
||||
# 回退到旧路径(向后兼容)
|
||||
path = os.path.join(os.path.dirname(__file__), "logs", "actions.log")
|
||||
# 修正路径:GUI应该读取根目录的logs/actions.log
|
||||
import path_config
|
||||
path = path_config.get_actions_log_path()
|
||||
try:
|
||||
if os.path.exists(path):
|
||||
# 仿照 web_gui 的实现:只读最后一小段,避免文件巨大
|
||||
@@ -3405,8 +3435,14 @@ def main():
|
||||
def auto_refresh_actions_log() -> None:
|
||||
refresh_actions_log()
|
||||
root.after(2000, auto_refresh_actions_log) # type: ignore[arg-type]
|
||||
|
||||
|
||||
# 定期刷新预约队列(每5秒)
|
||||
def auto_refresh_reservations() -> None:
|
||||
refresh_reservations()
|
||||
root.after(5000, auto_refresh_reservations) # type: ignore[arg-type]
|
||||
|
||||
root.after(2000, auto_refresh_actions_log) # type: ignore[arg-type]
|
||||
root.after(5000, auto_refresh_reservations) # type: ignore[arg-type]
|
||||
|
||||
# 定期刷新统计信息(每3秒)
|
||||
def auto_refresh_stats() -> None:
|
||||
|
||||
Reference in new issue
Block a user