feat: panel

This commit is contained in:
bietiaop 2024-07-13 17:52:31 +08:00
parent 35c8c95b80
commit 27171c5727
77 changed files with 2126 additions and 312 deletions

View file

@ -1,5 +1,6 @@
import { SingleGachaLog, ZZZGachaLogResp } from '../model/gacha.js';
import { sleep } from '../utils/time.js';
import { rank } from './convert.js';
import { getGachaLog, saveGachaLog } from './db.js';
import { ZZZ_GET_GACHA_LOG_API } from './mysapi/api.js';
@ -96,7 +97,12 @@ export async function getZZZGachaLogByAuthkey(
* @param {string} authKey
* @param {string} uid
* @returns {Promise<{
* [x: string]: SingleGachaLog[];
* data: {
* [x: string]: SingleGachaLog[];
* },
* count: {
* [x: string]: number;
* }
* }>}
*/
export async function updateGachaLog(authKey, uid) {
@ -104,26 +110,13 @@ export async function updateGachaLog(authKey, uid) {
if (!previousLog) {
previousLog = {};
}
let newCount = {};
for (const name in gacha_type_meta_data) {
if (!previousLog[name]) {
previousLog[name] = [];
}
previousLog[name] = previousLog[name].map(
i =>
new SingleGachaLog(
i.uid,
i.gacha_id,
i.gacha_type,
i.item_id,
i.count,
i.time,
i.name,
i.lang,
i.item_type,
i.rank_type,
i.id
)
);
newCount[name] = 0;
previousLog[name] = previousLog[name].map(i => new SingleGachaLog(i));
const lastSaved = previousLog[name]?.[0];
let page = 1;
let endId = '0';
@ -145,6 +138,7 @@ export async function updateGachaLog(authKey, uid) {
break queryLabel;
}
newData.push(item);
newCount[name]++;
}
endId = log.list[log.list.length - 1]?.id || endId;
page++;
@ -154,14 +148,12 @@ export async function updateGachaLog(authKey, uid) {
previousLog[name] = [...newData, ...previousLog[name]];
}
saveGachaLog(uid, previousLog);
return previousLog;
return {
data: previousLog,
count: newCount,
};
}
const RANK_MAP = {
4: 'S',
3: 'A',
2: 'B',
};
const HOMO_TAG = ['非到极致', '运气不好', '平稳保底', '小欧一把', '欧狗在此'];
const EMOJI = [
[4, 8, 13],
@ -186,10 +178,10 @@ const NORMAL_LIST = [
];
const FLOORS_MAP = {
'邦布频段': [50, 70],
'音擎频段': [50, 70],
'独家频段': [60, 80],
'常驻频段': [60, 80],
邦布频段: [50, 70],
音擎频段: [50, 70],
独家频段: [60, 80],
常驻频段: [60, 80],
};
function getLevelFromList(ast, lst) {
@ -214,22 +206,7 @@ export async function anaylizeGachaLog(uid) {
}
const result = [];
for (const name in savedData) {
const data = savedData[name].map(
item =>
new SingleGachaLog(
item.uid,
item.gacha_id,
item.gacha_type,
item.item_id,
item.count,
item.time,
item.name,
item.lang,
item.item_type,
item.rank_type,
item.id
)
);
const data = savedData[name].map(item => new SingleGachaLog(item));
const earliest = data[data.length - 1];
const latest = data[0];
const list = [];
@ -256,7 +233,7 @@ export async function anaylizeGachaLog(uid) {
}
list.push({
...item,
rank_type_label: RANK_MAP[item.rank_type],
rank_type_label: rank.getRankChar(item.rank_type),
isUp: isUp,
totalCount: '-',
color: 'white',