Skip to content

Commit 31f2a99

Browse files
committed
refactor: 修改背包统计,摩拉统计排在最前面
1 parent 39bd7d8 commit 31f2a99

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

html/bg.html

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,20 @@ <h1>{{ .title }}</h1>
211211
});
212212

213213
// 按材料名升序排序
214-
dataRows.sort((a, b) => a.cl.localeCompare(b.cl));
214+
dataRows.sort((a, b) => {
215+
if (a.cl === '摩拉数值' && b.cl !== '摩拉数值') {
216+
return -1; // a是摩拉,排前面
217+
} else if (a.cl !== '摩拉数值' && b.cl === '摩拉数值') {
218+
return 1; // b是摩拉,排前面
219+
} else {
220+
return a.cl.localeCompare(b.cl); // 都是摩拉或都不是,按字母排序
221+
}
222+
});
215223

216224
// 清空 tbody
217225
tbody.innerHTML = '';
218226

219-
// // 颜色分配和材料记录
220-
// const colorMap = {};
221-
// const colorPalette = [
222-
// '#e74c3c', '#3498db', '#2ecc71', '#f39c12', '#9b59b6',
223-
// '#1abc9c', '#d35400', '#43e20a', '#16a085', '#c0392b'
224-
// ];
225-
// let colorIndex = 0;
227+
226228
let materialMap = {};
227229
let lastCl = null;
228230

@@ -238,12 +240,6 @@ <h1>{{ .title }}</h1>
238240
}
239241
lastCl = cl;
240242

241-
// // 分配颜色
242-
// if (!colorMap[cl]) {
243-
// colorMap[cl] = colorPalette[colorIndex % colorPalette.length];
244-
// colorIndex++;
245-
// }
246-
// element.style.backgroundColor = colorMap[cl] + '20'; // 半透明
247243

248244
// 显示数量变化
249245
if (materialMap[cl] !== undefined) {

0 commit comments

Comments
 (0)