fix: getLatestUrl does not get the latest url

This commit is contained in:
mio 2023-05-01 17:40:06 +08:00
parent 20ba48513c
commit 2bc52de233
2 changed files with 13 additions and 13 deletions

View File

@ -1,6 +1,6 @@
{
"name": "star-rail-warp-export",
"version": "0.0.3",
"version": "0.0.4",
"main": "./dist/electron/main/main.js",
"author": "biuuu <https://github.com/biuuu>",
"license": "MIT",

View File

@ -84,17 +84,17 @@ const detectGameLocale = async (userPath) => {
const getLatestUrl = (list) => {
let result = list[list.length - 1]
let time = 0
for (let i = 0; i < list.length; i++) {
const tsMch = list[i].match(/timestamp=(\d+)/)
if (tsMch?.[1]) {
const ts = parseInt(tsMch[1])
if (time <= parseInt(tsMch[1])) {
time = ts
result = list[i]
}
}
}
// let time = 0
// for (let i = 0; i < list.length; i++) {
// const tsMch = list[i].match(/timestamp=(\d+)/)
// if (tsMch?.[1]) {
// const ts = parseInt(tsMch[1])
// if (time <= parseInt(tsMch[1])) {
// time = ts
// result = list[i]
// }
// }
// }
return result
}
@ -118,7 +118,7 @@ const readLog = async () => {
const gamePathMch = logText.match(/\w:\/.*?(Star\sRail\/Game\/StarRail_Data)/)
if (gamePathMch) {
const cacheText = await fs.readFile(path.join(gamePathMch[0], '/webCaches/Cache/Cache_Data/data_2'), 'utf8')
const urlMch = cacheText.match(/https.+?&auth_appid=webview_gacha&.+?authkey=.+?&game_biz=hkrpg_.+/g)
const urlMch = cacheText.match(/https.+?&auth_appid=webview_gacha&.+?authkey=.+?&game_biz=hkrpg_.+?&plat_type=pc/g)
if (urlMch) {
cacheFolder = path.join(gamePathMch[0], '/webCaches/Cache/')
return getLatestUrl(urlMch)