Skip to content

Commit

Permalink
fix: update the hostname of API
Browse files Browse the repository at this point in the history
  • Loading branch information
biuuu committed Mar 13, 2024
1 parent feffe00 commit 7d1f762
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 51 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.3",
"version": "0.11.4",
"main": "./dist/electron/main/main.js",
"author": "biuuu <https://github.com/biuuu>",
"homepage": "https://github.com/biuuu/genshin-wish-export",
Expand Down
45 changes: 15 additions & 30 deletions src/main/getData.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { enableProxy, disableProxy } = require('./module/system-proxy')
const mitmproxy = require('./module/node-mitmproxy')

const dataMap = new Map()
let apiDomain = 'https://hk4e-api.mihoyo.com'
let apiDomain = 'https://public-operation-hk4e.mihoyo.com'

const saveData = async (data, url) => {
const obj = Object.assign({}, data)
Expand Down Expand Up @@ -219,7 +219,7 @@ const getGachaLogs = async ([key, name], queryString) => {
let res = []
let uid = 0
let endId = 0
const url = `${apiDomain}/event/gacha_info/api/getGachaLog?${queryString}`
const url = `${apiDomain}/gacha_info/api/getGachaLog?${queryString}`
do {
if (page % 10 === 0) {
sendMsg(i18n.parse(text.fetch.interval, { name, page }))
Expand Down Expand Up @@ -278,7 +278,7 @@ const checkResStatus = (res) => {
}

const tryGetUid = async (queryString) => {
const url = `${apiDomain}/event/gacha_info/api/getGachaLog?${queryString}`
const url = `${apiDomain}/gacha_info/api/getGachaLog?${queryString}`
try {
for (let [key] of defaultTypeMap) {
const res = await request(`${url}&gacha_type=${key}&page=1&size=6`)
Expand All @@ -303,9 +303,9 @@ const getQuerystring = (url) => {
const text = i18n.log
const { searchParams, host } = new URL(fixAuthkey(url))
if (host.includes('webstatic-sea') || host.includes('hk4e-api-os') || host.includes('hoyoverse.com')) {
apiDomain = 'https://hk4e-api-os.mihoyo.com'
apiDomain = 'https://hk4e-api-os.hoyoverse.com'
} else {
apiDomain = 'https://hk4e-api.mihoyo.com'
apiDomain = 'https://public-operation-hk4e.mihoyo.com'
}
const authkey = searchParams.get('authkey')
if (!authkey) {
Expand Down Expand Up @@ -362,33 +362,14 @@ const useProxy = async () => {
const tryRequest = async (url, retry = false) => {
const queryString = getQuerystring(url)
if (!queryString) return false
const gachaTypeUrl = `${apiDomain}/event/gacha_info/api/getConfigList?${queryString}`
try {
const res = await request(gachaTypeUrl)
if (res.retcode !== 0) {
return false
}
return true
} catch (e) {
if (e.code === 'ERR_PROXY_CONNECTION_FAILED' && !retry) {
await disableProxy()
return await tryRequest(url, true)
}
sendMsg(e.message.replace(url, '***'), 'ERROR')
throw e
}
const gachaTypeUrl = `${apiDomain}/gacha_info/api/getConfigList?${queryString}`
const res = await request(gachaTypeUrl)
checkResStatus(res)
}

const getUrl = async () => {
let url = await readLog()
if (!url && config.proxyMode) {
url = await useProxy()
} else if (url) {
const result = await tryRequest(url)
if (!result && config.proxyMode) {
url = await useProxy()
}
}
await tryRequest(url)
return url
}

Expand All @@ -412,15 +393,19 @@ const fetchData = async (urlOverride) => {
}
let queryString = searchParams.toString()
const vUid = await tryGetUid(queryString)
const localLang = dataMap.has(vUid) ? dataMap.get(vUid).lang : ''
let localLang = dataMap.has(vUid) ? dataMap.get(vUid).lang : ''
if (localLang) {
if (!localLang.startsWith('zh-')) {
localLang = localLang.replace(/-\w+$/, '')
}
searchParams.set('lang', localLang)
}
queryString = searchParams.toString()
const gachaType = getItemTypeNameMap(localLang)
const result = new Map()
const typeMap = new Map()
const lang = searchParams.get('lang')
console.log(lang)
const gachaType = getItemTypeNameMap(lang)
let originUid = 0
for (const type of gachaType) {
const { list, uid } = await getGachaLogs(type, queryString)
Expand Down
21 changes: 1 addition & 20 deletions src/renderer/components/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,6 @@
</el-switch>
<p class="text-gray-400 text-xs m-1.5">{{text.fetchFullHistoryHint}}</p>
</el-form-item>
<el-form-item :label="text.proxyMode">
<el-switch
@change="saveSetting"
v-model="settingForm.proxyMode">
</el-switch>
<p class="text-gray-400 text-xs m-1.5">{{text.proxyModeHint}}</p>
<el-button class="focus:outline-none" @click="disableProxy">{{text.closeProxy}}</el-button>
<p class="text-gray-400 text-xs m-1.5">{{text.closeProxyHint}}</p>
</el-form-item>
<!-- <el-form-item label="导出到Github Gists">
<el-input placeholder="请输入内容" v-model="settingForm.gistsToken" :disabled="gistsConfigDisabled" style="max-width: 500px;">
<template #append>
<el-button v-show="gistsConfigDisabled" @click="configGistsToken">设置Token</el-button>
<el-button v-show="!gistsConfigDisabled" @click="saveGistsToken" class="focus:outline-none">保存Token</el-button>
</template>
</el-input>
<p class="text-gray-400 text-xs m-1.5 leading-normal">该功能用于将抽卡记录导出为UIGF JSON格式并同步至Github Gists,单击“设置Token”按钮,本地浏览器将会跳转至GithubTokens设置页面,新增您的个人Token,并打开Gists功能的读写权限,最后将新生成的Token存入这里,单击“保存Token”完成设置</p>
<el-button @click="uploadGists" type="success" plain class="focus:outline-none" :disabled="!settingForm.gistsToken" :loading="uploadGistsLoading">同步至Gists</el-button>
</el-form-item> -->
</el-form>
<h3 class="text-lg my-4">{{about.title}}</h3>
<p class="text-gray-600 text-xs mt-1">{{about.license}}</p>
Expand Down Expand Up @@ -215,4 +196,4 @@ onMounted(async () => {
.el-form-item--default {
margin-bottom: 14px !important;
}
</style>
</style>

0 comments on commit 7d1f762

Please sign in to comment.