diff --git a/Dockerfile b/Dockerfile index 07d93cb..0f30afc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.12-slim-bookworm -ARG WEB_VERSION=2.0.8 +ARG WEB_VERSION=2.0.9 ARG VCS_REF=unknown LABEL org.opencontainers.image.source="https://github.com/attilanet/myrzx_bot" \ org.opencontainers.image.title="myrzx_bot Web" \ diff --git a/README.md b/README.md index 374826b..0d9b01f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # 牧羊人之心Bot -Web **2.0.8**,源码发布入口为 `main`;原生 PySide6 桌面正式版本保留 **1.2.0**(`v1.2.0`)。两者的适配资料基线均为《牧羊人之心》Android **1.9.68**。 +Web **2.0.9**,源码发布入口为 `main`;原生 PySide6 桌面正式版本保留 **1.2.0**(`v1.2.0`)。两者的适配资料基线均为《牧羊人之心》Android **1.9.68**。 支持多账号独立运行、牧场培养、每日事务、主线与委托推进、近似战斗模拟、探险、扫荡及本地掉落分析,能力与验证限制见下文。 ## 运行指引 -### Web 2.0.8(源码发布入口 main) +### Web 2.0.9(源码发布入口 main) Windows 使用 Python 3.12+,在项目根目录执行: @@ -19,6 +19,8 @@ py -3 -m venv .venv-web Web 无需 Node/npm 或 PySide6,数据独立保存在 `local_state/ranch_web`。Linux Python 启动、离线演示与环境配置见 [Web 运行说明](ranch_web/README.md);单服务 Docker、`/data` 持久化、子路径反代与宿主机受控更新见 [Web 部署说明](deploy/web/README.md)。 +**2.0.9** 仅移除设置页重复的最近抽取、喂养等待、赠礼下次就绪和执行计划批量运行提示;保留账号简短状态、错误、表格、表单与原单一底部分类日志,后端、日志及策略逻辑不变。本补丁21项相关测试通过,历史结果不计入,见 [发布说明](analysis/RELEASE_2_0_9.md)。 + **2.0.8** 自动委托提供“当前委托 / 每日记录”,跨城市按合格候选的预计氪金 **20→15→10** 排序并说明回退原因;按角色、北京时间自然日持久记录接取、推进和领奖,保留最近90天、每角色最多5000条事件。静态预计奖励与领奖回包确认金额分开,缺失金额保持未确认;旧历史仅从本地任务 journal 可证实的部分回填。详见 [2.0.8 发布说明](analysis/RELEASE_2_0_8.md)。 沿用 **2.0.7** 的主培养修复:主培养固定为已养成的高等级魔物,更优资质只作备用;自动喂养、赠礼、潜能突破仅作用于主培养。已启用孵蛋规则按主培养1只、严格更优备用最多1只整理,详见 [2.0.7 发布说明](analysis/RELEASE_2_0_7.md)。 @@ -38,7 +40,7 @@ Web 无需 Node/npm 或 PySide6,数据独立保存在 `local_state/ranch_web` | 组件与版本 | 《牧羊人之心》Android 基线 | 入口与状态 | | --- | --- | --- | -| Web 2.0.8 | 1.9.68 | 源码发布入口 `main`,`Start_Ranch_Web.cmd` / `sh start-web.sh` | +| Web 2.0.9 | 1.9.68 | 源码发布入口 `main`,`Start_Ranch_Web.cmd` / `sh start-web.sh` | | 桌面 1.2.0(`v1.2.0`) | 1.9.68 | 当前桌面版本;`Start_Ranch_Helper.cmd` / `python -m ranch_assistant` | | 桌面 1.1.1(`v1.1.1`) | 1.9.68 | 历史正式版本,1.1 系列修复与界面更新 | | 桌面 1.1.0(`v1.1.0`) | 1.9.68 | 历史已发布版本 | diff --git a/analysis/RELEASE_2_0_9.md b/analysis/RELEASE_2_0_9.md new file mode 100644 index 0000000..f75bdf2 --- /dev/null +++ b/analysis/RELEASE_2_0_9.md @@ -0,0 +1,15 @@ +# Web 2.0.9 发布说明 + +Web **2.0.9** 基于 **2.0.8**;游戏资料 **1.9.68**,桌面正式版 **1.2.0**。 + +- 移除设置页重复的最近抽取、喂养等待、赠礼下次就绪和执行计划批量运行提示,详情沿用原单一底部分类日志。 +- 保留账号简短状态、错误、业务表格、配置表单与日志显隐、筛选和账号隔离;后端、日志及策略逻辑不变。 +- Web 元数据与当前部署示例更新为 2.0.9;[2.0.8 自动委托与每日历史](RELEASE_2_0_8.md)等既有功能沿用。 + +## 验证 + +本补丁21项相关测试全部通过:浏览器8项、任务日志10项、独立更新器包3项;无失败或跳过。浏览器冻结证据为 `test-artifacts/ui209/verification.json`,任务日志独立复核10/10通过(1.320秒)。Node 语法、差异检查和桌面视觉复核通过,历史版本结果不计入本补丁。 + +另验证6项私有助手操作门禁;更新包3份源文件逐字节一致、可复现构建及版本 / 帮助 / 离线计划通过,以上检查不计入21项测试。 + +更新包位于 `test-artifacts/releases/v2.0.9/updater.pyz`,同目录 `SHA256SUMS` 使用 LF 换行。标签 `v2.0.9`,镜像 `ghcr.io/attilanet/myrzx_bot-web:v2.0.9`;在线更新须等稳定 Release 与正式镜像均就绪,见 [部署说明](../deploy/web/README.md)。本轮未部署 X99 或执行真实游戏操作。 diff --git a/compose.yaml b/compose.yaml index b44f940..6cd62c4 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,11 +1,11 @@ name: ranch-web services: web: - image: ${RANCH_WEB_IMAGE:-ghcr.io/attilanet/myrzx_bot-web:v2.0.8} + image: ${RANCH_WEB_IMAGE:-ghcr.io/attilanet/myrzx_bot-web:v2.0.9} build: context: . args: - WEB_VERSION: ${RANCH_WEB_BUILD_VERSION:-2.0.8} + WEB_VERSION: ${RANCH_WEB_BUILD_VERSION:-2.0.9} user: "10001:10001" init: true restart: unless-stopped diff --git a/deploy/web/README.md b/deploy/web/README.md index 3920482..db53ebf 100644 --- a/deploy/web/README.md +++ b/deploy/web/README.md @@ -1,6 +1,8 @@ # Web 2 Linux Docker 部署与更新 -当前应用及更新示例为 `v2.0.8`。下文首次初始化章节保留 2.0.1 流程及历史版本示例。游戏资料基线为 `1.9.68`,桌面版保留 `1.2.0`。镜像流水线成功、Git tag 与 GitHub Release 是不同的发布步骤:在线更新必须等对应镜像及非草稿、非预发布的 Release 均发布后才能使用。私有仓库未获授权返回 404 属于访问失败,不代表没有版本;只有成功读取列表且没有稳定 2.x 时才显示“暂无正式版”。 +当前应用及更新示例为 `v2.0.9`。下文首次初始化章节保留 2.0.1 流程及历史版本示例。游戏资料基线为 `1.9.68`,桌面版保留 `1.2.0`。镜像流水线成功、Git tag 与 GitHub Release 是不同的发布步骤:在线更新必须等对应镜像及非草稿、非预发布的 Release 均发布后才能使用。私有仓库未获授权返回 404 属于访问失败,不代表没有版本;只有成功读取列表且没有稳定 2.x 时才显示“暂无正式版”。 + +2.0.9 仅整理设置页重复运行提示,21项相关测试通过;以下历史结果不计入本补丁,见 [本版发布说明](../../analysis/RELEASE_2_0_9.md)。 已在 2.0.1 完成私有仓库和 GHCR 认证的部署,稳定 Release 与正式镜像发布后,可直接通过“帮助 → 检查版本更新…”升级,无需先安装 2.0.2、重复初始化或替换宿主机更新器。尚未接入私有在线更新的宿主机才需参考下文“已有宿主机首次初始化”。 @@ -21,7 +23,7 @@ sudo install -m 0600 -o root -g root deploy/web/image.env.example .image.env sudoedit .env .image.env ``` -在 `.env` 填入独立的 `RANCH_WEB_PASSWORD`,这是 Web 管理密码,不是游戏密码;`.image.env` 的目标示例为 `RANCH_WEB_IMAGE=ghcr.io/attilanet/myrzx_bot-web:v2.0.8`,需确认对应镜像已发布后再 pull。Compose 默认只发布到宿主机 `127.0.0.1:8765`,容器内监听 `0.0.0.0:8765` 并强制管理密码。使用域名反代时,同时配置 `RANCH_WEB_ALLOWED_HOSTS` 与 `RANCH_WEB_ALLOWED_ORIGINS`;TLS 入口设置 `RANCH_WEB_SECURE_COOKIE=true`。代理保留正确的 Host,写请求依赖来源校验。 +在 `.env` 填入独立的 `RANCH_WEB_PASSWORD`,这是 Web 管理密码,不是游戏密码;`.image.env` 的目标示例为 `RANCH_WEB_IMAGE=ghcr.io/attilanet/myrzx_bot-web:v2.0.9`,需确认对应镜像已发布后再 pull。Compose 默认只发布到宿主机 `127.0.0.1:8765`,容器内监听 `0.0.0.0:8765` 并强制管理密码。使用域名反代时,同时配置 `RANCH_WEB_ALLOWED_HOSTS` 与 `RANCH_WEB_ALLOWED_ORIGINS`;TLS 入口设置 `RANCH_WEB_SECURE_COOKIE=true`。代理保留正确的 Host,写请求依赖来源校验。 `/opt/ranch-web/data` 挂到容器 `/data`,包括账号、加密会话与密钥、配置、委托历史、SQLite 统计和更新请求;独立于桌面数据。心跳控制目录独立只读挂到 `/run/ranch-updater`。使用 bind mount 的目录必须预先创建,Compose 不会悄悄创建 root 所有、容器无法写入的目录。默认容器用户 `10001:10001`,根文件系统只读,临时文件写到 `/tmp`。不要对现有账号目录重新初始化密钥。 @@ -53,7 +55,7 @@ Web 只读检查官方 GitHub Releases;默认只接受 `v2.MINOR.PATCH`,跳 ### 已完成 2.0.1 初始化的宿主机 -稳定 Release 与正式镜像发布后,用户打开“帮助 → 检查版本更新…”,检查到 2.0.8 后手动提交更新请求,可从 2.0.1 直接安装。现有私有仓库认证、GHCR 登录与宿主机更新器继续使用;Web 按钮仍要求有效心跳及 `accept_web_requests=true`。请求显示 `pending` 只表示已提交,宿主机完成备份、安装及健康检查后才确认成功;升级完成后刷新网页以加载新版界面,底部日志默认收起。Windows 或未启用执行器时仍仅可检查版本。自动安装默认关闭。 +稳定 Release 与正式镜像发布后,用户打开“帮助 → 检查版本更新…”,检查到 2.0.9 后手动提交更新请求,可从 2.0.1 直接安装。现有私有仓库认证、GHCR 登录与宿主机更新器继续使用;Web 按钮仍要求有效心跳及 `accept_web_requests=true`。请求显示 `pending` 只表示已提交,宿主机完成备份、安装及健康检查后才确认成功;升级完成后刷新网页以加载新版界面,底部日志默认收起。Windows 或未启用执行器时仍仅可检查版本。自动安装默认关闭。 ### 全新宿主机安装 @@ -108,7 +110,7 @@ python3 -B /opt/ranch-web/updater.pyz --version Docker 保存的宿主机登录配置供更新器拉镜像使用;不要复制开发机的 Git/registry 凭据,也不要把 Docker 凭据放进 GitHub Token 文件或 Web 容器。[GHCR 官方认证说明](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) -4. 使用新包先检查再由用户明确发起在线更新。以下 `--apply v2.0.1` 仅保留首次初始化的历史示例,不是本轮 2.0.8 升级命令: +4. 使用新包先检查再由用户明确发起在线更新。以下 `--apply v2.0.1` 仅保留首次初始化的历史示例,不是本轮 2.0.9 升级命令: ```sh sudo python3 -B /opt/ranch-web/updater.pyz --config /etc/ranch-web-updater.toml --check @@ -166,9 +168,9 @@ Windows 或未安装执行器的 Docker 部署仍能检查版本,但按钮会 2.0.8 共验证739项独立测试:736通过、3项 Windows 跳过;其中非浏览器662项(659通过、3跳过),浏览器77项全部验证通过,详见 [发布说明](../../analysis/RELEASE_2_0_8.md#验证)。2.0.7 结果保留在 [历史发布说明](../../analysis/RELEASE_2_0_7.md#验证)。以下命令可复现本地更新器构建与离线检查;历史 Windows 离线验证与 Linux 部署烟测见 [Web 运行说明](../../ranch_web/README.md#离线验证),不计入本版验收。可在无 Docker 的机器上构建临时更新器资产并打印计划;`--dry-run` 不联网、不读取凭据、不调用 Docker,也不写文件: ```sh -python -B tools/build_web_updater.py --output test-artifacts/releases/v2.0.8/updater.pyz -python -B test-artifacts/releases/v2.0.8/updater.pyz --version -python -B test-artifacts/releases/v2.0.8/updater.pyz --config deploy/web/updater.example.toml --apply v2.0.8 --dry-run +python -B tools/build_web_updater.py --output test-artifacts/releases/v2.0.9/updater.pyz +python -B test-artifacts/releases/v2.0.9/updater.pyz --version +python -B test-artifacts/releases/v2.0.9/updater.pyz --config deploy/web/updater.example.toml --apply v2.0.9 --dry-run python -B -m unittest ranch_web.tests.test_updates ranch_web.tests.test_web_updater ranch_web.tests.test_private_updates ranch_web.tests.test_web_updater_package -v ``` diff --git a/deploy/web/image.env.example b/deploy/web/image.env.example index 7b7f76e..074a013 100644 --- a/deploy/web/image.env.example +++ b/deploy/web/image.env.example @@ -1,2 +1,2 @@ -# Pull only after the v2.0.8 image publishing workflow succeeds and the image is available. -RANCH_WEB_IMAGE=ghcr.io/attilanet/myrzx_bot-web:v2.0.8 +# Pull only after the v2.0.9 image publishing workflow succeeds and the image is available. +RANCH_WEB_IMAGE=ghcr.io/attilanet/myrzx_bot-web:v2.0.9 diff --git a/ranch_web/PRODUCT.md b/ranch_web/PRODUCT.md index 99baeb9..4bf4682 100644 --- a/ranch_web/PRODUCT.md +++ b/ranch_web/PRODUCT.md @@ -1,8 +1,10 @@ -# 牧羊人之心牧场助手 · Web 2.0.8 +# 牧羊人之心牧场助手 · Web 2.0.9 ## 产品约束 -把现有桌面助手的功能和操作结构迁移至单管理员 Web 工作台。桌面版是页面顺序、信息密度、业务名称、保护条件与交互的依据,保留桌面兼容。Web `2.0.8`,源码发布入口 `main`,游戏数据版本 `1.9.68`;桌面正式版保留 `1.2.0`。启动与配置见 [运行说明](README.md),Docker 与更新条件见 [部署说明](../deploy/web/README.md),功能与验证状态见 [2.0.8 发布说明](../analysis/RELEASE_2_0_8.md)。 +把现有桌面助手的功能和操作结构迁移至单管理员 Web 工作台。桌面版是页面顺序、信息密度、业务名称、保护条件与交互的依据,保留桌面兼容。Web `2.0.9`,源码发布入口 `main`,游戏数据版本 `1.9.68`;桌面正式版保留 `1.2.0`。启动与配置见 [运行说明](README.md),Docker 与更新条件见 [部署说明](../deploy/web/README.md),既有功能与历史验证见 [2.0.8 发布说明](../analysis/RELEASE_2_0_8.md)。 + +2.0.9 仅整理设置页重复运行提示,保留账号简短状态、错误、表格、表单与原单一底部分类日志;后端、日志及策略逻辑不变,21项相关测试通过,历史结果不计入本补丁,见 [本版发布说明](../analysis/RELEASE_2_0_9.md)。 使用者在 Windows 本机配置、验证,随后可在 Linux Docker 常驻运行。多个浏览器访问同一个管理员工作台;账号互相隔离,各账号串行执行,账号之间可以并行。 diff --git a/ranch_web/README.md b/ranch_web/README.md index 88a63e6..9bd030c 100644 --- a/ranch_web/README.md +++ b/ranch_web/README.md @@ -1,6 +1,8 @@ -# Web 2.0.8 运行说明 +# Web 2.0.9 运行说明 -Web **2.0.8**,源码发布入口 `main`,游戏资料基线 **1.9.68**。桌面正式版保留 **1.2.0**,入口为 `python -m ranch_assistant`;Web 使用独立依赖与数据根。自动委托提供当前委托与每日记录,功能和验证状态见 [2.0.8 发布说明](../analysis/RELEASE_2_0_8.md)。 +Web **2.0.9**,源码发布入口 `main`,游戏资料基线 **1.9.68**。桌面正式版保留 **1.2.0**,入口为 `python -m ranch_assistant`;Web 使用独立依赖与数据根。自动委托提供当前委托与每日记录,功能和历史验证状态见 [2.0.8 发布说明](../analysis/RELEASE_2_0_8.md)。 + +2.0.9 仅整理设置页重复运行提示,21项相关测试通过,历史结果不计入本补丁,见 [本版发布说明](../analysis/RELEASE_2_0_9.md)。 Web 采用 FastAPI / Uvicorn 和原生 HTML/CSS/ES 模块,无 Node、npm 或前端编译步骤,不安装 PySide6。页面和策略能力沿用现有核心,详细业务范围与原有限制见 [桌面使用说明](../ranch_assistant/README.md)。多浏览器连接同一个管理员工作台;一个服务实例内,各账号独立线程并行,同一账号操作串行。 @@ -104,7 +106,7 @@ sh start-web.sh --no-browser Web 检查固定官方 GitHub Releases 的稳定 `v2.x.y`,跳过桌面 1.x、未来 3.x、草稿和预发布。开发版本 `2.0.0.dev1` 可升级至同数字的正式 `v2.0.0`;没有正式 Web 2 发布时明确显示暂无更新。Windows 默认仅检查;Web “更新”按钮仅在宿主机显式启用并有有效只读心跳时可提交 `pending` 请求,安装、备份和回滚由宿主机执行。默认定时检查只通知,自动安装需操作者 opt-in。 -已在 **2.0.1** 完成私有仓库和 GHCR 认证的部署,稳定 Release 和正式镜像就绪、宿主机心跳有效后,可直接通过“帮助 → 检查版本更新…”升级 **2.0.8**,无需先安装 2.0.2、重复初始化或替换宿主机更新器。升级完成后刷新网页以加载新版界面,底部日志默认收起。安装结果以宿主机健康检查为准;首次配置仅供尚未初始化的宿主机参考。 +已在 **2.0.1** 完成私有仓库和 GHCR 认证的部署,稳定 Release 和正式镜像就绪、宿主机心跳有效后,可直接通过“帮助 → 检查版本更新…”升级 **2.0.9**,无需先安装 2.0.2、重复初始化或替换宿主机更新器。升级完成后刷新网页以加载新版界面,底部日志默认收起。安装结果以宿主机健康检查为准;首次配置仅供尚未初始化的宿主机参考。 ## 离线验证 diff --git a/ranch_web/__init__.py b/ranch_web/__init__.py index 12e3857..4322e05 100644 --- a/ranch_web/__init__.py +++ b/ranch_web/__init__.py @@ -1,6 +1,6 @@ """Headless Web workspace for the ranch assistant.""" -__version__ = "2.0.8" +__version__ = "2.0.9" GAME_VERSION = "1.9.68" __all__ = ["__version__", "GAME_VERSION"] diff --git a/ranch_web/static/app.js b/ranch_web/static/app.js index b954e9b..13d66c2 100644 --- a/ranch_web/static/app.js +++ b/ranch_web/static/app.js @@ -415,7 +415,7 @@ async function exportYields(account=current()) { async function command(name,account=current()) { try { if(name==='add-account'||name==='add-demo')return await addAccount(name==='add-demo'); - if(name==='about')return dialog('关于牧场助手',el('div',{},el('p',{text:`牧羊人之心牧场助手 Web ${state.meta?.version || '2.0.8'}`}),el('p',{text:`游戏数据版本 ${state.meta?.gameVersion || '1.9.68'}`})),{info:true}); + if(name==='about')return dialog('关于牧场助手',el('div',{},el('p',{text:`牧羊人之心牧场助手 Web ${state.meta?.version || '2.0.9'}`}),el('p',{text:`游戏数据版本 ${state.meta?.gameVersion || '1.9.68'}`})),{info:true}); if(name==='updates')return await showUpdates(); if(name==='admin-logout'){hideWorkbench();try{await api.logout();}finally{requireAuth();}return;} if(!account)throw new Error('请先新增或选择账号。'); @@ -640,7 +640,7 @@ async function bootstrap() { $('#app').hidden=false; const [meta,schema]=await Promise.all([api.meta(),api.schema()]);state.meta=meta;state.schema=schema; if(state.redirecting)return; - $('#app-version').textContent=meta.version || '2.0.8';$('#game-version').textContent=meta.gameVersion || '1.9.68';$('#access-mode').textContent=auth.access_mode==='local'||auth.access_mode==='loopback'?'本机工作台':auth.required?'管理工作台':'本机工作台'; + $('#app-version').textContent=meta.version || '2.0.9';$('#game-version').textContent=meta.gameVersion || '1.9.68';$('#access-mode').textContent=auth.access_mode==='local'||auth.access_mode==='loopback'?'本机工作台':auth.required?'管理工作台':'本机工作台'; await syncAccounts();if(state.redirecting)return;state.ready=true;setStatus('工作台已连接'); }catch(failure){if(failure.status===401||$('#app').hidden){requireAuth();return;}if(state.redirecting)return;setStatus(failure.message);$('#page-host').replaceChildren(el('div',{class:'initial-state'},el('p',{text:failure.message}),el('button',{text:'重新连接',onClick:bootstrap})));} } diff --git a/ranch_web/static/index.html b/ranch_web/static/index.html index 6d33606..2d9d912 100644 --- a/ranch_web/static/index.html +++ b/ranch_web/static/index.html @@ -26,7 +26,7 @@ - 牧羊人之心牧场助手 2.0.8 + 牧羊人之心牧场助手 2.0.9
diff --git a/ranch_web/static/pages.js b/ranch_web/static/pages.js index bbb5793..74c7273 100644 --- a/ranch_web/static/pages.js +++ b/ranch_web/static/pages.js @@ -116,7 +116,6 @@ export class PageView { this.subtabs = el('div', {class: 'subtabs', role: 'tablist', 'aria-label': '子页面', hidden: true}); this.filterHost = el('div', {class: 'filter-bar'}); this.summary = el('p', {class: 'page-summary'}); - this.runtimeStatus=el('div',{class:'page-summary',hidden:true}); this.formHost = el('div', {class: 'policy-form'}); this.actionsHost = el('div', {class: 'page-toolbar'}); this.content = el('div', {class: 'page-content'}); @@ -124,7 +123,7 @@ export class PageView { dirty: path => account.edits.has(pathKey(path)), onError: this.error, onSelection: () => this.syncActions(), onContext: (event, selected, row) => this.openContext(event, selected, row), onDetail: row => this.showDetail(row)}; this.form = new PolicyForm(this.formHost, this.context); - this.surface = el('div', {class: 'page-surface'}, this.errorBox, this.subtabs, this.filterHost, this.summary, this.runtimeStatus, this.formHost, this.actionsHost, this.content); + this.surface = el('div', {class: 'page-surface'}, this.errorBox, this.subtabs, this.filterHost, this.summary, this.formHost, this.actionsHost, this.content); this.body = el('div', {class: 'page-body'}, this.surface, this.loading); this.root.append(this.header, this.body); if (key === 'login') this.login = new LoginPage(this.content, this); @@ -248,7 +247,7 @@ export class PageView { this.updateFilters(data.filters || []); this.summary.textContent = typeof data.summary === 'string' ? data.summary : textValue(data.summary || ''); this.summary.hidden = !data.summary; - this.updateRuntimeStatus(data.details || {}, data.battle_mode); + if (data.details?.statistics_error) this.showError(textValue(data.details.statistics_error)); let fields = data.form || this.options.schema(this.key); if (this.key === 'login') fields = fields.filter(field => !(field.path?.[0] === 'auto_relogin' && field.path[1] === 'enabled')); fields=fields.map(field=>field.path?.[0]==='policy'&&field.path[1]==='buy_ten'?{...field,disabled:!this.account.config?.policy?.allow_single_draw}:field); @@ -276,29 +275,6 @@ export class PageView { } else this.table.update(data.columns || [], data.rows || []); } - updateRuntimeStatus(details, battleMode) { - const lines=[]; - if(this.key==='hatching'){ - if(this.activeSubtab==='喂养策略' && Array.isArray(details.feed_status))lines.push(['feed_status','当前喂养状态:'+textValue(details.feed_status[1])]); - if(this.activeSubtab==='孵蛋策略' && details.last_draw!==undefined)lines.push(['last_draw','最近抽蛋:'+textValue(details.last_draw)]); - } - if(this.key==='gifts' && Object.hasOwn(details,'next_ready_at')){ - const ready=details.next_ready_at; - lines.push(['next_ready_at',ready===null?'下次赠礼:当前没有符合条件的目标或物品,等待状态更新':'下次可赠礼:'+chinaTime(ready,{date:true})+'(北京时间)']); - } - // Planner notes are current execution/wait reasons, unlike DTO help text. - const notes = Array.isArray(details.notes) ? [...new Set(details.notes.filter(note => typeof note === 'string' && note.trim()))] : []; - if(notes.length)lines.push(['planner_notes',notes.join('\n')]); - if(details.statistics_error)lines.push(['statistics_error',textValue(details.statistics_error)]); - if(battleMode?.label)lines.push(['battle_mode',battleMode.label]); - const signature=JSON.stringify(lines); - if(signature!==this.runtimeSignature){ - this.runtimeStatus.replaceChildren(...lines.map(([key,text])=>el('p',{'data-view-status':key,text}))); - this.runtimeSignature=signature; - } - this.runtimeStatus.hidden=!lines.length; - } - showDetail(row) { const data = this.data.details?.[row.id] || row.details; if (!data) return; diff --git a/ranch_web/tests/browser/test_page_loading_browser.py b/ranch_web/tests/browser/test_page_loading_browser.py index 98931d1..4a4fcf8 100644 --- a/ranch_web/tests/browser/test_page_loading_browser.py +++ b/ranch_web/tests/browser/test_page_loading_browser.py @@ -131,11 +131,12 @@ class PageLoadingBrowserTests(unittest.TestCase): expect(panel.locator("tbody tr")).to_have_count(32) self.page.screenshot(path=str(artifacts / "settled-dense.png")) - def test_passive_refresh_preserves_editing_table_and_business_reasons(self): + def test_passive_refresh_preserves_editing_table_without_inline_notes(self): self.open() panel = self.bag() expect(panel.locator("tbody tr")).to_have_count(32) - expect(panel.locator('[data-view-status="planner_notes"]')).to_have_text("金币不足,等待补货") + expect(panel.locator('[data-view-status="planner_notes"]')).to_have_count(0) + expect(panel).not_to_contain_text("金币不足,等待补货") self.assertNotIn("STATIC_HELP_SENTINEL", panel.inner_text()) self.assertNotIn("STATIC_NOTE_SENTINEL", panel.inner_text()) self.assertEqual(panel.locator(".info-note, .field-help").count(), 0) @@ -156,6 +157,7 @@ class PageLoadingBrowserTests(unittest.TestCase): expect(field).to_be_focused() expect(field).to_have_value("") self.assertTrue(field.evaluate("node => node === window.loadingField && window.loadingTable.isConnected && node.closest('.page-panel').querySelector('table') === window.loadingTable")) + expect(panel).not_to_contain_text("金币不足,等待补货") expect(self.page.locator("#log-panel")).to_be_hidden() self.assertEqual(self.page.locator("#log-panel").count(), 1) diff --git a/ranch_web/tests/browser/test_workbench_browser.py b/ranch_web/tests/browser/test_workbench_browser.py index 6213265..773e8a8 100644 --- a/ranch_web/tests/browser/test_workbench_browser.py +++ b/ranch_web/tests/browser/test_workbench_browser.py @@ -148,7 +148,7 @@ class WorkbenchBrowserTests(unittest.TestCase): expect(panel.locator('.form-section legend')).to_have_text('孵蛋策略') panel.locator('.subtab[data-key="喂养策略"]').click() expect(panel.locator('.form-section legend')).to_have_text('喂养策略') - expect(panel.locator('[data-view-status="feed_status"]')).to_be_visible() + expect(panel.locator('[data-view-status="feed_status"]')).to_have_count(0) if key=='mainline': expect(panel.locator('.subtab[data-key="policy"]')).to_be_visible() panel.locator('.subtab[data-key="policy"]').click() @@ -444,17 +444,20 @@ class WorkbenchBrowserTests(unittest.TestCase): expect(panel.locator('td[data-column="per_stamina"]')).to_have_attribute('title','0.001') self.assertEqual(self.errors,[]) - def test_runtime_statuses_and_preset_without_confirmation(self): + def test_settings_omit_runtime_statuses_and_preset_without_confirmation(self): def gifts_view(route): self.fulfill(route,{'data':{'page':'gifts','title':'自动赠礼','summary':'离线状态','form':[],'filters':[],'columns':[],'rows':[],'actions':[], 'details':{'next_ready_at':1794294489}},'loading':False}) self.page.route(f'**/api/accounts/{self.first}/views/gifts?*',gifts_view) self.open() panel=self.go('hatching') - expect(panel.locator('[data-view-status="last_draw"]')).to_contain_text('最近抽蛋:') + expect(panel.locator('.form-section legend')).to_have_text('孵蛋策略') + expect(panel.locator('[data-view-status="last_draw"]')).to_have_count(0) + expect(panel).not_to_contain_text('最近抽蛋:') panel.locator('.subtab[data-key="喂养策略"]').click() - data=self.manager.view(self.first,'hatching',{})['data'] - expect(panel.locator('[data-view-status="feed_status"]')).to_contain_text(data['details']['feed_status'][1]) + expect(panel.locator('.form-section legend')).to_have_text('喂养策略') + expect(panel.locator('[data-view-status="feed_status"]')).to_have_count(0) + expect(panel).not_to_contain_text('当前喂养状态:') panel.locator('button[data-operation="apply_preset"]').click() expect(self.page.locator('#action-dialog')).not_to_be_visible() self.page.wait_for_timeout(1400) @@ -462,9 +465,72 @@ class WorkbenchBrowserTests(unittest.TestCase): self.assertTrue(self.manager.get_config(self.first)['config']['policy']['egg_rules']['1001010']['enabled']) self.assertFalse(self.manager.status(self.first)['running']) panel=self.go('gifts') - expect(panel.locator('[data-view-status="next_ready_at"]')).to_contain_text('北京时间') + expect(panel.locator('[data-view-status="next_ready_at"]')).to_have_count(0) + expect(panel).not_to_contain_text('下次可赠礼:') + expect(panel.locator('button[data-operation="configure_bag"]')).to_be_visible() self.assertEqual(self.errors,[]) + def test_bulk_runtime_notes_stay_out_of_settings_and_statistics_errors_retry(self): + keys = ('hatching', 'mainline', 'gifts', 'commissions', 'exploration', 'maps', 'ranch', 'daily', 'plans') + statistics_error = '本地统计读取失败,请查看服务器日志' + + def diagnostics_view(route): + response = route.fetch().json() # Disposable loopback server and demo data only. + data = response.get('data') + if data is not None: + data.setdefault('details', {}).update({ + 'notes': [f'INLINE_RUNTIME_ONLY_{i}: retained primary / gift / potential / waiting' for i in range(40)], + 'last_draw': 'INLINE_DRAW_ONLY', 'feed_status': ['waiting', 'INLINE_FEED_ONLY'], + 'next_ready_at': 1794294489, + }) + data['battle_mode'] = {'label': 'INLINE_BATTLE_MODE_ONLY'} + if data['page'] == 'statistics': + data['details']['statistics_error'] = statistics_error + self.fulfill(route, response) + + self.page.route(f'**/api/accounts/{self.first}/views/*', diagnostics_view) + self.open() + for key in keys: + with self.subTest(page=key): + panel = self.go(key) + expect(panel.locator('[data-view-status]')).to_have_count(0) + self.assertNotIn('INLINE_', panel.evaluate('node => node.outerHTML')) + expect(panel.locator('.page-error')).to_be_hidden() + panel = self.go('hatching') + artifacts = Path(__file__).resolve().parents[3] / 'test-artifacts' / 'ui209' + artifacts.mkdir(parents=True, exist_ok=True) + for width, height in ((1280, 800), (390, 844)): + self.page.set_viewport_size({'width': width, 'height': height}) + for tab in ('孵蛋策略', '牧场策略', '喂养策略'): + panel.locator(f'.subtab[data-key="{tab}"]').click() + expect(panel.locator('.form-section legend')).to_have_text(tab) + self.assertNotIn('INLINE_', panel.evaluate('node => node.outerHTML')) + panel.locator('.subtab[data-key="孵蛋策略"]').click() + first_control = panel.locator('.form-section input').first + expect(first_control).to_be_visible() + self.assertTrue(first_control.evaluate('''node => { + const r = node.getBoundingClientRect(), panel = node.closest('.page-panel').getBoundingClientRect(); + return r.top >= panel.top && r.bottom <= Math.min(panel.bottom, innerHeight); + }'''), 'Settings must begin inside the visible workbench') + self.assertLessEqual(self.page.evaluate('document.documentElement.scrollWidth'), width) + self.page.screenshot(path=str(artifacts / f'hatching-{width}x{height}.png')) + expect(self.page.locator('#strategy-toggle')).to_be_visible() + expect(self.page.locator('#log-panel')).to_have_count(1) + expect(self.page.locator('#log-panel')).to_be_hidden() + self.page.locator('#log-toggle').click() + expect(self.page.locator('#log-panel')).to_be_visible() + self.page.locator('#log-toggle').click() + expect(self.page.locator('#log-panel')).to_be_hidden() + panel = self.go('statistics') + expect(panel.get_by_role('alert')).to_contain_text('本地统计读取失败,请查看服务器日志') + expect(panel.locator('.page-loading')).to_be_hidden() + statistics_error = '' + with self.page.expect_response(lambda response: '/views/statistics?' in response.url): + panel.get_by_role('button', name='重新读取', exact=True).click() + expect(panel.get_by_role('alert')).to_be_hidden() + expect(panel.locator('.statistics-table-host table')).to_be_visible() + self.assertEqual(self.errors, []) + def test_update_dialog_polls_host_progress_recovers_and_stops_on_close(self): calls=[] applied=False