新增 runner/tui.mjs(~470 行):前台运行时自动开一块实时面板, 框线布局显示状态 / 课程 / 学时 / 课时 / 视频进度条 / 进度 / 最近日志。 - 学习统计 runner/study.mjs:只累计视频真在播的时长(暂停、重试退避、 页面加载都不计),学分按课程去重(重试 / 刷新不重复计) - 页面侧新增 credit 快照:平台只把本门学分写在倒计时文案里, 学完文案就消失,所以边播边记 - log.mjs 增加 setConsoleSink:面板接管终端那一路,日志文件仍是纯文本 - 面板里按 q 等价 Ctrl+C,走 stop.request 同一条优雅收尾路径 - 尺寸自适应:宽度跟随终端(不封顶 120 列),无 resize 事件的平台 靠定时刷新发现尺寸变化;变窄时按旧帧在新宽度下的折行数回退光标, 折完超过窗口高就整屏重置;宽度 / 高度不足按重要性丢字段 - 非 TTY(重定向 / 管道 / 计划任务 / --check)自动降级为逐行日志, 不写 ANSI 控制字符;--no-tui / YUN_XUE_TANG_TUI=0 可手动关闭, --no-color / NO_COLOR 关颜色 - 监控轮询从 2000ms 调到 1000ms,与面板刷新对齐 - supervisor 收尾时先收面板再逐行打退出日志,并汇总本次学习时长 / 学分 - check.mjs 增加裸 CR 检查:脚本里的 config\runner 曾被写成裸 CR, 变成 config<CR>unner 导致找不到配置文件 自测:npm run test:tui(渲染 / 列宽 / 极端尺寸)、npm run test:study(假时钟口径)
61 lines
1.7 KiB
Batchfile
61 lines
1.7 KiB
Batchfile
@echo off
|
|
rem ---------------------------------------------------------------
|
|
rem This file must stay PURE ASCII.
|
|
rem cmd.exe reads batch files byte-by-byte with the current code page;
|
|
rem multi-byte characters (e.g. Chinese) corrupt line offsets and make
|
|
rem it report nonsense like "'npm' is not recognized".
|
|
rem All Chinese messages come from the Node runner output instead.
|
|
rem
|
|
rem Usage:
|
|
rem scripts\start-headless.cmd use config\runner.config.mjs
|
|
rem scripts\start-headless.cmd --help print all options
|
|
rem scripts\start-headless.cmd --max 3 command line overrides config file
|
|
rem ---------------------------------------------------------------
|
|
setlocal
|
|
chcp 65001 >nul
|
|
cd /d "%~dp0.."
|
|
title YunXueTang Assistant - headless runner
|
|
|
|
where node >nul 2>nul
|
|
if errorlevel 1 goto no_node
|
|
|
|
if exist "yun-xue-tang-assistant.user.js" goto have_build
|
|
echo [build] build output not found, running npm run build ...
|
|
call npm run build
|
|
if errorlevel 1 goto build_fail
|
|
|
|
:have_build
|
|
if not exist "config\runner.config.mjs" goto no_config
|
|
echo [config] config\runner.config.mjs found, editing it is enough (no rebuild needed)
|
|
goto run
|
|
|
|
:no_config
|
|
echo [warn] config\runner.config.mjs not found, built-in defaults will be used
|
|
|
|
:run
|
|
echo [run] headless runner starting, press Ctrl+C to stop
|
|
echo.
|
|
node "runner/headless.mjs" %*
|
|
set RC=%ERRORLEVEL%
|
|
|
|
if "%RC%"=="0" goto done
|
|
echo.
|
|
echo [exit] code %RC%
|
|
echo 0 finished 1 no progress 2 env/args error 3 login failed
|
|
echo full log: run-logs\headless.log
|
|
pause
|
|
exit /b %RC%
|
|
|
|
:done
|
|
exit /b 0
|
|
|
|
:no_node
|
|
echo [error] node.exe not found. Install Node.js 22+ from https://nodejs.org/
|
|
pause
|
|
exit /b 1
|
|
|
|
:build_fail
|
|
echo [error] build failed. Run npm install first.
|
|
pause
|
|
exit /b 1
|