mirror of
https://github.com/earthjasonlin/zzz-signal-search-export.git
synced 2025-08-04 19:20:08 +08:00
feat(uigf): support UIGFv4.0(Beta)
Users don't have to delete their data. New data structure is used automatically when new data is fetched - Set `count` to `"1"` as default for old data - Record `count` from API - Link to the UIGF website BREAKING CHANGE: SRGF is no longer supported, use UIGFv4.0(Beta) instead
This commit is contained in:
@@ -2,8 +2,9 @@ const { app, ipcMain, dialog } = require('electron')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const getData = require('./getData').getData
|
||||
const { version } = require('../../package.json')
|
||||
const { name, version } = require('../../package.json')
|
||||
const i18n = require('./i18n')
|
||||
const { exit } = require('process')
|
||||
|
||||
const getTimeString = () => {
|
||||
return new Date().toLocaleString('sv').replace(/[- :]/g, '').slice(0, -2)
|
||||
@@ -24,25 +25,28 @@ const start = async () => {
|
||||
}
|
||||
const result = {
|
||||
info: {
|
||||
uid: data.uid,
|
||||
lang: data.lang,
|
||||
export_time: formatDate(new Date()),
|
||||
export_timestamp: Math.ceil(Date.now() / 1000),
|
||||
export_app: 'zzz-signal-search-export',
|
||||
export_app: `${name}`,
|
||||
export_app_version: `v${version}`,
|
||||
region_time_zone: data.region_time_zone,
|
||||
srgf_version: 'v1.0'
|
||||
version: "v4.0"
|
||||
},
|
||||
list: []
|
||||
nap: [
|
||||
{
|
||||
uid: current,
|
||||
timezone: data.region_time_zone,
|
||||
lang: data.lang,
|
||||
list: []
|
||||
}
|
||||
]
|
||||
}
|
||||
const listTemp = []
|
||||
for (let [type, arr] of data.result) {
|
||||
arr.forEach(log => {
|
||||
listTemp.push({
|
||||
gacha_id: log.gacha_id,
|
||||
gacha_type: log.gacha_type,
|
||||
gacha_type: log.gacha_type,
|
||||
item_id: log.item_id,
|
||||
count: '1',
|
||||
count: log.count,
|
||||
time: log.time,
|
||||
name: log.name,
|
||||
item_type: log.item_type,
|
||||
@@ -53,14 +57,14 @@ const start = async () => {
|
||||
}
|
||||
listTemp.sort((a, b) => Number(BigInt(a.id) - BigInt(b.id)))
|
||||
listTemp.forEach(item => {
|
||||
result.list.push({
|
||||
result.nap[0].list.push({
|
||||
...item
|
||||
})
|
||||
})
|
||||
const filePath = dialog.showSaveDialogSync({
|
||||
defaultPath: path.join(app.getPath('downloads'), `SRGF_${data.uid}_${getTimeString()}`),
|
||||
defaultPath: path.join(app.getPath('downloads'), `UIGF_${data.uid}_${getTimeString()}`),
|
||||
filters: [
|
||||
{ name: i18n.srgf.fileType, extensions: ['json'] }
|
||||
{ name: i18n.uigf.fileType, extensions: ['json'] }
|
||||
]
|
||||
})
|
||||
if (filePath) {
|
||||
@@ -69,6 +73,6 @@ const start = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.handle('EXPORT_SRGF_JSON', async () => {
|
||||
ipcMain.handle('EXPORT_UIGF_JSON', async () => {
|
||||
await start()
|
||||
})
|
@@ -58,6 +58,13 @@ const readData = async () => {
|
||||
const data = await readJSON(dataPath, name)
|
||||
data.typeMap = new Map(data.typeMap) || defaultTypeMap
|
||||
data.result = new Map(data.result)
|
||||
data.result.forEach((value, key) => {
|
||||
value.forEach(item => {
|
||||
if (!('count' in item)) {
|
||||
item.count = "1";
|
||||
}
|
||||
});
|
||||
});
|
||||
if (data.uid) {
|
||||
dataMap.set(data.uid, data)
|
||||
}
|
||||
@@ -423,8 +430,8 @@ const fetchData = async (urlOverride) => {
|
||||
for (const type of gachaType) {
|
||||
const { list, uid, region, region_time_zone } = await getGachaLogs(type, queryString)
|
||||
const logs = list.map((item) => {
|
||||
const { id, item_id, item_type, name, rank_type, time, gacha_id, gacha_type } = item
|
||||
return { id, item_id, item_type, name, rank_type, time, gacha_id, gacha_type }
|
||||
const { id, item_id, item_type, name, rank_type, time, gacha_id, gacha_type, count} = item
|
||||
return { id, item_id, item_type, name, rank_type, time, gacha_id, gacha_type, count }
|
||||
})
|
||||
logs.reverse()
|
||||
typeMap.set(type.key, type.name)
|
||||
|
@@ -66,7 +66,7 @@ const parseText = (text, data) => {
|
||||
}
|
||||
|
||||
const mainProps = [
|
||||
'symbol', 'ui', 'log', 'excel',"srgf"
|
||||
'symbol', 'ui', 'log', 'excel',"uigf"
|
||||
]
|
||||
|
||||
const i18n = new Proxy(raw, {
|
||||
|
@@ -4,7 +4,7 @@ const { disableProxy, proxyStatus } = require('./module/system-proxy')
|
||||
require('./getData')
|
||||
require('./bridge')
|
||||
require('./excel')
|
||||
require('./SRGFJson')
|
||||
require('./UIGFJson')
|
||||
const { getUpdateInfo } = require('./update/index')
|
||||
|
||||
const isDev = !app.isPackaged
|
||||
|
Reference in New Issue
Block a user