feat: add daily commission history for Web 2.0.8

This commit is contained in:
AttilaNet
2026-11-13 09:59:43 +08:00
parent ad25d5b403
commit 296653d8d3
25 changed files with 2179 additions and 96 deletions
+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.7'}`}),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.8'}`}),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.7';$('#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.8';$('#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.7</span></span>
<span class="window-title">牧羊人之心牧场助手 <span id="app-version">2.0.8</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>
+13 -6
View File
@@ -9,7 +9,7 @@ export const PAGES = [
['commissions', '自动委托'], ['exploration', '自动探险'], ['maps', '自动扫荡'], ['statistics', '数据分析'], ['plans', '执行计划'], ['yields', '收益资料'],
];
export const initialQuery = page => page === 'bag' ? {category: 'eggs'} : page === 'mainline' ? {category: 'mainline', state: 'current'} : page === 'ranch' ? {grouped: false} : page === 'maps' ? {category: 'all', only_unlocked: true} : {};
export const initialQuery = page => page === 'bag' ? {category: 'eggs'} : page === 'mainline' ? {category: 'mainline', state: 'current'} : page === 'commissions' ? {tab: 'current'} : page === 'ranch' ? {grouped: false} : page === 'maps' ? {category: 'all', only_unlocked: true} : {};
class LoginPage {
constructor(host, page) {
@@ -161,7 +161,7 @@ export class PageView {
filters.forEach(field => {
if (this.key === 'bag' && field.key === 'category') return;
included.add(field.key);
if (!Object.hasOwn(this.query, field.key)) this.query[field.key] = field.value;
if (!Object.hasOwn(this.query, field.key) || field.type === 'date' && !this.query[field.key]) this.query[field.key] = field.value;
let item = this.filters.get(field.key);
const signature = JSON.stringify({...field, value: undefined});
if (!item || item.signature !== signature && !item.root.contains(document.activeElement)) {
@@ -170,6 +170,7 @@ export class PageView {
set: (_, value) => this.setQuery(field.key, value), onError: this.error,
});
if (field.key === 'search') { entry.root.type = 'search'; entry.root.placeholder = this.key === 'maps' ? '关卡、名称或掉落物品' : '按名称或编号筛选'; }
if (field.type === 'date') entry.root.type = 'date';
const root = el('label', {}, el('span', {text: field.label}), entry.root);
item?.root.remove();
item = {root, entry, signature};
@@ -187,11 +188,17 @@ export class PageView {
if (this.key === 'bag') tabs = [{key:'eggs',title:'魔物蛋'}, {key:'usable',title:'可使用'}, {key:'consumables',title:'消耗品'}, {key:'materials',title:'材料'}, {key:'other',title:'其他'}, {key:'equipment',title:'装备'}];
if (!tabs.length && this.key === 'hatching') tabs = ['孵蛋策略','牧场策略','喂养策略'].map(title => ({key:title,title}));
if (!tabs.length && this.key === 'mainline') tabs = [{key:'tasks',title:'任务状态'}, {key:'policy',title:'推进策略'}];
if (this.key === 'commissions') this.activeSubtab = this.query.tab || 'current';
const signature = JSON.stringify(tabs);
if (this.tabSignature !== signature) {
if (!this.activeSubtab || !tabs.some(tab => tab.key === this.activeSubtab)) this.activeSubtab = this.key === 'bag' ? this.query.category || tabs[0]?.key : tabs[0]?.key;
this.subtabs.replaceChildren(...tabs.map(tab => el('button', {type: 'button', class: 'subtab', role: 'tab', 'data-key': tab.key, text: tab.title || tab.label,
onClick: () => { this.activeSubtab = tab.key; if (this.key === 'bag') this.setQuery('category', tab.key); this.render(this.data || data); }})));
onClick: () => {
this.activeSubtab = tab.key;
if (this.key === 'commissions') { this.setQuery('tab', tab.key); this.updateSubtabs(data); return; }
if (this.key === 'bag') this.setQuery('category', tab.key);
this.render(this.data || data);
}})));
this.tabSignature = signature;
}
$$('.subtab', this.subtabs).forEach(button => { const selected = button.dataset.key === this.activeSubtab; button.setAttribute('aria-selected', selected); button.tabIndex = selected ? 0 : -1; });
@@ -220,7 +227,7 @@ export class PageView {
const currencies = action.currencies ? optionsList(action.currencies) : [null];
currencies.forEach(currency => {
const button = el('button', {type: 'button', text: `${action.label}${currency ? `(${currency.label})` : ''}`, 'data-operation': action.operation,
'data-selection': action.selection, onClick: () => this.options.action(this, action, currency?.value).catch(this.error)});
'data-selection': action.selection, onClick: () => action.operation === 'reload_view' ? this.options.load(this, true).catch(this.error) : this.options.action(this, action, currency?.value).catch(this.error)});
this.actionsHost.append(button);
});
});
@@ -296,12 +303,12 @@ export class PageView {
const data = this.data.details?.[row.id] || row.details;
if (!data) return;
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'?'战斗详情':this.key==='commissions'?'委托详情':'详情';
dialog(title, el('div', {class:'detail-sections'}, detailsList(data, labels)), {info:true});
}
openContext(event, selected, row) {
const items = [{label:'刷新本页',run:()=>this.perform('refresh',{page:this.key})}];
const items = [{label:'刷新本页',run:()=>this.key === 'commissions' && this.query.tab === 'history' ? this.options.load(this, true) : this.perform('refresh',{page:this.key})}];
if (this.key === 'ranch') {
items.push({label:'查看魔物详情',run:()=>this.showDetail(row)});
(this.data.actions || []).filter(action => ['lock','unlock','sell','feed'].includes(action.operation)).forEach(action => items.push({label:action.label,disabled:!selected.length,run:()=>this.options.action(this,action)}));