feat: Support export as Star Rail Gacha Log Format file (#39)

This commit is contained in:
TremblingMoeNew 2023-06-29 15:02:36 +08:00 committed by GitHub
parent f2592040cb
commit 4ab2f60b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 38 additions and 42 deletions

@ -3,6 +3,7 @@
"ui.button.load": "Lade Daten", "ui.button.load": "Lade Daten",
"ui.button.update": "Aktualisieren", "ui.button.update": "Aktualisieren",
"ui.button.excel": "In Excel exportieren", "ui.button.excel": "In Excel exportieren",
"ui.button.srgf": "In SRGF exportieren",
"ui.button.url": "Eingabe URL", "ui.button.url": "Eingabe URL",
"ui.button.setting": "Einstellungen", "ui.button.setting": "Einstellungen",
"ui.button.option": "Optionen", "ui.button.option": "Optionen",
@ -75,5 +76,6 @@
"excel.wish2": "Wunsch 2", "excel.wish2": "Wunsch 2",
"excel.customFont": "Arial", "excel.customFont": "Arial",
"excel.filePrefix": "", "excel.filePrefix": "",
"excel.fileType": "Excel Datei" "excel.fileType": "Excel Datei",
"srgf.fileType": "Star Rail Gacha Log Format Datei"
} }

@ -4,6 +4,7 @@
"ui.button.update": "Update", "ui.button.update": "Update",
"ui.button.directUpdate": "Direct update", "ui.button.directUpdate": "Direct update",
"ui.button.excel": "Export Excel", "ui.button.excel": "Export Excel",
"ui.button.srgf": "Export SRGF",
"ui.button.url": "Input URL", "ui.button.url": "Input URL",
"ui.button.setting": "Settings", "ui.button.setting": "Settings",
"ui.button.option": "Option", "ui.button.option": "Option",
@ -94,6 +95,7 @@
"excel.customFont": "Arial", "excel.customFont": "Arial",
"excel.filePrefix": "Star Rail Warp logger", "excel.filePrefix": "Star Rail Warp logger",
"excel.fileType": "Excel file", "excel.fileType": "Excel file",
"srgf.fileType": "Star Rail Gacha Log Format file",
"ui.extra.cacheClean": "1. Confirm whether the warp 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 Star Rail \n3. Click the \"Open Web Cache Folder\" button above to open the \"Cache\" folder \n4. Delete the \"Cache_ Data\" folder \n5. Start the Star Rail game and open the warp history page in the game \n6. Close this dialog and click the \"Update Data\" button", "ui.extra.cacheClean": "1. Confirm whether the warp 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 Star Rail \n3. Click the \"Open Web Cache Folder\" button above to open the \"Cache\" folder \n4. Delete the \"Cache_ Data\" folder \n5. Start the Star Rail game and open the warp 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/Star Rail/Games/StarRail_Data/webCaches/Cache/\"", "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/Star Rail/Games/StarRail_Data/webCaches/Cache/\"",
"ui.extra.urlCopied": "URL Copied" "ui.extra.urlCopied": "URL Copied"

@ -4,6 +4,7 @@
"ui.button.update": "Mettre à jour", "ui.button.update": "Mettre à jour",
"ui.button.directUpdate": "Mise à jour directe", "ui.button.directUpdate": "Mise à jour directe",
"ui.button.excel": "Exporter vers Excel", "ui.button.excel": "Exporter vers Excel",
"ui.button.srgf": "Exporter vers SRGF",
"ui.button.url": "URL d'import", "ui.button.url": "URL d'import",
"ui.button.setting": "Paramètres", "ui.button.setting": "Paramètres",
"ui.button.option": "Options", "ui.button.option": "Options",

@ -3,6 +3,7 @@
"ui.button.load": "データの読み込み", "ui.button.load": "データの読み込み",
"ui.button.update": "更新データ", "ui.button.update": "更新データ",
"ui.button.excel": "Excelにエクスポート", "ui.button.excel": "Excelにエクスポート",
"ui.button.srgf": "SRGFにエクスポート",
"ui.button.url": "URL入力", "ui.button.url": "URL入力",
"ui.button.setting": "設定", "ui.button.setting": "設定",
"ui.button.option": "オプション", "ui.button.option": "オプション",

