🐛 修复上传数据异常

This commit is contained in:
BTMuli
2026-01-12 12:51:58 +08:00
parent d306286c06
commit 6c3c11c077
2 changed files with 42 additions and 2 deletions

View File

@@ -299,8 +299,24 @@ async function handleHutaoUpload(uids: Array<string>): Promise<void> {
await showLoading.start("正在上传至胡桃云...", "正在刷新Token");
await hutaoStore.tryRefreshToken();
for (const u of uids) {
await showLoading.update(`正在上传UID:${u}`);
const dataRaw = await TSUserGacha.record.all(u);
await showLoading.start(`正在上传UID:${u}`, "正在获取EndId");
let endIdRes: TGApp.Plugins.Hutao.Gacha.EndIdRes = {
"100": 0,
"200": 0,
"301": 0,
"302": 0,
"500": 0,
};
const endIdResp = await hutao.Gacha.endIds(accessToken.value!, u);
if ("retcode" in endIdResp) {
showSnackbar.warn(`[${endIdResp.retcode}] ${endIdResp.message}`);
} else endIdRes = endIdResp;
const dataRaw: Array<TGApp.Sqlite.Gacha.Gacha> = [];
for (const [k, v] of Object.entries(endIdRes)) {
const gachaRead = await TSUserGacha.record.endId(u, k, v.toString());
await showLoading.update(`${k}-${v.toString()}-${gachaRead.length}`);
dataRaw.push(...gachaRead);
}
const data: TGApp.Plugins.Hutao.Gacha.UploadData = {
Uid: u,
Items: dataRaw.map((i) => ({

View File

@@ -122,6 +122,29 @@ async function getGachaRecords(uid: string): Promise<Array<TGApp.Sqlite.Gacha.Ga
return await db.select("SELECT * FROM GachaRecords WHERE uid = ?;", [uid]);
}
/**
* 获取指定EndId后的祈愿记录
* @since Beta v0.9.1
* @param uid - UID
* @param pool - Pool
* @param endId - endId
* @returns 祈愿记录
*/
async function getGachaRecordsByEndId(
uid: string,
pool: string,
endId?: string,
): Promise<Array<TGApp.Sqlite.Gacha.Gacha>> {
const db = await TGSqlite.getDB();
if (endId && endId !== "0") {
return await db.select(
"SELECT * FROM GachaRecords WHERE uid = ? AND uigfType = ? AND id > ?;",
[uid, pool, endId],
);
}
return await db.select("SELECT * FROM GachaRecords WHERE uid = ? AND uigfType = ?;", [uid, pool]);
}
/**
* 获取用户祈愿记录,并按照日期进行分组排序
* @since Beta v0.6.8
@@ -404,6 +427,7 @@ const TSUserGacha = {
},
record: {
all: getGachaRecords,
endId: getGachaRecordsByEndId,
time: getGachaRecordsByDate,
pool: getGachaRecordsByPool,
},