diff --git a/.github/workflows/web-image.yml b/.github/workflows/web-image.yml index f7a9f54..6dee4ac 100644 --- a/.github/workflows/web-image.yml +++ b/.github/workflows/web-image.yml @@ -23,6 +23,7 @@ concurrency: jobs: image: + if: github.event.deleted != true runs-on: ubuntu-latest timeout-minutes: 25 permissions: diff --git a/Dockerfile b/Dockerfile index 665ce9f..048747f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.12-slim-bookworm -ARG WEB_VERSION=2.0.4 +ARG WEB_VERSION=2.0.5 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 cf6881b..68b76eb 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # 牧羊人之心Bot -本轮 Web 发布目标 **2.0.4**,源码入口为 `main`;原生 PySide6 桌面正式版本保留 **1.2.0**(`v1.2.0`)。两者的适配资料基线均为《牧羊人之心》Android **1.9.68**。 +本轮 Web 发布目标 **2.0.5**,源码入口为 `main`;原生 PySide6 桌面正式版本保留 **1.2.0**(`v1.2.0`)。两者的适配资料基线均为《牧羊人之心》Android **1.9.68**。 支持多账号独立运行、牧场培养、每日事务、主线与委托推进、近似战斗模拟、探险、扫荡及本地掉落分析,能力与验证限制见下文。 ## 运行指引 -### Web 2.0.4(main) +### Web 2.0.5(main) Windows 使用 Python 3.12+,在项目根目录执行: @@ -19,7 +19,7 @@ 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.4** 修复“网络超时恢复后已登录但策略停止”的问题,持久保存策略启停意图并恢复后台自动登录,保留 2.0.3 的原底部分类日志。已接入私有在线更新的部署可通过“帮助 → 检查版本更新…”安装,镜像和稳定 Release 均发布后可用;无需手动部署。详见 [发布说明](analysis/RELEASE_2_0_4.md)。 +**2.0.5** 精简页面说明文字,加载反馈改为内容区居中的圆形转圈,保留必要的错误、执行状态与业务数据。沿用持续自动登录与策略恢复。通过“帮助 → 检查版本更新…”安装,详见 [发布说明](analysis/RELEASE_2_0_5.md)。 ### 桌面 1.2.0 @@ -36,7 +36,7 @@ Web 无需 Node/npm 或 PySide6,数据独立保存在 `local_state/ranch_web` | 组件与版本 | 《牧羊人之心》Android 基线 | 入口与状态 | | --- | --- | --- | -| Web 2.0.4 | 1.9.68 | 本轮发布目标;源码入口 `main`,`Start_Ranch_Web.cmd` / `sh start-web.sh` | +| Web 2.0.5 | 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 | 历史已发布版本 | @@ -44,9 +44,9 @@ Web 无需 Node/npm 或 PySide6,数据独立保存在 `local_state/ranch_web` 本表记录适配资料基线,不代表其他客户端版本兼容或全部功能已完成实机验收。Docker 镜像以标签流水线成功结果为准,在线更新依赖对应 GitHub Release 条目;详见 [部署说明](deploy/web/README.md)。 -## Web 2.0.4 主要功能与分类日志 +## Web 2.0.5 主要功能与分类日志 -2.0.4 将 2.0.2 的日志界面改为所有功能页共用原有底部日志区,切换页签只显示当前账号、当前功能的日志;取消总日志/全部模式及页内日志框。操作说明见 [2.0.4 发布说明](analysis/RELEASE_2_0_4.md)。其余功能沿用现有实现。 +2.0.5 将 2.0.2 的日志界面改为所有功能页共用原有底部日志区,切换页签只显示当前账号、当前功能的日志;取消总日志/全部模式及页内日志框。操作说明见 [2.0.5 发布说明](analysis/RELEASE_2_0_5.md)。其余功能沿用现有实现。 - **原布局与15页**:沿用桌面页面顺序、账号页签、顶部玩家数值与统一启停、可调整日志区。 - **多账号与独立后台**:各账号隔离并行、同账号请求串行;关闭网页或退出管理登录后,服务端继续监控及已开启的策略。 @@ -60,7 +60,7 @@ Web 无需 Node/npm 或 PySide6,数据独立保存在 `local_state/ranch_web` 连接状态区分在线、临时故障重试、游戏会话失效与未连接,显示最后成功通信及下次重试时间,旧快照标注为缓存。临时故障先停止策略,再退避执行只读探测;会话失效时停止游戏轮询,按自动重登设置等待,或手动恢复、重新登录。手动选服、恢复会话及自动重登成功后,均自动执行已勾选功能,可在顶部停止。获取区服候选或登录失败不视为成功;未确认的写操作不自动重发,页面轮询不会清除游戏连接错误。 -战斗模拟仍为近似模型,特殊关卡并非全部支持。本版验证结果统一见 [发布说明](analysis/RELEASE_2_0_4.md#验证),历史记录见 [Web 验证说明](ranch_web/README.md#离线验证);离线验证不代表真实游戏 API 或生产升级/回滚验收。 +战斗模拟仍为近似模型,特殊关卡并非全部支持。本版验证结果统一见 [发布说明](analysis/RELEASE_2_0_5.md#验证),历史记录见 [Web 验证说明](ranch_web/README.md#离线验证);离线验证不代表真实游戏 API 或生产升级/回滚验收。 ## 桌面 1.2.0 功能基线 diff --git a/analysis/RELEASE_2_0_5.md b/analysis/RELEASE_2_0_5.md new file mode 100644 index 0000000..6b72294 --- /dev/null +++ b/analysis/RELEASE_2_0_5.md @@ -0,0 +1,25 @@ +# Web 2.0.5 发布说明 + +Web **2.0.5** 精简控制台文字,统一页面加载反馈。游戏资料基线 **1.9.68**,桌面版仍为 **1.2.0**。 + +## 界面调整 + +- 删除字段下方帮助、页面操作说明、重复提示等非业务小字。 +- 首次打开与刷新页面使用内容区居中的圆形加载指示,去掉角落的“正在读取”“后台更新中”“已载入”等文字。 +- 保留表单标签、业务数量、资源费用、执行状态、错误原因、重登倒计时和必要操作确认。 +- 沿用 2.0.4 的持续自动登录、策略运行意图和异常恢复;日志仍只使用原底部区域,按账号和页签过滤,默认收起。 + +## 升级与版本整理 + +正式版本 `v2.0.5`,镜像 `ghcr.io/attilanet/myrzx_bot-web:v2.0.5`。已接入更新通道的部署从“帮助 → 检查版本更新…”手动安装,更新完成后刷新浏览器。 + +本次发布成功并合入 main 后,按项目维护要求清理旧 GitHub Release、旧 Tag 和已合并开发分支;本地保留清理前备份。Git 提交历史、账号数据及现有服务器镜像不在清理范围内。 + +## 验证 + +- 浏览器 **68 个不同用例通过**:原有及界面精简回归 65 项,加独立加载专项 3 项;重复复验不重复计数。 +- 后端视图、API、管理登录、配置、子路径与更新包专项 **92 项通过**。 +- 加载专项覆盖居中圆形动画、完成与失败后收起、离线及账号切换清理、被动刷新不打断输入焦点和表格节点。 +- 已检查加载中与加载完成页面截图,并通过差异检查。 + +测试使用临时数据与本机浏览器,不执行真实游戏操作,也不手动部署 X99。 diff --git a/compose.yaml b/compose.yaml index e7c17ef..c01d21f 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.4} + image: ${RANCH_WEB_IMAGE:-ghcr.io/attilanet/myrzx_bot-web:v2.0.5} build: context: . args: - WEB_VERSION: ${RANCH_WEB_BUILD_VERSION:-2.0.4} + WEB_VERSION: ${RANCH_WEB_BUILD_VERSION:-2.0.5} user: "10001:10001" init: true restart: unless-stopped diff --git a/deploy/web/README.md b/deploy/web/README.md index 10a9558..0ebb40d 100644 --- a/deploy/web/README.md +++ b/deploy/web/README.md @@ -1,8 +1,8 @@ # Web 2 Linux Docker 部署与更新 -当前更新示例以 `v2.0.4` 为目标;下文 2.0.1 首次初始化步骤保留历史版本。游戏资料基线为 `1.9.68`,桌面版保留 `1.2.0`。镜像流水线成功、Git tag 与 GitHub Release 是不同的发布步骤:在线更新必须等对应镜像及非草稿、非预发布的 Release 均发布后才能使用。私有仓库未获授权返回 404 属于访问失败,不代表没有版本;只有成功读取列表且没有稳定 2.x 时才显示“暂无正式版”。 +当前更新示例以 `v2.0.5` 为目标;下文 2.0.1 首次初始化步骤保留历史版本。游戏资料基线为 `1.9.68`,桌面版保留 `1.2.0`。镜像流水线成功、Git tag 与 GitHub Release 是不同的发布步骤:在线更新必须等对应镜像及非草稿、非预发布的 Release 均发布后才能使用。私有仓库未获授权返回 404 属于访问失败,不代表没有版本;只有成功读取列表且没有稳定 2.x 时才显示“暂无正式版”。 -已在 2.0.1 完成私有仓库和 GHCR 认证的部署,可在 2.0.4 稳定 Release 与正式镜像就绪后直接通过“帮助 → 检查版本更新…”升级,无需先安装 2.0.2、重复初始化或替换宿主机更新器。尚未接入私有在线更新的宿主机才需参考下文“已有宿主机首次初始化”。 +已在 2.0.1 完成私有仓库和 GHCR 认证的部署,可在 2.0.5 稳定 Release 与正式镜像就绪后直接通过“帮助 → 检查版本更新…”升级,无需先安装 2.0.2、重复初始化或替换宿主机更新器。尚未接入私有在线更新的宿主机才需参考下文“已有宿主机首次初始化”。 ## 容器与持久化 @@ -19,7 +19,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.4`,需确认对应镜像已发布后再 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.5`,需确认对应镜像已发布后再 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`。不要对现有账号目录重新初始化密钥。 @@ -51,7 +51,7 @@ Web 只读检查官方 GitHub Releases;默认只接受 `v2.MINOR.PATCH`,跳 ### 已完成 2.0.1 初始化的宿主机 -`v2.0.4` 稳定 Release 与正式镜像发布后,用户打开“帮助 → 检查版本更新…”,检查到 2.0.4 后手动提交更新请求,可从 2.0.1 直接安装。现有私有仓库认证、GHCR 登录与宿主机更新器继续使用;Web 按钮仍要求有效心跳及 `accept_web_requests=true`。请求显示 `pending` 只表示已提交,宿主机完成备份、安装及健康检查后才确认成功;升级完成后刷新网页以加载新版界面,底部日志默认收起。Windows 或未启用执行器时仍仅可检查版本。自动安装默认关闭。 +`v2.0.5` 稳定 Release 与正式镜像发布后,用户打开“帮助 → 检查版本更新…”,检查到 2.0.5 后手动提交更新请求,可从 2.0.1 直接安装。现有私有仓库认证、GHCR 登录与宿主机更新器继续使用;Web 按钮仍要求有效心跳及 `accept_web_requests=true`。请求显示 `pending` 只表示已提交,宿主机完成备份、安装及健康检查后才确认成功;升级完成后刷新网页以加载新版界面,底部日志默认收起。Windows 或未启用执行器时仍仅可检查版本。自动安装默认关闭。 ### 全新宿主机准备 @@ -68,20 +68,20 @@ python3 -B /opt/ranch-web/updater.pyz --version ### 已有宿主机首次初始化(用户自行执行) -以下保留 2.0.1 引入私有在线更新时的初始化步骤与 Release 链接,仅供尚未初始化的宿主机参考;已完成私有仓库和 GHCR 认证的部署无需重做。步骤中的 `v2.0.1` 是首次初始化的历史目标,当前应用更新目标为 `v2.0.4`。 +以下保留 2.0.1 引入私有在线更新时的初始化步骤与 Release 链接,仅供尚未初始化的宿主机参考;已完成私有仓库和 GHCR 认证的部署无需重做。步骤中的 `v2.0.1` 是首次初始化的历史目标,当前应用更新目标为 `v2.0.5`。 前提是原有 `/opt/ranch-web` Compose 部署、数据目录及 `/etc/ranch-web-updater.toml` 均已存在,配置仍由 root 持有。保留原有数据和配置,不重新初始化密钥;数据目录由 `10001:10001` 持有。以下仅初始化在线更新器,不需要复制项目源码或 Compose。 -1. 用户登录有私有仓库读取权限的 GitHub 账号,从 [v2.0.1 Release](https://github.com/attilanet/myrzx_bot/releases/tag/v2.0.1) 下载 `updater.pyz` 和 `SHA256SUMS`,放到宿主机临时目录。确认 Release 已发布且镜像可读取,在下载目录执行 `sha256sum -c SHA256SUMS` 后安装: +1. 用户登录有私有仓库读取权限的 GitHub 账号,从 [当前正式 Release](https://github.com/attilanet/myrzx_bot/releases/tag/v2.0.5) 下载 `updater.pyz` 和 `SHA256SUMS`,放到宿主机临时目录。确认 Release 已发布且镜像可读取,在下载目录执行 `sha256sum -c SHA256SUMS` 后安装: ```sh sudo install -m 0644 -o root -g root updater.pyz /opt/ranch-web/updater.pyz python3 -B /opt/ranch-web/updater.pyz --help python3 -B /opt/ranch-web/updater.pyz --version - python3 -B /opt/ranch-web/updater.pyz --config /etc/ranch-web-updater.toml --apply v2.0.1 --dry-run + python3 -B /opt/ranch-web/updater.pyz --config /etc/ranch-web-updater.toml --apply v2.0.5 --dry-run ``` - `--version` 应显示 `ranch-web-updater 2.0.1`;`--help`、`--version` 和 `--dry-run` 均不联网、不读取 Token、不调用 Docker,dry-run 不创建文件。Python 需为 3.12+。 + `--version` 应显示 `ranch-web-updater 2.0.5`;`--help`、`--version` 和 `--dry-run` 均不联网、不读取 Token、不调用 Docker,dry-run 不创建文件。Python 需为 3.12+。 2. 用户创建只授予本仓库 Contents **read** 的 fine-grained GitHub Token,用交互终端输入;值不出现在 argv、shell 历史或更新状态中: @@ -161,12 +161,12 @@ Windows 或未安装执行器的 Docker 部署仍能检查版本,但按钮会 [web-image.yml](../../.github/workflows/web-image.yml) 仅对官方仓库的严格稳定 `v2.x.y` tag 推送 `ghcr.io/attilanet/myrzx_bot-web:v2.x.y`;校验 `ranch_web.__version__` 必须与 tag 一致,不能只改变镜像 label。PR 与手动运行只测试、构建,不推送。开发分支 push 不触发正式镜像发布,也没有 `latest` 滚动升级通道。CI 执行更新器、私有凭据和独立包回归,并在无外网容器中检查 healthcheck、非 root 数据写权限、无 Qt 和正常停止;镜像发布状态以对应 tag 的工作流结果为准。 -2.0.4 验证结果统一见 [发布说明](../../analysis/RELEASE_2_0_4.md#验证)。以下命令用于更新器离线验证;历史 Windows 离线验证与 Linux 部署烟测见 [Web 运行说明](../../ranch_web/README.md#离线验证),不计入本版验收。可在无 Docker 的机器上构建临时更新器资产并打印计划;`--dry-run` 不联网、不读取凭据、不调用 Docker,也不写文件: +2.0.5 验证结果统一见 [发布说明](../../analysis/RELEASE_2_0_5.md#验证)。以下命令用于更新器离线验证;历史 Windows 离线验证与 Linux 部署烟测见 [Web 运行说明](../../ranch_web/README.md#离线验证),不计入本版验收。可在无 Docker 的机器上构建临时更新器资产并打印计划;`--dry-run` 不联网、不读取凭据、不调用 Docker,也不写文件: ```sh python -B tools/build_web_updater.py --output test-artifacts/updater.pyz python -B test-artifacts/updater.pyz --version -python -B test-artifacts/updater.pyz --config deploy/web/updater.example.toml --apply v2.0.4 --dry-run +python -B test-artifacts/updater.pyz --config deploy/web/updater.example.toml --apply v2.0.5 --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 35f604b..0f83583 100644 --- a/deploy/web/image.env.example +++ b/deploy/web/image.env.example @@ -1,2 +1,2 @@ -# Pull only after the v2.0.4 image publishing workflow succeeds and the image is available. -RANCH_WEB_IMAGE=ghcr.io/attilanet/myrzx_bot-web:v2.0.4 +# Pull only after the v2.0.5 image publishing workflow succeeds and the image is available. +RANCH_WEB_IMAGE=ghcr.io/attilanet/myrzx_bot-web:v2.0.5 diff --git a/ranch_web/PRODUCT.md b/ranch_web/PRODUCT.md index f393213..9937c21 100644 --- a/ranch_web/PRODUCT.md +++ b/ranch_web/PRODUCT.md @@ -1,8 +1,8 @@ -# 牧羊人之心牧场助手 · Web 2.0.4 +# 牧羊人之心牧场助手 · Web 2.0.5 ## 产品约束 -把现有桌面助手的功能和操作结构迁移至单管理员 Web 工作台。桌面版是页面顺序、信息密度、业务名称、保护条件与交互的依据,保留桌面兼容。本轮 Web 发布目标为 `2.0.4`,源码入口 `main`,游戏数据版本 `1.9.68`;桌面正式版保留 `1.2.0`。启动与配置见 [运行说明](README.md),Docker 与更新条件见 [部署说明](../deploy/web/README.md)。 +把现有桌面助手的功能和操作结构迁移至单管理员 Web 工作台。桌面版是页面顺序、信息密度、业务名称、保护条件与交互的依据,保留桌面兼容。本轮 Web 发布目标为 `2.0.5`,源码入口 `main`,游戏数据版本 `1.9.68`;桌面正式版保留 `1.2.0`。启动与配置见 [运行说明](README.md),Docker 与更新条件见 [部署说明](../deploy/web/README.md)。 使用者在 Windows 本机配置、验证,随后可在 Linux Docker 常驻运行。多个浏览器访问同一个管理员工作台;账号互相隔离,各账号串行执行,账号之间可以并行。 @@ -24,9 +24,13 @@ - 数据分析用真实 DTO 绘制 SVG 条形图,保留来源筛选、体力效率、样本和不确定性说明。没有样本时明确说明。 - 策略统一导入导出;收益 CSV/XLSX 导入与可用数据下载。错误展示具体原因,不把不支持的任务伪装成可执行任务。 - 帮助可检查 GitHub 正式版本并提交受控更新请求。未配置部署器时明确显示原因,更新提交不表示更新成功。 -- 已在 2.0.1 完成私有仓库和 GHCR 认证的部署,可在 2.0.4 发布就绪后直接通过“帮助 → 检查版本更新…”升级,无需先安装 2.0.2、重复初始化或替换宿主机更新器;升级完成后刷新网页以加载新版界面,安装结果以宿主机健康检查为准。 +- 已在 2.0.1 完成私有仓库和 GHCR 认证的部署,可在 2.0.5 发布就绪后直接通过“帮助 → 检查版本更新…”升级,无需先安装 2.0.2、重复初始化或替换宿主机更新器;升级完成后刷新网页以加载新版界面,安装结果以宿主机健康检查为准。 -## 2.0.4 持续运行与自动恢复 +## 2.0.5 界面精简 + +删除字段帮助、页面操作说明等重复小字。页面首次读取与刷新使用内容区居中的圆形加载指示,不再在角落显示“正在读取”“已载入”。保留业务数量、资源费用、运行与错误状态,以及必要确认。 + +## 持续运行与自动恢复(2.0.4 起) 账号登录后默认执行已勾选策略,只有用户点击“停止”才暂停;点击“开启”恢复。启停选择由服务端持久保存,掉线、重新登录、关闭网页或服务重启不会误改。停止策略不停止连接监控与自动重登。 diff --git a/ranch_web/README.md b/ranch_web/README.md index a4e3b46..4bee848 100644 --- a/ranch_web/README.md +++ b/ranch_web/README.md @@ -1,6 +1,6 @@ -# Web 2.0.4 运行说明 +# Web 2.0.5 运行说明 -本轮 Web 发布目标 **2.0.4**,源码入口 `main`,游戏资料基线 **1.9.68**。桌面正式版保留 **1.2.0**,入口为 `python -m ranch_assistant`;Web 使用独立依赖与数据根。 +本轮 Web 发布目标 **2.0.5**,源码入口 `main`,游戏资料基线 **1.9.68**。桌面正式版保留 **1.2.0**,入口为 `python -m ranch_assistant`;Web 使用独立依赖与数据根。 Web 采用 FastAPI / Uvicorn 和原生 HTML/CSS/ES 模块,无 Node、npm 或前端编译步骤,不安装 PySide6。页面和策略能力沿用现有核心,详细业务范围与原有限制见 [桌面使用说明](../ranch_assistant/README.md)。多浏览器连接同一个管理员工作台;一个服务实例内,各账号独立线程并行,同一账号操作串行。 @@ -10,8 +10,8 @@ Web 采用 FastAPI / Uvicorn 和原生 HTML/CSS/ES 模块,无 Node、npm 或 - [x] 保留账号页签、顶部数值与统一启停、可调日志;规则自动保存,配置与统计按账号/角色隔离,每次成功登录后自动执行已配置且已勾选的功能,可在顶部停止。 - [x] Windows Python 启动与离线演示;Web 导入链和依赖不使用 Qt,无 Node 构建步骤。 - [x] 提供 Linux Docker 与稳定 2.x 受控更新、停机备份及失败回滚脚本;历史 Linux Docker 部署、持久化权限、健康检查和定时更新检查烟测见下文。 -- [x] 本轮发布目标为 `2.0.4`,保留桌面兼容;战斗模拟为近似模型,特殊关卡并非全部支持,真实游戏 API 验收范围不因版本号变更而扩大。 -- 2.0.4 修复掉线恢复后策略意外停止,启停选择跨重登与重启保留;登录记录存在即持续自动重登。详见 [本版发布说明](../analysis/RELEASE_2_0_4.md)。 +- [x] 本轮发布目标为 `2.0.5`,保留桌面兼容;战斗模拟为近似模型,特殊关卡并非全部支持,真实游戏 API 验收范围不因版本号变更而扩大。 +- 2.0.5 清理非业务说明小字,页面加载使用居中圆形进度指示;保留必要错误、执行状态和业务数据。详见 [本版发布说明](../analysis/RELEASE_2_0_5.md)。 - 2.0.3 修复 2.0.2 日志布局:所有页签复用原有底部日志区,按当前账号与功能筛选,默认收起;操作约定见 [产品说明](PRODUCT.md#203-底部分类日志),验收结果见 [发布说明](../analysis/RELEASE_2_0_3.md#验证)。 ## Windows 本地运行 @@ -97,13 +97,13 @@ 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 认证的部署,可在 2.0.4 稳定 Release 和正式镜像就绪、宿主机心跳有效后,直接通过“帮助 → 检查版本更新…”升级 **2.0.4**,无需先安装 2.0.2、重复初始化或替换宿主机更新器。升级完成后刷新网页以加载新版界面,底部日志默认收起。安装结果以宿主机健康检查为准;首次配置仅供尚未初始化的宿主机参考。 +已在 **2.0.1** 完成私有仓库和 GHCR 认证的部署,可在 2.0.5 稳定 Release 和正式镜像就绪、宿主机心跳有效后,直接通过“帮助 → 检查版本更新…”升级 **2.0.5**,无需先安装 2.0.2、重复初始化或替换宿主机更新器。升级完成后刷新网页以加载新版界面,底部日志默认收起。安装结果以宿主机健康检查为准;首次配置仅供尚未初始化的宿主机参考。 ## 离线验证 -2.0.4 验证结果统一见 [发布说明](../analysis/RELEASE_2_0_4.md#验证),以下历史记录不计入本版验收。 +2.0.5 验证结果统一见 [发布说明](../analysis/RELEASE_2_0_5.md#验证),以下历史记录不计入本版验收。 -### 历史验证记录(不计入 2.0.4) +### 历史验证记录(不计入 2.0.5) 2.0.2 验证记录见 [历史发布说明](../analysis/RELEASE_2_0_2.md#验证)。 diff --git a/ranch_web/__init__.py b/ranch_web/__init__.py index 49bb892..b1c422b 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.4" +__version__ = "2.0.5" GAME_VERSION = "1.9.68" __all__ = ["__version__", "GAME_VERSION"] diff --git a/ranch_web/static/app.js b/ranch_web/static/app.js index 1b6b28d..15324ef 100644 --- a/ranch_web/static/app.js +++ b/ranch_web/static/app.js @@ -27,10 +27,10 @@ function strategyRequested(summary) { return typeof summary?.strategy_requested= function strategyDetails(account) { if(!account)return ''; const summary=account.summary,requested=strategyRequested(summary); - if(!requested)return summary.strategy_requested===false?'策略已停止(用户暂停);暂停会保留到再次“开启”,账号仍会按设定时长自动重登。':'策略已停止,可在顶部“开启”继续执行已勾选功能。'; - if(summary.strategy_state==='blocked')return `策略等待处理:${summary.strategy_message || '请检查执行结果,确认后再继续。'}`; - if(summary.running && gameAvailable(account))return '角色状态自动刷新,正在自动执行已配置且已勾选的功能;可在顶部“停止”。'; - const parts=['已请求自动执行已勾选功能,等待恢复;可在顶部“停止”暂停执行。']; + if(!requested)return summary.strategy_requested===false?'策略已停止(用户暂停)':'策略已停止'; + if(summary.strategy_state==='blocked')return `策略等待处理:${summary.strategy_message || '等待确认执行结果'}`; + if(summary.running && gameAvailable(account))return '策略运行中'; + const parts=['等待自动恢复']; if(summary.strategy_message)parts.push(summary.strategy_message); const value=summary.strategy_retry_at; const retryAt=typeof value==='number'?(value<1e12?value*1000:value):Date.parse(value); @@ -96,8 +96,8 @@ function renderPageConnection(page) { } const stale=!gameAvailable(page.account),message=connectionDetails(page.account); page.connectionStatus.hidden=!stale;page.connectionStatus.textContent=message; - if(stale){page.loading.dataset.loading='false';page.loading.textContent=page.data?'已载入缓存':'缓存中暂无数据';clearTimeout(page.loadTimer);} - else if(page.loading.textContent.includes('缓存')){page.loading.textContent=page.data?'已载入':'正在读取…';page.loading.dataset.loading=String(!page.data);} + if(stale || page.root.hidden){clearTimeout(page.loadTimer);page.pending=false;} + page.setLoading(!stale && page.errorBox.hidden && (page.fetching || page.pending)); $$('button[data-operation]',page.actionsHost).filter(button=>gameRefreshOperations.has(button.dataset.operation)).forEach(button=>button.disabled=stale); } @@ -292,7 +292,7 @@ async function perform(account,operation,payload={},options={}) { const page=options.page || account.pages.get(account.page);if(page)await loadPage(page,true); if(operation==='login'&&result)account.pages.get('login')?.login?.update(result); if(operation==='forget_login')account.lastFailure=''; - const message=loginOperations.has(operation)?account.summary.running && strategyRequested(account.summary)?'已读取角色,已自动开启策略,执行已配置且已勾选的功能;可在顶部“停止”。':`已读取角色。${strategyDetails(account)}`:result?.message; + const message=loginOperations.has(operation)?account.summary.running && strategyRequested(account.summary)?'已读取角色,策略运行中':`已读取角色。${strategyDetails(account)}`:result?.message; if(message && operation!=='refresh')notice(message); setStatus(operation==='refresh'?'状态已刷新':message || `${operationLabels[operation] || '操作'}已完成`); return result; @@ -310,15 +310,17 @@ function getPage(account,key) { async function loadPage(page,force=false) { if(!force && !gameAvailable(page.account) && (page.key!=='login'||state.webStatusError||page.account.transportErrors.has('status'))){clearTimeout(page.loadTimer);renderPageConnection(page);return;} if(page.fetching){if(force)page.reload=true;return;} - page.fetching=true;const generation=page.generation || 0; + clearTimeout(page.loadTimer); + page.fetching=true;page.clearError();renderPageConnection(page); + const generation=page.generation || 0; try { const response=await api.view(page.account.id,page.key,page.query); - if(generation!==(page.generation||0))return; - page.clearError();page.render(response.data,response.loading);page.lastLoad=Date.now(); + if(generation!==(page.generation||0)){page.pending=false;return;} + page.pending=Boolean(response.loading);page.render(response.data);page.lastLoad=Date.now(); transportError(page.account,`view:${page.key}`,'页面数据',null);renderPageConnection(page); - if(response.loading && gameAvailable(page.account)){clearTimeout(page.loadTimer);page.loadTimer=setTimeout(()=>loadPage(page),650);} - }catch(failure){if(generation===(page.generation||0)){page.showError(failure.message);transportError(page.account,`view:${page.key}`,'页面数据',failure);}} - finally{page.fetching=false;if(page.reload){page.reload=false;loadPage(page);}} + if(page.pending && gameAvailable(page.account) && !page.root.hidden && page.root.isConnected)page.loadTimer=setTimeout(()=>loadPage(page),650); + }catch(failure){if(generation===(page.generation||0)){page.pending=false;clearTimeout(page.loadTimer);page.showError(failure.message);transportError(page.account,`view:${page.key}`,'页面数据',failure);}} + finally{page.fetching=false;renderPageConnection(page);if(page.reload){page.reload=false;loadPage(page);}} } function selectPage(key) { @@ -326,7 +328,10 @@ function selectPage(key) { saveLogScroll(account); if(account.page!==key)account.pages.get(account.page)?.login?.clearPassword(); account.page=key; - state.accounts.forEach(other=>other.pages.forEach(page=>{page.root.hidden=other.id!==account.id||page.key!==key;})); + state.accounts.forEach(other=>other.pages.forEach(page=>{ + page.root.hidden=other.id!==account.id||page.key!==key; + if(page.root.hidden){clearTimeout(page.loadTimer);page.pending=false;page.setLoading(false);} + })); const page=getPage(account,key);page.root.hidden=false; renderLogs(); $$('.page-tab').forEach(tab=>{const selected=tab.dataset.page===key;tab.setAttribute('aria-selected',String(selected));tab.tabIndex=selected?0:-1;}); @@ -339,6 +344,7 @@ async function selectAccount(id) { if(previous?.edits.size)flushConfig(previous).catch(error); state.active=id;const account=current();if(!account)return; $('#page-host').querySelector('.initial-state')?.remove(); + $('#page-host').querySelector(':scope > .loading-state')?.remove(); renderAccountTabs();renderSummary();renderLogs(true);applyLogLayout(account);selectPage(account.page); if(!account.config)try{await refreshConfig(account);}catch(failure){error(failure);} fetchLogs(account); @@ -346,7 +352,7 @@ async function selectAccount(id) { async function addAccount(demo=false) { const label=el('input',{type:'text','aria-label':'账号页签名称',placeholder:demo?'离线演示':'账号名称(可留空)',maxlength:80}); - const result=await dialog(demo?'新增离线演示账号':'新增账号',el('div',{},el('label',{class:'field'},el('span',{class:'field-label',text:'账号名称'}),label),el('p',{class:'info-note',text:demo?'使用服务端离线演示状态,不连接游戏服务器。':'创建独立账号工作区,然后在登录页连接游戏角色。'})),{confirm:'新增',read:()=>({label:label.value.trim()})}); + const result=await dialog(demo?'新增离线演示账号':'新增账号',el('label',{class:'field'},el('span',{class:'field-label',text:'账号名称'}),label),{confirm:'新增',read:()=>({label:label.value.trim()})}); if(!result)return; const summary=await api.create(result.label,demo);state.accounts.set(summary.id,makeAccount(summary));await selectAccount(summary.id);notice(demo?'离线演示账号已创建':'账号已创建,请在登录页登录。'); } @@ -409,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.4'}`}),el('p',{text:`游戏数据版本 ${state.meta?.gameVersion || '1.9.68'}`}),el('p',{class:'info-note',text:'与桌面助手共用核心策略。配置在服务端自动保存;在线时默认自动执行已勾选功能,连接恢复后继续执行。顶部“停止”仅暂停执行,暂停在重新登录和服务重启后仍保留,直到再次“开启”。已保存的账号按设定时长自动重登,退出登录不取消;只有清除登录记录或删除账号才取消。'})),{info:true}); + if(name==='about')return dialog('关于牧场助手',el('div',{},el('p',{text:`牧羊人之心牧场助手 Web ${state.meta?.version || '2.0.5'}`}),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('请先新增或选择账号。'); @@ -429,7 +435,7 @@ async function command(name,account=current()) { } if(name==='remove-account'){ if(!await confirm('移除当前账号',`移除“${account.summary.label || '当前账号'}”及其保存的会话和策略?此操作无法撤销。`,{confirm:'移除账号',danger:true}))return; - await api.remove(account.id);account.jobs.forEach(record=>record.reject(new Error('账号已移除')));account.pages.forEach(page=>{clearTimeout(page.loadTimer);page.root.remove();});clearTimeout(account.saveTimer);state.accounts.delete(account.id);state.active=null; + await api.remove(account.id);account.jobs.forEach(record=>record.reject(new Error('账号已移除')));account.pages.forEach(page=>{clearTimeout(page.loadTimer);page.setLoading(false);page.root.remove();});clearTimeout(account.saveTimer);state.accounts.delete(account.id);state.active=null; if(state.accounts.size)await selectAccount(state.accounts.keys().next().value);else showNoAccounts();renderAccountTabs();renderSummary();return; } if(name==='export-config'){ @@ -449,10 +455,16 @@ async function command(name,account=current()) { async function showUpdates() { const content=el('div',{class:'detail-sections'}),values=el('div'),message=el('p'),check=el('button',{type:'button',text:'检查 GitHub 正式版本'}),apply=el('button',{type:'button',text:'提交更新请求…',disabled:true}); + const loading=el('div',{class:'loading-state',role:'status','aria-label':'正在读取版本与更新状态',hidden:true},el('span',{class:'loading-spinner','aria-hidden':'true'})); + const region=el('div',{class:'loading-region','aria-busy':'false'},values,loading); const labels={unchecked:'尚未检查',no_release:'尚无正式版本',up_to_date:'已是最新版本',available:'发现新版本',check_failed:'版本检查失败',unavailable:'更新器未就绪',pending:'等待宿主机处理',applying:'正在更新并检查健康',succeeded:'更新完成,健康检查通过',rolled_back:'更新失败,已回滚',failed:'更新失败'}; const lifetime=new AbortController(); - let status,timer,closed=false,busy=false; + let status,timer,loadingTimer,closed=false,busy=false; const active=()=>!closed && content.isConnected && $('#action-dialog').open; + const setLoading=value=>{ + clearTimeout(loadingTimer);loading.hidden=true;region.setAttribute('aria-busy',String(value)); + if(value)loadingTimer=setTimeout(()=>{if(active())loading.hidden=false;},150); + }; const bounded=async callback=>{ const controller=new AbortController(),abort=()=>controller.abort(); lifetime.signal.addEventListener('abort',abort,{once:true}); @@ -478,31 +490,31 @@ async function showUpdates() { async function poll(){ if(!active())return; if(busy){schedule();return;} - busy=true; + busy=true;setLoading(true); try{render(await bounded(signal=>api.updates({signal})));} catch(failure){await disconnected(failure);} - finally{busy=false;schedule();} + finally{busy=false;setLoading(false);schedule();} } check.addEventListener('click',async()=>{ - if(busy)return;busy=true;clearTimeout(timer);check.disabled=true;check.textContent='正在检查…'; + if(busy)return;busy=true;setLoading(true);clearTimeout(timer);check.disabled=true; try{render(await bounded(signal=>api.checkUpdates({signal})));} catch(failure){if(active())message.textContent=failure.name==='AbortError'?'版本检查暂未返回,稍后将自动读取最新状态。':failure.message;} - finally{busy=false;check.disabled=false;check.textContent='检查 GitHub 正式版本';schedule();} + finally{busy=false;setLoading(false);check.disabled=false;schedule();} }); apply.addEventListener('click',async()=>{ if(busy || !status?.can_apply)return; const version=status.latest_version; if(!window.confirm(`提交 ${version} 更新请求?执行器将处理请求并可能重启服务。`))return; - busy=true;clearTimeout(timer);apply.disabled=true; + busy=true;setLoading(true);clearTimeout(timer);apply.disabled=true; try{render(await bounded(signal=>api.applyUpdate(version,{signal})));} catch(failure){await disconnected(failure);} - finally{busy=false;schedule();} + finally{busy=false;setLoading(false);schedule();} }); - content.append(values,message,el('div',{class:'page-toolbar'},check,apply),el('p',{class:'info-note',text:'仅检查 GitHub 正式版本。窗口打开时每 3 秒读取宿主机状态;提交请求后由受控更新器处理,服务恢复且健康检查通过后才显示完成。'})); + content.append(region,message,el('div',{class:'page-toolbar'},check,apply)); const open=dialog('版本与更新',content,{info:true}); poll(); try{await open;} - finally{closed=true;clearTimeout(timer);lifetime.abort();} + finally{closed=true;clearTimeout(timer);setLoading(false);lifetime.abort();} } function setLogVisible(visible) { @@ -563,18 +575,20 @@ async function fetchLogs(account) { } async function showDebugEntry(account,entry) { - const pre=el('pre',{class:'debug-json',text:'正在读取所选条目的脱敏详情…'});const open=dialog('请求 / 响应详情(已脱敏)',pre,{info:true}); + const pre=el('pre',{class:'debug-json',hidden:true}),loading=el('div',{class:'loading-state',role:'status','aria-label':'正在读取所选条目的脱敏详情'},el('span',{class:'loading-spinner','aria-hidden':'true'})); + const content=el('div',{'aria-busy':'true'},loading,pre),open=dialog('请求 / 响应详情(已脱敏)',content,{info:true}); try{ let path; try{path=apiPath(entry.detail_url || entry.debug_url);}catch{/* Use the account's own endpoint for untrusted URLs. */} const detail=await (path?request(path):api.debugEntry(account.id,entry.id)); pre.textContent=JSON.stringify(detail.details ?? detail,null,2); }catch(failure){pre.textContent=failure.message;} + finally{loading.hidden=true;pre.hidden=false;content.setAttribute('aria-busy','false');} await open; } function showNoAccounts() { - state.active=null;$('#page-host').replaceChildren(el('div',{class:'initial-state'},el('p',{text:'尚未添加账号。新增账号后登录游戏,或使用离线演示查看工作台。'}),el('div',{class:'page-toolbar'},el('button',{text:'新增账号…',onClick:()=>command('add-account')}),el('button',{text:'新增离线演示账号',onClick:()=>command('add-demo')})))); + state.active=null;$('#page-host').replaceChildren(el('div',{class:'initial-state'},el('p',{text:'尚未添加账号。'}),el('div',{class:'page-toolbar'},el('button',{text:'新增账号…',onClick:()=>command('add-account')}),el('button',{text:'新增离线演示账号',onClick:()=>command('add-demo')})))); renderAccountTabs();renderSummary();applyLogLayout();setStatus('等待新增账号'); } @@ -584,7 +598,7 @@ async function syncAccounts() { catch(failure){if(failure.status!==401){state.webStatusError=`Web 状态读取失败:${failure.message || String(failure)} 正在重试。`;renderAccountTabs();renderSummary();}throw failure;} const summaries=Array.isArray(response)?response:response.accounts || []; const ids=new Set(summaries.map(summary=>summary.id)); - for(const [id,account]of state.accounts)if(!ids.has(id)){account.pages.forEach(page=>{clearTimeout(page.loadTimer);page.root.remove();});state.accounts.delete(id);} + for(const [id,account]of state.accounts)if(!ids.has(id)){account.pages.forEach(page=>{clearTimeout(page.loadTimer);page.setLoading(false);page.root.remove();});state.accounts.delete(id);} summaries.forEach(summary=>{ const account=state.accounts.get(summary.id);if(account){acceptSummary(account,summary);account.transportErrors.delete('status');if(account.config&&account.revision!==summary.revision&&!account.edits.size&&!account.savePromise)refreshConfig(account).catch(error);} else state.accounts.set(summary.id,makeAccount(summary)); @@ -612,7 +626,7 @@ function hideWorkbench() { $$('dialog[open]').forEach(root=>root.close()); $$('.context-menu').forEach(root=>root.remove()); $$('input[type="password"]').forEach(input=>input.value=''); - state.accounts.forEach(account=>{clearTimeout(account.saveTimer);account.pages.forEach(page=>clearTimeout(page.loadTimer));}); + state.accounts.forEach(account=>{clearTimeout(account.saveTimer);account.pages.forEach(page=>{clearTimeout(page.loadTimer);page.pending=false;page.setLoading(false);});}); } function requireAuth() { @@ -626,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.4';$('#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.5';$('#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/forms.js b/ranch_web/static/forms.js index f635788..8c76425 100644 --- a/ranch_web/static/forms.js +++ b/ranch_web/static/forms.js @@ -122,7 +122,6 @@ export function control(field, {get, set, onError = () => {}}) { }; } root.dataset.configPath = pathKey(path); - root.title = field.help || field.description || label; root.disabled = Boolean(field.disabled || field.readonly); sync(); return {root, sync, field}; @@ -156,7 +155,7 @@ export class PolicyForm { entry.root.classList.add('field-input'); const boolean = ['boolean', 'bool', 'checkbox'].includes(field.type); const wide = ['id_counts', 'counts', 'reserves', 'multiselect'].includes(field.type); - const row = el('label', {class: `field${boolean ? ' checkbox-field' : ''}${wide ? ' field-wide' : ''}`, title: field.help || field.description || ''}); + const row = el('label', {class: `field${boolean ? ' checkbox-field' : ''}${wide ? ' field-wide' : ''}`}); if (entry.root.tagName === 'DIV') { const fieldRow = el('div', {class: `field${wide ? ' field-wide' : ''}`}, el('span', {class: 'field-label', text: field.label}), entry.root); groups.get(group).append(fieldRow); @@ -166,7 +165,6 @@ export class PolicyForm { groups.get(group).append(row); entry.row = row; } - if (field.help || field.description) groups.get(group).append(el('span', {class: 'field-help', text: field.help || field.description})); this.controls.push(entry); }); this.signature = signature; diff --git a/ranch_web/static/index.html b/ranch_web/static/index.html index b412f98..45329b9 100644 --- a/ranch_web/static/index.html +++ b/ranch_web/static/index.html @@ -26,8 +26,8 @@ - 牧羊人之心牧场助手 2.0.4 - 正在连接本地服务 + 牧羊人之心牧场助手 2.0.5 +