diff --git a/package-lock.json b/package-lock.json index c0fcaf8..a541188 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vnite", - "version": "1.5.10", + "version": "1.5.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vnite", - "version": "1.5.10", + "version": "1.5.11", "hasInstallScript": true, "dependencies": { "@electron-toolkit/preload": "^3.0.0", diff --git a/src/renderer/src/components/AddGame.jsx b/src/renderer/src/components/AddGame.jsx index 7ddcaf3..d34a466 100644 --- a/src/renderer/src/components/AddGame.jsx +++ b/src/renderer/src/components/AddGame.jsx @@ -88,12 +88,12 @@ function Info() { let navigate = useNavigate(); const { gameName, gid, vid, setGameName, setGID, setVID, setAlert, setGameList, isLoading, setIsLoading } = useAddGame(); async function submitInfo() { - setIsLoading(true); if (gameName === '' && gid === '') { setAlert('请填写游戏原名!'); setTimeout(() => { setAlert(''); }, 3000); return } + setIsLoading(true); if (gid) { if (String(gid).toLowerCase().startsWith('ga')) { try { @@ -219,7 +219,19 @@ function GameList() { </table> </div> <div className='flex flex-row-reverse items-end gap-5 pt-3'> - <button className='transition-all btn bg-custom-stress text-custom-text-light hover:brightness-125' onClick={() => { next() }}>下一步</button> + <button className='transition-all btn bg-custom-stress text-custom-text-light hover:brightness-125' onClick={() => { + if (gid === '') { + if (gameList.length === 1) { + setGID(gameList[0]["id"]) + setGameName(gameList[0]["name"]) + } else { + setAlert("请选择游戏!") + setTimeout(() => { setAlert(''); }, 3000); + return; + } + } + next() + }}>下一步</button> <button className='transition-all btn bg-custom-stress text-custom-text-light hover:brightness-125' onClick={() => { navigate(-1) }}>上一步</button> </div> </div> @@ -337,7 +349,7 @@ function GamePath() { } function GameBg() { - const { gameBgList, gameName, savePath, isLoading, gamePath, setGameBg, gameBg, gid, setIsLoading, vid } = useAddGame(); + const { gameBgList, gameName, savePath, isLoading, setAlert, gamePath, setGameBg, gameBg, gid, setIsLoading, vid } = useAddGame(); let navigate = useNavigate(); async function submitAllData() { if (gameBg === '' && gameBgList.length !== 0) { diff --git a/src/renderer/src/components/scraper.mjs b/src/renderer/src/components/scraper.mjs index 74161c4..e1550c0 100644 --- a/src/renderer/src/components/scraper.mjs +++ b/src/renderer/src/components/scraper.mjs @@ -688,10 +688,11 @@ async function queryVNDB(filters, fields) { // 获取游戏截图 async function getScreenshotsByTitle(title) { try { - const data = await queryVNDB(["search", "=", title], "title, screenshots{url}"); + const data = await queryVNDB(["search", "=", title], "titles.title, screenshots{url}"); if (data.results.length > 0) { - const vn = data.results[0]; - console.log(`获取到 "${vn.title}" 的截图:`); + let vn = data.results.find(vn => vn.titles.some(titleJson => titleJson.title === title)); + vn = vn ? vn : data.results[0]; // 不确定会不会找不到对应名称,目前没有测试到这种情况 + console.log(`获取到 "${title}" 的截图:`); return vn.screenshots.map(screenshot => screenshot.url); } else { console.log(`未找到标题为 "${title}" 的视觉小说。`); @@ -757,14 +758,15 @@ async function getCoverByVID(vid) { // 获取游戏封面 async function getCoverByTitle(title) { try { - const data = await queryVNDB(["search", "=", title], "title, image{url}"); + const data = await queryVNDB(["search", "=", title], "titles.title, image{url}"); if (data.results.length > 0) { - const vn = data.results[0]; + let vn = data.results.find(vn => vn.titles.some(titleJson => titleJson.title === title)); + vn = vn ? vn : data.results[0]; // 不确定会不会找不到对应名称,目前没有测试到这种情况 if (vn.image) { - console.log(`获取到 "${vn.title}" 的封面:`); + console.log(`获取到 "${title}" 的封面:`); return vn.image.url; } else { - console.log(`"${vn.title}" 没有封面图片。`); + console.log(`"${title}" 没有封面图片。`); return ''; } } else { @@ -783,10 +785,11 @@ async function getCoverByTitle(title) { async function getVIDByTitle(title) { try { - const data = await queryVNDB(["search", "=", title], "id, title"); + const data = await queryVNDB(["search", "=", title], "id, titles.title"); if (data.results.length > 0) { - const vn = data.results[0]; - console.log(`获取到 "${vn.title}" 的ID:`); + let vn = data.results.find(vn => vn.titles.some(titleJson => titleJson.title === title)); + vn = vn ? vn : data.results[0]; // 不确定会不会找不到对应名称,目前没有测试到这种情况 + console.log(`获取到 "${title}" 的ID:`); return vn.id; } else { console.log(`未找到标题为 "${title}" 的视觉小说。`);