mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: country code judgement problem
This commit is contained in:
parent
c1ca4f2f9b
commit
cc1f5611a7
3 changed files with 5 additions and 5 deletions
|
|
@ -317,7 +317,7 @@ export function supportGuoba () {
|
||||||
component: 'InputNumber',
|
component: 'InputNumber',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 20
|
max: 100
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -106,15 +106,17 @@ export default class SydneyAIClient {
|
||||||
let accessible = !(await isCN()) || this.opts.proxy
|
let accessible = !(await isCN()) || this.opts.proxy
|
||||||
if (accessible && !Config.sydneyForceUseReverse) {
|
if (accessible && !Config.sydneyForceUseReverse) {
|
||||||
// 本身能访问bing.com,那就不用反代啦,重置host
|
// 本身能访问bing.com,那就不用反代啦,重置host
|
||||||
|
logger.info('change hosts to https://www.bing.com')
|
||||||
this.opts.host = 'https://www.bing.com'
|
this.opts.host = 'https://www.bing.com'
|
||||||
}
|
}
|
||||||
|
logger.mark('使用host:' + this.opts.host)
|
||||||
const response = await fetch(`${this.opts.host}/turing/conversation/create`, fetchOptions)
|
const response = await fetch(`${this.opts.host}/turing/conversation/create`, fetchOptions)
|
||||||
let text = await response.text()
|
let text = await response.text()
|
||||||
try {
|
try {
|
||||||
return JSON.parse(text)
|
return JSON.parse(text)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('创建sydney对话失败: status code: ' + response.status + response.statusText)
|
logger.error('创建sydney对话失败: status code: ' + response.status + response.statusText)
|
||||||
console.error(text)
|
logger.error(text)
|
||||||
throw new Error(text)
|
throw new Error(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -364,9 +364,7 @@ export async function isCN () {
|
||||||
let response = await fetch('https://ipinfo.io/country')
|
let response = await fetch('https://ipinfo.io/country')
|
||||||
let countryCode = (await response.text()).trim()
|
let countryCode = (await response.text()).trim()
|
||||||
await redis.set('CHATGPT:COUNTRY_CODE', countryCode, { EX: 3600 })
|
await redis.set('CHATGPT:COUNTRY_CODE', countryCode, { EX: 3600 })
|
||||||
if (countryCode !== 'CN') {
|
return countryCode === 'CN'
|
||||||
return false
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(err)
|
console.warn(err)
|
||||||
// 没拿到归属地默认CN
|
// 没拿到归属地默认CN
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue