Skip to content

Commit

Permalink
fix: attempting to fix errors where data cannot be exported (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
biuuu committed Mar 17, 2024
1 parent 7d1f762 commit 7a5c8fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genshin-wish-export",
"version": "0.11.4",
"version": "0.11.5",
"main": "./dist/electron/main/main.js",
"author": "biuuu <https://github.com/biuuu>",
"homepage": "https://github.com/biuuu/genshin-wish-export",
Expand Down
6 changes: 3 additions & 3 deletions src/main/UIGFJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const getItemTypeNameMap = require('./gachaTypeMap').getItemTypeNameMap
const { version } = require('../../package.json')
const config = require('./config')
const fetch = require('electron-fetch').default
const { readJSON, saveJSON, existsFile, userDataPath } = require('./utils')
const { readJSON, saveJSON, existsFile, userDataPath, fixLocalMap } = require('./utils')
const Ajv = require('ajv')

// acquire uigf schema
Expand Down Expand Up @@ -128,7 +128,7 @@ const saveLookupTable = async () => {
// get item id
const getItemId = async (lang, name) => {
// fetch item id from api.uigf.org if cannot find it from existing item id dictionary
if (!itemIdDict.get(lang).has(name)) {
if (!itemIdDict.has(lang) || !itemIdDict.get(lang).has(name)) {
const response = await fetch(`https://api.uigf.org/identify/genshin/${name}`)
const responseJson = await response.json()
if (!responseJson.item_id) {
Expand Down Expand Up @@ -160,7 +160,7 @@ const uigfJson = async () => {
list: []
}
const listTemp = []
const uigfLang = uigfLangMap.get(data.lang)
const uigfLang = uigfLangMap.get(data.lang) || uigfLangMap.get(fixLocalMap.get(data.lang))
for (let [type, arr] of data.result) {
for (let item of arr) {
listTemp.push({
Expand Down
20 changes: 19 additions & 1 deletion src/main/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@ const localeMap = new Map([
['vi-vn', ['vi']]
])

const fixLocalMap = new Map([
['en', 'en-us'],
['fr', 'fr-fr'],
['de', 'de-de'],
['es', 'es-es'],
['pt', 'pt-pt'],
['ru', 'ru-ru'],
['ja', 'ja-jp'],
['ko', 'ko-kr'],
['th', 'th-th'],
['vi', 'vi-vn'],
['id', 'id-id'],
['zh-cn', 'zh-cn'],
['zh-tw', 'zh-tw'],
['tr', 'tr-tr'],
['it', 'it-it']
])

const detectLocale = () => {
const locale = app.getLocale()
let result = 'zh-cn'
Expand Down Expand Up @@ -224,6 +242,6 @@ async function getCacheText(gamePath) {

module.exports = {
readdir, sleep, request, hash, cipherAes, decipherAes, saveLog,
sendMsg, existsFile, readJSON, saveJSON, initWindow, getWin, localIp, userPath, detectLocale, langMap,
sendMsg, existsFile, readJSON, saveJSON, initWindow, getWin, localIp, userPath, detectLocale, langMap, fixLocalMap,
getCacheText, appRoot, userDataPath
}

0 comments on commit 7a5c8fd

Please sign in to comment.