From 0e4f3599c943cf35bac0d7d00c21d52715a08efd Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Tue, 23 Jul 2024 11:10:27 +0800 Subject: [PATCH] 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 --- src/i18n/English.json | 4 ++-- src/i18n/简体中文.json | 4 ++-- src/i18n/繁體中文.json | 4 ++-- src/main/{SRGFJson.js => UIGFJson.js} | 32 +++++++++++++++------------ src/main/getData.js | 11 +++++++-- src/main/i18n.js | 2 +- src/main/main.js | 2 +- src/renderer/App.vue | 10 ++++----- src/renderer/components/Setting.vue | 4 +++- 9 files changed, 43 insertions(+), 30 deletions(-) rename src/main/{SRGFJson.js => UIGFJson.js} (73%) diff --git a/src/i18n/English.json b/src/i18n/English.json index 3052163..0262557 100644 --- a/src/i18n/English.json +++ b/src/i18n/English.json @@ -5,7 +5,7 @@ "ui.button.directUpdate": "Direct update", "ui.button.files": "Export Files", "ui.button.excel": "Export Excel", - "ui.button.srgf": "Export JSON", + "ui.button.uigf": "Export UIGF (Beta)", "ui.button.url": "Input URL", "ui.button.setting": "Settings", "ui.button.option": "Option", @@ -99,7 +99,7 @@ "excel.customFont": "Arial", "excel.filePrefix": "Zenless Zone Zero Signal Search Log", "excel.fileType": "Excel file", - "srgf.fileType": "Zenless Zone Zero Gacha Log Format file (SRGF)", + "uigf.fileType": "Uniformed Interchangeable GachaLog Format v4.0 (Beta)", "ui.extra.cacheClean": "1. Confirm whether the search history in the game has been opened, and if the error \"User authentication expired\" still appears, try the following steps \n2. Close the game window of Zenless Zone Zero \n3. Click the \"Open Web Cache Folder\" button above to open the \"Cache\" folder \n4. Delete the \"Cache_Data\" folder \n5. Start the Zenless Zone Zero game and open the search history page in the game \n6. Close this dialog and click the \"Update Data\" button", "ui.extra.findCacheFolder": "If the \"Open cache folder\" button does not respond, you can manually find the game's web cache folder. The directory is \"Your game installation path/ZenlessZoneZero_Data/webCaches/Cache/\"", "ui.extra.urlCopied": "URL Copied" diff --git a/src/i18n/简体中文.json b/src/i18n/简体中文.json index 0fbbe89..bac9d13 100644 --- a/src/i18n/简体中文.json +++ b/src/i18n/简体中文.json @@ -5,7 +5,7 @@ "ui.button.directUpdate": "直接更新", "ui.button.files": "导出文件", "ui.button.excel": "导出Excel", - "ui.button.srgf":"导出JSON", + "ui.button.uigf":"导出UIGF (Beta)", "ui.button.url": "输入URL", "ui.button.setting": "设置", "ui.button.option": "选项", @@ -98,7 +98,7 @@ "excel.customFont": "微软雅黑", "excel.filePrefix": "绝区零调频记录", "excel.fileType": "Excel文件", - "srgf.fileType":"绝区零调频记录格式文件(SRGF)", + "uigf.fileType":"统一可交换抽卡记录标准 v4.0(Beta)", "ui.extra.cacheClean": "1. 确认是否已经打开游戏内的抽卡历史记录,如果仍然出现“身份认证已过期”的错误,再尝试下面的步骤\n2. 关闭绝区零的游戏窗口\n3. 点击上方的“打开缓存文件夹”按钮,打开Cache文件夹\n4. 删除Cache_Data文件夹\n5. 启动绝区零游戏,打开游戏内抽卡历史记录页面\n6. 关闭这个对话框,再点击“更新数据”按钮", "ui.extra.findCacheFolder": "如果点“打开缓存文件夹”按钮没有反应,可以手动找到游戏的网页缓存文件夹,目录为“你的游戏安装路径/ZenlessZoneZero_Data/webCaches/Cache/”", "ui.extra.urlCopied": "URL已复制" diff --git a/src/i18n/繁體中文.json b/src/i18n/繁體中文.json index d63341a..042b32a 100644 --- a/src/i18n/繁體中文.json +++ b/src/i18n/繁體中文.json @@ -5,7 +5,7 @@ "ui.button.directUpdate": "直接更新", "ui.button.files": "導出文件", "ui.button.excel": "導出Excel", - "ui.button.srgf":"導出JSON", + "ui.button.uigf":"導出UIGF (Beta)", "ui.button.url": "輸入URL", "ui.button.setting": "設置", "ui.button.option": "選項", @@ -97,7 +97,7 @@ "excel.customFont": "微軟雅黑", "excel.filePrefix": "絕區零調頻記錄", "excel.fileType": "Excel文件", - "srgf.fileType":"絕區零調頻記錄格式文件(SRGF)", + "uigf.fileType":"統一可交換抽卡記錄標準 v4.0(Beta)", "ui.extra.cacheClean": "1. 確認是否已經打開遊戲內的抽卡歷史記錄,如果仍然出現「身份認證已過期」的錯誤,再嘗試下面的步驟\n2. 關閉絕區零的遊戲窗口\n3. 點擊上方的「打開緩存文件夾」按鈕,打開Cache文件夾\n4. 刪除Cache_Data文件夾\n5. 啟動絕區零遊戲,打開遊戲內抽卡歷史記錄頁面\n6. 關閉這個對話框,再點擊「更新數據」按鈕", "ui.extra.findCacheFolder": "如果點「打開緩存文件夾」按鈕沒有反應,可以手動找到遊戲的網頁緩存文件夾,目錄為「你的遊戲安裝路徑/ZenlessZoneZero_Data/webCaches/Cache/」", "ui.extra.urlCopied": "URL已復製" diff --git a/src/main/SRGFJson.js b/src/main/UIGFJson.js similarity index 73% rename from src/main/SRGFJson.js rename to src/main/UIGFJson.js index 62e6d9a..6510d6e 100644 --- a/src/main/SRGFJson.js +++ b/src/main/UIGFJson.js @@ -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() }) diff --git a/src/main/getData.js b/src/main/getData.js index b49f455..7bc52de 100644 --- a/src/main/getData.js +++ b/src/main/getData.js @@ -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) diff --git a/src/main/i18n.js b/src/main/i18n.js index 92d9e85..2364956 100644 --- a/src/main/i18n.js +++ b/src/main/i18n.js @@ -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, { diff --git a/src/main/main.js b/src/main/main.js index fb5d17f..adf307d 100644 --- a/src/main/main.js +++ b/src/main/main.js @@ -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 diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 59f6d58..5c54fbf 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -11,7 +11,7 @@ @@ -238,15 +238,15 @@ const saveExcel = async () => { await ipcRenderer.invoke('SAVE_EXCEL') } -const exportSRGFJSON = () => { - ipcRenderer.invoke('EXPORT_SRGF_JSON') +const exportUIGFJSON = () => { + ipcRenderer.invoke('EXPORT_UIGF_JSON') } const exportCommand = (type) => { if (type === 'excel') { saveExcel() - } else if (type === 'srgf-json') { - exportSRGFJSON() + } else if (type === 'uigf-json') { + exportUIGFJSON() } } diff --git a/src/renderer/components/Setting.vue b/src/renderer/components/Setting.vue index 35a60b7..6762179 100644 --- a/src/renderer/components/Setting.vue +++ b/src/renderer/components/Setting.vue @@ -48,7 +48,8 @@

{{about.title}}

{{about.license}}

-

Github: https://github.com/earthjasonlin/zzz-signal-search-export

+

GitHub: https://github.com/earthjasonlin/zzz-signal-search-export

+

UIGF: https://uigf.org/

@@ -130,6 +131,7 @@ const disableProxy = async () => { } const openGithub = () => shell.openExternal('https://github.com/earthjasonlin/zzz-signal-search-export') +const openUIGF = () => shell.openExternal('https://uigf.org/') const openLink = (link) => shell.openExternal(link) const deleteData = async (uid, action) => {