refactor: 前端JS拆分为8个模块(base/list/monitor/editor/tasks/tools/apps/admin,按依赖顺序加载)+ 删除废弃文件(start_web.bat/main.py/fix_web.bat/cleanup.py,web已全覆盖)+ 文档同步 + 修复/api/summary缺导入

This commit is contained in:
2026-08-11 14:53:04 +08:00
parent 2e491b19e2
commit 060157ea1a
19 changed files with 2584 additions and 2767 deletions
-48
View File
@@ -1,48 +0,0 @@
"""清理 STF 上残留的设备占用(强杀进程导致没正常释放时用)。
运行:python scripts/cleanup.py
"""
import os
import sys
# 让脚本既能直接运行(python scripts/cleanup.py)又能作为模块运行。
# scripts/ 的上一级是项目根目录(core 包的父目录),需加入 sys.path。
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if _PROJECT_ROOT not in sys.path:
sys.path.insert(0, _PROJECT_ROOT)
import requests
from config import STF_URL, STF_TOKEN
headers = {"Authorization": f"Bearer {STF_TOKEN}"}
# /user/devices 返回当前用户正在占用的设备
resp = requests.get(f"{STF_URL}/api/v1/user/devices", headers=headers)
resp.raise_for_status()
data = resp.json()
mine = data.get("devices", [])
print(f"当前账户占用的设备数: {len(mine)}")
for d in mine:
print(f" - {d.get('serial')} using={d.get('using')}")
# 全部释放
for d in mine:
serial = d["serial"]
try:
requests.post(
f"{STF_URL}/api/v1/user/devices/{serial}/remoteDisconnect",
headers=headers,
)
except Exception:
pass
r = requests.delete(f"{STF_URL}/api/v1/user/devices/{serial}", headers=headers)
print(f"释放 {serial}: HTTP {r.status_code}")
# 再看一次总设备池
resp = requests.get(f"{STF_URL}/api/v1/devices", headers=headers)
resp.raise_for_status()
free = [d for d in resp.json().get("devices", [])
if d.get("present") and d.get("ready") and not d.get("using") and d.get("owner") is None]
print(f"\n清理后空闲设备数: {len(free)}")
for d in free:
print(f" - {d.get('serial')}")
-57
View File
@@ -1,57 +0,0 @@
@echo off
title Fix Web Access
:: Auto elevate to admin
net session >nul 2>&1
if %errorLevel% neq 0 (
echo Requesting admin privileges...
powershell -Command "Start-Process cmd -ArgumentList '/c ""%~f0""' -Verb RunAs"
exit /b
)
echo ============================================
echo Fix Web Backend Access
echo ============================================
echo.
:: 1. Disable residual system proxy (blocks localhost)
echo [1/4] Disabling system proxy...
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f >nul 2>&1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f >nul 2>&1
echo Done.
echo.
:: 2. Add firewall rules for Python
echo [2/4] Adding firewall rules for Python...
for /f "delims=" %%i in ('where python') do set PYTHON_PATH=%%i
if not defined PYTHON_PATH (
echo ERROR: Python not found in PATH
pause
exit /b 1
)
echo Python path: %PYTHON_PATH%
netsh advfirewall firewall delete rule name="PythonWeb" >nul 2>&1
netsh advfirewall firewall add rule name="PythonWeb" dir=in action=allow program="%PYTHON_PATH%" enable=yes profile=any >nul
netsh advfirewall firewall delete rule name="PythonWebOut" >nul 2>&1
netsh advfirewall firewall add rule name="PythonWebOut" dir=out action=allow program="%PYTHON_PATH%" enable=yes profile=any >nul
echo Done.
echo.
:: 3. Flush DNS cache
echo [3/4] Flushing DNS cache...
ipconfig /flushdns >nul 2>&1
echo Done.
echo.
:: 4. Show excluded port ranges for reference
echo [4/4] TCP excluded port ranges (for reference):
netsh interface ipv4 show excludedportrange protocol=tcp
echo.
echo ============================================
echo Fix complete! Now:
echo 1. Close ALL browser windows and reopen
echo 2. Run: python web_server.py
echo 3. Open: http://127.0.0.1:18050/
echo ============================================
pause
+1 -1
View File
@@ -15,7 +15,7 @@ SKIP_EXTS = {".pyc", ".pyo"}
# 路径片段包含这些的跳过
SKIP_PARTS = {"__pycache__"}
# 文件名完全匹配这些的跳过
SKIP_FILES = {"fix_web.bat"}
SKIP_FILES = {}
# 文件名后缀匹配这些的跳过
SKIP_SUFFIX = (".migrated",)
# 特定目录下特定后缀跳过