@ -4,6 +4,7 @@
"ui.button.update": "更新数据", "ui.button.update": "更新数据",
"ui.button.directUpdate": "直接更新", "ui.button.directUpdate": "直接更新",
"ui.button.excel": "导出Excel", "ui.button.excel": "导出Excel",
"ui.button.srgf":"导出SRGF",
"ui.button.url": "输入URL", "ui.button.url": "输入URL",
"ui.button.setting": "设置", "ui.button.setting": "设置",
"ui.button.option": "选项", "ui.button.option": "选项",
@ -94,6 +95,7 @@
"excel.customFont": "微软雅黑", "excel.customFont": "微软雅黑",
"excel.filePrefix": "星穹铁道跃迁记录", "excel.filePrefix": "星穹铁道跃迁记录",
"excel.fileType": "Excel文件", "excel.fileType": "Excel文件",
"srgf.fileType":"星穹铁道跃迁记录格式文件",
"ui.extra.cacheClean": "1. 确认是否已经打开游戏内的抽卡历史记录,如果仍然出现“身份认证已过期”的错误,再尝试下面的步骤\n2. 关闭星穹铁道的游戏窗口\n3. 点击上方的“打开缓存文件夹”按钮打开Cache文件夹\n4. 删除Cache_Data文件夹\n5. 启动星穹铁道游戏,打开游戏内抽卡历史记录页面\n6. 关闭这个对话框,再点击“更新数据”按钮", "ui.extra.cacheClean": "1. 确认是否已经打开游戏内的抽卡历史记录,如果仍然出现“身份认证已过期”的错误,再尝试下面的步骤\n2. 关闭星穹铁道的游戏窗口\n3. 点击上方的“打开缓存文件夹”按钮打开Cache文件夹\n4. 删除Cache_Data文件夹\n5. 启动星穹铁道游戏,打开游戏内抽卡历史记录页面\n6. 关闭这个对话框,再点击“更新数据”按钮",
"ui.extra.findCacheFolder": "如果点“打开缓存文件夹”按钮没有反应,可以手动找到游戏的网页缓存文件夹,目录为“你的游戏安装路径/Star Rail/Game/StarRail_Data/webCaches/Cache/”", "ui.extra.findCacheFolder": "如果点“打开缓存文件夹”按钮没有反应,可以手动找到游戏的网页缓存文件夹,目录为“你的游戏安装路径/Star Rail/Game/StarRail_Data/webCaches/Cache/”",
"ui.extra.urlCopied": "URL已复制" "ui.extra.urlCopied": "URL已复制"

@ -4,6 +4,7 @@
"ui.button.update": "更新資料", "ui.button.update": "更新資料",
"ui.button.directUpdate": "直接更新", "ui.button.directUpdate": "直接更新",
"ui.button.excel": "匯出 Excel", "ui.button.excel": "匯出 Excel",
"ui.button.srgf": "匯出 SRGF",
"ui.button.url": "輸入 URL", "ui.button.url": "輸入 URL",
"ui.button.setting": "設定", "ui.button.setting": "設定",
"ui.button.option": "選項", "ui.button.option": "選項",
@ -83,6 +84,7 @@
"excel.customFont": "微軟正黑體", "excel.customFont": "微軟正黑體",
"excel.filePrefix": "星穹鐵道躍遷紀錄", "excel.filePrefix": "星穹鐵道躍遷紀錄",
"excel.fileType": "Excel 檔案", "excel.fileType": "Excel 檔案",
"srgf.fileType":"星穹鐵道躍遷紀錄格式檔案",
"ui.extra.cacheClean": "1. 確認是否已經開啟遊戲內的躍遷歷史紀錄,如果仍然出現「身分驗證已過期」的錯誤,再嘗試下面的步驟\n2. 關閉「崩壞:星穹鐵道」的遊戲視窗\n3. 按一下上方的「開啟快取資料夾」按鈕開啟「Cache」資料夾\n4. 刪除「Cache_Data」資料夾\n5. 啟動「崩壞:星穹鐵道」遊戲,開啟遊戲內躍遷歷史紀錄頁面\n6. 關閉這個對話方塊,再按下「更新資料」按鈕", "ui.extra.cacheClean": "1. 確認是否已經開啟遊戲內的躍遷歷史紀錄,如果仍然出現「身分驗證已過期」的錯誤,再嘗試下面的步驟\n2. 關閉「崩壞:星穹鐵道」的遊戲視窗\n3. 按一下上方的「開啟快取資料夾」按鈕開啟「Cache」資料夾\n4. 刪除「Cache_Data」資料夾\n5. 啟動「崩壞:星穹鐵道」遊戲,開啟遊戲內躍遷歷史紀錄頁面\n6. 關閉這個對話方塊,再按下「更新資料」按鈕",
"ui.extra.findCacheFolder": "如果按下「開啟快取資料夾」按鈕沒有回應,可以手動找到遊戲的網頁快取資料夾,目錄為「您的遊戲安裝路徑/Star Rail/Games/StarRail_Data/webCaches/Cache/」" "ui.extra.findCacheFolder": "如果按下「開啟快取資料夾」按鈕沒有回應,可以手動找到遊戲的網頁快取資料夾,目錄為「您的遊戲安裝路徑/Star Rail/Games/StarRail_Data/webCaches/Cache/」"
} }

