From 0cdc7662f7c800f0fc02e5e6505f70e59fcc17f0 Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Tue, 23 Jul 2024 15:03:30 +0800 Subject: [PATCH] feat(uigf): support multiple account export --- src/i18n/English.json | 3 +- src/i18n/简体中文.json | 3 +- src/i18n/繁體中文.json | 3 +- src/main/UIGFJson.js | 94 ++++++++++++++++++++++-------------------- src/renderer/App.vue | 35 ++++++++++++++-- 5 files changed, 87 insertions(+), 51 deletions(-) diff --git a/src/i18n/English.json b/src/i18n/English.json index 0262557..22022af 100644 --- a/src/i18n/English.json +++ b/src/i18n/English.json @@ -102,5 +102,6 @@ "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" + "ui.extra.urlCopied": "URL Copied", + "ui.uigf.title": "Please select the UID(s) you want to export" } diff --git a/src/i18n/简体中文.json b/src/i18n/简体中文.json index bac9d13..c2151cc 100644 --- a/src/i18n/简体中文.json +++ b/src/i18n/简体中文.json @@ -101,5 +101,6 @@ "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已复制" + "ui.extra.urlCopied": "URL已复制", + "ui.uigf.title": "请选择要导出的UID" } diff --git a/src/i18n/繁體中文.json b/src/i18n/繁體中文.json index 042b32a..61d7bc9 100644 --- a/src/i18n/繁體中文.json +++ b/src/i18n/繁體中文.json @@ -100,5 +100,6 @@ "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已復製" + "ui.extra.urlCopied": "URL已復製", + "ui.uigf.title": "請選擇要導出的UID" } diff --git a/src/main/UIGFJson.js b/src/main/UIGFJson.js index a1e59da..6e44c89 100644 --- a/src/main/UIGFJson.js +++ b/src/main/UIGFJson.js @@ -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) }) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 5c54fbf..1d4da53 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -91,7 +91,7 @@ import Setting from './components/Setting.vue' import gachaDetail from './gachaDetail' import { version } from '../../package.json' import gachaType from '../gachaType.json' -import { ElMessage } from 'element-plus' +import { ElMessage, ElMessageBox } from 'element-plus' const state = reactive({ status: 'init', @@ -239,7 +239,37 @@ const saveExcel = async () => { } const exportUIGFJSON = () => { - ipcRenderer.invoke('EXPORT_UIGF_JSON') + let uidList = [] + dataMap.value.forEach(item => { + uidList.push(item.uid) + }) + + ElMessageBox({ + title: state.i18n.ui.uigf.title, + message: ` +
+ ${uidList.map(uid => ` +
+ + +
+ `).join('')} +
+ `, + dangerouslyUseHTMLString: true, + showCancelButton: true, + confirmButtonText: state.i18n.ui.common.ok, + cancelButtonText: state.i18n.ui.common.cancel, + beforeClose: (action, instance, done) => { + if (action === 'confirm') { + const selected_uids = uidList.filter(uid => document.getElementById(uid).checked); + ipcRenderer.invoke('EXPORT_UIGF_JSON', selected_uids); + } + done(); + } + }).then(() => { + }).catch(() => { + }); } const exportCommand = (type) => { @@ -249,7 +279,6 @@ const exportCommand = (type) => { exportUIGFJSON() } } - const openCacheFolder = async () => { await ipcRenderer.invoke('OPEN_CACHE_FOLDER') }