fix(web): remove duplicate inline runtime status notes (2.0.9)

This commit is contained in:
AttilaNet
2026-11-13 10:36:23 +08:00
parent 048be71ed1
commit cfce3e0bc5
14 changed files with 125 additions and 58 deletions
+4 -2
View File
@@ -1,8 +1,10 @@
# 牧羊人之心牧场助手 · Web 2.0.8
# 牧羊人之心牧场助手 · Web 2.0.9
## 产品约束
把现有桌面助手的功能和操作结构迁移至单管理员 Web 工作台。桌面版是页面顺序、信息密度、业务名称、保护条件与交互的依据,保留桌面兼容。Web `2.0.8`,源码发布入口 `main`,游戏数据版本 `1.9.68`;桌面正式版保留 `1.2.0`。启动与配置见 [运行说明](README.md),Docker 与更新条件见 [部署说明](../deploy/web/README.md),功能与验证状态见 [2.0.8 发布说明](../analysis/RELEASE_2_0_8.md)。
把现有桌面助手的功能和操作结构迁移至单管理员 Web 工作台。桌面版是页面顺序、信息密度、业务名称、保护条件与交互的依据,保留桌面兼容。Web `2.0.9`,源码发布入口 `main`,游戏数据版本 `1.9.68`;桌面正式版保留 `1.2.0`。启动与配置见 [运行说明](README.md),Docker 与更新条件见 [部署说明](../deploy/web/README.md),既有功能与历史验证见 [2.0.8 发布说明](../analysis/RELEASE_2_0_8.md)。
2.0.9 仅整理设置页重复运行提示,保留账号简短状态、错误、表格、表单与原单一底部分类日志;后端、日志及策略逻辑不变,21项相关测试通过,历史结果不计入本补丁,见 [本版发布说明](../analysis/RELEASE_2_0_9.md)。
使用者在 Windows 本机配置、验证,随后可在 Linux Docker 常驻运行。多个浏览器访问同一个管理员工作台;账号互相隔离,各账号串行执行,账号之间可以并行。
+5 -3
View File
@@ -1,6 +1,8 @@
# Web 2.0.8 运行说明
# Web 2.0.9 运行说明
Web **2.0.8**,源码发布入口 `main`,游戏资料基线 **1.9.68**。桌面正式版保留 **1.2.0**,入口为 `python -m ranch_assistant`;Web 使用独立依赖与数据根。自动委托提供当前委托与每日记录,功能和验证状态见 [2.0.8 发布说明](../analysis/RELEASE_2_0_8.md)。
Web **2.0.9**,源码发布入口 `main`,游戏资料基线 **1.9.68**。桌面正式版保留 **1.2.0**,入口为 `python -m ranch_assistant`;Web 使用独立依赖与数据根。自动委托提供当前委托与每日记录,功能和历史验证状态见 [2.0.8 发布说明](../analysis/RELEASE_2_0_8.md)。
2.0.9 仅整理设置页重复运行提示,21项相关测试通过,历史结果不计入本补丁,见 [本版发布说明](../analysis/RELEASE_2_0_9.md)。
Web 采用 FastAPI / Uvicorn 和原生 HTML/CSS/ES 模块,无 Node、npm 或前端编译步骤,不安装 PySide6。页面和策略能力沿用现有核心,详细业务范围与原有限制见 [桌面使用说明](../ranch_assistant/README.md)。多浏览器连接同一个管理员工作台;一个服务实例内,各账号独立线程并行,同一账号操作串行。
@@ -104,7 +106,7 @@ sh start-web.sh --no-browser
Web 检查固定官方 GitHub Releases 的稳定 `v2.x.y`,跳过桌面 1.x、未来 3.x、草稿和预发布。开发版本 `2.0.0.dev1` 可升级至同数字的正式 `v2.0.0`;没有正式 Web 2 发布时明确显示暂无更新。Windows 默认仅检查;Web “更新”按钮仅在宿主机显式启用并有有效只读心跳时可提交 `pending` 请求,安装、备份和回滚由宿主机执行。默认定时检查只通知,自动安装需操作者 opt-in。
已在 **2.0.1** 完成私有仓库和 GHCR 认证的部署,稳定 Release 和正式镜像就绪、宿主机心跳有效后,可直接通过“帮助 → 检查版本更新…”升级 **2.0.8**,无需先安装 2.0.2、重复初始化或替换宿主机更新器。升级完成后刷新网页以加载新版界面,底部日志默认收起。安装结果以宿主机健康检查为准;首次配置仅供尚未初始化的宿主机参考。
已在 **2.0.1** 完成私有仓库和 GHCR 认证的部署,稳定 Release 和正式镜像就绪、宿主机心跳有效后,可直接通过“帮助 → 检查版本更新…”升级 **2.0.9**,无需先安装 2.0.2、重复初始化或替换宿主机更新器。升级完成后刷新网页以加载新版界面,底部日志默认收起。安装结果以宿主机健康检查为准;首次配置仅供尚未初始化的宿主机参考。
## 离线验证
+1 -1
View File
@@ -1,6 +1,6 @@
"""Headless Web workspace for the ranch assistant."""
__version__ = "2.0.8"
__version__ = "2.0.9"
GAME_VERSION = "1.9.68"
__all__ = ["__version__", "GAME_VERSION"]
+2 -2
View File
@@ -415,7 +415,7 @@ async function exportYields(account=current()) {
async function command(name,account=current()) {
try {
if(name==='add-account'||name==='add-demo')return await addAccount(name==='add-demo');
if(name==='about')return dialog('关于牧场助手',el('div',{},el('p',{text:`牧羊人之心牧场助手 Web ${state.meta?.version || '2.0.8'}`}),el('p',{text:`游戏数据版本 ${state.meta?.gameVersion || '1.9.68'}`})),{info:true});
if(name==='about')return dialog('关于牧场助手',el('div',{},el('p',{text:`牧羊人之心牧场助手 Web ${state.meta?.version || '2.0.9'}`}),el('p',{text:`游戏数据版本 ${state.meta?.gameVersion || '1.9.68'}`})),{info:true});
if(name==='updates')return await showUpdates();
if(name==='admin-logout'){hideWorkbench();try{await api.logout();}finally{requireAuth();}return;}
if(!account)throw new Error('请先新增或选择账号。');
@@ -640,7 +640,7 @@ async function bootstrap() {
$('#app').hidden=false;
const [meta,schema]=await Promise.all([api.meta(),api.schema()]);state.meta=meta;state.schema=schema;
if(state.redirecting)return;
$('#app-version').textContent=meta.version || '2.0.8';$('#game-version').textContent=meta.gameVersion || '1.9.68';$('#access-mode').textContent=auth.access_mode==='local'||auth.access_mode==='loopback'?'本机工作台':auth.required?'管理工作台':'本机工作台';
$('#app-version').textContent=meta.version || '2.0.9';$('#game-version').textContent=meta.gameVersion || '1.9.68';$('#access-mode').textContent=auth.access_mode==='local'||auth.access_mode==='loopback'?'本机工作台':auth.required?'管理工作台':'本机工作台';
await syncAccounts();if(state.redirecting)return;state.ready=true;setStatus('工作台已连接');
}catch(failure){if(failure.status===401||$('#app').hidden){requireAuth();return;}if(state.redirecting)return;setStatus(failure.message);$('#page-host').replaceChildren(el('div',{class:'initial-state'},el('p',{text:failure.message}),el('button',{text:'重新连接',onClick:bootstrap})));}
}
+1 -1
View File
@@ -26,7 +26,7 @@
</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>
<span class="window-title">牧羊人之心牧场助手 <span id="app-version">2.0.8</span></span>
<span class="window-title">牧羊人之心牧场助手 <span id="app-version">2.0.9</span></span>
<span id="access-mode" class="muted"></span>
</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>
+2 -26
View File
@@ -116,7 +116,6 @@ export class PageView {
this.subtabs = el('div', {class: 'subtabs', role: 'tablist', 'aria-label': '子页面', hidden: true});
this.filterHost = el('div', {class: 'filter-bar'});
this.summary = el('p', {class: 'page-summary'});
this.runtimeStatus=el('div',{class:'page-summary',hidden:true});
this.formHost = el('div', {class: 'policy-form'});
this.actionsHost = el('div', {class: 'page-toolbar'});
this.content = el('div', {class: 'page-content'});
@@ -124,7 +123,7 @@ export class PageView {
dirty: path => account.edits.has(pathKey(path)), onError: this.error, onSelection: () => this.syncActions(),
onContext: (event, selected, row) => this.openContext(event, selected, row), onDetail: row => this.showDetail(row)};
this.form = new PolicyForm(this.formHost, this.context);
this.surface = el('div', {class: 'page-surface'}, this.errorBox, this.subtabs, this.filterHost, this.summary, this.runtimeStatus, this.formHost, this.actionsHost, this.content);
this.surface = el('div', {class: 'page-surface'}, this.errorBox, this.subtabs, this.filterHost, this.summary, this.formHost, this.actionsHost, this.content);
this.body = el('div', {class: 'page-body'}, this.surface, this.loading);
this.root.append(this.header, this.body);
if (key === 'login') this.login = new LoginPage(this.content, this);
@@ -248,7 +247,7 @@ export class PageView {
this.updateFilters(data.filters || []);
this.summary.textContent = typeof data.summary === 'string' ? data.summary : textValue(data.summary || '');
this.summary.hidden = !data.summary;
this.updateRuntimeStatus(data.details || {}, data.battle_mode);
if (data.details?.statistics_error) this.showError(textValue(data.details.statistics_error));
let fields = data.form || this.options.schema(this.key);
if (this.key === 'login') fields = fields.filter(field => !(field.path?.[0] === 'auto_relogin' && field.path[1] === 'enabled'));
fields=fields.map(field=>field.path?.[0]==='policy'&&field.path[1]==='buy_ten'?{...field,disabled:!this.account.config?.policy?.allow_single_draw}:field);
@@ -276,29 +275,6 @@ export class PageView {
} else this.table.update(data.columns || [], data.rows || []);
}
updateRuntimeStatus(details, battleMode) {
const lines=[];
if(this.key==='hatching'){
if(this.activeSubtab==='喂养策略' && Array.isArray(details.feed_status))lines.push(['feed_status','当前喂养状态:'+textValue(details.feed_status[1])]);
if(this.activeSubtab==='孵蛋策略' && details.last_draw!==undefined)lines.push(['last_draw','最近抽蛋:'+textValue(details.last_draw)]);
}
if(this.key==='gifts' && Object.hasOwn(details,'next_ready_at')){
const ready=details.next_ready_at;
lines.push(['next_ready_at',ready===null?'下次赠礼:当前没有符合条件的目标或物品,等待状态更新':'下次可赠礼:'+chinaTime(ready,{date:true})+'(北京时间)']);
}
// Planner notes are current execution/wait reasons, unlike DTO help text.
const notes = Array.isArray(details.notes) ? [...new Set(details.notes.filter(note => typeof note === 'string' && note.trim()))] : [];
if(notes.length)lines.push(['planner_notes',notes.join('\n')]);
if(details.statistics_error)lines.push(['statistics_error',textValue(details.statistics_error)]);
if(battleMode?.label)lines.push(['battle_mode',battleMode.label]);
const signature=JSON.stringify(lines);
if(signature!==this.runtimeSignature){
this.runtimeStatus.replaceChildren(...lines.map(([key,text])=>el('p',{'data-view-status':key,text})));
this.runtimeSignature=signature;
}
this.runtimeStatus.hidden=!lines.length;
}
showDetail(row) {
const data = this.data.details?.[row.id] || row.details;
if (!data) return;
@@ -131,11 +131,12 @@ class PageLoadingBrowserTests(unittest.TestCase):
expect(panel.locator("tbody tr")).to_have_count(32)
self.page.screenshot(path=str(artifacts / "settled-dense.png"))
def test_passive_refresh_preserves_editing_table_and_business_reasons(self):
def test_passive_refresh_preserves_editing_table_without_inline_notes(self):
self.open()
panel = self.bag()
expect(panel.locator("tbody tr")).to_have_count(32)
expect(panel.locator('[data-view-status="planner_notes"]')).to_have_text("金币不足,等待补货")
expect(panel.locator('[data-view-status="planner_notes"]')).to_have_count(0)
expect(panel).not_to_contain_text("金币不足,等待补货")
self.assertNotIn("STATIC_HELP_SENTINEL", panel.inner_text())
self.assertNotIn("STATIC_NOTE_SENTINEL", panel.inner_text())
self.assertEqual(panel.locator(".info-note, .field-help").count(), 0)
@@ -156,6 +157,7 @@ class PageLoadingBrowserTests(unittest.TestCase):
expect(field).to_be_focused()
expect(field).to_have_value("")
self.assertTrue(field.evaluate("node => node === window.loadingField && window.loadingTable.isConnected && node.closest('.page-panel').querySelector('table') === window.loadingTable"))
expect(panel).not_to_contain_text("金币不足,等待补货")
expect(self.page.locator("#log-panel")).to_be_hidden()
self.assertEqual(self.page.locator("#log-panel").count(), 1)
@@ -148,7 +148,7 @@ class WorkbenchBrowserTests(unittest.TestCase):
expect(panel.locator('.form-section legend')).to_have_text('孵蛋策略')
panel.locator('.subtab[data-key="喂养策略"]').click()
expect(panel.locator('.form-section legend')).to_have_text('喂养策略')
expect(panel.locator('[data-view-status="feed_status"]')).to_be_visible()
expect(panel.locator('[data-view-status="feed_status"]')).to_have_count(0)
if key=='mainline':
expect(panel.locator('.subtab[data-key="policy"]')).to_be_visible()
panel.locator('.subtab[data-key="policy"]').click()
@@ -444,17 +444,20 @@ class WorkbenchBrowserTests(unittest.TestCase):
expect(panel.locator('td[data-column="per_stamina"]')).to_have_attribute('title','0.001')
self.assertEqual(self.errors,[])
def test_runtime_statuses_and_preset_without_confirmation(self):
def test_settings_omit_runtime_statuses_and_preset_without_confirmation(self):
def gifts_view(route):
self.fulfill(route,{'data':{'page':'gifts','title':'自动赠礼','summary':'离线状态','form':[],'filters':[],'columns':[],'rows':[],'actions':[],
'details':{'next_ready_at':1794294489}},'loading':False})
self.page.route(f'**/api/accounts/{self.first}/views/gifts?*',gifts_view)
self.open()
panel=self.go('hatching')
expect(panel.locator('[data-view-status="last_draw"]')).to_contain_text('最近抽蛋:')
expect(panel.locator('.form-section legend')).to_have_text('孵蛋策略')
expect(panel.locator('[data-view-status="last_draw"]')).to_have_count(0)
expect(panel).not_to_contain_text('最近抽蛋:')
panel.locator('.subtab[data-key="喂养策略"]').click()
data=self.manager.view(self.first,'hatching',{})['data']
expect(panel.locator('[data-view-status="feed_status"]')).to_contain_text(data['details']['feed_status'][1])
expect(panel.locator('.form-section legend')).to_have_text('喂养策略')
expect(panel.locator('[data-view-status="feed_status"]')).to_have_count(0)
expect(panel).not_to_contain_text('当前喂养状态:')
panel.locator('button[data-operation="apply_preset"]').click()
expect(self.page.locator('#action-dialog')).not_to_be_visible()
self.page.wait_for_timeout(1400)
@@ -462,9 +465,72 @@ class WorkbenchBrowserTests(unittest.TestCase):
self.assertTrue(self.manager.get_config(self.first)['config']['policy']['egg_rules']['1001010']['enabled'])
self.assertFalse(self.manager.status(self.first)['running'])
panel=self.go('gifts')
expect(panel.locator('[data-view-status="next_ready_at"]')).to_contain_text('北京时间')
expect(panel.locator('[data-view-status="next_ready_at"]')).to_have_count(0)
expect(panel).not_to_contain_text('下次可赠礼:')
expect(panel.locator('button[data-operation="configure_bag"]')).to_be_visible()
self.assertEqual(self.errors,[])
def test_bulk_runtime_notes_stay_out_of_settings_and_statistics_errors_retry(self):
keys = ('hatching', 'mainline', 'gifts', 'commissions', 'exploration', 'maps', 'ranch', 'daily', 'plans')
statistics_error = '本地统计读取失败,请查看服务器日志'
def diagnostics_view(route):
response = route.fetch().json() # Disposable loopback server and demo data only.
data = response.get('data')
if data is not None:
data.setdefault('details', {}).update({
'notes': [f'INLINE_RUNTIME_ONLY_{i}: retained primary / gift / potential / waiting' for i in range(40)],
'last_draw': 'INLINE_DRAW_ONLY', 'feed_status': ['waiting', 'INLINE_FEED_ONLY'],
'next_ready_at': 1794294489,
})
data['battle_mode'] = {'label': 'INLINE_BATTLE_MODE_ONLY'}
if data['page'] == 'statistics':
data['details']['statistics_error'] = statistics_error
self.fulfill(route, response)
self.page.route(f'**/api/accounts/{self.first}/views/*', diagnostics_view)
self.open()
for key in keys:
with self.subTest(page=key):
panel = self.go(key)
expect(panel.locator('[data-view-status]')).to_have_count(0)
self.assertNotIn('INLINE_', panel.evaluate('node => node.outerHTML'))
expect(panel.locator('.page-error')).to_be_hidden()
panel = self.go('hatching')
artifacts = Path(__file__).resolve().parents[3] / 'test-artifacts' / 'ui209'
artifacts.mkdir(parents=True, exist_ok=True)
for width, height in ((1280, 800), (390, 844)):
self.page.set_viewport_size({'width': width, 'height': height})
for tab in ('孵蛋策略', '牧场策略', '喂养策略'):
panel.locator(f'.subtab[data-key="{tab}"]').click()
expect(panel.locator('.form-section legend')).to_have_text(tab)
self.assertNotIn('INLINE_', panel.evaluate('node => node.outerHTML'))
panel.locator('.subtab[data-key="孵蛋策略"]').click()
first_control = panel.locator('.form-section input').first
expect(first_control).to_be_visible()
self.assertTrue(first_control.evaluate('''node => {
const r = node.getBoundingClientRect(), panel = node.closest('.page-panel').getBoundingClientRect();
return r.top >= panel.top && r.bottom <= Math.min(panel.bottom, innerHeight);
}'''), 'Settings must begin inside the visible workbench')
self.assertLessEqual(self.page.evaluate('document.documentElement.scrollWidth'), width)
self.page.screenshot(path=str(artifacts / f'hatching-{width}x{height}.png'))
expect(self.page.locator('#strategy-toggle')).to_be_visible()
expect(self.page.locator('#log-panel')).to_have_count(1)
expect(self.page.locator('#log-panel')).to_be_hidden()
self.page.locator('#log-toggle').click()
expect(self.page.locator('#log-panel')).to_be_visible()
self.page.locator('#log-toggle').click()
expect(self.page.locator('#log-panel')).to_be_hidden()
panel = self.go('statistics')
expect(panel.get_by_role('alert')).to_contain_text('本地统计读取失败,请查看服务器日志')
expect(panel.locator('.page-loading')).to_be_hidden()
statistics_error = ''
with self.page.expect_response(lambda response: '/views/statistics?' in response.url):
panel.get_by_role('button', name='重新读取', exact=True).click()
expect(panel.get_by_role('alert')).to_be_hidden()
expect(panel.locator('.statistics-table-host table')).to_be_visible()
self.assertEqual(self.errors, [])
def test_update_dialog_polls_host_progress_recovers_and_stops_on_close(self):
calls=[]
applied=False