ui: simplify helper copy and center page loading feedback
This commit is contained in:
@@ -23,6 +23,7 @@ concurrency:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
image:
|
image:
|
||||||
|
if: github.event.deleted != true
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 25
|
timeout-minutes: 25
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
FROM python:3.12-slim-bookworm
|
FROM python:3.12-slim-bookworm
|
||||||
|
|
||||||
ARG WEB_VERSION=2.0.4
|
ARG WEB_VERSION=2.0.5
|
||||||
ARG VCS_REF=unknown
|
ARG VCS_REF=unknown
|
||||||
LABEL org.opencontainers.image.source="https://github.com/attilanet/myrzx_bot" \
|
LABEL org.opencontainers.image.source="https://github.com/attilanet/myrzx_bot" \
|
||||||
org.opencontainers.image.title="myrzx_bot Web" \
|
org.opencontainers.image.title="myrzx_bot Web" \
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# 牧羊人之心Bot
|
# 牧羊人之心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+,在项目根目录执行:
|
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)。
|
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
|
### 桌面 1.2.0
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ Web 无需 Node/npm 或 PySide6,数据独立保存在 `local_state/ranch_web`
|
|||||||
|
|
||||||
| 组件与版本 | 《牧羊人之心》Android 基线 | 入口与状态 |
|
| 组件与版本 | 《牧羊人之心》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.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.1(`v1.1.1`) | 1.9.68 | 历史正式版本,1.1 系列修复与界面更新 |
|
||||||
| 桌面 1.1.0(`v1.1.0`) | 1.9.68 | 历史已发布版本 |
|
| 桌面 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)。
|
本表记录适配资料基线,不代表其他客户端版本兼容或全部功能已完成实机验收。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页**:沿用桌面页面顺序、账号页签、顶部玩家数值与统一启停、可调整日志区。
|
- **原布局与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 功能基线
|
## 桌面 1.2.0 功能基线
|
||||||
|
|
||||||
|
|||||||
@@ -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。
|
||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
name: ranch-web
|
name: ranch-web
|
||||||
services:
|
services:
|
||||||
web:
|
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:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
WEB_VERSION: ${RANCH_WEB_BUILD_VERSION:-2.0.4}
|
WEB_VERSION: ${RANCH_WEB_BUILD_VERSION:-2.0.5}
|
||||||
user: "10001:10001"
|
user: "10001:10001"
|
||||||
init: true
|
init: true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
+10
-10
@@ -1,8 +1,8 @@
|
|||||||
# Web 2 Linux Docker 部署与更新
|
# 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
|
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`。不要对现有账号目录重新初始化密钥。
|
`/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 初始化的宿主机
|
### 已完成 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。
|
前提是原有 `/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
|
```sh
|
||||||
sudo install -m 0644 -o root -g root updater.pyz /opt/ranch-web/updater.pyz
|
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 --help
|
||||||
python3 -B /opt/ranch-web/updater.pyz --version
|
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 历史或更新状态中:
|
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 的工作流结果为准。
|
[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
|
```sh
|
||||||
python -B tools/build_web_updater.py --output test-artifacts/updater.pyz
|
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 --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
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
# Pull only after the v2.0.4 image publishing workflow succeeds and the image is available.
|
# 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.4
|
RANCH_WEB_IMAGE=ghcr.io/attilanet/myrzx_bot-web:v2.0.5
|
||||||
|
|||||||
@@ -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 常驻运行。多个浏览器访问同一个管理员工作台;账号互相隔离,各账号串行执行,账号之间可以并行。
|
使用者在 Windows 本机配置、验证,随后可在 Linux Docker 常驻运行。多个浏览器访问同一个管理员工作台;账号互相隔离,各账号串行执行,账号之间可以并行。
|
||||||
|
|
||||||
@@ -24,9 +24,13 @@
|
|||||||
- 数据分析用真实 DTO 绘制 SVG 条形图,保留来源筛选、体力效率、样本和不确定性说明。没有样本时明确说明。
|
- 数据分析用真实 DTO 绘制 SVG 条形图,保留来源筛选、体力效率、样本和不确定性说明。没有样本时明确说明。
|
||||||
- 策略统一导入导出;收益 CSV/XLSX 导入与可用数据下载。错误展示具体原因,不把不支持的任务伪装成可执行任务。
|
- 策略统一导入导出;收益 CSV/XLSX 导入与可用数据下载。错误展示具体原因,不把不支持的任务伪装成可执行任务。
|
||||||
- 帮助可检查 GitHub 正式版本并提交受控更新请求。未配置部署器时明确显示原因,更新提交不表示更新成功。
|
- 帮助可检查 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 起)
|
||||||
|
|
||||||
账号登录后默认执行已勾选策略,只有用户点击“停止”才暂停;点击“开启”恢复。启停选择由服务端持久保存,掉线、重新登录、关闭网页或服务重启不会误改。停止策略不停止连接监控与自动重登。
|
账号登录后默认执行已勾选策略,只有用户点击“停止”才暂停;点击“开启”恢复。启停选择由服务端持久保存,掉线、重新登录、关闭网页或服务重启不会误改。停止策略不停止连接监控与自动重登。
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -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)。多浏览器连接同一个管理员工作台;一个服务实例内,各账号独立线程并行,同一账号操作串行。
|
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] 保留账号页签、顶部数值与统一启停、可调日志;规则自动保存,配置与统计按账号/角色隔离,每次成功登录后自动执行已配置且已勾选的功能,可在顶部停止。
|
||||||
- [x] Windows Python 启动与离线演示;Web 导入链和依赖不使用 Qt,无 Node 构建步骤。
|
- [x] Windows Python 启动与离线演示;Web 导入链和依赖不使用 Qt,无 Node 构建步骤。
|
||||||
- [x] 提供 Linux Docker 与稳定 2.x 受控更新、停机备份及失败回滚脚本;历史 Linux Docker 部署、持久化权限、健康检查和定时更新检查烟测见下文。
|
- [x] 提供 Linux Docker 与稳定 2.x 受控更新、停机备份及失败回滚脚本;历史 Linux Docker 部署、持久化权限、健康检查和定时更新检查烟测见下文。
|
||||||
- [x] 本轮发布目标为 `2.0.4`,保留桌面兼容;战斗模拟为近似模型,特殊关卡并非全部支持,真实游戏 API 验收范围不因版本号变更而扩大。
|
- [x] 本轮发布目标为 `2.0.5`,保留桌面兼容;战斗模拟为近似模型,特殊关卡并非全部支持,真实游戏 API 验收范围不因版本号变更而扩大。
|
||||||
- 2.0.4 修复掉线恢复后策略意外停止,启停选择跨重登与重启保留;登录记录存在即持续自动重登。详见 [本版发布说明](../analysis/RELEASE_2_0_4.md)。
|
- 2.0.5 清理非业务说明小字,页面加载使用居中圆形进度指示;保留必要错误、执行状态和业务数据。详见 [本版发布说明](../analysis/RELEASE_2_0_5.md)。
|
||||||
- 2.0.3 修复 2.0.2 日志布局:所有页签复用原有底部日志区,按当前账号与功能筛选,默认收起;操作约定见 [产品说明](PRODUCT.md#203-底部分类日志),验收结果见 [发布说明](../analysis/RELEASE_2_0_3.md#验证)。
|
- 2.0.3 修复 2.0.2 日志布局:所有页签复用原有底部日志区,按当前账号与功能筛选,默认收起;操作约定见 [产品说明](PRODUCT.md#203-底部分类日志),验收结果见 [发布说明](../analysis/RELEASE_2_0_3.md#验证)。
|
||||||
|
|
||||||
## Windows 本地运行
|
## 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。
|
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#验证)。
|
2.0.2 验证记录见 [历史发布说明](../analysis/RELEASE_2_0_2.md#验证)。
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Headless Web workspace for the ranch assistant."""
|
"""Headless Web workspace for the ranch assistant."""
|
||||||
|
|
||||||
__version__ = "2.0.4"
|
__version__ = "2.0.5"
|
||||||
GAME_VERSION = "1.9.68"
|
GAME_VERSION = "1.9.68"
|
||||||
|
|
||||||
__all__ = ["__version__", "GAME_VERSION"]
|
__all__ = ["__version__", "GAME_VERSION"]
|
||||||
|
|||||||
+45
-31
@@ -27,10 +27,10 @@ function strategyRequested(summary) { return typeof summary?.strategy_requested=
|
|||||||
function strategyDetails(account) {
|
function strategyDetails(account) {
|
||||||
if(!account)return '';
|
if(!account)return '';
|
||||||
const summary=account.summary,requested=strategyRequested(summary);
|
const summary=account.summary,requested=strategyRequested(summary);
|
||||||
if(!requested)return summary.strategy_requested===false?'策略已停止(用户暂停);暂停会保留到再次“开启”,账号仍会按设定时长自动重登。':'策略已停止,可在顶部“开启”继续执行已勾选功能。';
|
if(!requested)return summary.strategy_requested===false?'策略已停止(用户暂停)':'策略已停止';
|
||||||
if(summary.strategy_state==='blocked')return `策略等待处理:${summary.strategy_message || '请检查执行结果,确认后再继续。'}`;
|
if(summary.strategy_state==='blocked')return `策略等待处理:${summary.strategy_message || '等待确认执行结果'}`;
|
||||||
if(summary.running && gameAvailable(account))return '角色状态自动刷新,正在自动执行已配置且已勾选的功能;可在顶部“停止”。';
|
if(summary.running && gameAvailable(account))return '策略运行中';
|
||||||
const parts=['已请求自动执行已勾选功能,等待恢复;可在顶部“停止”暂停执行。'];
|
const parts=['等待自动恢复'];
|
||||||
if(summary.strategy_message)parts.push(summary.strategy_message);
|
if(summary.strategy_message)parts.push(summary.strategy_message);
|
||||||
const value=summary.strategy_retry_at;
|
const value=summary.strategy_retry_at;
|
||||||
const retryAt=typeof value==='number'?(value<1e12?value*1000:value):Date.parse(value);
|
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);
|
const stale=!gameAvailable(page.account),message=connectionDetails(page.account);
|
||||||
page.connectionStatus.hidden=!stale;page.connectionStatus.textContent=message;
|
page.connectionStatus.hidden=!stale;page.connectionStatus.textContent=message;
|
||||||
if(stale){page.loading.dataset.loading='false';page.loading.textContent=page.data?'已载入缓存':'缓存中暂无数据';clearTimeout(page.loadTimer);}
|
if(stale || page.root.hidden){clearTimeout(page.loadTimer);page.pending=false;}
|
||||||
else if(page.loading.textContent.includes('缓存')){page.loading.textContent=page.data?'已载入':'正在读取…';page.loading.dataset.loading=String(!page.data);}
|
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);
|
$$('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);
|
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==='login'&&result)account.pages.get('login')?.login?.update(result);
|
||||||
if(operation==='forget_login')account.lastFailure='';
|
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);
|
if(message && operation!=='refresh')notice(message);
|
||||||
setStatus(operation==='refresh'?'状态已刷新':message || `${operationLabels[operation] || '操作'}已完成`);
|
setStatus(operation==='refresh'?'状态已刷新':message || `${operationLabels[operation] || '操作'}已完成`);
|
||||||
return result;
|
return result;
|
||||||
@@ -310,15 +310,17 @@ function getPage(account,key) {
|
|||||||
async function loadPage(page,force=false) {
|
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(!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;}
|
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 {
|
try {
|
||||||
const response=await api.view(page.account.id,page.key,page.query);
|
const response=await api.view(page.account.id,page.key,page.query);
|
||||||
if(generation!==(page.generation||0))return;
|
if(generation!==(page.generation||0)){page.pending=false;return;}
|
||||||
page.clearError();page.render(response.data,response.loading);page.lastLoad=Date.now();
|
page.pending=Boolean(response.loading);page.render(response.data);page.lastLoad=Date.now();
|
||||||
transportError(page.account,`view:${page.key}`,'页面数据',null);renderPageConnection(page);
|
transportError(page.account,`view:${page.key}`,'页面数据',null);renderPageConnection(page);
|
||||||
if(response.loading && gameAvailable(page.account)){clearTimeout(page.loadTimer);page.loadTimer=setTimeout(()=>loadPage(page),650);}
|
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.showError(failure.message);transportError(page.account,`view:${page.key}`,'页面数据',failure);}}
|
}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;if(page.reload){page.reload=false;loadPage(page);}}
|
finally{page.fetching=false;renderPageConnection(page);if(page.reload){page.reload=false;loadPage(page);}}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectPage(key) {
|
function selectPage(key) {
|
||||||
@@ -326,7 +328,10 @@ function selectPage(key) {
|
|||||||
saveLogScroll(account);
|
saveLogScroll(account);
|
||||||
if(account.page!==key)account.pages.get(account.page)?.login?.clearPassword();
|
if(account.page!==key)account.pages.get(account.page)?.login?.clearPassword();
|
||||||
account.page=key;
|
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;
|
const page=getPage(account,key);page.root.hidden=false;
|
||||||
renderLogs();
|
renderLogs();
|
||||||
$$('.page-tab').forEach(tab=>{const selected=tab.dataset.page===key;tab.setAttribute('aria-selected',String(selected));tab.tabIndex=selected?0:-1;});
|
$$('.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);
|
if(previous?.edits.size)flushConfig(previous).catch(error);
|
||||||
state.active=id;const account=current();if(!account)return;
|
state.active=id;const account=current();if(!account)return;
|
||||||
$('#page-host').querySelector('.initial-state')?.remove();
|
$('#page-host').querySelector('.initial-state')?.remove();
|
||||||
|
$('#page-host').querySelector(':scope > .loading-state')?.remove();
|
||||||
renderAccountTabs();renderSummary();renderLogs(true);applyLogLayout(account);selectPage(account.page);
|
renderAccountTabs();renderSummary();renderLogs(true);applyLogLayout(account);selectPage(account.page);
|
||||||
if(!account.config)try{await refreshConfig(account);}catch(failure){error(failure);}
|
if(!account.config)try{await refreshConfig(account);}catch(failure){error(failure);}
|
||||||
fetchLogs(account);
|
fetchLogs(account);
|
||||||
@@ -346,7 +352,7 @@ async function selectAccount(id) {
|
|||||||
|
|
||||||
async function addAccount(demo=false) {
|
async function addAccount(demo=false) {
|
||||||
const label=el('input',{type:'text','aria-label':'账号页签名称',placeholder:demo?'离线演示':'账号名称(可留空)',maxlength:80});
|
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;
|
if(!result)return;
|
||||||
const summary=await api.create(result.label,demo);state.accounts.set(summary.id,makeAccount(summary));await selectAccount(summary.id);notice(demo?'离线演示账号已创建':'账号已创建,请在登录页登录。');
|
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()) {
|
async function command(name,account=current()) {
|
||||||
try {
|
try {
|
||||||
if(name==='add-account'||name==='add-demo')return await addAccount(name==='add-demo');
|
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==='updates')return await showUpdates();
|
||||||
if(name==='admin-logout'){hideWorkbench();try{await api.logout();}finally{requireAuth();}return;}
|
if(name==='admin-logout'){hideWorkbench();try{await api.logout();}finally{requireAuth();}return;}
|
||||||
if(!account)throw new Error('请先新增或选择账号。');
|
if(!account)throw new Error('请先新增或选择账号。');
|
||||||
@@ -429,7 +435,7 @@ async function command(name,account=current()) {
|
|||||||
}
|
}
|
||||||
if(name==='remove-account'){
|
if(name==='remove-account'){
|
||||||
if(!await confirm('移除当前账号',`移除“${account.summary.label || '当前账号'}”及其保存的会话和策略?此操作无法撤销。`,{confirm:'移除账号',danger:true}))return;
|
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(state.accounts.size)await selectAccount(state.accounts.keys().next().value);else showNoAccounts();renderAccountTabs();renderSummary();return;
|
||||||
}
|
}
|
||||||
if(name==='export-config'){
|
if(name==='export-config'){
|
||||||
@@ -449,10 +455,16 @@ async function command(name,account=current()) {
|
|||||||
|
|
||||||
async function showUpdates() {
|
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 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 labels={unchecked:'尚未检查',no_release:'尚无正式版本',up_to_date:'已是最新版本',available:'发现新版本',check_failed:'版本检查失败',unavailable:'更新器未就绪',pending:'等待宿主机处理',applying:'正在更新并检查健康',succeeded:'更新完成,健康检查通过',rolled_back:'更新失败,已回滚',failed:'更新失败'};
|
||||||
const lifetime=new AbortController();
|
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 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 bounded=async callback=>{
|
||||||
const controller=new AbortController(),abort=()=>controller.abort();
|
const controller=new AbortController(),abort=()=>controller.abort();
|
||||||
lifetime.signal.addEventListener('abort',abort,{once:true});
|
lifetime.signal.addEventListener('abort',abort,{once:true});
|
||||||
@@ -478,31 +490,31 @@ async function showUpdates() {
|
|||||||
async function poll(){
|
async function poll(){
|
||||||
if(!active())return;
|
if(!active())return;
|
||||||
if(busy){schedule();return;}
|
if(busy){schedule();return;}
|
||||||
busy=true;
|
busy=true;setLoading(true);
|
||||||
try{render(await bounded(signal=>api.updates({signal})));}
|
try{render(await bounded(signal=>api.updates({signal})));}
|
||||||
catch(failure){await disconnected(failure);}
|
catch(failure){await disconnected(failure);}
|
||||||
finally{busy=false;schedule();}
|
finally{busy=false;setLoading(false);schedule();}
|
||||||
}
|
}
|
||||||
check.addEventListener('click',async()=>{
|
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})));}
|
try{render(await bounded(signal=>api.checkUpdates({signal})));}
|
||||||
catch(failure){if(active())message.textContent=failure.name==='AbortError'?'版本检查暂未返回,稍后将自动读取最新状态。':failure.message;}
|
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()=>{
|
apply.addEventListener('click',async()=>{
|
||||||
if(busy || !status?.can_apply)return;
|
if(busy || !status?.can_apply)return;
|
||||||
const version=status.latest_version;
|
const version=status.latest_version;
|
||||||
if(!window.confirm(`提交 ${version} 更新请求?执行器将处理请求并可能重启服务。`))return;
|
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})));}
|
try{render(await bounded(signal=>api.applyUpdate(version,{signal})));}
|
||||||
catch(failure){await disconnected(failure);}
|
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});
|
const open=dialog('版本与更新',content,{info:true});
|
||||||
poll();
|
poll();
|
||||||
try{await open;}
|
try{await open;}
|
||||||
finally{closed=true;clearTimeout(timer);lifetime.abort();}
|
finally{closed=true;clearTimeout(timer);setLoading(false);lifetime.abort();}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLogVisible(visible) {
|
function setLogVisible(visible) {
|
||||||
@@ -563,18 +575,20 @@ async function fetchLogs(account) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function showDebugEntry(account,entry) {
|
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{
|
try{
|
||||||
let path;
|
let path;
|
||||||
try{path=apiPath(entry.detail_url || entry.debug_url);}catch{/* Use the account's own endpoint for untrusted URLs. */}
|
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));
|
const detail=await (path?request(path):api.debugEntry(account.id,entry.id));
|
||||||
pre.textContent=JSON.stringify(detail.details ?? detail,null,2);
|
pre.textContent=JSON.stringify(detail.details ?? detail,null,2);
|
||||||
}catch(failure){pre.textContent=failure.message;}
|
}catch(failure){pre.textContent=failure.message;}
|
||||||
|
finally{loading.hidden=true;pre.hidden=false;content.setAttribute('aria-busy','false');}
|
||||||
await open;
|
await open;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNoAccounts() {
|
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('等待新增账号');
|
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;}
|
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 summaries=Array.isArray(response)?response:response.accounts || [];
|
||||||
const ids=new Set(summaries.map(summary=>summary.id));
|
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=>{
|
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);}
|
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));
|
else state.accounts.set(summary.id,makeAccount(summary));
|
||||||
@@ -612,7 +626,7 @@ function hideWorkbench() {
|
|||||||
$$('dialog[open]').forEach(root=>root.close());
|
$$('dialog[open]').forEach(root=>root.close());
|
||||||
$$('.context-menu').forEach(root=>root.remove());
|
$$('.context-menu').forEach(root=>root.remove());
|
||||||
$$('input[type="password"]').forEach(input=>input.value='');
|
$$('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() {
|
function requireAuth() {
|
||||||
@@ -626,7 +640,7 @@ async function bootstrap() {
|
|||||||
$('#app').hidden=false;
|
$('#app').hidden=false;
|
||||||
const [meta,schema]=await Promise.all([api.meta(),api.schema()]);state.meta=meta;state.schema=schema;
|
const [meta,schema]=await Promise.all([api.meta(),api.schema()]);state.meta=meta;state.schema=schema;
|
||||||
if(state.redirecting)return;
|
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('工作台已连接');
|
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})));}
|
}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})));}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ export function control(field, {get, set, onError = () => {}}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
root.dataset.configPath = pathKey(path);
|
root.dataset.configPath = pathKey(path);
|
||||||
root.title = field.help || field.description || label;
|
|
||||||
root.disabled = Boolean(field.disabled || field.readonly);
|
root.disabled = Boolean(field.disabled || field.readonly);
|
||||||
sync();
|
sync();
|
||||||
return {root, sync, field};
|
return {root, sync, field};
|
||||||
@@ -156,7 +155,7 @@ export class PolicyForm {
|
|||||||
entry.root.classList.add('field-input');
|
entry.root.classList.add('field-input');
|
||||||
const boolean = ['boolean', 'bool', 'checkbox'].includes(field.type);
|
const boolean = ['boolean', 'bool', 'checkbox'].includes(field.type);
|
||||||
const wide = ['id_counts', 'counts', 'reserves', 'multiselect'].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') {
|
if (entry.root.tagName === 'DIV') {
|
||||||
const fieldRow = el('div', {class: `field${wide ? ' field-wide' : ''}`}, el('span', {class: 'field-label', text: field.label}), entry.root);
|
const fieldRow = el('div', {class: `field${wide ? ' field-wide' : ''}`}, el('span', {class: 'field-label', text: field.label}), entry.root);
|
||||||
groups.get(group).append(fieldRow);
|
groups.get(group).append(fieldRow);
|
||||||
@@ -166,7 +165,6 @@ export class PolicyForm {
|
|||||||
groups.get(group).append(row);
|
groups.get(group).append(row);
|
||||||
entry.row = 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.controls.push(entry);
|
||||||
});
|
});
|
||||||
this.signature = signature;
|
this.signature = signature;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
</div></details>
|
</div></details>
|
||||||
<details class="menu"><summary accesskey="h">帮助<span class="access-key">(H)</span></summary><div class="menu-popup"><button data-command="updates">检查版本更新…</button><button data-command="debug">调试日志</button><button data-command="about">关于…</button></div></details>
|
<details class="menu"><summary accesskey="h">帮助<span class="access-key">(H)</span></summary><div class="menu-popup"><button data-command="updates">检查版本更新…</button><button data-command="debug">调试日志</button><button data-command="about">关于…</button></div></details>
|
||||||
</nav>
|
</nav>
|
||||||
<span class="window-title">牧羊人之心牧场助手 <span id="app-version">2.0.4</span></span>
|
<span class="window-title">牧羊人之心牧场助手 <span id="app-version">2.0.5</span></span>
|
||||||
<span id="access-mode" class="muted">正在连接本地服务</span>
|
<span id="access-mode" class="muted"></span>
|
||||||
</header>
|
</header>
|
||||||
<div class="account-bar"><div id="account-tabs" class="account-tabs" role="tablist" aria-label="账号"></div><button id="add-account" class="compact" title="新增账号">+ 新增账号</button></div>
|
<div class="account-bar"><div id="account-tabs" class="account-tabs" role="tablist" aria-label="账号"></div><button id="add-account" class="compact" title="新增账号">+ 新增账号</button></div>
|
||||||
<div class="toolbar" aria-label="角色状态和运行控制">
|
<div class="toolbar" aria-label="角色状态和运行控制">
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<div class="summary-line"><span id="data-summary">等待连接服务</span><span id="save-status" role="status">配置未载入</span></div>
|
<div class="summary-line"><span id="data-summary">等待连接服务</span><span id="save-status" role="status">配置未载入</span></div>
|
||||||
<main id="workspace" class="workspace">
|
<main id="workspace" class="workspace">
|
||||||
<nav id="page-tabs" class="page-tabs" role="tablist" aria-label="功能页面"></nav>
|
<nav id="page-tabs" class="page-tabs" role="tablist" aria-label="功能页面"></nav>
|
||||||
<div id="page-host" class="page-host"><div class="initial-state" role="status">正在载入工作台…</div></div>
|
<div id="page-host" class="page-host"><div class="loading-state" role="status" aria-label="加载中"><span class="loading-spinner" aria-hidden="true"></span></div></div>
|
||||||
</main>
|
</main>
|
||||||
<div id="log-resizer" class="log-resizer" role="separator" tabindex="0" aria-label="调整日志高度" aria-orientation="horizontal" aria-valuemin="64" aria-valuemax="480" aria-valuenow="150" title="上下拖动调整日志高度;也可使用方向键" hidden></div>
|
<div id="log-resizer" class="log-resizer" role="separator" tabindex="0" aria-label="调整日志高度" aria-orientation="horizontal" aria-valuemin="64" aria-valuemax="480" aria-valuenow="150" title="上下拖动调整日志高度;也可使用方向键" hidden></div>
|
||||||
<section id="log-panel" class="log-panel" aria-label="登录日志" hidden><div class="log-toolbar"><strong id="log-heading">登录日志</strong><label><input id="debug-log" type="checkbox">调试 / 脱敏</label><label><input id="log-follow" type="checkbox" checked>自动滚动</label><label>搜索 <input id="log-search" type="search" aria-label="登录日志搜索" placeholder="筛选日志文字"></label><span id="log-count" class="muted" aria-live="off"></span><span class="spacer"></span><button id="download-log" class="small">下载日志</button><button id="clear-log" class="small" title="只清空本账号本页日志显示,保留其他页面及服务端历史">清空显示</button></div><div id="log-lines" class="log-lines" tabindex="0" role="log" aria-live="off" aria-label="登录日志内容"></div></section>
|
<section id="log-panel" class="log-panel" aria-label="登录日志" hidden><div class="log-toolbar"><strong id="log-heading">登录日志</strong><label><input id="debug-log" type="checkbox">调试 / 脱敏</label><label><input id="log-follow" type="checkbox" checked>自动滚动</label><label>搜索 <input id="log-search" type="search" aria-label="登录日志搜索" placeholder="筛选日志文字"></label><span id="log-count" class="muted" aria-live="off"></span><span class="spacer"></span><button id="download-log" class="small">下载日志</button><button id="clear-log" class="small" title="只清空本账号本页日志显示,保留其他页面及服务端历史">清空显示</button></div><div id="log-lines" class="log-lines" tabindex="0" role="log" aria-live="off" aria-label="登录日志内容"></div></section>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ body { margin: 0; min-height: 100dvh; display: grid; place-items: center; paddin
|
|||||||
.admin-login { width: 100%; max-width: 370px; padding: 24px; background: #fff; border: 1px solid #cbd1d8; border-radius: 5px; }
|
.admin-login { width: 100%; max-width: 370px; padding: 24px; background: #fff; border: 1px solid #cbd1d8; border-radius: 5px; }
|
||||||
h1 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
|
h1 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
|
||||||
p { margin: 0; line-height: 1.65; overflow-wrap: anywhere; }
|
p { margin: 0; line-height: 1.65; overflow-wrap: anywhere; }
|
||||||
#auth-description { color: #55616e; margin-bottom: 20px; }
|
|
||||||
form { display: flex; flex-direction: column; gap: 8px; }
|
form { display: flex; flex-direction: column; gap: 8px; }
|
||||||
input, button { font: inherit; min-width: 0; min-height: 36px; padding: 7px 10px; border: 1px solid #afb8c2; border-radius: 3px; }
|
input, button { font: inherit; min-width: 0; min-height: 36px; padding: 7px 10px; border: 1px solid #afb8c2; border-radius: 3px; }
|
||||||
input { width: 100%; background: #fff; color: inherit; caret-color: #245d9b; }
|
input { width: 100%; background: #fff; color: inherit; caret-color: #245d9b; }
|
||||||
@@ -20,7 +19,10 @@ button { margin-top: 8px; background: #245d9b; color: #fff; border-color: #245d9
|
|||||||
button:hover { background: #1c4d83; }
|
button:hover { background: #1c4d83; }
|
||||||
button:disabled { cursor: default; opacity: .58; }
|
button:disabled { cursor: default; opacity: .58; }
|
||||||
input:focus-visible, button:focus-visible { outline: 2px solid #245d9b; outline-offset: 2px; }
|
input:focus-visible, button:focus-visible { outline: 2px solid #245d9b; outline-offset: 2px; }
|
||||||
#auth-status { color: #55616e; }
|
.loading-state { display: grid; place-items: center; min-height: 64px; }
|
||||||
|
.loading-spinner { display: block; width: 32px; height: 32px; border: 3px solid #cbd1d8; border-top-color: #245d9b; border-radius: 50%; animation: loading-spin .8s linear infinite; box-shadow: 0 0 0 4px #ffffffb3; }
|
||||||
|
@keyframes loading-spin { to { transform: rotate(360deg); } }
|
||||||
|
@media (prefers-reduced-motion: reduce) { .loading-spinner { animation: none; } }
|
||||||
#auth-error { color: #99251e; white-space: pre-wrap; }
|
#auth-error { color: #99251e; white-space: pre-wrap; }
|
||||||
noscript { display: block; margin-top: 16px; line-height: 1.65; }
|
noscript { display: block; margin-top: 16px; line-height: 1.65; }
|
||||||
::selection { background: #c5dbf5; color: #142b46; }
|
::selection { background: #c5dbf5; color: #142b46; }
|
||||||
|
|||||||
@@ -13,11 +13,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<main class="admin-login" aria-labelledby="auth-title">
|
<main class="admin-login" aria-labelledby="auth-title">
|
||||||
<h1 id="auth-title">登录管理工作台</h1>
|
<h1 id="auth-title">登录管理工作台</h1>
|
||||||
<p id="auth-description">请输入此 Web 工作台的管理密码。</p>
|
<form id="auth-form" method="post" action="/api/auth/login">
|
||||||
<form id="auth-form" method="post" action="/api/auth/login" aria-describedby="auth-description">
|
|
||||||
<label for="admin-password">管理密码</label>
|
<label for="admin-password">管理密码</label>
|
||||||
<input id="admin-password" name="password" type="password" autocomplete="current-password" required aria-describedby="auth-error" disabled>
|
<input id="admin-password" name="password" type="password" autocomplete="current-password" required aria-describedby="auth-error" disabled>
|
||||||
<p id="auth-status" role="status">正在检查登录状态…</p>
|
<div id="auth-status" class="loading-state" role="status" aria-label="加载中"><span class="loading-spinner" aria-hidden="true"></span></div>
|
||||||
<p id="auth-error" role="alert" hidden></p>
|
<p id="auth-error" role="alert" hidden></p>
|
||||||
<button type="submit" disabled>登录</button>
|
<button type="submit" disabled>登录</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -10,13 +10,12 @@ const error = document.querySelector('#auth-error');
|
|||||||
let busy = false;
|
let busy = false;
|
||||||
let leaving = false;
|
let leaving = false;
|
||||||
|
|
||||||
function setBusy(value, message = '') {
|
function setBusy(value) {
|
||||||
busy = value;
|
busy = value;
|
||||||
input.disabled = value;
|
input.disabled = value;
|
||||||
button.disabled = value;
|
button.disabled = value;
|
||||||
form.setAttribute('aria-busy', String(value));
|
form.setAttribute('aria-busy', String(value));
|
||||||
status.textContent = message;
|
status.hidden = !value;
|
||||||
status.hidden = !message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showError(message) {
|
function showError(message) {
|
||||||
@@ -27,7 +26,7 @@ function showError(message) {
|
|||||||
function openWorkbench() {
|
function openWorkbench() {
|
||||||
leaving = true;
|
leaving = true;
|
||||||
input.value = '';
|
input.value = '';
|
||||||
setBusy(true, '正在进入工作台…');
|
setBusy(true);
|
||||||
location.replace(webPath('/'));
|
location.replace(webPath('/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ async function authRequest(path, body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkAuth() {
|
async function checkAuth() {
|
||||||
setBusy(true, '正在检查登录状态…');
|
setBusy(true);
|
||||||
error.hidden = true;
|
error.hidden = true;
|
||||||
try {
|
try {
|
||||||
const auth = await authRequest('/api/auth/status');
|
const auth = await authRequest('/api/auth/status');
|
||||||
@@ -78,7 +77,7 @@ form.addEventListener('submit', async event => {
|
|||||||
const body = JSON.stringify({password: input.value});
|
const body = JSON.stringify({password: input.value});
|
||||||
input.value = '';
|
input.value = '';
|
||||||
error.hidden = true;
|
error.hidden = true;
|
||||||
setBusy(true, '正在登录…');
|
setBusy(true);
|
||||||
try {
|
try {
|
||||||
const auth = await authRequest('/api/auth/login', body);
|
const auth = await authRequest('/api/auth/login', body);
|
||||||
if (!auth.required || auth.authenticated) openWorkbench();
|
if (!auth.required || auth.authenticated) openWorkbench();
|
||||||
|
|||||||
+45
-27
@@ -18,7 +18,7 @@ class LoginPage {
|
|||||||
this.autoReloginMessage = el('p', {role: 'status'});
|
this.autoReloginMessage = el('p', {role: 'status'});
|
||||||
this.autoReloginCountdown = el('p', {'data-auto-relogin-countdown': '', role: 'timer', 'aria-live': 'off', hidden: true});
|
this.autoReloginCountdown = el('p', {'data-auto-relogin-countdown': '', role: 'timer', 'aria-live': 'off', hidden: true});
|
||||||
this.autoReloginCredentials = el('p', {'data-auto-relogin-credentials': '', role: 'status', hidden: true,
|
this.autoReloginCredentials = el('p', {'data-auto-relogin-credentials': '', role: 'status', hidden: true,
|
||||||
text: '缺少服务端记住的账号和密码。请勾选“记住账号和密码”并完成登录,才能自动重登原区服角色。'});
|
text: '未保存账号或密码,自动重登不可用。'});
|
||||||
this.autoReloginStatus = el('div', {class: 'page-summary', 'data-auto-relogin-status': ''}, this.autoReloginMessage, this.autoReloginCountdown, this.autoReloginCredentials);
|
this.autoReloginStatus = el('div', {class: 'page-summary', 'data-auto-relogin-status': ''}, this.autoReloginMessage, this.autoReloginCountdown, this.autoReloginCredentials);
|
||||||
this.account = el('input', {type: 'text', name: 'game-account', autocomplete: 'username', 'aria-label': '游戏账号'});
|
this.account = el('input', {type: 'text', name: 'game-account', autocomplete: 'username', 'aria-label': '游戏账号'});
|
||||||
this.password = el('input', {type: 'password', name: 'game-password', autocomplete: 'current-password', 'aria-label': '游戏密码'});
|
this.password = el('input', {type: 'password', name: 'game-password', autocomplete: 'current-password', 'aria-label': '游戏密码'});
|
||||||
@@ -48,11 +48,9 @@ class LoginPage {
|
|||||||
this.restore = el('button', {type: 'button', text: '恢复选中会话(无需重新输密码)', disabled: true, onClick: () => page.perform('restore_session', {session_id: this.saved.value}).catch(page.error)});
|
this.restore = el('button', {type: 'button', text: '恢复选中会话(无需重新输密码)', disabled: true, onClick: () => page.perform('restore_session', {session_id: this.saved.value}).catch(page.error)});
|
||||||
this.root.append(form,
|
this.root.append(form,
|
||||||
field('第二步:区服 / 角色', el('div', {class: 'server-row'}, this.servers, this.enter)),
|
field('第二步:区服 / 角色', el('div', {class: 'server-row'}, this.servers, this.enter)),
|
||||||
el('p', {class: 'info-note', text: '账号验证 → 获取官方区服 → 选择区服 → 进入区服 → 读取角色。在线时默认自动刷新状态并自动执行已勾选功能;顶部“停止”仅暂停执行,重新登录和服务重启后仍保持暂停,直到再次“开启”。'}),
|
|
||||||
el('div', {class: 'session-block policy-form'}, field('已保存账号 / 区服 / 角色', this.saved), el('div', {class: 'login-actions'}, this.restore)),
|
el('div', {class: 'session-block policy-form'}, field('已保存账号 / 区服 / 角色', this.saved), el('div', {class: 'login-actions'}, this.restore)),
|
||||||
el('div', {class: 'page-toolbar'}, el('button', {type: 'button', text: '退出登录', onClick: () => page.perform('logout').catch(page.error)}),
|
el('div', {class: 'page-toolbar'}, el('button', {type: 'button', text: '退出登录', onClick: () => page.perform('logout').catch(page.error)}),
|
||||||
el('button', {type: 'button', text: '退出并清除登录记录…', onClick: () => page.options.command('forget-login', page.account)})),
|
el('button', {type: 'button', text: '退出并清除登录记录…', onClick: () => page.options.command('forget-login', page.account)})));
|
||||||
el('p', {class: 'info-note', text: '记住的账号密码和登录会话由服务端加密保存。浏览器不会保存游戏凭据。账号登录并保存原区服、原角色后会持续保持登录:掉线、退出登录或服务重启,均按设定时长自动重登并恢复监控;默认等待 30 分钟,可修改为 10 分钟等时长。关闭页面不影响自动重登。只有“退出并清除登录记录”或删除账号才取消自动重登;手动停止的执行仍保持暂停。'}));
|
|
||||||
host.append(this.autoReloginStatus, this.root);
|
host.append(this.autoReloginStatus, this.root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +70,9 @@ class LoginPage {
|
|||||||
|
|
||||||
updateStatus() {
|
updateStatus() {
|
||||||
const status = this.page.account.summary?.auto_relogin_status;
|
const status = this.page.account.summary?.auto_relogin_status;
|
||||||
const message = status?.message || '已保存的账号会持续自动重登,等待服务端状态;可设置重登等待时长。';
|
const message = status?.message || '';
|
||||||
if (this.autoReloginMessage.textContent !== message) this.autoReloginMessage.textContent = message;
|
if (this.autoReloginMessage.textContent !== message) this.autoReloginMessage.textContent = message;
|
||||||
|
this.autoReloginMessage.hidden = !message;
|
||||||
this.autoReloginCredentials.hidden = this.hasSavedPassword !== false;
|
this.autoReloginCredentials.hidden = this.hasSavedPassword !== false;
|
||||||
const attemptAt = typeof status?.next_attempt_at === 'string' ? Date.parse(status.next_attempt_at) : NaN;
|
const attemptAt = typeof status?.next_attempt_at === 'string' ? Date.parse(status.next_attempt_at) : NaN;
|
||||||
this.autoReloginCountdown.hidden = !Number.isFinite(attemptAt);
|
this.autoReloginCountdown.hidden = !Number.isFinite(attemptAt);
|
||||||
@@ -82,6 +81,7 @@ class LoginPage {
|
|||||||
const countdown = remaining ? `${remaining} 秒后自动重新登录(${chinaTime(status.next_attempt_at, {date: true})},北京时间)` : '等待服务端执行自动重登';
|
const countdown = remaining ? `${remaining} 秒后自动重新登录(${chinaTime(status.next_attempt_at, {date: true})},北京时间)` : '等待服务端执行自动重登';
|
||||||
if (this.autoReloginCountdown.textContent !== countdown) this.autoReloginCountdown.textContent = countdown;
|
if (this.autoReloginCountdown.textContent !== countdown) this.autoReloginCountdown.textContent = countdown;
|
||||||
}
|
}
|
||||||
|
this.autoReloginStatus.hidden = !message && this.autoReloginCountdown.hidden && this.autoReloginCredentials.hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOptions(select, options, placeholder) {
|
updateOptions(select, options, placeholder) {
|
||||||
@@ -105,11 +105,12 @@ export class PageView {
|
|||||||
this.query = initialQuery(key);
|
this.query = initialQuery(key);
|
||||||
this.filters = new Map();
|
this.filters = new Map();
|
||||||
this.data = null;
|
this.data = null;
|
||||||
this.root = el('section', {class: 'page-panel', role: 'tabpanel', 'aria-label': PAGES.find(page => page[0] === key)[1], 'data-page': key, hidden: true});
|
this.root = el('section', {class: 'page-panel', role: 'tabpanel', 'aria-label': PAGES.find(page => page[0] === key)[1], 'aria-busy': 'false', 'data-page': key, hidden: true});
|
||||||
this.header = el('div', {class: 'page-header'});
|
this.header = el('div', {class: 'page-header'});
|
||||||
this.title = el('h2', {text: PAGES.find(page => page[0] === key)[1]});
|
this.title = el('h2', {text: PAGES.find(page => page[0] === key)[1]});
|
||||||
this.loading = el('span', {class: 'page-loading', role: 'status', text: '正在读取…', 'data-loading': 'true'});
|
this.loading = el('div', {class: 'page-loading loading-state', role: 'status', 'aria-label': `正在加载${this.title.textContent}`, 'data-loading': 'false', hidden: true},
|
||||||
this.header.append(this.title, this.loading);
|
el('span', {class: 'loading-spinner', 'aria-hidden': 'true'}));
|
||||||
|
this.header.append(this.title);
|
||||||
this.errorBox = el('div', {class: 'page-error', role: 'alert', hidden: true});
|
this.errorBox = el('div', {class: 'page-error', role: 'alert', hidden: true});
|
||||||
this.error = error => { this.showError(error.message || String(error)); notice(error.message || String(error), true); };
|
this.error = error => { this.showError(error.message || String(error)); notice(error.message || String(error), true); };
|
||||||
this.subtabs = el('div', {class: 'subtabs', role: 'tablist', 'aria-label': '子页面', hidden: true});
|
this.subtabs = el('div', {class: 'subtabs', role: 'tablist', 'aria-label': '子页面', hidden: true});
|
||||||
@@ -119,18 +120,32 @@ export class PageView {
|
|||||||
this.formHost = el('div', {class: 'policy-form'});
|
this.formHost = el('div', {class: 'policy-form'});
|
||||||
this.actionsHost = el('div', {class: 'page-toolbar'});
|
this.actionsHost = el('div', {class: 'page-toolbar'});
|
||||||
this.content = el('div', {class: 'page-content'});
|
this.content = el('div', {class: 'page-content'});
|
||||||
this.notes = el('div', {class: 'info-note'});
|
|
||||||
this.context = {get: (path, fallback) => getPath(account.config, path, fallback), set: (path, value, field, row) => options.edit(account, path, value, field, row),
|
this.context = {get: (path, fallback) => getPath(account.config, path, fallback), set: (path, value, field, row) => options.edit(account, path, value, field, row),
|
||||||
dirty: path => account.edits.has(pathKey(path)), onError: this.error, onSelection: () => this.syncActions(),
|
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)};
|
onContext: (event, selected, row) => this.openContext(event, selected, row), onDetail: row => this.showDetail(row)};
|
||||||
this.form = new PolicyForm(this.formHost, this.context);
|
this.form = new PolicyForm(this.formHost, this.context);
|
||||||
this.root.append(this.header, this.errorBox, this.subtabs, this.filterHost, this.summary, this.runtimeStatus, this.formHost, this.actionsHost, this.content, this.notes);
|
this.surface = el('div', {class: 'page-surface'}, this.errorBox, this.subtabs, this.filterHost, this.summary, this.runtimeStatus, 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);
|
if (key === 'login') this.login = new LoginPage(this.content, this);
|
||||||
tabKeys(this.subtabs, '.subtab');
|
tabKeys(this.subtabs, '.subtab');
|
||||||
}
|
}
|
||||||
|
|
||||||
perform(operation, payload = {}) { return this.options.perform(this.account, operation, payload, {page: this}); }
|
perform(operation, payload = {}) { return this.options.perform(this.account, operation, payload, {page: this}); }
|
||||||
showError(message) { this.errorBox.replaceChildren(el('span', {text: message}), el('button', {text: '重新读取', type: 'button', onClick: () => this.options.load(this, true)})); this.errorBox.hidden = false; }
|
setLoading(loading) {
|
||||||
|
const busy = Boolean(loading && !this.root.hidden && this.root.isConnected);
|
||||||
|
if (this.loading.dataset.loading === String(busy)) return;
|
||||||
|
clearTimeout(this.loadingTimer);
|
||||||
|
this.root.setAttribute('aria-busy', String(busy));
|
||||||
|
this.loading.dataset.loading = String(busy);
|
||||||
|
this.loading.hidden = true;
|
||||||
|
// Skip the visual flash for fast reads; expose busy status immediately.
|
||||||
|
if (busy) this.loadingTimer = setTimeout(() => {
|
||||||
|
if (!this.root.hidden && this.root.isConnected) this.loading.hidden = false;
|
||||||
|
else this.setLoading(false);
|
||||||
|
}, 150);
|
||||||
|
}
|
||||||
|
showError(message) { this.setLoading(false); this.errorBox.replaceChildren(el('span', {text: message}), el('button', {text: '重新读取', type: 'button', onClick: () => this.options.load(this, true)})); this.errorBox.hidden = false; }
|
||||||
clearError() { this.errorBox.hidden = true; }
|
clearError() { this.errorBox.hidden = true; }
|
||||||
|
|
||||||
setQuery(key, value) {
|
setQuery(key, value) {
|
||||||
@@ -219,15 +234,14 @@ export class PageView {
|
|||||||
$$('button[data-selection]', this.actionsHost).forEach(button => { button.disabled = !selected; });
|
$$('button[data-selection]', this.actionsHost).forEach(button => { button.disabled = !selected; });
|
||||||
}
|
}
|
||||||
|
|
||||||
render(data, loading = false) {
|
render(data) {
|
||||||
if (!data) { this.loading.textContent = '正在读取…'; this.loading.dataset.loading = 'true'; return; }
|
if (!data) return;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.loading.dataset.loading = String(loading);
|
|
||||||
this.loading.textContent = loading ? '后台更新中…' : '已载入';
|
|
||||||
this.updateSubtabs(data);
|
this.updateSubtabs(data);
|
||||||
this.updateFilters(data.filters || []);
|
this.updateFilters(data.filters || []);
|
||||||
this.summary.textContent = typeof data.summary === 'string' ? data.summary : textValue(data.summary || '');
|
this.summary.textContent = typeof data.summary === 'string' ? data.summary : textValue(data.summary || '');
|
||||||
this.updateRuntimeStatus(data.details || {});
|
this.summary.hidden = !data.summary;
|
||||||
|
this.updateRuntimeStatus(data.details || {}, data.battle_mode);
|
||||||
let fields = data.form || this.options.schema(this.key);
|
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'));
|
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);
|
fields=fields.map(field=>field.path?.[0]==='policy'&&field.path[1]==='buy_ten'?{...field,disabled:!this.account.config?.policy?.allow_single_draw}:field);
|
||||||
@@ -238,11 +252,6 @@ export class PageView {
|
|||||||
if (this.login) { this.login.update(data); return; }
|
if (this.login) { this.login.update(data); return; }
|
||||||
this.content.hidden = policyTab;
|
this.content.hidden = policyTab;
|
||||||
if (policyTab) return;
|
if (policyTab) return;
|
||||||
const notes = data.notes || data.details?.note || data.details?.notes || data.details?.help || data.hint || '';
|
|
||||||
const noteText=Array.isArray(notes)?notes.join('\n'):typeof notes==='string'?notes:textValue(notes);
|
|
||||||
this.notes.textContent=[noteText,...(data.battle_mode?[data.battle_mode.label,data.battle_mode.damage_rule]:[])].filter(Boolean).join('\n');
|
|
||||||
this.notes.style.whiteSpace = 'pre-wrap';
|
|
||||||
this.notes.hidden = !this.notes.textContent;
|
|
||||||
const groups = data.groups || [];
|
const groups = data.groups || [];
|
||||||
const grouped = this.key === 'maps' || this.key === 'ranch' && (this.query.grouped === true || this.query.grouped === 'true');
|
const grouped = this.key === 'maps' || this.key === 'ranch' && (this.query.grouped === true || this.query.grouped === 'true');
|
||||||
const mode = this.key === 'statistics' ? 'statistics' : grouped ? 'grouped' : 'table';
|
const mode = this.key === 'statistics' ? 'statistics' : grouped ? 'grouped' : 'table';
|
||||||
@@ -250,7 +259,7 @@ export class PageView {
|
|||||||
if (this.content.contains(document.activeElement)) return;
|
if (this.content.contains(document.activeElement)) return;
|
||||||
this.content.replaceChildren();
|
this.content.replaceChildren();
|
||||||
this.contentMode = mode;
|
this.contentMode = mode;
|
||||||
this.table = mode === 'grouped' ? new GroupedTables(this.content, this.context, {collapsed: this.key === 'maps'}) : mode === 'table' ? new DataTable(this.content, this.context, {emptyMessage: this.key === 'plans' ? '当前没有执行计划。请配置策略并刷新 / 预览,查看下一步或等待原因。' : '当前筛选下没有条目。可调整筛选,或登录后刷新状态。'}) : null;
|
this.table = mode === 'grouped' ? new GroupedTables(this.content, this.context, {collapsed: this.key === 'maps'}) : mode === 'table' ? new DataTable(this.content, this.context, {emptyMessage: this.key === 'plans' ? '当前没有执行计划。' : '当前筛选下没有条目。'}) : null;
|
||||||
if (mode === 'statistics') this.buildStatistics();
|
if (mode === 'statistics') this.buildStatistics();
|
||||||
}
|
}
|
||||||
if (mode === 'statistics') this.renderStatistics(data);
|
if (mode === 'statistics') this.renderStatistics(data);
|
||||||
@@ -260,7 +269,7 @@ export class PageView {
|
|||||||
} else this.table.update(data.columns || [], data.rows || []);
|
} else this.table.update(data.columns || [], data.rows || []);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRuntimeStatus(details) {
|
updateRuntimeStatus(details, battleMode) {
|
||||||
const lines=[];
|
const lines=[];
|
||||||
if(this.key==='hatching'){
|
if(this.key==='hatching'){
|
||||||
if(this.activeSubtab==='喂养策略' && Array.isArray(details.feed_status))lines.push(['feed_status','当前喂养状态:'+textValue(details.feed_status[1])]);
|
if(this.activeSubtab==='喂养策略' && Array.isArray(details.feed_status))lines.push(['feed_status','当前喂养状态:'+textValue(details.feed_status[1])]);
|
||||||
@@ -270,7 +279,16 @@ export class PageView {
|
|||||||
const ready=details.next_ready_at;
|
const ready=details.next_ready_at;
|
||||||
lines.push(['next_ready_at',ready===null?'下次赠礼:当前没有符合条件的目标或物品,等待状态更新':'下次可赠礼:'+chinaTime(ready,{date:true})+'(北京时间)']);
|
lines.push(['next_ready_at',ready===null?'下次赠礼:当前没有符合条件的目标或物品,等待状态更新':'下次可赠礼:'+chinaTime(ready,{date:true})+'(北京时间)']);
|
||||||
}
|
}
|
||||||
this.runtimeStatus.replaceChildren(...lines.map(([key,text])=>el('p',{'data-view-status':key,text})));
|
// 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;
|
this.runtimeStatus.hidden=!lines.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +297,7 @@ export class PageView {
|
|||||||
if (!data) return;
|
if (!data) return;
|
||||||
const labels = {name:'名称',species:'种类',id:'魔物ID',level:'等级 / 当前上限',quality:'资质 攻/防/血/敏',reference_stats:'参考攻击 / 防御 / 生命 / 敏捷',growth:'成长数值',likes:'喜欢的物品',feel:'好感 / 上限',feed_exp:'喂养经验',scope:'管理范围'};
|
const labels = {name:'名称',species:'种类',id:'魔物ID',level:'等级 / 当前上限',quality:'资质 攻/防/血/敏',reference_stats:'参考攻击 / 防御 / 生命 / 敏捷',growth:'成长数值',likes:'喜欢的物品',feel:'好感 / 上限',feed_exp:'喂养经验',scope:'管理范围'};
|
||||||
const title=this.key==='ranch'?'魔物详情':this.key==='mainline'?'任务详情':this.key==='battles'?'战斗详情':'详情';
|
const title=this.key==='ranch'?'魔物详情':this.key==='mainline'?'任务详情':this.key==='battles'?'战斗详情':'详情';
|
||||||
dialog(title, el('div', {class:'detail-sections'}, detailsList(data, labels), this.key==='ranch'?el('p', {class:'info-note',text:'参考属性不含装备、羁绊或全局加成。'}):null), {info:true});
|
dialog(title, el('div', {class:'detail-sections'}, detailsList(data, labels)), {info:true});
|
||||||
}
|
}
|
||||||
|
|
||||||
openContext(event, selected, row) {
|
openContext(event, selected, row) {
|
||||||
@@ -296,7 +314,7 @@ export class PageView {
|
|||||||
this.statisticsPicker = el('div', {class:'statistics-picker',role:'listbox','aria-label':'关卡 / 难度'});
|
this.statisticsPicker = el('div', {class:'statistics-picker',role:'listbox','aria-label':'关卡 / 难度'});
|
||||||
this.chart = el('div',{class:'chart-scroll','aria-label':'掉落统计图'});
|
this.chart = el('div',{class:'chart-scroll','aria-label':'掉落统计图'});
|
||||||
this.statisticsTableHost = el('div',{class:'statistics-table-host'});
|
this.statisticsTableHost = el('div',{class:'statistics-table-host'});
|
||||||
this.statisticsTable = new DataTable(this.statisticsTableHost,this.context,{selection:false,emptyMessage:'所选关卡尚无已确认样本;完成扫荡后将显示实际统计。'});
|
this.statisticsTable = new DataTable(this.statisticsTableHost,this.context,{selection:false,emptyMessage:'所选关卡尚无已确认样本。'});
|
||||||
this.statisticsSummary = el('p',{class:'page-summary'});
|
this.statisticsSummary = el('p',{class:'page-summary'});
|
||||||
this.content.append(el('div',{class:'statistics-layout'},this.statisticsPicker,el('div',{class:'statistics-main'},this.statisticsSummary,this.chart,this.statisticsTableHost)));
|
this.content.append(el('div',{class:'statistics-layout'},this.statisticsPicker,el('div',{class:'statistics-main'},this.statisticsSummary,this.chart,this.statisticsTableHost)));
|
||||||
}
|
}
|
||||||
@@ -358,7 +376,7 @@ export class PageView {
|
|||||||
if (this.chartSignature === signature) return;
|
if (this.chartSignature === signature) return;
|
||||||
this.chartSignature = signature;
|
this.chartSignature = signature;
|
||||||
this.chart.replaceChildren();
|
this.chart.replaceChildren();
|
||||||
if (!bars.length) { this.chart.append(empty(emptyReason || '暂无已确认的统计样本。图表将随实际扫荡记录生成。')); return; }
|
if (!bars.length) { this.chart.append(empty(emptyReason || '暂无已确认的统计样本。')); return; }
|
||||||
const ns='http://www.w3.org/2000/svg', width=760, height=Math.max(120,bars.length*29+50), labelWidth=175;
|
const ns='http://www.w3.org/2000/svg', width=760, height=Math.max(120,bars.length*29+50), labelWidth=175;
|
||||||
const svg=document.createElementNS(ns,'svg');
|
const svg=document.createElementNS(ns,'svg');
|
||||||
svg.setAttribute('viewBox',`0 0 ${width} ${height}`);svg.setAttribute('class','drop-chart');svg.setAttribute('role','img');svg.setAttribute('aria-label',metric==='per_stamina'?'每点体力掉落数量':'实测掉落率');
|
svg.setAttribute('viewBox',`0 0 ${width} ${height}`);svg.setAttribute('class','drop-chart');svg.setAttribute('role','img');svg.setAttribute('aria-label',metric==='per_stamina'?'每点体力掉落数量':'实测掉落率');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
*{box-sizing:border-box}body{margin:0}button,input,select,textarea{font:inherit;color:inherit}button,select,input[type=number],input[type=text],input[type=password],input[type=search],textarea{border:1px solid #afb8c2;border-radius:3px;background:#fff;min-height:27px}button{padding:3px 10px;cursor:pointer;white-space:nowrap;background:#f8f9fb}button:hover{background:#e9edf2;border-color:#8291a1}button:active{background:#dce4ed}button:disabled,input:disabled,select:disabled{cursor:default;opacity:.58}input,select{padding:2px 6px}input[type=checkbox]{width:14px;height:14px;min-height:0;margin:0 4px 0 0;accent-color:var(--accent);vertical-align:middle;flex-shrink:0}input[type=number]{font-variant-numeric:tabular-nums;min-width:62px;width:88px}input[type=search]{min-width:170px}select{max-width:100%}textarea{padding:6px;resize:vertical;min-height:60px}button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex]:focus-visible,a:focus-visible{outline:2px solid var(--accent);outline-offset:2px}::selection{background:#c5dbf5;color:#142b46}input,textarea{caret-color:var(--accent)}[hidden]{display:none!important}h1,h2,h3,p{margin:0}h1{font-size:16px;font-weight:600}h2,h3{font-size:14px;font-weight:600}p{line-height:1.65}a{color:var(--accent);text-underline-offset:3px}.muted{color:var(--muted);font-size:12px}.spacer{flex:1}.primary{background:#245d9b;color:#fff;border-color:#245d9b}.primary:hover{background:#1c4d83;color:#fff}.danger{color:#94231d;border-color:#c39c99}.error-text{color:#99251e;white-space:pre-wrap;overflow-wrap:anywhere}.small,.compact{min-height:24px;padding:2px 8px;font-size:12px}
|
*{box-sizing:border-box}body{margin:0}button,input,select,textarea{font:inherit;color:inherit}button,select,input[type=number],input[type=text],input[type=password],input[type=search],textarea{border:1px solid #afb8c2;border-radius:3px;background:#fff;min-height:27px}button{padding:3px 10px;cursor:pointer;white-space:nowrap;background:#f8f9fb}button:hover{background:#e9edf2;border-color:#8291a1}button:active{background:#dce4ed}button:disabled,input:disabled,select:disabled{cursor:default;opacity:.58}input,select{padding:2px 6px}input[type=checkbox]{width:14px;height:14px;min-height:0;margin:0 4px 0 0;accent-color:var(--accent);vertical-align:middle;flex-shrink:0}input[type=number]{font-variant-numeric:tabular-nums;min-width:62px;width:88px}input[type=search]{min-width:170px}select{max-width:100%}textarea{padding:6px;resize:vertical;min-height:60px}button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex]:focus-visible,a:focus-visible{outline:2px solid var(--accent);outline-offset:2px}::selection{background:#c5dbf5;color:#142b46}input,textarea{caret-color:var(--accent)}[hidden]{display:none!important}h1,h2,h3,p{margin:0}h1{font-size:16px;font-weight:600}h2,h3{font-size:14px;font-weight:600}p{line-height:1.65}a{color:var(--accent);text-underline-offset:3px}.muted{color:var(--muted);font-size:12px}.spacer{flex:1}.primary{background:#245d9b;color:#fff;border-color:#245d9b}.primary:hover{background:#1c4d83;color:#fff}.danger{color:#94231d;border-color:#c39c99}.error-text{color:#99251e;white-space:pre-wrap;overflow-wrap:anywhere}.small,.compact{min-height:24px;padding:2px 8px;font-size:12px}
|
||||||
.workbench{height:100dvh;min-height:420px;display:flex;flex-direction:column;overflow:hidden}.window-header{display:flex;align-items:center;min-height:29px;gap:16px;padding:0 10px 0 4px;border-bottom:1px solid var(--border);background:#f6f7f9}.window-title{font-size:12px;color:#404c59}.window-title #app-version{margin-left:5px;color:var(--muted)}#access-mode{margin-left:auto}.menu-bar{display:flex;gap:1px}.menu{position:relative}.menu>summary{list-style:none;padding:5px 9px;cursor:pointer;border-radius:2px}.menu>summary::-webkit-details-marker{display:none}.menu[open]>summary,.menu>summary:hover{background:#dfe8f3}.access-key{font-size:11px;margin-left:3px;color:var(--muted)}.menu-popup{position:absolute;top:100%;left:0;z-index:30;min-width:220px;padding:4px;background:#fff;border:1px solid #acb6c1;box-shadow:0 5px 14px #172a4026}.menu-popup button{display:block;width:100%;border:0;border-radius:0;text-align:left;background:transparent;padding:6px 12px}.menu-popup button:hover{background:var(--tint)}.menu-popup hr{border:0;border-top:1px solid var(--border);margin:4px 2px}
|
.workbench{height:100dvh;min-height:420px;display:flex;flex-direction:column;overflow:hidden}.window-header{display:flex;align-items:center;min-height:29px;gap:16px;padding:0 10px 0 4px;border-bottom:1px solid var(--border);background:#f6f7f9}.window-title{font-size:12px;color:#404c59}.window-title #app-version{margin-left:5px;color:var(--muted)}#access-mode{margin-left:auto}.menu-bar{display:flex;gap:1px}.menu{position:relative}.menu>summary{list-style:none;padding:5px 9px;cursor:pointer;border-radius:2px}.menu>summary::-webkit-details-marker{display:none}.menu[open]>summary,.menu>summary:hover{background:#dfe8f3}.access-key{font-size:11px;margin-left:3px;color:var(--muted)}.menu-popup{position:absolute;top:100%;left:0;z-index:30;min-width:220px;padding:4px;background:#fff;border:1px solid #acb6c1;box-shadow:0 5px 14px #172a4026}.menu-popup button{display:block;width:100%;border:0;border-radius:0;text-align:left;background:transparent;padding:6px 12px}.menu-popup button:hover{background:var(--tint)}.menu-popup hr{border:0;border-top:1px solid var(--border);margin:4px 2px}
|
||||||
.account-bar{display:flex;gap:6px;align-items:center;padding:5px 6px 0;min-height:36px;background:#e7ebef;border-bottom:1px solid var(--border)}.account-tabs{display:flex;overflow-x:auto;gap:3px;align-self:stretch;min-width:0;scrollbar-width:thin}.account-tab{border-radius:4px 4px 0 0;border:1px solid var(--border);border-bottom:0;display:flex;gap:6px;align-items:center;max-width:230px;background:#f1f3f5;min-height:30px;padding:4px 13px}.account-tab[aria-selected=true]{background:#fff;box-shadow:inset 0 2px 0 var(--accent)}.account-tab .account-label{overflow:hidden;text-overflow:ellipsis}.account-dot{width:6px;height:6px;border-radius:50%;background:#7b8490;flex-shrink:0}.account-dot.running{background:var(--green)}.account-dot.error{background:var(--danger)}#add-account{margin:0 0 5px;flex-shrink:0}.toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:8px 18px;padding:8px 8px 5px;background:#fff}.player-line{display:flex;align-items:center;flex-wrap:wrap;gap:12px;min-height:27px;flex:1 1 auto}.player-line>span{white-space:nowrap}.player-line b{font-weight:600;font-variant-numeric:tabular-nums}.player-line>strong{max-width:180px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.connection{font-size:12px;color:var(--muted)}.connection.online{color:#176331}.connection.demo{color:#805300}.experience{display:inline-flex;gap:5px;align-items:center}progress{width:58px;height:6px;accent-color:var(--accent)}progress::-webkit-progress-bar{background:#e2e7ee;border-radius:2px}progress::-webkit-progress-value{background:#467aa9;border-radius:2px}.run-controls{display:flex;align-items:center;gap:5px;flex-wrap:wrap}.run-controls>label{display:flex;align-items:center;gap:5px}.run-button{min-width:76px;font-weight:600;background:var(--green);border-color:#185b2d;color:#fff}.run-button:hover{background:#1b6332;color:#fff;border-color:#185b2d}.run-button.running{background:var(--danger);border-color:#8f1e18}.run-button.running:hover{background:#992019}.run-button:disabled{opacity:1;background:#727b82;border-color:#727b82}.summary-line{display:flex;gap:10px;align-items:center;min-height:25px;padding:2px 8px 5px;background:#fff;font-size:12px;color:var(--muted)}#data-summary{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1}#save-status{flex-shrink:0}#save-status.pending{color:#805300}#save-status.failed{color:#99251e}
|
.account-bar{display:flex;gap:6px;align-items:center;padding:5px 6px 0;min-height:36px;background:#e7ebef;border-bottom:1px solid var(--border)}.account-tabs{display:flex;overflow-x:auto;gap:3px;align-self:stretch;min-width:0;scrollbar-width:thin}.account-tab{border-radius:4px 4px 0 0;border:1px solid var(--border);border-bottom:0;display:flex;gap:6px;align-items:center;max-width:230px;background:#f1f3f5;min-height:30px;padding:4px 13px}.account-tab[aria-selected=true]{background:#fff;box-shadow:inset 0 2px 0 var(--accent)}.account-tab .account-label{overflow:hidden;text-overflow:ellipsis}.account-dot{width:6px;height:6px;border-radius:50%;background:#7b8490;flex-shrink:0}.account-dot.running{background:var(--green)}.account-dot.error{background:var(--danger)}#add-account{margin:0 0 5px;flex-shrink:0}.toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:8px 18px;padding:8px 8px 5px;background:#fff}.player-line{display:flex;align-items:center;flex-wrap:wrap;gap:12px;min-height:27px;flex:1 1 auto}.player-line>span{white-space:nowrap}.player-line b{font-weight:600;font-variant-numeric:tabular-nums}.player-line>strong{max-width:180px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.connection{font-size:12px;color:var(--muted)}.connection.online{color:#176331}.connection.demo{color:#805300}.experience{display:inline-flex;gap:5px;align-items:center}progress{width:58px;height:6px;accent-color:var(--accent)}progress::-webkit-progress-bar{background:#e2e7ee;border-radius:2px}progress::-webkit-progress-value{background:#467aa9;border-radius:2px}.run-controls{display:flex;align-items:center;gap:5px;flex-wrap:wrap}.run-controls>label{display:flex;align-items:center;gap:5px}.run-button{min-width:76px;font-weight:600;background:var(--green);border-color:#185b2d;color:#fff}.run-button:hover{background:#1b6332;color:#fff;border-color:#185b2d}.run-button.running{background:var(--danger);border-color:#8f1e18}.run-button.running:hover{background:#992019}.run-button:disabled{opacity:1;background:#727b82;border-color:#727b82}.summary-line{display:flex;gap:10px;align-items:center;min-height:25px;padding:2px 8px 5px;background:#fff;font-size:12px;color:var(--muted)}#data-summary{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1}#save-status{flex-shrink:0}#save-status.pending{color:#805300}#save-status.failed{color:#99251e}
|
||||||
.workspace{display:flex;flex-direction:column;flex:1;min-height:155px;padding:0 6px;overflow:hidden;background:#fff}.page-tabs{display:flex;flex-shrink:0;overflow-x:auto;gap:0;border-bottom:1px solid #9eabb9;scrollbar-width:thin}.page-tab{border-radius:3px 3px 0 0;border:1px solid transparent;background:#f1f3f5;padding:6px 10px;min-height:30px;margin-right:1px;font-size:12px}.page-tab[aria-selected=true]{background:#fff;border-color:#9eabb9;border-bottom-color:#fff;color:#174d83;box-shadow:inset 0 2px 0 #245d9b;font-weight:600}.page-tab:hover{background:#e8f0f9}.page-host{flex:1;min-height:0;overflow:hidden;position:relative}.page-panel{height:100%;display:flex;flex-direction:column;overflow:auto;padding:7px 2px 4px;gap:7px;scrollbar-gutter:stable}.page-header{display:flex;gap:8px;align-items:center;flex-wrap:wrap;min-height:25px}.page-header h2{margin-right:7px}.page-summary{color:var(--muted);font-size:12px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}.page-toolbar,.filter-bar{display:flex;flex-wrap:wrap;gap:5px 9px;align-items:center}.filter-bar label{display:inline-flex;gap:5px;align-items:center}.page-loading{font-size:12px;color:var(--muted);margin-left:auto}.page-loading[data-loading=true]::before{content:"";display:inline-block;width:7px;height:7px;background:#688aaf;border-radius:50%;margin-right:5px}.subtabs{display:flex;gap:2px;border-bottom:1px solid var(--border);flex-shrink:0}.subtab{background:#f0f2f5;border:1px solid var(--border);border-bottom:0;border-radius:3px 3px 0 0;font-size:12px;padding:4px 10px}.subtab[aria-selected=true]{background:#e8f0f9;color:#174d83;border-color:#94adc7}.initial-state,.empty-state{padding:24px 18px;color:var(--muted);line-height:1.8}.empty-state p{max-width:65ch}.empty-state button{margin-top:12px}.page-error{padding:8px 10px;background:#fff4f3;border:1px solid #ddbbb7;color:#8e251f;display:flex;align-items:center;gap:10px;white-space:pre-wrap}.info-note{font-size:12px;color:var(--muted);line-height:1.65;padding:5px 0;max-width:115ch}.inline-note{color:var(--muted);font-size:12px}
|
.workspace{display:flex;flex-direction:column;flex:1;min-height:155px;padding:0 6px;overflow:hidden;background:#fff}.page-tabs{display:flex;flex-shrink:0;overflow-x:auto;gap:0;border-bottom:1px solid #9eabb9;scrollbar-width:thin}.page-tab{border-radius:3px 3px 0 0;border:1px solid transparent;background:#f1f3f5;padding:6px 10px;min-height:30px;margin-right:1px;font-size:12px}.page-tab[aria-selected=true]{background:#fff;border-color:#9eabb9;border-bottom-color:#fff;color:#174d83;box-shadow:inset 0 2px 0 #245d9b;font-weight:600}.page-tab:hover{background:#e8f0f9}.page-host{flex:1;min-height:0;overflow:hidden;position:relative}.page-panel{height:100%;display:flex;flex-direction:column;overflow:auto;padding:7px 2px 4px;gap:7px;scrollbar-gutter:stable}.page-header{display:flex;gap:8px;align-items:center;flex-wrap:wrap;min-height:25px}.page-header h2{margin-right:7px}.page-summary{color:var(--muted);font-size:12px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}.page-toolbar,.filter-bar{display:flex;flex-wrap:wrap;gap:5px 9px;align-items:center}.filter-bar label{display:inline-flex;gap:5px;align-items:center}.subtabs{display:flex;gap:2px;border-bottom:1px solid var(--border);flex-shrink:0}.subtab{background:#f0f2f5;border:1px solid var(--border);border-bottom:0;border-radius:3px 3px 0 0;font-size:12px;padding:4px 10px}.subtab[aria-selected=true]{background:#e8f0f9;color:#174d83;border-color:#94adc7}.initial-state,.empty-state{padding:24px 18px;color:var(--muted);line-height:1.8}.empty-state p{max-width:65ch}.empty-state button{margin-top:12px}.page-error{padding:8px 10px;background:#fff4f3;border:1px solid #ddbbb7;color:#8e251f;display:flex;align-items:center;gap:10px;white-space:pre-wrap}.info-note{font-size:12px;color:var(--muted);line-height:1.65;padding:5px 0;max-width:115ch}.inline-note{color:var(--muted);font-size:12px}
|
||||||
.table-scroll{overflow:auto;min-height:80px;flex:1;border:1px solid var(--border);background:#fff;position:relative}.data-table{border-collapse:separate;border-spacing:0;width:100%;font-size:12px;white-space:nowrap;text-align:left;font-variant-numeric:tabular-nums}.data-table th{position:sticky;top:0;z-index:2;background:#eef1f5;color:#303d4c;font-weight:500;border-bottom:1px solid #bac4cf;border-right:1px solid #d5dbe2;height:28px;padding:3px 8px;white-space:nowrap}.data-table th button{font:inherit;border:0;background:transparent;padding:0;min-height:20px;display:flex;align-items:center;gap:6px;width:100%;text-align:left}.data-table th .sort-mark{color:#506a85;font-size:10px;min-width:8px}.data-table td{border-bottom:1px solid #e4e8ed;border-right:1px solid #eef0f3;padding:2px 7px;height:29px;max-width:300px;overflow:hidden;text-overflow:ellipsis}.data-table tr:nth-child(even)>td{background:#fafbfc}.data-table tr:hover>td{background:#f0f5fa}.data-table tr[aria-selected=true]>td{background:#dfecfa}.data-table td.number{text-align:right}.data-table td.cell-edit{padding:2px 4px;overflow:visible}.data-table td.cell-edit input[type=number]{min-height:24px;height:24px;width:76px;font-size:12px}.data-table td.cell-edit select{min-height:24px;height:24px;font-size:12px;max-width:220px}.data-table td.cell-edit input[type=text]{min-height:24px;width:140px;font-size:12px}.data-table .selection-cell{width:29px;min-width:29px;text-align:center;padding:0 5px;position:sticky;left:0;z-index:1}.data-table th.selection-cell{z-index:3}.data-table .cell-wrap{white-space:normal;min-width:190px;line-height:1.5}.data-table .cell-ellipsis{max-width:260px}.data-table .cell-boolean{color:#176331}.table-footer{display:flex;gap:12px;align-items:center;min-height:20px;font-size:12px;color:var(--muted)}.table-footer>button{margin-left:auto}.grouped-tables{display:flex;flex-direction:column;gap:5px;overflow:auto;flex:1;min-height:100px}.table-group{border:1px solid var(--border);background:#fff}.table-group>summary{cursor:pointer;font-weight:600;font-size:12px;padding:7px 9px;background:#eef1f5;position:sticky;top:0;z-index:3}.table-group>summary small{font-weight:400;color:var(--muted);margin-left:10px}.table-group .table-scroll{border:0;max-height:410px}.table-group .data-table th{top:0}.table-group .table-footer{padding:3px 8px}
|
.table-scroll{overflow:auto;min-height:80px;flex:1;border:1px solid var(--border);background:#fff;position:relative}.data-table{border-collapse:separate;border-spacing:0;width:100%;font-size:12px;white-space:nowrap;text-align:left;font-variant-numeric:tabular-nums}.data-table th{position:sticky;top:0;z-index:2;background:#eef1f5;color:#303d4c;font-weight:500;border-bottom:1px solid #bac4cf;border-right:1px solid #d5dbe2;height:28px;padding:3px 8px;white-space:nowrap}.data-table th button{font:inherit;border:0;background:transparent;padding:0;min-height:20px;display:flex;align-items:center;gap:6px;width:100%;text-align:left}.data-table th .sort-mark{color:#506a85;font-size:10px;min-width:8px}.data-table td{border-bottom:1px solid #e4e8ed;border-right:1px solid #eef0f3;padding:2px 7px;height:29px;max-width:300px;overflow:hidden;text-overflow:ellipsis}.data-table tr:nth-child(even)>td{background:#fafbfc}.data-table tr:hover>td{background:#f0f5fa}.data-table tr[aria-selected=true]>td{background:#dfecfa}.data-table td.number{text-align:right}.data-table td.cell-edit{padding:2px 4px;overflow:visible}.data-table td.cell-edit input[type=number]{min-height:24px;height:24px;width:76px;font-size:12px}.data-table td.cell-edit select{min-height:24px;height:24px;font-size:12px;max-width:220px}.data-table td.cell-edit input[type=text]{min-height:24px;width:140px;font-size:12px}.data-table .selection-cell{width:29px;min-width:29px;text-align:center;padding:0 5px;position:sticky;left:0;z-index:1}.data-table th.selection-cell{z-index:3}.data-table .cell-wrap{white-space:normal;min-width:190px;line-height:1.5}.data-table .cell-ellipsis{max-width:260px}.data-table .cell-boolean{color:#176331}.table-footer{display:flex;gap:12px;align-items:center;min-height:20px;font-size:12px;color:var(--muted)}.table-footer>button{margin-left:auto}.grouped-tables{display:flex;flex-direction:column;gap:5px;overflow:auto;flex:1;min-height:100px}.table-group{border:1px solid var(--border);background:#fff}.table-group>summary{cursor:pointer;font-weight:600;font-size:12px;padding:7px 9px;background:#eef1f5;position:sticky;top:0;z-index:3}.table-group>summary small{font-weight:400;color:var(--muted);margin-left:10px}.table-group .table-scroll{border:0;max-height:410px}.table-group .data-table th{top:0}.table-group .table-footer{padding:3px 8px}
|
||||||
.policy-form{display:flex;flex-direction:column;gap:9px;flex-shrink:0}.form-section{margin:0;border:1px solid #d6dce3;padding:7px 10px 10px;min-width:0}.form-section legend{font-size:12px;font-weight:600;padding:0 5px;color:#344458}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(270px,1fr));gap:7px 22px;max-width:1100px}.field{display:flex;align-items:center;gap:8px;min-width:0;font-size:12px}.field>.field-label{min-width:135px;flex:0 1 195px;line-height:1.5}.field>.field-input{flex:1;min-width:0;max-width:310px}.field input[type=number].field-input{max-width:130px}.field.checkbox-field{min-height:27px}.field-help{font-size:12px;color:var(--muted);line-height:1.5;display:block;grid-column:1/-1}.field-wide{grid-column:1/-1}.field.invalid input{border-color:var(--danger)}.field[data-dirty=true] .field-label::after{content:" ·";color:#805300}.inline-editor{display:inline-flex;align-items:center;gap:3px}.multi-select{display:flex;flex-wrap:wrap;gap:4px 12px;padding:4px 0;min-width:0}.multi-select label{display:inline-flex;align-items:center;gap:2px}.member-selects{display:flex;gap:3px;flex-wrap:wrap;align-items:center}.member-selects select{width:165px}.member-selects button{min-height:24px}.login-layout{max-width:790px;display:flex;flex-direction:column;gap:10px;padding:4px 8px}.login-layout .form-grid{grid-template-columns:1fr}.login-layout input[type=text],.login-layout input[type=password]{width:320px;max-width:100%}.login-layout .field>.field-label{flex-basis:145px;min-width:145px}.login-layout .field>.field-input{max-width:none}.login-options{display:flex;gap:14px;margin-left:153px;font-size:12px}.login-actions{display:flex;gap:6px;margin-left:153px;flex-wrap:wrap}.server-row{display:flex;gap:6px;flex:1;min-width:0}.server-row select{min-width:180px;flex:1}.session-block{margin-top:4px;padding-top:14px;border-top:1px solid var(--border)}.demo-note{font-size:12px;color:#805300;background:#fff9ea;border:1px solid #e1d0a7;padding:6px 9px;line-height:1.6}.detail-list{display:grid;grid-template-columns:max-content 1fr;gap:6px 18px;font-size:12px}.detail-list dt{color:var(--muted)}.detail-list dd{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}.detail-sections{display:flex;flex-direction:column;gap:12px}.statistics-layout{display:flex;gap:9px;min-height:180px;flex:1}.statistics-picker{width:260px;flex-shrink:0;overflow:auto;border:1px solid var(--border)}.statistics-picker button{display:block;border:0;border-radius:0;width:100%;text-align:left;overflow:hidden;text-overflow:ellipsis;font-size:12px}.statistics-picker button[aria-selected=true]{background:var(--tint);color:#174d83}.statistics-main{min-width:0;flex:1;display:flex;flex-direction:column;gap:8px}.chart-scroll{min-height:120px;max-height:310px;overflow:auto;border:1px solid var(--border);padding:8px}.drop-chart{display:block;min-width:450px;width:100%;height:auto}.chart-label{font-size:12px;fill:#344458}.chart-value{font-size:11px;fill:#344458;font-variant-numeric:tabular-nums}.chart-bar{fill:#4979a4}.chart-grid{stroke:#e3e7ed;stroke-width:1}
|
.policy-form{display:flex;flex-direction:column;gap:9px;flex-shrink:0}.form-section{margin:0;border:1px solid #d6dce3;padding:7px 10px 10px;min-width:0}.form-section legend{font-size:12px;font-weight:600;padding:0 5px;color:#344458}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(270px,1fr));gap:7px 22px;max-width:1100px}.field{display:flex;align-items:center;gap:8px;min-width:0;font-size:12px}.field>.field-label{min-width:135px;flex:0 1 195px;line-height:1.5}.field>.field-input{flex:1;min-width:0;max-width:310px}.field input[type=number].field-input{max-width:130px}.field.checkbox-field{min-height:27px}.field-help{font-size:12px;color:var(--muted);line-height:1.5;display:block;grid-column:1/-1}.field-wide{grid-column:1/-1}.field.invalid input{border-color:var(--danger)}.field[data-dirty=true] .field-label::after{content:" ·";color:#805300}.inline-editor{display:inline-flex;align-items:center;gap:3px}.multi-select{display:flex;flex-wrap:wrap;gap:4px 12px;padding:4px 0;min-width:0}.multi-select label{display:inline-flex;align-items:center;gap:2px}.member-selects{display:flex;gap:3px;flex-wrap:wrap;align-items:center}.member-selects select{width:165px}.member-selects button{min-height:24px}.login-layout{max-width:790px;display:flex;flex-direction:column;gap:10px;padding:4px 8px}.login-layout .form-grid{grid-template-columns:1fr}.login-layout input[type=text],.login-layout input[type=password]{width:320px;max-width:100%}.login-layout .field>.field-label{flex-basis:145px;min-width:145px}.login-layout .field>.field-input{max-width:none}.login-options{display:flex;gap:14px;margin-left:153px;font-size:12px}.login-actions{display:flex;gap:6px;margin-left:153px;flex-wrap:wrap}.server-row{display:flex;gap:6px;flex:1;min-width:0}.server-row select{min-width:180px;flex:1}.session-block{margin-top:4px;padding-top:14px;border-top:1px solid var(--border)}.demo-note{font-size:12px;color:#805300;background:#fff9ea;border:1px solid #e1d0a7;padding:6px 9px;line-height:1.6}.detail-list{display:grid;grid-template-columns:max-content 1fr;gap:6px 18px;font-size:12px}.detail-list dt{color:var(--muted)}.detail-list dd{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}.detail-sections{display:flex;flex-direction:column;gap:12px}.statistics-layout{display:flex;gap:9px;min-height:180px;flex:1}.statistics-picker{width:260px;flex-shrink:0;overflow:auto;border:1px solid var(--border)}.statistics-picker button{display:block;border:0;border-radius:0;width:100%;text-align:left;overflow:hidden;text-overflow:ellipsis;font-size:12px}.statistics-picker button[aria-selected=true]{background:var(--tint);color:#174d83}.statistics-main{min-width:0;flex:1;display:flex;flex-direction:column;gap:8px}.chart-scroll{min-height:120px;max-height:310px;overflow:auto;border:1px solid var(--border);padding:8px}.drop-chart{display:block;min-width:450px;width:100%;height:auto}.chart-label{font-size:12px;fill:#344458}.chart-value{font-size:11px;fill:#344458;font-variant-numeric:tabular-nums}.chart-bar{fill:#4979a4}.chart-grid{stroke:#e3e7ed;stroke-width:1}
|
||||||
.log-resizer{height:7px;min-height:7px;cursor:row-resize;background:#e3e7ec;position:relative;border-top:1px solid #b8c1cb;border-bottom:1px solid #c8d0d9}.log-resizer::after{content:"";position:absolute;width:34px;height:2px;background:#8f9ba8;left:calc(50% - 17px);top:2px}.log-resizer:hover{background:#cedbe9}.log-panel{height:var(--log-height);min-height:64px;max-height:55vh;display:flex;flex-direction:column;background:#fff}.log-toolbar{display:flex;gap:13px;align-items:center;padding:3px 8px;background:#f1f3f5;border-bottom:1px solid var(--border);min-height:29px;font-size:12px}.log-toolbar strong{font-weight:600}.log-toolbar label{display:flex;align-items:center;gap:2px}.log-lines{padding:4px 9px;overflow:auto;flex:1;font:12px/1.65 Consolas,"Microsoft YaHei UI",monospace;white-space:pre-wrap;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.log-entry{min-height:19px}.log-entry .log-time{color:#6a7480;margin-right:8px}.log-entry.error{color:#99251e}.log-entry.warning{color:#805300}.log-entry.debug{color:#55616e}.status-bar{min-height:24px;display:flex;align-items:center;gap:14px;padding:3px 8px;border-top:1px solid var(--border);background:#f1f3f5;font-size:12px;overflow:hidden;white-space:nowrap}.status-bar #status-text{overflow:hidden;text-overflow:ellipsis;max-width:50vw}.status-bar #job-status{overflow:hidden;text-overflow:ellipsis}.notice{position:fixed;right:16px;bottom:35px;max-width:min(540px,calc(100vw - 32px));background:#eef5fc;color:#1d456d;border:1px solid #99b5d1;padding:10px 14px;z-index:80;box-shadow:0 4px 14px #1b2d4326;font-size:13px;line-height:1.5;white-space:pre-wrap}.notice.error{background:#fff2f0;border-color:#d2aaa5;color:#99251e}dialog{border:1px solid #a4afbb;border-radius:5px;padding:0;max-width:min(740px,calc(100vw - 28px));width:560px;max-height:88dvh;background:#fff;color:#202832;box-shadow:0 12px 44px #172a4040}dialog::backdrop{background:#152d493d}dialog>form{display:flex;flex-direction:column;max-height:85dvh}.dialog-header{display:flex;align-items:center;gap:12px;padding:10px 14px;border-bottom:1px solid var(--border);background:#f4f6f8}.dialog-close{margin-left:auto;border:0;background:transparent;padding:0 5px;font-size:22px;line-height:1}.dialog-content{padding:14px;overflow:auto;display:flex;flex-direction:column;gap:12px;min-height:40px}.dialog-content p{font-size:13px;white-space:pre-wrap;overflow-wrap:anywhere}.dialog-content .field{align-items:flex-start}.dialog-content .field input{flex:1;min-width:0}.dialog-content .form-grid{grid-template-columns:1fr}.dialog-footer{display:flex;justify-content:flex-end;gap:7px;padding:10px 14px;border-top:1px solid var(--border);background:#f6f7f9}#dialog-error{padding:0 14px 10px}#auth-dialog{width:370px;padding:18px}#auth-dialog form{gap:13px}#auth-dialog .dialog-footer{margin:0 -18px -18px}#auth-dialog .field{display:flex;flex-direction:column;align-items:stretch;gap:6px}.context-menu{position:fixed;z-index:50;background:#fff;border:1px solid #acb6c1;box-shadow:0 5px 14px #172a4026;padding:4px;min-width:190px}.context-menu button{display:block;width:100%;text-align:left;background:transparent;border:0;border-radius:0;padding:5px 10px}.context-menu button:hover{background:var(--tint)}
|
.log-resizer{height:7px;min-height:7px;cursor:row-resize;background:#e3e7ec;position:relative;border-top:1px solid #b8c1cb;border-bottom:1px solid #c8d0d9}.log-resizer::after{content:"";position:absolute;width:34px;height:2px;background:#8f9ba8;left:calc(50% - 17px);top:2px}.log-resizer:hover{background:#cedbe9}.log-panel{height:var(--log-height);min-height:64px;max-height:55vh;display:flex;flex-direction:column;background:#fff}.log-toolbar{display:flex;gap:13px;align-items:center;padding:3px 8px;background:#f1f3f5;border-bottom:1px solid var(--border);min-height:29px;font-size:12px}.log-toolbar strong{font-weight:600}.log-toolbar label{display:flex;align-items:center;gap:2px}.log-lines{padding:4px 9px;overflow:auto;flex:1;font:12px/1.65 Consolas,"Microsoft YaHei UI",monospace;white-space:pre-wrap;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.log-entry{min-height:19px}.log-entry .log-time{color:#6a7480;margin-right:8px}.log-entry.error{color:#99251e}.log-entry.warning{color:#805300}.log-entry.debug{color:#55616e}.status-bar{min-height:24px;display:flex;align-items:center;gap:14px;padding:3px 8px;border-top:1px solid var(--border);background:#f1f3f5;font-size:12px;overflow:hidden;white-space:nowrap}.status-bar #status-text{overflow:hidden;text-overflow:ellipsis;max-width:50vw}.status-bar #job-status{overflow:hidden;text-overflow:ellipsis}.notice{position:fixed;right:16px;bottom:35px;max-width:min(540px,calc(100vw - 32px));background:#eef5fc;color:#1d456d;border:1px solid #99b5d1;padding:10px 14px;z-index:80;box-shadow:0 4px 14px #1b2d4326;font-size:13px;line-height:1.5;white-space:pre-wrap}.notice.error{background:#fff2f0;border-color:#d2aaa5;color:#99251e}dialog{border:1px solid #a4afbb;border-radius:5px;padding:0;max-width:min(740px,calc(100vw - 28px));width:560px;max-height:88dvh;background:#fff;color:#202832;box-shadow:0 12px 44px #172a4040}dialog::backdrop{background:#152d493d}dialog>form{display:flex;flex-direction:column;max-height:85dvh}.dialog-header{display:flex;align-items:center;gap:12px;padding:10px 14px;border-bottom:1px solid var(--border);background:#f4f6f8}.dialog-close{margin-left:auto;border:0;background:transparent;padding:0 5px;font-size:22px;line-height:1}.dialog-content{padding:14px;overflow:auto;display:flex;flex-direction:column;gap:12px;min-height:40px}.dialog-content p{font-size:13px;white-space:pre-wrap;overflow-wrap:anywhere}.dialog-content .field{align-items:flex-start}.dialog-content .field input{flex:1;min-width:0}.dialog-content .form-grid{grid-template-columns:1fr}.dialog-footer{display:flex;justify-content:flex-end;gap:7px;padding:10px 14px;border-top:1px solid var(--border);background:#f6f7f9}#dialog-error{padding:0 14px 10px}#auth-dialog{width:370px;padding:18px}#auth-dialog form{gap:13px}#auth-dialog .dialog-footer{margin:0 -18px -18px}#auth-dialog .field{display:flex;flex-direction:column;align-items:stretch;gap:6px}.context-menu{position:fixed;z-index:50;background:#fff;border:1px solid #acb6c1;box-shadow:0 5px 14px #172a4026;padding:4px;min-width:190px}.context-menu button{display:block;width:100%;text-align:left;background:transparent;border:0;border-radius:0;padding:5px 10px}.context-menu button:hover{background:var(--tint)}
|
||||||
@@ -10,7 +10,21 @@
|
|||||||
@media(max-width:1000px){.window-title{display:none}.toolbar{gap:5px}.run-controls{width:100%}.player-line{gap:10px}.page-tab{padding-left:8px;padding-right:8px}.form-grid{grid-template-columns:repeat(2,minmax(240px,1fr))}.statistics-picker{width:220px}}
|
@media(max-width:1000px){.window-title{display:none}.toolbar{gap:5px}.run-controls{width:100%}.player-line{gap:10px}.page-tab{padding-left:8px;padding-right:8px}.form-grid{grid-template-columns:repeat(2,minmax(240px,1fr))}.statistics-picker{width:220px}}
|
||||||
@media(max-width:650px){:root{--log-height:120px}.workbench{min-width:340px}.window-header{gap:5px}.menu>summary{padding:5px 7px}.access-key{display:none}#access-mode{font-size:11px}.toolbar{padding:6px}.player-line{gap:7px 10px}.player-line>strong{max-width:135px}.experience progress{display:none}.run-controls{gap:4px}.run-controls>button{padding-left:7px;padding-right:7px;font-size:12px}.form-grid{grid-template-columns:1fr}.field>.field-label{min-width:120px}.field-wide{grid-column:auto}.login-layout{padding:3px}.login-layout .field{align-items:stretch;flex-direction:column;gap:4px}.login-layout .field>.field-label{flex-basis:auto;min-width:0}.login-layout input[type=text],.login-layout input[type=password]{width:100%}.login-options,.login-actions{margin-left:0}.server-row{flex-wrap:wrap}.statistics-layout{flex-direction:column}.statistics-picker{width:100%;max-height:130px}.log-toolbar{gap:7px}#download-log{display:none}.status-bar{gap:8px}.status-bar #game-version{display:none}dialog .field{flex-direction:column;align-items:stretch}dialog .field-label{flex-basis:auto}#save-status{max-width:160px;overflow:hidden;text-overflow:ellipsis}}
|
@media(max-width:650px){:root{--log-height:120px}.workbench{min-width:340px}.window-header{gap:5px}.menu>summary{padding:5px 7px}.access-key{display:none}#access-mode{font-size:11px}.toolbar{padding:6px}.player-line{gap:7px 10px}.player-line>strong{max-width:135px}.experience progress{display:none}.run-controls{gap:4px}.run-controls>button{padding-left:7px;padding-right:7px;font-size:12px}.form-grid{grid-template-columns:1fr}.field>.field-label{min-width:120px}.field-wide{grid-column:auto}.login-layout{padding:3px}.login-layout .field{align-items:stretch;flex-direction:column;gap:4px}.login-layout .field>.field-label{flex-basis:auto;min-width:0}.login-layout input[type=text],.login-layout input[type=password]{width:100%}.login-options,.login-actions{margin-left:0}.server-row{flex-wrap:wrap}.statistics-layout{flex-direction:column}.statistics-picker{width:100%;max-height:130px}.log-toolbar{gap:7px}#download-log{display:none}.status-bar{gap:8px}.status-bar #game-version{display:none}dialog .field{flex-direction:column;align-items:stretch}dialog .field-label{flex-basis:auto}#save-status{max-width:160px;overflow:hidden;text-overflow:ellipsis}}
|
||||||
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}
|
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}
|
||||||
.page-content{display:flex;flex-direction:column;gap:7px;flex:1;min-height:160px;overflow:auto}.page-panel[data-page=login]>.page-content{flex:0 0 auto;min-height:0;overflow:visible}.statistics-table-host{display:flex;flex-direction:column;flex:1;min-height:100px}.count-id{width:100px}.statistics-city>summary,.statistics-stage>summary{cursor:pointer;font-size:12px;padding:6px 7px;line-height:1.5;overflow-wrap:anywhere}.statistics-city>summary{background:#eef1f5;border-bottom:1px solid #d8dee6;font-weight:600}.statistics-stage{margin-left:10px}.statistics-stage>summary:hover{background:#edf3fa}.statistics-levels{padding-left:12px}.statistics-levels button{padding:5px 8px}.debug-json{margin:0;font:12px/1.6 Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere}.log-entry.inspectable{cursor:pointer}.log-entry.inspectable:hover{background:#e8f0f9}.member-draft-note{font-size:11px;color:#805300}.counts-lines{display:flex;flex-direction:column;gap:3px;margin-bottom:4px}
|
.page-content{display:flex;flex-direction:column;gap:7px;flex:1;min-height:160px;overflow:auto}.page-panel[data-page=login] .page-content{flex:0 0 auto;min-height:0;overflow:visible}.statistics-table-host{display:flex;flex-direction:column;flex:1;min-height:100px}.count-id{width:100px}.statistics-city>summary,.statistics-stage>summary{cursor:pointer;font-size:12px;padding:6px 7px;line-height:1.5;overflow-wrap:anywhere}.statistics-city>summary{background:#eef1f5;border-bottom:1px solid #d8dee6;font-weight:600}.statistics-stage{margin-left:10px}.statistics-stage>summary:hover{background:#edf3fa}.statistics-levels{padding-left:12px}.statistics-levels button{padding:5px 8px}.debug-json{margin:0;font:12px/1.6 Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere}.log-entry.inspectable{cursor:pointer}.log-entry.inspectable:hover{background:#e8f0f9}.member-draft-note{font-size:11px;color:#805300}.counts-lines{display:flex;flex-direction:column;gap:3px;margin-bottom:4px}
|
||||||
.chart-axis{font-size:11px;fill:#55616e;font-variant-numeric:tabular-nums}
|
.chart-axis{font-size:11px;fill:#55616e;font-variant-numeric:tabular-nums}
|
||||||
#log-lines{overflow-anchor:none;overscroll-behavior:contain}
|
#log-lines{overflow-anchor:none;overscroll-behavior:contain}
|
||||||
.log-toolbar{flex-wrap:wrap;gap:5px 13px}.log-toolbar input[type=search]{width:170px;min-width:100px;max-width:100%}
|
.log-toolbar{flex-wrap:wrap;gap:5px 13px}.log-toolbar input[type=search]{width:170px;min-width:100px;max-width:100%}
|
||||||
|
|
||||||
|
.loading-state{display:grid;place-items:center;min-height:160px;align-self:stretch;flex:1}
|
||||||
|
.page-host>.loading-state{height:100%}
|
||||||
|
.loading-region{display:grid;min-height:160px}
|
||||||
|
.loading-region>*{grid-area:1/1}
|
||||||
|
.loading-region>.loading-state{z-index:4;pointer-events:none}
|
||||||
|
.loading-spinner{display:block;width:32px;height:32px;border:3px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:loading-spin .8s linear infinite;box-shadow:0 0 0 4px #ffffffb3}
|
||||||
|
@keyframes loading-spin{to{transform:rotate(360deg)}}
|
||||||
|
.page-header{flex-shrink:0}
|
||||||
|
.page-body{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);flex:1;min-width:0;min-height:160px;position:relative}
|
||||||
|
.page-surface{grid-area:1/1;display:flex;flex-direction:column;gap:7px;min-width:0;min-height:0;overflow:auto;scrollbar-gutter:stable}
|
||||||
|
.page-surface>:not(.page-content){flex-shrink:0}
|
||||||
|
.page-loading{grid-area:1/1;z-index:4;pointer-events:none;min-height:0}
|
||||||
|
@media(prefers-reduced-motion:reduce){.loading-spinner{animation:none}}
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ class AutoReloginBrowserTests(unittest.TestCase):
|
|||||||
strategy_requested=running, strategy_state="running" if running else "stopped")
|
strategy_requested=running, strategy_state="running" if running else "stopped")
|
||||||
return {"id": "mock-" + operation, "operation": operation, "status": "succeeded", "result": {}}
|
return {"id": "mock-" + operation, "operation": operation, "status": "succeeded", "result": {}}
|
||||||
|
|
||||||
def test_defaults_visible_explanations_and_existing_layout(self):
|
def test_defaults_visible_controls_and_existing_layout(self):
|
||||||
self.open()
|
self.open()
|
||||||
panel = self.go("login")
|
panel = self.go("login")
|
||||||
delay = self.delay_control(panel)
|
delay = self.delay_control(panel)
|
||||||
@@ -180,8 +180,13 @@ class AutoReloginBrowserTests(unittest.TestCase):
|
|||||||
expect(delay).to_have_value("30")
|
expect(delay).to_have_value("30")
|
||||||
for attribute, value in (("min", "1"), ("max", "10080"), ("step", "1")):
|
for attribute, value in (("min", "1"), ("max", "10080"), ("step", "1")):
|
||||||
expect(delay).to_have_attribute(attribute, value)
|
expect(delay).to_have_attribute(attribute, value)
|
||||||
for text in ("服务端", "记住账号和密码", "原区服", "角色", "恢复监控", "自动执行已勾选功能", "顶部“停止”", "关闭页面", "服务重启", "退出登录", "只有", "清除登录记录", "暂停"):
|
expect(panel.get_by_label("游戏账号", exact=True)).to_have_value("offline-fixture")
|
||||||
expect(panel).to_contain_text(text)
|
expect(panel.get_by_label("游戏密码", exact=True)).to_be_visible()
|
||||||
|
expect(panel.get_by_role("checkbox", name="记住账号和密码", exact=True)).to_be_checked()
|
||||||
|
expect(panel.get_by_label("区服 / 角色", exact=True)).to_be_visible()
|
||||||
|
expect(panel.get_by_role("button", name="进入选中区服", exact=True)).to_be_disabled()
|
||||||
|
expect(panel.get_by_role("button", name="恢复选中会话(无需重新输密码)", exact=True)).to_be_disabled()
|
||||||
|
expect(panel.locator("[data-auto-relogin-status]")).to_contain_text("尚未保存登录角色")
|
||||||
self.assertTrue(delay.evaluate("node => Boolean(node.closest('.policy-form'))"))
|
self.assertTrue(delay.evaluate("node => Boolean(node.closest('.policy-form'))"))
|
||||||
self.assertTrue(delay.evaluate("node => Boolean(node.compareDocumentPosition(document.querySelector('.login-layout')) & Node.DOCUMENT_POSITION_FOLLOWING)"))
|
self.assertTrue(delay.evaluate("node => Boolean(node.compareDocumentPosition(document.querySelector('.login-layout')) & Node.DOCUMENT_POSITION_FOLLOWING)"))
|
||||||
expect(panel.get_by_role("button", name="保存", exact=True)).to_have_count(0)
|
expect(panel.get_by_role("button", name="保存", exact=True)).to_have_count(0)
|
||||||
@@ -224,8 +229,8 @@ class AutoReloginBrowserTests(unittest.TestCase):
|
|||||||
expect(toggle).to_have_text("停止")
|
expect(toggle).to_have_text("停止")
|
||||||
expect(toggle).to_have_attribute("aria-pressed", "true")
|
expect(toggle).to_have_attribute("aria-pressed", "true")
|
||||||
expect(self.page.locator("#notice")).to_contain_text("已自动开启策略")
|
expect(self.page.locator("#notice")).to_contain_text("已自动开启策略")
|
||||||
expect(self.page.locator("#status-text")).to_contain_text("已配置且已勾选的功能")
|
expect(self.page.locator("#status-text")).to_contain_text("正在自动执行")
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text("顶部“停止”")
|
expect(self.page.locator("#data-summary")).to_contain_text("正在自动执行")
|
||||||
expect(self.page.locator("#page-tabs [role=tab]")).to_have_count(15)
|
expect(self.page.locator("#page-tabs [role=tab]")).to_have_count(15)
|
||||||
self.assertEqual(self.configs[self.first], original, "Logging in must preserve every feature selection")
|
self.assertEqual(self.configs[self.first], original, "Logging in must preserve every feature selection")
|
||||||
toggle.click()
|
toggle.click()
|
||||||
@@ -352,8 +357,7 @@ class AutoReloginBrowserTests(unittest.TestCase):
|
|||||||
self.delay_control(panel).fill("10")
|
self.delay_control(panel).fill("10")
|
||||||
hint = panel.locator("[data-auto-relogin-credentials]")
|
hint = panel.locator("[data-auto-relogin-credentials]")
|
||||||
expect(hint).to_be_visible()
|
expect(hint).to_be_visible()
|
||||||
expect(hint).to_contain_text("缺少")
|
expect(hint).to_have_text("未保存账号或密码,自动重登不可用。")
|
||||||
expect(hint).to_contain_text("记住账号和密码")
|
|
||||||
self.page.wait_for_timeout(1000)
|
self.page.wait_for_timeout(1000)
|
||||||
self.saved(self.first, False, 10)
|
self.saved(self.first, False, 10)
|
||||||
expect(remember).not_to_be_checked()
|
expect(remember).not_to_be_checked()
|
||||||
@@ -425,7 +429,7 @@ class AutoReloginBrowserTests(unittest.TestCase):
|
|||||||
running=True, strategy_requested=True, strategy_state="running")
|
running=True, strategy_requested=True, strategy_state="running")
|
||||||
expect(status).to_contain_text("已恢复监控并自动执行已勾选功能")
|
expect(status).to_contain_text("已恢复监控并自动执行已勾选功能")
|
||||||
expect(self.page.locator("#strategy-toggle")).to_have_text("停止")
|
expect(self.page.locator("#strategy-toggle")).to_have_text("停止")
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text("正在自动执行已配置且已勾选的功能")
|
expect(self.page.locator("#data-summary")).to_contain_text("正在自动执行")
|
||||||
self.assertEqual(self.configs[self.first], original)
|
self.assertEqual(self.configs[self.first], original)
|
||||||
self.assertEqual(self.actions, [])
|
self.assertEqual(self.actions, [])
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ class ConnectionBrowserTests(unittest.TestCase):
|
|||||||
self.summary.update(connection_state="expired", connection_message=failure_reason, error=failure_reason)
|
self.summary.update(connection_state="expired", connection_message=failure_reason, error=failure_reason)
|
||||||
expect(self.page.locator("#connection")).to_have_text("登录已过期")
|
expect(self.page.locator("#connection")).to_have_text("登录已过期")
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text(self.summary["connection_message"])
|
expect(self.page.locator("#data-summary")).to_contain_text(self.summary["connection_message"])
|
||||||
expect(panel.locator(".page-loading")).to_contain_text("缓存")
|
expect(panel.locator("[data-connection-status]")).to_contain_text(failure_reason)
|
||||||
|
expect(panel).to_have_attribute("aria-busy", "false")
|
||||||
|
expect(panel.locator(".page-loading")).to_be_hidden()
|
||||||
expect(panel.locator("[data-connection-status]")).to_contain_text("2026/11/11")
|
expect(panel.locator("[data-connection-status]")).to_contain_text("2026/11/11")
|
||||||
expect(self.page.locator("#strategy-toggle")).to_be_disabled()
|
expect(self.page.locator("#strategy-toggle")).to_be_disabled()
|
||||||
expect(self.page.locator("#refresh")).to_be_disabled()
|
expect(self.page.locator("#refresh")).to_be_disabled()
|
||||||
@@ -98,7 +100,8 @@ class ConnectionBrowserTests(unittest.TestCase):
|
|||||||
expect(self.page.locator(selector)).to_be_visible()
|
expect(self.page.locator(selector)).to_be_visible()
|
||||||
expect(self.page.locator(selector)).to_contain_text(f"上次失败:{failure_reason}")
|
expect(self.page.locator(selector)).to_contain_text(f"上次失败:{failure_reason}")
|
||||||
expect(self.page.locator(f'.account-tab[data-account="{self.first}"] .account-dot')).not_to_have_class("account-dot error")
|
expect(self.page.locator(f'.account-tab[data-account="{self.first}"] .account-dot')).not_to_have_class("account-dot error")
|
||||||
expect(panel.locator(".page-loading")).not_to_contain_text("缓存")
|
expect(panel.locator(".page-loading")).to_have_attribute("data-loading", "false")
|
||||||
|
expect(panel.locator(".page-loading")).to_be_hidden()
|
||||||
self.assertEqual(self.page.locator("#page-tabs [role=tab]").count(), 15)
|
self.assertEqual(self.page.locator("#page-tabs [role=tab]").count(), 15)
|
||||||
self.assertEqual(self.external_requests, [])
|
self.assertEqual(self.external_requests, [])
|
||||||
self.assertEqual(self.errors, [])
|
self.assertEqual(self.errors, [])
|
||||||
@@ -187,7 +190,10 @@ class ConnectionBrowserTests(unittest.TestCase):
|
|||||||
self.page.on("request", lambda request: actions.append(request.url) if "/actions/" in request.url else None)
|
self.page.on("request", lambda request: actions.append(request.url) if "/actions/" in request.url else None)
|
||||||
panel = self.go("bag")
|
panel = self.go("bag")
|
||||||
expect(panel.locator("[data-connection-status]")).to_contain_text("Web 服务已重启")
|
expect(panel.locator("[data-connection-status]")).to_contain_text("Web 服务已重启")
|
||||||
expect(panel.locator(".page-loading")).to_contain_text("缓存")
|
expect(panel.get_by_text("已保存的背包", exact=True)).to_be_visible()
|
||||||
|
expect(panel).to_have_attribute("aria-busy", "false")
|
||||||
|
expect(panel.locator(".page-loading")).to_have_attribute("data-loading", "false")
|
||||||
|
expect(panel.locator(".page-loading")).to_be_hidden()
|
||||||
self.page.locator('[data-command="start"]').dispatch_event("click")
|
self.page.locator('[data-command="start"]').dispatch_event("click")
|
||||||
self.page.locator("#refresh").dispatch_event("click")
|
self.page.locator("#refresh").dispatch_event("click")
|
||||||
self.page.wait_for_timeout(1800)
|
self.page.wait_for_timeout(1800)
|
||||||
|
|||||||
@@ -0,0 +1,190 @@
|
|||||||
|
"""Focused loading regressions using disposable demo accounts and local routes only."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from . import test_workbench_browser as fixtures
|
||||||
|
|
||||||
|
if fixtures.AVAILABLE:
|
||||||
|
from playwright.sync_api import expect
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipUnless(fixtures.AVAILABLE, "Python Playwright and a system Chromium browser are required")
|
||||||
|
class PageLoadingBrowserTests(unittest.TestCase):
|
||||||
|
setUpClass = classmethod(fixtures.WorkbenchBrowserTests.setUpClass.__func__)
|
||||||
|
tearDownClass = classmethod(fixtures.WorkbenchBrowserTests.tearDownClass.__func__)
|
||||||
|
await_job = fixtures.WorkbenchBrowserTests.await_job
|
||||||
|
open = fixtures.WorkbenchBrowserTests.open
|
||||||
|
fulfill = staticmethod(fixtures.WorkbenchBrowserTests.fulfill)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
guard = patch("requests.sessions.Session.request", side_effect=AssertionError("Live HTTP is forbidden"))
|
||||||
|
guard.start()
|
||||||
|
self.addCleanup(guard.stop)
|
||||||
|
fixtures.WorkbenchBrowserTests.setUp(self)
|
||||||
|
self.external_requests, self.script_errors, self.pending = [], [], []
|
||||||
|
self.page.on("pageerror", lambda failure: self.script_errors.append(str(failure)))
|
||||||
|
|
||||||
|
def local_only(route):
|
||||||
|
if route.request.url.startswith(self.base + "/"):
|
||||||
|
route.continue_()
|
||||||
|
else:
|
||||||
|
self.external_requests.append(route.request.url)
|
||||||
|
route.abort()
|
||||||
|
|
||||||
|
self.context.route("**/*", local_only)
|
||||||
|
self.summary = copy.deepcopy(self.manager.status(self.first))
|
||||||
|
self.summary.update(demo=False, connected=True, connection_state="online", error="",
|
||||||
|
connection_message="游戏连接正常", running=False)
|
||||||
|
self.page.route("**/api/accounts", lambda route: self.fulfill(
|
||||||
|
route, [self.summary, self.manager.status(self.second)]))
|
||||||
|
self.response = {"loading": False, "data": {
|
||||||
|
"page": "bag", "summary": "32 项库存", "filters": [], "actions": [],
|
||||||
|
"form": [{"path": ["policy", "protect_star"], "label": "保护星级", "type": "integer", "min": 0, "max": 5}],
|
||||||
|
"columns": [{"key": "name", "label": "名称"}, {"key": "count", "label": "数量"},
|
||||||
|
{"key": "status", "label": "状态"}],
|
||||||
|
"rows": [{"id": str(i), "name": f"库存魔物 {i + 1}", "count": i + 1, "status": "可用"} for i in range(32)],
|
||||||
|
"details": {"help": "STATIC_HELP_SENTINEL", "note": "STATIC_NOTE_SENTINEL",
|
||||||
|
"notes": ["金币不足,等待补货"]}}}
|
||||||
|
self.hold, self.fail = False, False
|
||||||
|
|
||||||
|
def view(route):
|
||||||
|
if self.hold:
|
||||||
|
self.pending.append(route)
|
||||||
|
elif self.fail:
|
||||||
|
route.fulfill(status=503, content_type="application/json", body='{"detail":"读取失败"}')
|
||||||
|
else:
|
||||||
|
self.fulfill(route, self.response)
|
||||||
|
|
||||||
|
self.page.route(f"**/api/accounts/{self.first}/views/bag?*", view)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
try:
|
||||||
|
self.assertEqual(self.external_requests, [])
|
||||||
|
self.assertEqual(self.script_errors, [])
|
||||||
|
finally:
|
||||||
|
self.context.close()
|
||||||
|
|
||||||
|
def wait_request(self):
|
||||||
|
deadline = time.monotonic() + 8
|
||||||
|
while not self.pending and time.monotonic() < deadline:
|
||||||
|
self.page.wait_for_timeout(50)
|
||||||
|
self.assertTrue(self.pending, "Expected a delayed local view request")
|
||||||
|
return self.pending.pop(0)
|
||||||
|
|
||||||
|
def bag(self):
|
||||||
|
self.page.locator('.page-tab[data-page="bag"]').click()
|
||||||
|
return self.page.locator('.page-panel[data-page="bag"]:not([hidden])')
|
||||||
|
|
||||||
|
def assert_centered(self, panel):
|
||||||
|
spinner = panel.locator(".loading-spinner")
|
||||||
|
expect(spinner).to_be_visible()
|
||||||
|
body, circle = panel.locator(".page-body").bounding_box(), spinner.bounding_box()
|
||||||
|
for axis, size in (("x", "width"), ("y", "height")):
|
||||||
|
self.assertAlmostEqual(body[axis] + body[size] / 2, circle[axis] + circle[size] / 2, delta=2)
|
||||||
|
self.assertAlmostEqual(circle["width"], circle["height"], delta=1)
|
||||||
|
expect(panel).to_have_attribute("aria-busy", "true")
|
||||||
|
expect(panel.locator(".page-loading")).to_have_attribute("aria-label", "正在加载背包")
|
||||||
|
expect(panel.locator(".page-loading")).to_have_text("")
|
||||||
|
self.assertEqual(panel.locator(".page-header").inner_text(), "背包")
|
||||||
|
|
||||||
|
def test_delayed_empty_load_resolves_and_saves_screenshots(self):
|
||||||
|
self.open()
|
||||||
|
self.assertEqual(self.page.locator("#page-host > .loading-state").count(), 0)
|
||||||
|
self.hold = True
|
||||||
|
panel = self.bag()
|
||||||
|
route = self.wait_request()
|
||||||
|
self.assert_centered(panel)
|
||||||
|
artifacts = Path(__file__).resolve().parents[3] / "test-artifacts" / "ui205"
|
||||||
|
artifacts.mkdir(parents=True, exist_ok=True)
|
||||||
|
self.page.screenshot(path=str(artifacts / "loading-centered.png"))
|
||||||
|
self.fulfill(route, {"loading": True, "data": None})
|
||||||
|
route = self.wait_request()
|
||||||
|
self.assert_centered(panel)
|
||||||
|
self.page.emulate_media(reduced_motion="reduce")
|
||||||
|
self.assertEqual(panel.locator(".loading-spinner").evaluate("node => getComputedStyle(node).animationName"), "none")
|
||||||
|
self.page.set_viewport_size({"width": 375, "height": 812})
|
||||||
|
self.assert_centered(panel)
|
||||||
|
self.page.set_viewport_size({"width": 1280, "height": 800})
|
||||||
|
self.hold = False
|
||||||
|
self.fulfill(route, self.response)
|
||||||
|
expect(panel).to_have_attribute("aria-busy", "false")
|
||||||
|
expect(panel.locator(".page-loading")).to_be_hidden()
|
||||||
|
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):
|
||||||
|
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("金币不足,等待补货")
|
||||||
|
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)
|
||||||
|
field = panel.get_by_role("spinbutton", name="保护星级")
|
||||||
|
field.fill("")
|
||||||
|
field.evaluate("node => { window.loadingField = node; window.loadingTable = node.closest('.page-panel').querySelector('table'); }")
|
||||||
|
self.hold = True
|
||||||
|
route = self.wait_request() # The ordinary passive polling path.
|
||||||
|
self.assert_centered(panel)
|
||||||
|
self.assertEqual(panel.locator(".page-loading").evaluate("node => getComputedStyle(node).pointerEvents"), "none")
|
||||||
|
field.click(timeout=1500) # A visible spinner must allow native editing.
|
||||||
|
expect(field).to_be_focused()
|
||||||
|
self.fulfill(route, {**self.response, "loading": True})
|
||||||
|
route = self.wait_request() # The 650 ms pending-data follow-up.
|
||||||
|
self.hold = False
|
||||||
|
self.fulfill(route, self.response)
|
||||||
|
expect(panel).to_have_attribute("aria-busy", "false")
|
||||||
|
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(self.page.locator("#log-panel")).to_be_hidden()
|
||||||
|
self.assertEqual(self.page.locator("#log-panel").count(), 1)
|
||||||
|
|
||||||
|
def test_failure_offline_and_account_switch_stop_loading(self):
|
||||||
|
self.open()
|
||||||
|
self.hold = True
|
||||||
|
panel = self.bag()
|
||||||
|
route = self.wait_request()
|
||||||
|
self.assert_centered(panel)
|
||||||
|
self.hold, self.fail = False, True
|
||||||
|
route.fulfill(status=503, content_type="application/json", body='{"detail":"读取失败"}')
|
||||||
|
expect(panel.locator(".page-error")).to_be_visible()
|
||||||
|
expect(panel).to_have_attribute("aria-busy", "false")
|
||||||
|
expect(panel.locator(".page-loading")).to_be_hidden()
|
||||||
|
self.hold, self.fail = True, False
|
||||||
|
panel.get_by_role("button", name="重新读取").click()
|
||||||
|
route = self.wait_request()
|
||||||
|
self.assert_centered(panel)
|
||||||
|
self.summary.update(connection_state="offline", connected=False, connection_message="连接已中断")
|
||||||
|
expect(self.page.locator("#connection")).to_have_text("游戏离线")
|
||||||
|
expect(panel).to_have_attribute("aria-busy", "false")
|
||||||
|
expect(panel.locator(".page-loading")).to_be_hidden()
|
||||||
|
self.hold = False
|
||||||
|
self.fulfill(route, {**self.response, "loading": True})
|
||||||
|
expect(panel.locator("tbody tr")).to_have_count(32)
|
||||||
|
expect(panel.get_by_role("spinbutton", name="保护星级")).to_be_enabled()
|
||||||
|
expect(panel.locator(".page-loading")).to_be_hidden()
|
||||||
|
self.summary.update(connection_state="online", connected=True, connection_message="游戏连接正常")
|
||||||
|
expect(self.page.locator("#connection")).to_have_text("已登录")
|
||||||
|
self.hold = True
|
||||||
|
self.page.locator('.page-tab[data-page="bag"]').click()
|
||||||
|
route = self.wait_request()
|
||||||
|
self.assert_centered(panel)
|
||||||
|
self.page.locator(f'.account-tab[data-account="{self.second}"]').click()
|
||||||
|
old_panel = self.page.locator('.page-panel[data-page="bag"]')
|
||||||
|
expect(old_panel).to_be_hidden()
|
||||||
|
expect(old_panel).to_have_attribute("aria-busy", "false")
|
||||||
|
self.fulfill(route, {**self.response, "loading": True})
|
||||||
|
self.page.wait_for_timeout(800)
|
||||||
|
expect(old_panel.locator(".page-loading")).to_be_hidden()
|
||||||
|
expect(old_panel).to_have_attribute("aria-busy", "false")
|
||||||
|
self.assertEqual(self.pending, [], "Inactive accounts must not retain pending-load retries")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,330 @@
|
|||||||
|
"""Quiet shared UI with synthetic DTOs and browser-fulfilled HTTP only.
|
||||||
|
|
||||||
|
Run: python -B -m unittest ranch_web.tests.browser.test_quiet_ui_browser -v
|
||||||
|
Shared renderers use the real index shell with application bootstrap stubbed out.
|
||||||
|
Administrator-login tests load the real standalone HTML, JavaScript and CSS.
|
||||||
|
No server, account directory, backend API or external network is used.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
import unittest
|
||||||
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
|
from .test_workbench_browser import AVAILABLE, EDGE
|
||||||
|
|
||||||
|
if AVAILABLE:
|
||||||
|
from playwright.sync_api import expect, sync_playwright
|
||||||
|
|
||||||
|
|
||||||
|
STATIC = Path(__file__).resolve().parents[2] / "static"
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipUnless(AVAILABLE, "Python Playwright and a system Chromium browser are required")
|
||||||
|
class QuietUIBrowserTests(unittest.TestCase):
|
||||||
|
base = "http://quiet-ui.invalid"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.playwright = sync_playwright().start()
|
||||||
|
cls.addClassCleanup(cls.playwright.stop)
|
||||||
|
cls.browser = cls.playwright.chromium.launch(executable_path=str(EDGE), headless=True)
|
||||||
|
cls.addClassCleanup(cls.browser.close)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.context = self.browser.new_context(viewport={"width": 1280, "height": 800})
|
||||||
|
self.addCleanup(self.context.close)
|
||||||
|
self.addCleanup(self.context.unroute_all, behavior="ignoreErrors")
|
||||||
|
self.context.set_default_timeout(5000)
|
||||||
|
self.unexpected_requests, self.errors, self.login_requests = [], [], []
|
||||||
|
self.pending_status, self.pending_login = [], []
|
||||||
|
self.hold_status = self.hold_login = False
|
||||||
|
self.context.route("**/*", self.fixture)
|
||||||
|
self.page = self.context.new_page()
|
||||||
|
self.page.on("pageerror", lambda error: self.errors.append(str(error)))
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.assertEqual(self.unexpected_requests, [])
|
||||||
|
self.assertEqual(self.errors, [])
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def reply(route, data, status=200):
|
||||||
|
route.fulfill(status=status, content_type="application/json", body=json.dumps(data, ensure_ascii=False))
|
||||||
|
|
||||||
|
def fixture(self, route):
|
||||||
|
request = route.request
|
||||||
|
path = urlsplit(request.url).path
|
||||||
|
if request.url.startswith(self.base + "/"):
|
||||||
|
if path == "/api/auth/status" and request.method == "GET":
|
||||||
|
if self.hold_status:
|
||||||
|
self.pending_status.append(route)
|
||||||
|
else:
|
||||||
|
self.reply(route, {"required": True, "authenticated": False})
|
||||||
|
return
|
||||||
|
if path == "/api/auth/login" and request.method == "POST":
|
||||||
|
self.login_requests.append(request.post_data_json)
|
||||||
|
if self.hold_login:
|
||||||
|
self.pending_login.append(route)
|
||||||
|
else:
|
||||||
|
self.reply(route, {"detail": "管理密码错误,请重试。"}, status=401)
|
||||||
|
return
|
||||||
|
if path == "/static/app.js":
|
||||||
|
route.fulfill(content_type="application/javascript", body="// Shared-renderer fixture; no application bootstrap.\n")
|
||||||
|
return
|
||||||
|
filename = {"/": "index.html", "/login": "login.html"}.get(path)
|
||||||
|
if path.startswith("/static/") and Path(path).name == path.removeprefix("/static/"):
|
||||||
|
filename = Path(path).name
|
||||||
|
if filename and (STATIC / filename).is_file():
|
||||||
|
content_type = {".html": "text/html", ".js": "application/javascript", ".css": "text/css"}.get(Path(filename).suffix)
|
||||||
|
if content_type:
|
||||||
|
route.fulfill(content_type=content_type, body=(STATIC / filename).read_bytes())
|
||||||
|
return
|
||||||
|
self.unexpected_requests.append((request.method, request.url))
|
||||||
|
route.abort()
|
||||||
|
|
||||||
|
def pending(self, requests):
|
||||||
|
deadline = time.monotonic() + 5
|
||||||
|
while not requests and time.monotonic() < deadline:
|
||||||
|
self.page.wait_for_timeout(10)
|
||||||
|
self.assertTrue(requests, "Expected an intercepted fixture request")
|
||||||
|
return requests.pop(0)
|
||||||
|
|
||||||
|
def open_shell(self):
|
||||||
|
self.page.goto(self.base + "/", wait_until="networkidle")
|
||||||
|
self.page.locator("#app").evaluate("node => {node.hidden = false;}")
|
||||||
|
|
||||||
|
def render_form(self, fields):
|
||||||
|
self.open_shell()
|
||||||
|
self.page.evaluate("""async fields => {
|
||||||
|
const {PolicyForm} = await import('/static/forms.js');
|
||||||
|
const {getPath, setPath} = await import('/static/dom.js');
|
||||||
|
window.values = {}; window.writes = [];
|
||||||
|
const host = document.querySelector('#page-host');
|
||||||
|
host.replaceChildren();
|
||||||
|
window.quietForm = new PolicyForm(host, {
|
||||||
|
get: (path, fallback) => getPath(window.values, path, fallback),
|
||||||
|
set: (path, value) => {
|
||||||
|
setPath(window.values, path, value);
|
||||||
|
window.writes.push({path, value});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
window.quietForm.update(fields);
|
||||||
|
}""", fields)
|
||||||
|
|
||||||
|
def test_help_metadata_is_not_rendered_and_all_control_labels_remain(self):
|
||||||
|
fields = [
|
||||||
|
{"path": ["enabled"], "label": "自动领取", "type": "boolean", "value": True, "group": "策略"},
|
||||||
|
{"path": ["count"], "label": "领取数量", "type": "integer", "value": 2, "min": 1, "max": 5, "group": "策略"},
|
||||||
|
{"path": ["mode"], "label": "领取方式", "type": "select", "value": "all", "options": {"all": "全部", "daily": "每日"}},
|
||||||
|
{"path": ["name"], "label": "账号名称", "value": "离线账号"},
|
||||||
|
{"path": ["items"], "label": "物品编号", "type": "id_list", "value": [1]},
|
||||||
|
{"path": ["selected"], "label": "任务类型", "type": "multiselect", "value": ["daily"], "options": {"daily": "每日任务"}},
|
||||||
|
{"path": ["reserves"], "label": "物品保留", "type": "id_counts", "value": {"42": 2}},
|
||||||
|
{"path": ["locked"], "label": "只读设置", "value": "保留", "readonly": True},
|
||||||
|
{"path": ["rules"], "label": "魔物蛋", "type": "add_rule", "options": {"42": "测试蛋"}},
|
||||||
|
]
|
||||||
|
for index, field in enumerate(fields):
|
||||||
|
field["help" if index % 2 else "description"] = f"redundant-helper-{index}"
|
||||||
|
self.render_form(fields)
|
||||||
|
host = self.page.locator("#page-host")
|
||||||
|
expect(host.locator(".field-help")).to_have_count(0)
|
||||||
|
expect(host.locator(".field-label")).to_have_text([field["label"] for field in fields])
|
||||||
|
self.assertNotIn("redundant-helper-", host.evaluate("node => node.outerHTML"))
|
||||||
|
expect(host.get_by_role("checkbox", name="自动领取", exact=True)).to_be_checked()
|
||||||
|
expect(host.get_by_role("spinbutton", name="领取数量", exact=True)).to_have_value("2")
|
||||||
|
expect(host.get_by_role("combobox", name="领取方式", exact=True)).to_have_value("all")
|
||||||
|
expect(host.get_by_role("textbox", name="账号名称", exact=True)).to_have_value("离线账号")
|
||||||
|
expect(host.get_by_role("group", name="任务类型", exact=True)).to_be_visible()
|
||||||
|
expect(host.get_by_role("checkbox", name="每日任务", exact=True)).to_be_checked()
|
||||||
|
expect(host.get_by_role("group", name="物品保留", exact=True)).to_be_visible()
|
||||||
|
expect(host.get_by_role("spinbutton", name="物品保留数量", exact=True)).to_have_value("2")
|
||||||
|
expect(host.get_by_role("textbox", name="只读设置", exact=True)).to_be_disabled()
|
||||||
|
expect(host.get_by_role("combobox", name="魔物蛋", exact=True)).to_be_visible()
|
||||||
|
fields.append({"path": ["new"], "label": "新增设置", "help": "redundant-helper-new"})
|
||||||
|
self.page.evaluate("fields => window.quietForm.update(fields)", fields)
|
||||||
|
expect(host.get_by_role("textbox", name="新增设置", exact=True)).to_be_visible()
|
||||||
|
expect(host.locator(".field-help")).to_have_count(0)
|
||||||
|
self.assertNotIn("redundant-helper-", host.evaluate("node => node.outerHTML"))
|
||||||
|
self.assertEqual(self.page.evaluate("window.writes"), [])
|
||||||
|
|
||||||
|
def test_numeric_and_id_validation_still_reject_invalid_values_and_save_corrections(self):
|
||||||
|
self.render_form([
|
||||||
|
{"path": ["count"], "label": "领取数量", "type": "integer", "value": 2, "min": 1, "max": 5, "help": "redundant-helper-count"},
|
||||||
|
{"path": ["ids"], "label": "物品编号", "type": "id_list", "value": [1], "description": "redundant-helper-ids"},
|
||||||
|
])
|
||||||
|
count = self.page.get_by_role("spinbutton", name="领取数量", exact=True)
|
||||||
|
count.fill("0")
|
||||||
|
self.assertTrue(count.evaluate("node => node.validity.rangeUnderflow"))
|
||||||
|
self.assertEqual(self.page.evaluate("window.writes"), [])
|
||||||
|
count.fill("3")
|
||||||
|
ids = self.page.get_by_role("textbox", name="物品编号", exact=True)
|
||||||
|
ids.fill("1, wrong")
|
||||||
|
self.assertEqual(ids.evaluate("node => node.validationMessage"), "编号须为正整数,多个编号用逗号分隔")
|
||||||
|
self.assertEqual(self.page.evaluate("window.writes"), [{"path": ["count"], "value": 3}])
|
||||||
|
ids.fill("2, 2,3")
|
||||||
|
self.assertTrue(ids.evaluate("node => node.checkValidity()"))
|
||||||
|
self.assertEqual(self.page.evaluate("window.values"), {"count": 3, "ids": [2, 3]})
|
||||||
|
expect(self.page.locator(".field-help")).to_have_count(0)
|
||||||
|
|
||||||
|
def test_table_keeps_actionable_empty_state_and_member_validation_reasons(self):
|
||||||
|
self.open_shell()
|
||||||
|
self.page.evaluate("""async () => {
|
||||||
|
const {DataTable} = await import('/static/table.js');
|
||||||
|
const host = document.querySelector('#page-host'); host.replaceChildren();
|
||||||
|
window.writes = [];
|
||||||
|
window.quietTable = new DataTable(host, {
|
||||||
|
get: (path, fallback) => fallback,
|
||||||
|
set: (path, value) => window.writes.push({path, value}),
|
||||||
|
}, {emptyMessage: '没有可用队伍,请先添加魔物。'});
|
||||||
|
window.columns = [{key: 'name', label: '队伍'}, {key: 'members', label: '探险队伍', edit: {
|
||||||
|
type: 'members', path: ['teams', '*', 'members'],
|
||||||
|
options: [{value: 1, label: '队长', level: 30}, {value: 2, label: '队员甲', level: 20}, {value: 3, label: '队员乙', level: 10}],
|
||||||
|
}}];
|
||||||
|
window.quietTable.update(window.columns, []);
|
||||||
|
}""")
|
||||||
|
expect(self.page.locator(".empty-state")).to_have_text("没有可用队伍,请先添加魔物。")
|
||||||
|
self.page.evaluate("window.quietTable.update(window.columns, [{id: 'one', name: '第一队', members: []}])")
|
||||||
|
leader = self.page.get_by_role("combobox", name="探险队伍 · 第一队队长", exact=True)
|
||||||
|
member = self.page.get_by_role("combobox", name="探险队伍 · 第一队队员1", exact=True)
|
||||||
|
leader.select_option("1")
|
||||||
|
expect(self.page.locator(".member-draft-note")).to_have_text("已选择 1/3 只;选满队长和两名队员后保存")
|
||||||
|
member.select_option("1")
|
||||||
|
expect(self.page.locator(".member-draft-note")).to_have_text("探险队员不可重复")
|
||||||
|
self.assertEqual(member.evaluate("node => node.validationMessage"), "探险队员不可重复")
|
||||||
|
self.assertEqual(self.page.evaluate("window.writes"), [])
|
||||||
|
member.select_option("2")
|
||||||
|
self.page.get_by_role("combobox", name="探险队伍 · 第一队队员2", exact=True).select_option("3")
|
||||||
|
expect(self.page.locator(".member-draft-note")).to_be_hidden()
|
||||||
|
self.assertEqual(self.page.evaluate("window.writes"), [{"path": ["teams", "one", "members"], "value": [1, 2, 3]}])
|
||||||
|
|
||||||
|
def test_dialog_keeps_resource_fees_business_status_errors_and_destructive_confirmation(self):
|
||||||
|
self.open_shell()
|
||||||
|
self.page.evaluate("""async () => {
|
||||||
|
const {dialog} = await import('/static/ui.js');
|
||||||
|
const {el} = await import('/static/dom.js');
|
||||||
|
window.attempts = 0; window.result = null;
|
||||||
|
const count = el('input', {type: 'number', required: true, min: 1, 'aria-label': '扩建数量'});
|
||||||
|
const content = el('div', {}, el('p', {text: '扩建费用:金币 100、木材 20。消费后无法撤销。'}),
|
||||||
|
el('p', {class: 'info-note', role: 'status', text: '等待宿主机返回扩建结果…'}),
|
||||||
|
el('label', {}, '扩建数量', count));
|
||||||
|
dialog('确认扩建', content, {confirm: '确认消费', danger: true, read: async () => {
|
||||||
|
window.attempts += 1;
|
||||||
|
if (window.attempts === 1) throw new Error('金币不足:需要 100,当前 80,请补充后重试。');
|
||||||
|
return Number(count.value);
|
||||||
|
}}).then(value => {window.result = value;});
|
||||||
|
}""")
|
||||||
|
dialog = self.page.locator("#action-dialog")
|
||||||
|
expect(dialog).to_contain_text("扩建费用:金币 100、木材 20。消费后无法撤销。")
|
||||||
|
expect(dialog.get_by_role("status")).to_have_text("等待宿主机返回扩建结果…")
|
||||||
|
confirm = dialog.get_by_role("button", name="确认消费", exact=True)
|
||||||
|
expect(confirm).to_have_class("danger")
|
||||||
|
confirm.click()
|
||||||
|
self.assertEqual(self.page.evaluate("window.attempts"), 0)
|
||||||
|
dialog.get_by_role("spinbutton", name="扩建数量", exact=True).fill("1")
|
||||||
|
confirm.click()
|
||||||
|
expect(dialog.get_by_role("alert")).to_have_text("金币不足:需要 100,当前 80,请补充后重试。")
|
||||||
|
expect(confirm).to_be_enabled()
|
||||||
|
confirm.click()
|
||||||
|
expect(dialog).to_be_hidden()
|
||||||
|
self.assertEqual(self.page.evaluate("window.result"), 1)
|
||||||
|
self.page.evaluate("""async () => {
|
||||||
|
const {confirm} = await import('/static/ui.js');
|
||||||
|
window.result = null;
|
||||||
|
confirm('移除账号', '将删除此账号的配置和登录记录,无法撤销。', {danger: true})
|
||||||
|
.then(value => {window.result = value;});
|
||||||
|
}""")
|
||||||
|
expect(dialog).to_contain_text("将删除此账号的配置和登录记录,无法撤销。")
|
||||||
|
expect(self.page.locator("#dialog-cancel")).to_be_focused()
|
||||||
|
self.page.locator("#dialog-cancel").click()
|
||||||
|
self.assertFalse(self.page.evaluate("window.result"))
|
||||||
|
|
||||||
|
def test_login_check_has_centered_spinner_without_text_and_preserves_status_error(self):
|
||||||
|
self.hold_status = True
|
||||||
|
self.page.goto(self.base + "/login", wait_until="domcontentloaded")
|
||||||
|
pending = self.pending(self.pending_status)
|
||||||
|
status = self.page.locator("#auth-status")
|
||||||
|
expect(status).to_be_visible()
|
||||||
|
expect(status).to_have_class("loading-state")
|
||||||
|
expect(status).to_have_attribute("role", "status")
|
||||||
|
expect(status).to_have_attribute("aria-label", "加载中")
|
||||||
|
expect(status).to_have_text("")
|
||||||
|
expect(status.locator(".loading-spinner")).to_have_attribute("aria-hidden", "true")
|
||||||
|
expect(self.page.get_by_label("管理密码", exact=True)).to_be_disabled()
|
||||||
|
expect(self.page.get_by_role("button", name="登录", exact=True)).to_be_disabled()
|
||||||
|
expect(self.page.locator("#app, nav, #auth-description, .info-note, .field-help")).to_have_count(0)
|
||||||
|
for width, height in ((1280, 800), (390, 844)):
|
||||||
|
self.page.set_viewport_size({"width": width, "height": height})
|
||||||
|
spinner_box = status.locator(".loading-spinner").bounding_box()
|
||||||
|
status_box = status.bounding_box()
|
||||||
|
self.assertEqual(status.locator(".loading-spinner").evaluate("node => [node.offsetWidth, node.offsetHeight, getComputedStyle(node).borderRadius]"), [32, 32, "50%"])
|
||||||
|
self.assertAlmostEqual(spinner_box["x"] + spinner_box["width"] / 2, status_box["x"] + status_box["width"] / 2, delta=1)
|
||||||
|
self.assertLessEqual(self.page.evaluate("document.documentElement.scrollWidth"), width)
|
||||||
|
self.page.emulate_media(reduced_motion="reduce")
|
||||||
|
self.assertEqual(status.locator(".loading-spinner").evaluate("node => getComputedStyle(node).animationName"), "none")
|
||||||
|
self.reply(pending, {"detail": "管理服务暂不可用(HTTP 503),请稍后重试。"}, status=503)
|
||||||
|
expect(status).to_be_hidden()
|
||||||
|
expect(self.page.get_by_role("alert")).to_have_text("管理服务暂不可用(HTTP 503),请稍后重试。")
|
||||||
|
expect(self.page.get_by_label("管理密码", exact=True)).to_be_enabled()
|
||||||
|
expect(self.page.locator("#auth-form")).to_have_attribute("aria-busy", "false")
|
||||||
|
|
||||||
|
def test_login_keeps_required_label_error_retry_and_spinner_during_submission(self):
|
||||||
|
self.page.goto(self.base + "/login", wait_until="networkidle")
|
||||||
|
password = self.page.get_by_label("管理密码", exact=True)
|
||||||
|
button = self.page.get_by_role("button", name="登录", exact=True)
|
||||||
|
status = self.page.locator("#auth-status")
|
||||||
|
expect(password).to_have_attribute("autocomplete", "current-password")
|
||||||
|
expect(password).to_have_attribute("aria-describedby", "auth-error")
|
||||||
|
expect(status).to_be_hidden()
|
||||||
|
button.click()
|
||||||
|
self.assertTrue(password.evaluate("node => node.validity.valueMissing"))
|
||||||
|
self.assertEqual(self.login_requests, [])
|
||||||
|
self.hold_login = True
|
||||||
|
password.fill("synthetic-admin-password")
|
||||||
|
button.click()
|
||||||
|
pending = self.pending(self.pending_login)
|
||||||
|
expect(status).to_be_visible()
|
||||||
|
expect(status).to_have_text("")
|
||||||
|
expect(status.locator(".loading-spinner")).to_have_count(1)
|
||||||
|
expect(password).to_be_disabled()
|
||||||
|
expect(password).to_have_value("")
|
||||||
|
expect(button).to_be_disabled()
|
||||||
|
reason = '管理密码错误,请重试。 <img src=x onerror="alert(1)">'
|
||||||
|
self.reply(pending, {"detail": reason}, status=401)
|
||||||
|
expect(self.page.get_by_role("alert")).to_have_text(reason)
|
||||||
|
expect(self.page.locator("#auth-error img")).to_have_count(0)
|
||||||
|
expect(status).to_be_hidden()
|
||||||
|
expect(password).to_be_enabled()
|
||||||
|
expect(button).to_be_enabled()
|
||||||
|
expect(self.page).to_have_url(self.base + "/login")
|
||||||
|
password.fill("synthetic-retry-password")
|
||||||
|
button.click()
|
||||||
|
pending = self.pending(self.pending_login)
|
||||||
|
expect(self.page.get_by_role("alert")).to_be_hidden()
|
||||||
|
expect(status.locator(".loading-spinner")).to_have_count(1)
|
||||||
|
self.reply(pending, {"required": True, "authenticated": True})
|
||||||
|
expect(self.page).to_have_url(self.base + "/")
|
||||||
|
self.assertEqual(self.login_requests, [{"password": "synthetic-admin-password"}, {"password": "synthetic-retry-password"}])
|
||||||
|
|
||||||
|
def test_initial_workspace_spinner_version_and_single_bottom_log_are_preserved(self):
|
||||||
|
self.page.goto(self.base + "/", wait_until="networkidle")
|
||||||
|
expect(self.page.locator("#app")).to_be_hidden()
|
||||||
|
spinner = self.page.locator("#page-host > .loading-state")
|
||||||
|
expect(spinner).to_have_attribute("role", "status")
|
||||||
|
expect(spinner).to_have_attribute("aria-label", "加载中")
|
||||||
|
expect(spinner).to_have_text("")
|
||||||
|
expect(spinner.locator(".loading-spinner")).to_have_attribute("aria-hidden", "true")
|
||||||
|
expect(self.page.locator("#app-version")).to_have_text("2.0.5")
|
||||||
|
expect(self.page.locator("#access-mode")).to_have_text("")
|
||||||
|
expect(self.page.locator("#log-panel")).to_have_count(1)
|
||||||
|
expect(self.page.locator('[role="log"]')).to_have_count(1)
|
||||||
|
expect(self.page.locator("#log-panel")).to_be_hidden()
|
||||||
|
self.assertTrue(self.page.locator("#log-panel").evaluate("""node =>
|
||||||
|
Boolean(document.querySelector('#workspace').compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING)
|
||||||
|
&& Boolean(node.compareDocumentPosition(document.querySelector('.status-bar')) & Node.DOCUMENT_POSITION_FOLLOWING)
|
||||||
|
"""))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -74,14 +74,14 @@ class RunIntentBrowserTests(unittest.TestCase):
|
|||||||
self.poll()
|
self.poll()
|
||||||
expect(self.page.locator("#connection")).to_have_text("已登录")
|
expect(self.page.locator("#connection")).to_have_text("已登录")
|
||||||
expect(self.page.locator("#refresh")).to_be_enabled()
|
expect(self.page.locator("#refresh")).to_be_enabled()
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text("等待恢复")
|
expect(self.page.locator("#data-summary")).to_contain_text("等待自动恢复")
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text("上次失败")
|
expect(self.page.locator("#data-summary")).to_contain_text("上次失败")
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text("游戏请求超时")
|
expect(self.page.locator("#data-summary")).to_contain_text("游戏请求超时")
|
||||||
expect(toggle).to_have_text("停止")
|
expect(toggle).to_have_text("停止")
|
||||||
expect(self.page.locator(f'.account-tab[data-account="{self.first}"] .account-dot')).not_to_have_class("account-dot error")
|
expect(self.page.locator(f'.account-tab[data-account="{self.first}"] .account-dot')).not_to_have_class("account-dot error")
|
||||||
self.online()
|
self.online()
|
||||||
self.poll()
|
self.poll()
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text("正在自动执行")
|
expect(self.page.locator("#data-summary")).to_contain_text("策略运行中")
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text("上次失败")
|
expect(self.page.locator("#data-summary")).to_contain_text("上次失败")
|
||||||
expect(self.page.locator("#connection")).to_have_text("已登录")
|
expect(self.page.locator("#connection")).to_have_text("已登录")
|
||||||
expect(self.page.locator("#log-panel")).to_be_hidden()
|
expect(self.page.locator("#log-panel")).to_be_hidden()
|
||||||
@@ -122,7 +122,7 @@ class RunIntentBrowserTests(unittest.TestCase):
|
|||||||
expect(self.page.locator("#data-summary")).to_contain_text("用户暂停")
|
expect(self.page.locator("#data-summary")).to_contain_text("用户暂停")
|
||||||
toggle.click()
|
toggle.click()
|
||||||
expect(toggle).to_have_text("停止")
|
expect(toggle).to_have_text("停止")
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text("正在自动执行")
|
expect(self.page.locator("#data-summary")).to_contain_text("策略运行中")
|
||||||
self.assertEqual([(account, operation) for account, operation, _ in self.actions],
|
self.assertEqual([(account, operation) for account, operation, _ in self.actions],
|
||||||
[(self.first, "stop"), (self.first, "start")])
|
[(self.first, "stop"), (self.first, "start")])
|
||||||
self.assertEqual(self.writes, [])
|
self.assertEqual(self.writes, [])
|
||||||
@@ -138,7 +138,7 @@ class RunIntentBrowserTests(unittest.TestCase):
|
|||||||
expect(self.page.locator("#strategy-toggle")).to_be_enabled()
|
expect(self.page.locator("#strategy-toggle")).to_be_enabled()
|
||||||
expect(self.page.locator("#data-summary")).to_contain_text(reason)
|
expect(self.page.locator("#data-summary")).to_contain_text(reason)
|
||||||
expect(self.page.locator("#data-summary img")).to_have_count(0)
|
expect(self.page.locator("#data-summary img")).to_have_count(0)
|
||||||
expect(self.page.locator("#data-summary")).not_to_contain_text("正在自动执行")
|
expect(self.page.locator("#data-summary")).not_to_contain_text("策略运行中")
|
||||||
expect(self.page.locator("#data-summary")).not_to_contain_text("用户暂停")
|
expect(self.page.locator("#data-summary")).not_to_contain_text("用户暂停")
|
||||||
self.assertEqual(self.actions, [])
|
self.assertEqual(self.actions, [])
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ class RunIntentBrowserTests(unittest.TestCase):
|
|||||||
panel = self.go("hatching")
|
panel = self.go("hatching")
|
||||||
panel.locator('button[data-operation="apply_preset"]').click()
|
panel.locator('button[data-operation="apply_preset"]').click()
|
||||||
expect(self.page.locator("#notice")).to_contain_text("预设已保存")
|
expect(self.page.locator("#notice")).to_contain_text("预设已保存")
|
||||||
expect(self.page.locator("#notice")).to_contain_text("正在自动执行")
|
expect(self.page.locator("#notice")).to_contain_text("策略运行中")
|
||||||
expect(self.page.locator("#strategy-toggle")).to_have_text("停止")
|
expect(self.page.locator("#strategy-toggle")).to_have_text("停止")
|
||||||
self.assertEqual(len(self.writes), 1)
|
self.assertEqual(len(self.writes), 1)
|
||||||
self.assertTrue(self.configs[self.first]["policy"]["egg_rules"]["1001010"]["enabled"])
|
self.assertTrue(self.configs[self.first]["policy"]["egg_rules"]["1001010"]["enabled"])
|
||||||
|
|||||||
@@ -110,8 +110,10 @@ class WorkbenchBrowserTests(unittest.TestCase):
|
|||||||
def go(self, key, page=None):
|
def go(self, key, page=None):
|
||||||
page=page or self.page
|
page=page or self.page
|
||||||
page.locator(f'.page-tab[data-page="{key}"]').click()
|
page.locator(f'.page-tab[data-page="{key}"]').click()
|
||||||
page.wait_for_selector(f'.page-panel[data-page="{key}"]:not([hidden]) .page-loading[data-loading="false"]')
|
page.wait_for_selector(f'.page-panel[data-page="{key}"]:not([hidden]) .page-loading[data-loading="false"]', state="attached")
|
||||||
return page.locator(f'.page-panel[data-page="{key}"]:not([hidden])')
|
panel = page.locator(f'.page-panel[data-page="{key}"]:not([hidden])')
|
||||||
|
expect(panel).to_have_attribute("aria-busy", "false")
|
||||||
|
return panel
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def field(root,path):
|
def field(root,path):
|
||||||
|
|||||||
+12
-12
@@ -295,7 +295,7 @@ def _bag(dto, engine, config, query):
|
|||||||
"rule_defaults": {"enabled": False, "reserve": 0}, "rule_path": ["policy", "gift_items", key],
|
"rule_defaults": {"enabled": False, "reserve": 0}, "rule_path": ["policy", "gift_items", key],
|
||||||
"edits": {field: _edit(["policy", "gift_items", key, field], kind, disabled=not eligible,
|
"edits": {field: _edit(["policy", "gift_items", key, field], kind, disabled=not eligible,
|
||||||
reason="此类物品不进入自动赠礼" if not eligible else "") for field, kind in (("enabled", "boolean"), ("reserve", "integer"))}})
|
reason="此类物品不进入自动赠礼" if not eligible else "") for field, kind in (("enabled", "boolean"), ("reserve", "integer"))}})
|
||||||
dto["summary"] = f"{len(groups)} 类物品 / {sum(row['count'] for row in groups.values())} 件;同种库存合并显示"
|
dto["summary"] = f"{len(groups)} 类物品 / {sum(row['count'] for row in groups.values())} 件"
|
||||||
|
|
||||||
|
|
||||||
def _ranch(dto, engine, config, query):
|
def _ranch(dto, engine, config, query):
|
||||||
@@ -360,7 +360,7 @@ def _ranch(dto, engine, config, query):
|
|||||||
if row["group"] not in known:
|
if row["group"] not in known:
|
||||||
known.add(row["group"])
|
known.add(row["group"])
|
||||||
dto["groups"].append({"id": row["group"], "label": "培育室" if row["group"] == "incubator" else "未归属牧场", "count": counts[row["group"]], "collapsed": False})
|
dto["groups"].append({"id": row["group"], "label": "培育室" if row["group"] == "incubator" else "未归属牧场", "count": counts[row["group"]], "collapsed": False})
|
||||||
dto["summary"] = f"{len(snapshot.raw['rooms'])} 座牧场;显示 {len(dto['rows'])} 只魔物;勾选目标按较小优先级先执行"
|
dto["summary"] = f"{len(snapshot.raw['rooms'])} 座牧场;显示 {len(dto['rows'])} 只魔物"
|
||||||
targets = [{"value": int(mon["id"]), "label": f"{catalog.monster_label(mon)} Lv.{mon.get('level', 1)}/{catalog.max_level(mon)}"}
|
targets = [{"value": int(mon["id"]), "label": f"{catalog.monster_label(mon)} Lv.{mon.get('level', 1)}/{catalog.max_level(mon)}"}
|
||||||
for mon in snapshot.raw["monsters"] if mon.get("process") == 3 and catalog.max_level(mon) is not None and int(mon.get("level", 1)) < catalog.max_level(mon)]
|
for mon in snapshot.raw["monsters"] if mon.get("process") == 3 and catalog.max_level(mon) is not None and int(mon.get("level", 1)) < catalog.max_level(mon)]
|
||||||
dto["feed_targets"] = targets
|
dto["feed_targets"] = targets
|
||||||
@@ -376,7 +376,7 @@ def _daily(dto, engine, config, query):
|
|||||||
dto["columns"] = [_column(k, label) for k, label in (("name", "项目 / 邮件"), ("status", "状态"), ("reward", "奖励 / 附件"))]
|
dto["columns"] = [_column(k, label) for k, label in (("name", "项目 / 邮件"), ("status", "状态"), ("reward", "奖励 / 附件"))]
|
||||||
for row in entries(engine.catalog, engine.snapshot, engine.daily_ledger):
|
for row in entries(engine.catalog, engine.snapshot, engine.daily_ledger):
|
||||||
dto["rows"].append({"id": row.key, "name": row.name, "status": row.status, "reward": row.reward, "claimable": row.action is not None})
|
dto["rows"].append({"id": row.key, "name": row.name, "status": row.status, "reward": row.reward, "claimable": row.action is not None})
|
||||||
dto["summary"] = "刷新只更新状态;领取勾选项目立即处理可领奖励;自动领取需要开启顶部策略"
|
dto["summary"] = ""
|
||||||
dto["actions"].append({"operation": "claim_daily", "label": "领取勾选项目", "payload": {}})
|
dto["actions"].append({"operation": "claim_daily", "label": "领取勾选项目", "payload": {}})
|
||||||
|
|
||||||
|
|
||||||
@@ -388,7 +388,7 @@ def _hatching(dto, engine, config, query):
|
|||||||
dto["columns"] = [_column("kind", "类型"), _column("description", "下一步 / 等待条件")]
|
dto["columns"] = [_column("kind", "类型"), _column("description", "下一步 / 等待条件")]
|
||||||
dto["rows"] = _plans(engine)
|
dto["rows"] = _plans(engine)
|
||||||
policy = engine.policy
|
policy = engine.policy
|
||||||
dto["summary"] = "先在背包魔物蛋配置规则,再开启顶部策略;空坑按优先级随机1~2秒装填"
|
dto["summary"] = ""
|
||||||
dto["details"] = {"feed_status": engine.planner.feed_status(engine.snapshot, policy),
|
dto["details"] = {"feed_status": engine.planner.feed_status(engine.snapshot, policy),
|
||||||
"last_draw": engine.last_draw or "尚无记录", "notes": list(dict.fromkeys(engine.planner.notes)),
|
"last_draw": engine.last_draw or "尚无记录", "notes": list(dict.fromkeys(engine.planner.notes)),
|
||||||
"preset": {"label": "绿色史莱姆金币预设(仅孵此蛋)", "patch": {
|
"preset": {"label": "绿色史莱姆金币预设(仅孵此蛋)", "patch": {
|
||||||
@@ -414,7 +414,7 @@ def _gifts(dto, engine, config, query):
|
|||||||
"quality": catalog.quality_text(mon), "likes": catalog.likes_text(mon["typeId"]), "remaining": remaining,
|
"quality": catalog.quality_text(mon), "likes": catalog.likes_text(mon["typeId"]), "remaining": remaining,
|
||||||
"cooldown": duration(remaining) if remaining else "可赠礼"})
|
"cooldown": duration(remaining) if remaining else "可赠礼"})
|
||||||
engine.gift_planner.plan(snapshot, engine.policy, engine.quest_policy)
|
engine.gift_planner.plan(snapshot, engine.policy, engine.quest_policy)
|
||||||
dto["summary"] = "自动代表按等级 → 好感 → 综合成长资质选择并记住;满好感或冷却时不换喂同种另一只"
|
dto["summary"] = ""
|
||||||
dto["details"] = {"notes": list(engine.gift_planner.notes), "next_ready_at": engine.gift_planner.next_ready_at,
|
dto["details"] = {"notes": list(engine.gift_planner.notes), "next_ready_at": engine.gift_planner.next_ready_at,
|
||||||
"inventory_page": "bag", "targets_page": "ranch"}
|
"inventory_page": "bag", "targets_page": "ranch"}
|
||||||
|
|
||||||
@@ -475,7 +475,7 @@ def _mainline(dto, engine, config, query):
|
|||||||
continue
|
continue
|
||||||
dto["rows"].append(row)
|
dto["rows"].append(row)
|
||||||
dto["details"][row["id"]] = detail
|
dto["details"][row["id"]] = detail
|
||||||
dto["summary"] = f"显示 {len(dto['rows'])} / {len(sources)} 条任务;未支持的步骤显示原因" if sources else "尚未读取任务,请刷新任务 / 预览"
|
dto["summary"] = f"显示 {len(dto['rows'])} / {len(sources)} 条任务" if sources else "尚未读取任务"
|
||||||
dto["tabs"] = [{"key": "status", "title": "任务状态"}, {"key": "policy", "title": "推进策略"}]
|
dto["tabs"] = [{"key": "status", "title": "任务状态"}, {"key": "policy", "title": "推进策略"}]
|
||||||
dto["actions"] = [{"operation": "refresh_tasks", "label": "刷新任务 / 预览", "payload": {}}]
|
dto["actions"] = [{"operation": "refresh_tasks", "label": "刷新任务 / 预览", "payload": {}}]
|
||||||
dto["battle_mode"] = {"mode": "experimental", "label": "实验模拟(近似,未完整验证)", "damage_rule": "保持原始属性;我方对敌最终伤害10倍,单次最高50000"}
|
dto["battle_mode"] = {"mode": "experimental", "label": "实验模拟(近似,未完整验证)", "damage_rule": "保持原始属性;我方对敌最终伤害10倍,单次最高50000"}
|
||||||
@@ -528,7 +528,7 @@ def _battles(dto, engine, config, query):
|
|||||||
dto["details"][row["id"]] = {"时间(北京时间)": row["time"], "上下文": row["kind_label"], "任务 / 地图": row["name"],
|
dto["details"][row["id"]] = {"时间(北京时间)": row["time"], "上下文": row["kind_label"], "任务 / 地图": row["name"],
|
||||||
"战斗模式": "实验模拟(近似,未完整验证)" if mode == "experimental" else "原版运行时" if mode == "original" else "记录未标明",
|
"战斗模式": "实验模拟(近似,未完整验证)" if mode == "experimental" else "原版运行时" if mode == "original" else "记录未标明",
|
||||||
"队伍": row["team"], "结果": row["outcome_label"], "详情 / 阻塞原因": row["message"], "奖励": shown_reward, "伤害规则": damage}
|
"队伍": row["team"], "结果": row["outcome_label"], "详情 / 阻塞原因": row["message"], "奖励": shown_reward, "伤害规则": damage}
|
||||||
dto["summary"] = f"已读取 {len(records)} 条记录,显示 {len(dto['rows'])} 条" if records else "尚无已读取的战斗记录;未记录结果不代表战斗成功"
|
dto["summary"] = f"已读取 {len(records)} 条记录,显示 {len(dto['rows'])} 条" if records else "尚无已读取的战斗记录"
|
||||||
dto["actions"] = [{"operation": "refresh_tasks", "label": "刷新战斗记录", "payload": {}}]
|
dto["actions"] = [{"operation": "refresh_tasks", "label": "刷新战斗记录", "payload": {}}]
|
||||||
|
|
||||||
|
|
||||||
@@ -559,7 +559,7 @@ def _commissions(dto, engine, config, query):
|
|||||||
"交付限制": {"允许物品": engine.quest_policy.allow_items, "允许魔物": engine.quest_policy.allow_monsters,
|
"交付限制": {"允许物品": engine.quest_policy.allow_items, "允许魔物": engine.quest_policy.allow_monsters,
|
||||||
"单次金币上限": engine.quest_policy.max_money, "允许已支持战斗": engine.quest_policy.battle_tasks},
|
"单次金币上限": engine.quest_policy.max_money, "允许已支持战斗": engine.quest_policy.battle_tasks},
|
||||||
"接取优先级": "氪金奖励较高的委托优先;仅接取原规划器确认可支持的委托"}
|
"接取优先级": "氪金奖励较高的委托优先;仅接取原规划器确认可支持的委托"}
|
||||||
dto["summary"] = f"今日剩余可接次数:{snapshot.raw.get('history', {}).get('loopTaskNum', '未知')};当前委托:{len(engine.tasks.current(snapshot))};按氪金奖励优先"
|
dto["summary"] = f"今日剩余可接次数:{snapshot.raw.get('history', {}).get('loopTaskNum', '未知')};当前委托:{len(engine.tasks.current(snapshot))}"
|
||||||
|
|
||||||
|
|
||||||
def _exploration(dto, engine, config, query):
|
def _exploration(dto, engine, config, query):
|
||||||
@@ -602,7 +602,7 @@ def _exploration(dto, engine, config, query):
|
|||||||
"edits": {"enabled": _edit(["explore_policy", "teams", key, "enabled"], "boolean", disabled=disabled),
|
"edits": {"enabled": _edit(["explore_policy", "teams", key, "enabled"], "boolean", disabled=disabled),
|
||||||
"area": _edit(["explore_policy", "teams", key, "area"], "select", options=_options([("", "请选择地区")]) + area_options, disabled=disabled),
|
"area": _edit(["explore_policy", "teams", key, "area"], "select", options=_options([("", "请选择地区")]) + area_options, disabled=disabled),
|
||||||
"monsters": members_edit}})
|
"monsters": members_edit}})
|
||||||
dto["summary"] = f"已有 {len(rows)} 支探险队;配置 {len(policy.teams)} 支;启用 {sum(rule.enabled for rule in policy.teams.values())} 支。完成时自动领奖,再次出发由开关控制。"
|
dto["summary"] = f"已有 {len(rows)} 支探险队;配置 {len(policy.teams)} 支;启用 {sum(rule.enabled for rule in policy.teams.values())} 支"
|
||||||
dto["details"] = {"help": "留空任一槽位恢复自动选人;手动队员必须三只不同魔物,队员等级不可高于队长;不自动花钱开队或召回"}
|
dto["details"] = {"help": "留空任一槽位恢复自动选人;手动队员必须三只不同魔物,队员等级不可高于队长;不自动花钱开队或召回"}
|
||||||
|
|
||||||
|
|
||||||
@@ -717,7 +717,7 @@ def _statistics(dto, engine, config, query):
|
|||||||
"unit": "ratio" if metric == "rate" else "个 / 体力", "empty_reason": "请选择关卡和难度"}
|
"unit": "ratio" if metric == "rate" else "个 / 体力", "empty_reason": "请选择关卡和难度"}
|
||||||
dto["charts"] = [dto["chart"]]
|
dto["charts"] = [dto["chart"]]
|
||||||
if not stage_id:
|
if not stage_id:
|
||||||
dto["summary"] = "请选择关卡和难度;关卡来自本地配置,统计按当前账号读取"
|
dto["summary"] = "尚未选择关卡和难度"
|
||||||
return
|
return
|
||||||
if stage is None or level not in stage.get("level", {}):
|
if stage is None or level not in stage.get("level", {}):
|
||||||
raise ValueError("数据分析的关卡或难度无效")
|
raise ValueError("数据分析的关卡或难度无效")
|
||||||
@@ -742,7 +742,7 @@ def _statistics(dto, engine, config, query):
|
|||||||
def _execution_plans(dto, engine, config, query):
|
def _execution_plans(dto, engine, config, query):
|
||||||
dto["columns"] = [_column("kind", "类型"), _column("description", "计划动作")]
|
dto["columns"] = [_column("kind", "类型"), _column("description", "计划动作")]
|
||||||
dto["rows"] = _plans(engine)
|
dto["rows"] = _plans(engine)
|
||||||
dto["summary"] = f"{len(dto['rows'])} 项计划;仅预览,开启顶部策略后由原引擎执行"
|
dto["summary"] = f"{len(dto['rows'])} 项计划"
|
||||||
dto["details"] = {"notes": list(dict.fromkeys(engine.planner.notes))}
|
dto["details"] = {"notes": list(dict.fromkeys(engine.planner.notes))}
|
||||||
|
|
||||||
|
|
||||||
@@ -763,7 +763,7 @@ def _yields(dto, engine, config, query):
|
|||||||
dto["rows"].append({"id": type_id, "type_id": int(type_id), "name": info.get("name", "未知"), "star": info.get("star", "?"), "time_total": total, "time_text": duration(total),
|
dto["rows"].append({"id": type_id, "type_id": int(type_id), "name": info.get("name", "未知"), "star": info.get("star", "?"), "time_total": total, "time_text": duration(total),
|
||||||
"sell_money": money, "sell_exp": exp, "gold_per_hour": round(money * 3600 / total, 2), "exp_per_hour": round(exp * 3600 / total, 2),
|
"sell_money": money, "sell_exp": exp, "gold_per_hour": round(money * 3600 / total, 2), "exp_per_hour": round(exp * 3600 / total, 2),
|
||||||
"ratio": round(ratio, 3) if ratio is not None else "无经验", "recommendation": "适合喂养" if ratio is not None and ratio < threshold else "适合派遣"})
|
"ratio": round(ratio, 3) if ratio is not None else "无经验", "recommendation": "适合喂养" if ratio is not None and ratio < threshold else "适合派遣"})
|
||||||
dto["summary"] = f"本地资料共 {len(engine.catalog.monsters)} 种魔物,当前显示 {len(dto['rows'])} 种;CSV/XLSX覆盖值仅影响收益计算"
|
dto["summary"] = f"本地资料共 {len(engine.catalog.monsters)} 种魔物,当前显示 {len(dto['rows'])} 种"
|
||||||
dto["actions"].append({"operation": "import_yields", "label": "导入CSV / XLSX收益资料", "accept": ".csv,.xlsx"})
|
dto["actions"].append({"operation": "import_yields", "label": "导入CSV / XLSX收益资料", "accept": ".csv,.xlsx"})
|
||||||
dto["details"] = {"import_columns": ["typeId / 编号 / 魔物ID", "sell_money / 派遣金币", "sell_exp / 强化经验", "time_total / 孵化秒数"]}
|
dto["details"] = {"import_columns": ["typeId / 编号 / 魔物ID", "sell_money / 派遣金币", "sell_exp / 强化经验", "time_total / 孵化秒数"]}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user