feat: add daily commission history for Web 2.0.8
This commit is contained in:
@@ -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)}));
|
||||
|
||||
Reference in New Issue
Block a user