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

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

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