feat(uigf): support multiple account export

This commit is contained in:
2024-07-23 15:03:30 +08:00
parent 2814ed211b
commit 0cdc7662f7
5 changed files with 87 additions and 51 deletions

View File

@@ -17,21 +17,7 @@ const formatDate = (date) => {
return `${y}-${m}-${d} ${date.toLocaleString('zh-cn', { hour12: false }).slice(-8)}`
}
const start = async () => {
const { dataMap, current } = await getData()
const data = dataMap.get(current)
if (!data.result.size) {
throw new Error('数据为空')
}
const serverTimeZone = new Map([
["prod_gf_cn", 8]
])
let timezone
timezone = serverTimeZone.get(data.region)
if(!timezone) {
throw new Error('服务器时区不支持')
}
const start = async (uids) => {
const result = {
info: {
export_timestamp: Math.ceil(Date.now() / 1000),
@@ -39,39 +25,57 @@ const start = async () => {
export_app_version: `v${version}`,
version: "v4.0"
},
nap: [
{
uid: current,
timezone: timezone,
lang: data.lang,
list: []
}
]
nap: []
}
const listTemp = []
for (let [type, arr] of data.result) {
arr.forEach(log => {
listTemp.push({
gacha_id: log.gacha_id,
gacha_type: log.gacha_type,
item_id: log.item_id,
count: log.count,
time: log.time,
name: log.name,
item_type: log.item_type,
rank_type: log.rank_type,
id: log.id
const { dataMap, current } = await getData()
let fulldata = []
uids.forEach(uid => {
fulldata.push(dataMap.get(uid))
})
if (!fulldata.length) {
throw new Error('数据为空')
}
const serverTimeZone = new Map([
["prod_gf_cn", 8]
])
fulldata.forEach(data => {
let timezone
timezone = serverTimeZone.get(data.region)
if(!timezone) {
throw new Error('不支持此服务器')
}
const listTemp = []
for (let [type, arr] of data.result) {
arr.forEach(log => {
listTemp.push({
gacha_id: log.gacha_id,
gacha_type: log.gacha_type,
item_id: log.item_id,
count: log.count,
time: log.time,
name: log.name,
item_type: log.item_type,
rank_type: log.rank_type,
id: log.id
})
})
}
listTemp.sort((a, b) => Number(BigInt(a.id) - BigInt(b.id)))
let dataTemp = {
uid: data.uid,
timezone: timezone,
lang: data.lang,
list: []
}
listTemp.forEach(item => {
dataTemp.list.push({
...item
})
})
}
listTemp.sort((a, b) => Number(BigInt(a.id) - BigInt(b.id)))
listTemp.forEach(item => {
result.nap[0].list.push({
...item
})
result.nap.push(dataTemp)
})
const filePath = dialog.showSaveDialogSync({
defaultPath: path.join(app.getPath('downloads'), `UIGF_${data.uid}_${getTimeString()}`),
defaultPath: path.join(app.getPath('downloads'), fulldata.length > 1 ? `UIGF_${getTimeString()}` : `UIGF_${fulldata[0].uid}_${getTimeString()}`),
filters: [
{ name: i18n.uigf.fileType, extensions: ['json'] }
]
@@ -82,6 +86,6 @@ const start = async () => {
}
}
ipcMain.handle('EXPORT_UIGF_JSON', async () => {
await start()
ipcMain.handle('EXPORT_UIGF_JSON', async (event, uids) => {
await start(uids)
})