@ -3,6 +3,7 @@ const fs = require('fs-extra')
const path = require('path') const path = require('path')
const getData = require('./getData').getData const getData = require('./getData').getData
const { version } = require('../../package.json') const { version } = require('../../package.json')
const i18n = require('./i18n')
const getTimeString = () => { const getTimeString = () => {
return new Date().toLocaleString('sv').replace(/[- :]/g, '').slice(0, -2) return new Date().toLocaleString('sv').replace(/[- :]/g, '').slice(0, -2)
@ -15,67 +16,51 @@ const formatDate = (date) => {
return `${y}-${m}-${d} ${date.toLocaleString('zh-cn', { hour12: false }).slice(-8)}` return `${y}-${m}-${d} ${date.toLocaleString('zh-cn', { hour12: false }).slice(-8)}`
} }
const fakeIdFn = () => {
let id = 1000000000000000000n
return () => {
id = id + 1n
return id.toString()
}
}
const shouldBeString = (value) => {
if (typeof value !== 'string') {
return ''
}
return value
}
const start = async () => { const start = async () => {
const { dataMap, current } = await getData() const { dataMap, current } = await getData()
const data = dataMap.get(current) const data = dataMap.get(current)
if (!data.result.size) { if (!data.result.size) {
throw new Error('数据为空') throw new Error('数据为空')
} }
const fakeId = fakeIdFn()
const result = { const result = {
info: { info: {
uid: data.uid, uid: data.uid,
lang: data.lang, lang: data.lang,
export_time: formatDate(new Date()), export_time: formatDate(new Date()),
export_timestamp: Date.now(), export_timestamp: Math.ceil(Date.now()/1000),
export_app: 'genshin-wish-export', export_app: 'star-rail-warp-export',
export_app_version: `v${version}`, export_app_version: `v${version}`,
uigf_version: 'v2.2' region_time_zone: data.region_time_zone,
srgf_version: 'v1.0'
}, },
list: [] list: []
} }
const listTemp = [] const listTemp = []
for (let [type, arr] of data.result) { for (let [type, arr] of data.result) {
arr.forEach(item => { arr.forEach(log => {
listTemp.push({ listTemp.push({
gacha_type: shouldBeString(item[4]) || type, gacha_id:log.gacha_id,
time: item[0], gacha_type: log.gacha_type,
timestamp: new Date(item[0]).getTime(), item_id:log.item_id,
name: item[1], count:"1",
item_type: item[2], time:log.time,
rank_type: `${item[3]}`, name:log.name,
id: shouldBeString(item[5]) || '', item_type:log.item_type,
uigf_gacha_type: type rank_type:log.rank_type,
id:log.id
}) })
}) })
} }
listTemp.sort((a, b) => a.timestamp - b.timestamp) listTemp.sort((a, b) => BigInt(a.id) - BigInt(b.id))
listTemp.forEach(item => { listTemp.forEach(item => {
delete item.timestamp
result.list.push({ result.list.push({
...item, ...item
id: item.id || fakeId()
}) })
}) })
const filePath = dialog.showSaveDialogSync({ const filePath = dialog.showSaveDialogSync({
defaultPath: path.join(app.getPath('downloads'), `UIGF_${data.uid}_${getTimeString()}`), defaultPath: path.join(app.getPath('downloads'), `SRGF_${data.uid}_${getTimeString()}`),
filters: [ filters: [
{ name: 'JSON文件', extensions: ['json'] } { name: i18n.srgf.fileType, extensions: ['json'] }
] ]
}) })
if (filePath) { if (filePath) {
@ -84,6 +69,6 @@ const start = async () => {
} }
} }
ipcMain.handle('EXPORT_UIGF_JSON', async () => { ipcMain.handle('EXPORT_SRGF_JSON', async () => {
await start() await start()
}) })

@ -76,7 +76,7 @@ const parseText = (text, data) => {
} }
const mainProps = [ const mainProps = [
'symbol', 'ui', 'log', 'excel' 'symbol', 'ui', 'log', 'excel',"srgf"
] ]
const i18n = new Proxy(raw, { const i18n = new Proxy(raw, {

@ -4,7 +4,7 @@ const { disableProxy, proxyStatus } = require('./module/system-proxy')
require('./getData') require('./getData')
require('./bridge') require('./bridge')
require('./excel') require('./excel')
require('./UIGFJson') require('./SRGFJson')
const { getUpdateInfo } = require('./update/index') const { getUpdateInfo } = require('./update/index')
const isDev = !app.isPackaged const isDev = !app.isPackaged

@ -4,6 +4,7 @@
<div> <div>
<el-button type="primary" :icon="state.status === 'init' ? 'milk-tea': 'refresh-right'" class="focus:outline-none" :disabled="!allowClick()" plain @click="fetchData()" :loading="state.status === 'loading'">{{state.status === 'init' ? ui.button.load: ui.button.update}}</el-button> <el-button type="primary" :icon="state.status === 'init' ? 'milk-tea': 'refresh-right'" class="focus:outline-none" :disabled="!allowClick()" plain @click="fetchData()" :loading="state.status === 'loading'">{{state.status === 'init' ? ui.button.load: ui.button.update}}</el-button>
<el-button icon="folder-opened" @click="saveExcel" class="focus:outline-none" :disabled="!gachaData" type="success" plain>{{ui.button.excel}}</el-button> <el-button icon="folder-opened" @click="saveExcel" class="focus:outline-none" :disabled="!gachaData" type="success" plain>{{ui.button.excel}}</el-button>
<el-button icon="folder-opened" @click="exportSRGFJSON" class="focus:outline-none" :disabled="!gachaData" type="success" plain>{{ui.button.srgf}}</el-button>
<el-tooltip v-if="detail && state.status !== 'loading'" :content="ui.hint.newAccount" placement="bottom"> <el-tooltip v-if="detail && state.status !== 'loading'" :content="ui.hint.newAccount" placement="bottom">
<el-button @click="newUser()" plain icon="plus" class="focus:outline-none"></el-button> <el-button @click="newUser()" plain icon="plus" class="focus:outline-none"></el-button>
</el-tooltip> </el-tooltip>
@ -227,6 +228,10 @@ const saveExcel = async () => {
await ipcRenderer.invoke('SAVE_EXCEL') await ipcRenderer.invoke('SAVE_EXCEL')
} }
const exportSRGFJSON = () => {
ipcRenderer.invoke('EXPORT_SRGF_JSON')
}
const openCacheFolder = async () => { const openCacheFolder = async () => {
await ipcRenderer.invoke('OPEN_CACHE_FOLDER') await ipcRenderer.invoke('OPEN_CACHE_FOLDER')
} }

@ -139,10 +139,6 @@ const disableProxy = async () => {
const openGithub = () => shell.openExternal('https://github.com/biuuu/star-rail-warp-export') const openGithub = () => shell.openExternal('https://github.com/biuuu/star-rail-warp-export')
const openLink = (link) => shell.openExternal(link) const openLink = (link) => shell.openExternal(link)
const exportUIGFJSON = () => {
ipcRenderer.invoke('EXPORT_UIGF_JSON')
}
const deleteData = async (uid, action) => { const deleteData = async (uid, action) => {
state.dataActionLoading = true state.dataActionLoading = true
await ipcRenderer.invoke('DELETE_DATA', uid, action) await ipcRenderer.invoke('DELETE_DATA', uid, action)