Fix launcher paths and remove local hardcoding

This commit is contained in:
Codex committed 2026-05-20 19:18:34 +08:00
1 parent e7a7d3f888
commit 13b1f2150c
15 files changed
+145 -66

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
# Copilot 指令(douyin_guaji-main) # Copilot 指令(本仓库)
## 来自 `docs/完整技术文档.md` 的补充(要点) ## 来自 `docs/完整技术文档.md` 的补充(要点)
- 版本:V4.5(2026-01-18)。本文件为实现细节与验证命令的权威来源,agent 在执行重大改动前请核对文档中的“验证要点”。 - 版本:V4.5(2026-01-18)。本文件为实现细节与验证命令的权威来源,agent 在执行重大改动前请核对文档中的“验证要点”。
+4 -4
View File
@@ -373,7 +373,7 @@ pytest tests/unit/test_example.py::test_some_behavior -q
```bash ```bash
# 如果使用 Git # 如果使用 Git
git clone <repository-url> git clone <repository-url>
cd douyin_guaji-main cd <项目目录>
# 或直接下载 ZIP 文件并解压 # 或直接下载 ZIP 文件并解压
``` ```
@@ -872,7 +872,7 @@ python run_cli.py \
项目采用模块化设计,主要代码位于 `douyin/` 目录下,按功能划分为多个子模块: 项目采用模块化设计,主要代码位于 `douyin/` 目录下,按功能划分为多个子模块:
``` ```
douyin_guaji-main/ <项目目录>/
├── douyin/ # 核心业务逻辑模块 ├── douyin/ # 核心业务逻辑模块
│ ├── core/ # 核心调度和主流程 │ ├── core/ # 核心调度和主流程
│ │ ├── douyin_fudai.py # 主类 fudai_analyse(Mixin 组合) │ │ ├── douyin_fudai.py # 主类 fudai_analyse(Mixin 组合)
@@ -1235,7 +1235,7 @@ douyin_guaji-main/
1. **克隆项目** 1. **克隆项目**
```bash ```bash
git clone <repository-url> git clone <repository-url>
cd douyin_guaji-main cd <项目目录>
``` ```
2. **创建虚拟环境** 2. **创建虚拟环境**
@@ -1532,4 +1532,4 @@ douyin_guaji-main/
如果这个项目对你有帮助,欢迎 Star ⭐ 如果这个项目对你有帮助,欢迎 Star ⭐
</div> </div>
+7 -11
View File
@@ -38,17 +38,13 @@ try:
except Exception: except Exception:
_RESAMPLE = Image _RESAMPLE = Image
# 外部完整版 fudai 逻辑所在的工作树路径,用于镜像 screenshot 给那边使用 # 外部完整版 fudai 逻辑所在的工作树路径,用于镜像 screenshot 给那边使用。
# 使用环境变量或默认路径,避免硬编码用户路径 # 仅在显式设置 EXTERNAL_DOUYIN_FUDAI_DIR 时启用,避免绑定某台机器的旧路径。
_EXTERNAL_AXF_SCREENSHOT = os.path.join( _EXTERNAL_DOUYIN_FUDAI_DIR = os.environ.get("EXTERNAL_DOUYIN_FUDAI_DIR", "").strip()
os.environ.get( _EXTERNAL_AXF_SCREENSHOT = (
"EXTERNAL_DOUYIN_FUDAI_DIR", os.path.join(_EXTERNAL_DOUYIN_FUDAI_DIR, "pic", "screenshot.png")
os.path.join( if _EXTERNAL_DOUYIN_FUDAI_DIR
os.path.expanduser("~"), ".cursor", "worktrees", "douyin_guaji-main", "axf" else ""
),
),
"pic",
"screenshot.png",
) )
+1 -2
View File
@@ -7097,7 +7097,7 @@ debug_logger.log_exception(e, context={"step": "处理福袋"})
示例:快速启用截图镜像并保留调试图像(Linux/WSL 或 PowerShell 环境变量用法相似) 示例:快速启用截图镜像并保留调试图像(Linux/WSL 或 PowerShell 环境变量用法相似)
```bash ```bash
EXTERNAL_DOUYIN_FUDAI_DIR=/mnt/share/douyin_debug SKIP_OCR_INIT=1 python run_cli.py --device-id <DEVICE_ID> --needswitch EXTERNAL_DOUYIN_FUDAI_DIR=<外部调试目录> SKIP_OCR_INIT=1 python run_cli.py --device-id <DEVICE_ID> --needswitch
``` ```
示例:禁用截图镜像以提高性能 示例:禁用截图镜像以提高性能
@@ -7361,4 +7361,3 @@ def get_fudai_contain(analyser, renwu: int = 2):
- 第24章:OCR预处理和优化详解 - 第24章:OCR预处理和优化详解
- 第25章:路径配置系统详解 - 第25章:路径配置系统详解
- 第26章:文本处理工具函数详解 - 第26章:文本处理工具函数详解
+1 -2
View File
@@ -13,7 +13,7 @@
### ✅ 日志文件写入功能正常 ### ✅ 日志文件写入功能正常
**验证点1: 日志文件存在** **验证点1: 日志文件存在**
- 文件路径: `C:\Users\12742\Desktop\douyin_guaji-main\logs\unified_2025-12-22.log` - 文件路径: `logs/unified_2025-12-22.log`
- 文件大小: 8800 bytes - 文件大小: 8800 bytes
- 总行数: 126行 - 总行数: 126行
@@ -96,4 +96,3 @@ GUI应用的日志写入功能:
**测试状态**: ✅ 通过 **测试状态**: ✅ 通过
**功能状态**: ✅ 正常 **功能状态**: ✅ 正常
**建议**: 可以投入使用 **建议**: 可以投入使用
+7 -6
View File
@@ -19,8 +19,8 @@
2. **运行设置脚本(使用Bypass参数绕过执行策略)** 2. **运行设置脚本(使用Bypass参数绕过执行策略)**
```powershell ```powershell
cd "C:\Users\12742\Desktop\douyin_guaji-main" cd "<项目根目录>"
powershell.exe -ExecutionPolicy Bypass -File ".\setup_auto_commit.ps1" powershell.exe -ExecutionPolicy Bypass -File ".\scripts\setup_auto_commit.ps1"
``` ```
3. **完成!** 脚本会自动创建定时任务,每小时自动提交和推送代码。 3. **完成!** 脚本会自动创建定时任务,每小时自动提交和推送代码。
@@ -51,8 +51,8 @@
1. 选择"启动程序" 1. 选择"启动程序"
2. 点击"下一步" 2. 点击"下一步"
3. 程序或脚本:输入 `powershell.exe` 3. 程序或脚本:输入 `powershell.exe`
4. 添加参数:输入 `-ExecutionPolicy Bypass -File "C:\Users\12742\Desktop\douyin_guaji-main\auto_commit_push.ps1"` 4. 添加参数:输入 `-ExecutionPolicy Bypass -File "<项目根目录>\scripts\auto_commit_push.ps1"`
5. 起始于:输入 `C:\Users\12742\Desktop\douyin_guaji-main` 5. 起始于:输入 `<项目根目录>`
6. 点击"下一步" 6. 点击"下一步"
### 步骤5:完成设置 ### 步骤5:完成设置
@@ -85,7 +85,9 @@
您也可以使用以下PowerShell命令(以管理员身份运行)快速创建任务: 您也可以使用以下PowerShell命令(以管理员身份运行)快速创建任务:
```powershell ```powershell
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -File `"C:\Users\12742\Desktop\douyin_guaji-main\auto_commit_push.ps1`"" -WorkingDirectory "C:\Users\12742\Desktop\douyin_guaji-main" $projectRoot = "<项目根目录>"
$scriptPath = Join-Path $projectRoot "scripts\auto_commit_push.ps1"
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -File `"$scriptPath`"" -WorkingDirectory $projectRoot
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Hours 1) -RepetitionDuration (New-TimeSpan -Days 365) $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Hours 1) -RepetitionDuration (New-TimeSpan -Days 365)
@@ -130,4 +132,3 @@ Register-ScheduledTask -TaskName "Git自动提交推送" -Action $action -Trigge
4. 切换到"触发器"选项卡 4. 切换到"触发器"选项卡
5. 编辑触发器,修改重复间隔 5. 编辑触发器,修改重复间隔
6. 保存更改 6. 保存更改
+1 -1
View File
@@ -148,4 +148,4 @@ python run_cli.py --high-value-room-revisit-only-current-run
2. **价值预测**:基于历史数据预测房间价值潜力 2. **价值预测**:基于历史数据预测房间价值潜力
3. **多策略**:支持不同的重访策略选择 3. **多策略**:支持不同的重访策略选择
4. **统计报告**:生成重访效果统计报告</content> 4. **统计报告**:生成重访效果统计报告</content>
<parameter name="filePath">c:\Users\12742\Desktop\douyin_guaji-main\docs\高价值房间重访功能说明.md <parameter name="filePath">docs\高价值房间重访功能说明.md
+7 -14
View File
@@ -6,7 +6,7 @@ douyin_fudai_flow 代理模块(WebGUI 根目录)
完整的流程辅助函数实现位于: 完整的流程辅助函数实现位于:
C:\\Users\\12742\\.cursor\\worktrees\\douyin_guaji-main\\axf\\douyin_fudai_flow.py 环境变量 EXTERNAL_DOUYIN_FUDAI_DIR 指向的目录下的 douyin_fudai_flow.py
本模块的作用: 本模块的作用:
1. 动态加载上述外部模块; 1. 动态加载上述外部模块;
@@ -25,27 +25,20 @@ from types import ModuleType
from typing import Any, Callable from typing import Any, Callable
# 使用环境变量或默认路径,避免硬编码用户路径 _EXTERNAL_DIR = os.environ.get("EXTERNAL_DOUYIN_FUDAI_DIR", "").strip()
_EXTERNAL_DIR = os.environ.get( _EXTERNAL_PATH = (
"EXTERNAL_DOUYIN_FUDAI_DIR", os.path.join(_EXTERNAL_DIR, "douyin_fudai_flow.py") if _EXTERNAL_DIR else ""
os.path.join(
os.path.expanduser("~"),
".cursor",
"worktrees",
"douyin_guaji-main",
"axf"
)
) )
_EXTERNAL_PATH = os.path.join(_EXTERNAL_DIR, "douyin_fudai_flow.py")
def _load_external_flow_module() -> ModuleType: def _load_external_flow_module() -> ModuleType:
if not os.path.isfile(_EXTERNAL_PATH): if not _EXTERNAL_PATH or not os.path.isfile(_EXTERNAL_PATH):
# 如果外部文件不存在,创建一个空的模块 # 如果外部文件不存在,创建一个空的模块
import types import types
empty_module = types.ModuleType("douyin_fudai_flow_external") empty_module = types.ModuleType("douyin_fudai_flow_external")
empty_module.__file__ = _EXTERNAL_PATH empty_module.__file__ = _EXTERNAL_PATH
empty_module.__doc__ = "Empty fallback module - external douyin_fudai_flow.py not found" empty_module.__doc__ = "Empty fallback module - external douyin_fudai_flow.py not found"
empty_module.__dict__["_is_empty_fallback"] = True
return empty_module return empty_module
mod_name = "douyin_fudai_flow_external" mod_name = "douyin_fudai_flow_external"
@@ -66,7 +59,7 @@ _ext_mod = _load_external_flow_module()
# 先将外部模块中所有公开符号导出到当前命名空间 # 先将外部模块中所有公开符号导出到当前命名空间
# 只有当外部模块不是空模块时才导出符号 # 只有当外部模块不是空模块时才导出符号
if hasattr(_ext_mod, '__file__') and _ext_mod.__file__ != _EXTERNAL_PATH: if not getattr(_ext_mod, "_is_empty_fallback", False):
# 外部文件存在且已加载,导出其符号 # 外部文件存在且已加载,导出其符号
for _name, _value in list(vars(_ext_mod).items()): # type: ignore[arg-type] for _name, _value in list(vars(_ext_mod).items()): # type: ignore[arg-type]
if _name.startswith("_"): if _name.startswith("_"):
+4 -3
View File
@@ -15,8 +15,9 @@ from pathlib import Path
import tkinter as tk import tkinter as tk
from tkinter import ttk, scrolledtext, messagebox from tkinter import ttk, scrolledtext, messagebox
# 获取脚本所在目录 # 获取脚本所在目录和项目根目录
BASE_DIR = Path(__file__).parent.absolute() BASE_DIR = Path(__file__).parent.absolute()
PROJECT_ROOT = BASE_DIR.parent
LOG_FILE = BASE_DIR / "webgui_startup.log" LOG_FILE = BASE_DIR / "webgui_startup.log"
WEB_GUI_PY = BASE_DIR / "web_gui.py" WEB_GUI_PY = BASE_DIR / "web_gui.py"
@@ -196,7 +197,7 @@ class WebGUILauncher:
try: try:
# 检查是否有虚拟环境 # 检查是否有虚拟环境
venv_python = BASE_DIR / ".venv" / "Scripts" / "python.exe" venv_python = PROJECT_ROOT / ".venv" / "Scripts" / "python.exe"
if venv_python.exists(): if venv_python.exists():
python_exe = str(venv_python) python_exe = str(venv_python)
self.log("使用虚拟环境启动...") self.log("使用虚拟环境启动...")
@@ -212,7 +213,7 @@ class WebGUILauncher:
self.webgui_process = subprocess.Popen( self.webgui_process = subprocess.Popen(
[python_exe, str(WEB_GUI_PY)], [python_exe, str(WEB_GUI_PY)],
cwd=str(BASE_DIR), cwd=str(PROJECT_ROOT),
env=env, env=env,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
"""Compatibility launcher for the desktop GUI."""
from __future__ import annotations
import os
import runpy
import sys
from pathlib import Path
ROOT_DIR = Path(__file__).resolve().parent
TARGET = ROOT_DIR / "gui" / "gui_app.py"
VENV_PYTHON = ROOT_DIR / ".venv" / "Scripts" / "python.exe"
def _reexec_with_venv() -> None:
if not VENV_PYTHON.exists():
return
if Path(sys.executable).resolve() == VENV_PYTHON.resolve():
return
os.execv(str(VENV_PYTHON), [str(VENV_PYTHON), str(TARGET), *sys.argv[1:]])
def main() -> None:
_reexec_with_venv()
sys.argv = [str(TARGET), *sys.argv[1:]]
runpy.run_path(str(TARGET), run_name="__main__")
if __name__ == "__main__":
main()
+3 -10
View File
@@ -40,18 +40,11 @@ except Exception:
pass pass
# ==== 兼容导入完整逻辑模块 douyin_fudai 及其依赖 ============================== # ==== 兼容导入完整逻辑模块 douyin_fudai 及其依赖 ==============================
# 当前 WebGUI 目录中没有完整版 douyin_fudai.py,而是在 Cursor 的工作树中存在完整实现。 # 如果需要从外部工作树加载兼容模块,可显式设置 EXTERNAL_DOUYIN_FUDAI_DIR。
# 同时,我们在本目录下放置了一些 shim 模块(如 douyin_text_utils、douyin_swipe_ops 等), # 默认只使用当前仓库内置实现,避免绑定到某台机器的 Cursor worktree 路径。
# 需要优先加载这些本地实现,再去加载完整逻辑模块。
_BASE_DIR = os.path.dirname(__file__) _BASE_DIR = os.path.dirname(__file__)
# 使用环境变量或默认路径,避免硬编码用户路径 _EXTERNAL_DOUYIN_FUDAI_DIR = os.environ.get("EXTERNAL_DOUYIN_FUDAI_DIR", "").strip()
_EXTERNAL_DOUYIN_FUDAI_DIR = os.environ.get(
"EXTERNAL_DOUYIN_FUDAI_DIR",
os.path.join(
os.path.expanduser("~"), ".cursor", "worktrees", "douyin_guaji-main", "axf"
),
)
def _load_local_shim(mod_name: str, rel_path: str) -> None: def _load_local_shim(mod_name: str, rel_path: str) -> None:
+12 -6
View File
@@ -1,11 +1,17 @@
@echo off @echo off
REM Git自动提交和推送批处理脚本 REM Git auto commit and push batch launcher.
REM 每小时自动保存修改、提交并推送到GitHub REM Runs the PowerShell script from this scripts directory.
cd /d "C:\Users\12742\Desktop\douyin_guaji-main" cd /d "%~dp0.."
if errorlevel 1 (
echo Failed to switch to project root.
pause
exit /b 1
)
REM 运行PowerShell脚本 REM Run the PowerShell script.
powershell.exe -ExecutionPolicy Bypass -File "%~dp0auto_commit_push.ps1" powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0auto_commit_push.ps1"
set "EXIT_CODE=%ERRORLEVEL%"
pause pause
exit /b %EXIT_CODE%
+31 -3
View File
@@ -4,10 +4,39 @@
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
# Switch to project directory # Switch to project directory (parent of this scripts directory)
$projectPath = "C:\Users\12742\Desktop\douyin_guaji-main" $projectPath = Resolve-Path (Join-Path $PSScriptRoot "..")
Set-Location $projectPath Set-Location $projectPath
function Ensure-GitOnPath {
if (Get-Command git -ErrorAction SilentlyContinue) {
return
}
$candidateDirs = @(
"C:\Program Files\Git\cmd",
"C:\Program Files\Git\bin",
"C:\Program Files (x86)\Git\cmd",
"C:\Program Files (x86)\Git\bin",
(Join-Path $env:LOCALAPPDATA "Programs\Git\cmd"),
(Join-Path $env:LOCALAPPDATA "Programs\Git\bin"),
"C:\ProgramData\chocolatey\bin"
)
foreach ($dir in $candidateDirs) {
if ($dir -and (Test-Path -LiteralPath (Join-Path $dir "git.exe"))) {
$env:Path = "$dir;$env:Path"
if (Get-Command git -ErrorAction SilentlyContinue) {
return
}
}
}
throw "Git executable not found. Please install Git or add git.exe to PATH."
}
Ensure-GitOnPath
# Get current timestamp # Get current timestamp
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
@@ -49,4 +78,3 @@ try {
Write-Host "Stack trace: $($_.ScriptStackTrace)" -ForegroundColor Red Write-Host "Stack trace: $($_.ScriptStackTrace)" -ForegroundColor Red
exit 1 exit 1
} }
+2 -3
View File
@@ -14,8 +14,8 @@ if (-not $isAdmin) {
} }
$taskName = "Git自动提交推送" $taskName = "Git自动提交推送"
$scriptPath = "C:\Users\12742\Desktop\douyin_guaji-main\auto_commit_push.ps1" $scriptPath = Join-Path $PSScriptRoot "auto_commit_push.ps1"
$workingDir = "C:\Users\12742\Desktop\douyin_guaji-main" $workingDir = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
Write-Host "========================================" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Setting up Git Auto Commit Task" -ForegroundColor Cyan Write-Host "Setting up Git Auto Commit Task" -ForegroundColor Cyan
@@ -100,4 +100,3 @@ try {
} }
pause pause
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
"""Compatibility launcher for the Web GUI launcher window."""
from __future__ import annotations
import os
import runpy
import sys
from pathlib import Path
ROOT_DIR = Path(__file__).resolve().parent
TARGET = ROOT_DIR / "gui" / "webgui_launcher.py"
VENV_PYTHON = ROOT_DIR / ".venv" / "Scripts" / "python.exe"
def _reexec_with_venv() -> None:
if not VENV_PYTHON.exists():
return
if Path(sys.executable).resolve() == VENV_PYTHON.resolve():
return
os.execv(str(VENV_PYTHON), [str(VENV_PYTHON), str(TARGET), *sys.argv[1:]])
def main() -> None:
_reexec_with_venv()
sys.argv = [str(TARGET), *sys.argv[1:]]
runpy.run_path(str(TARGET), run_name="__main__")
if __name__ == "__main__":
main()