mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
feat: 增加API key和设定的配置功能
This commit is contained in:
parent
d1a8f667d6
commit
fa1b1877d0
5 changed files with 109 additions and 9 deletions
|
|
@ -351,3 +351,20 @@ export function formatDuration (duration) {
|
|||
|
||||
return result || '0秒钟'
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断服务器所在地是否为中国
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export async function isCN () {
|
||||
if (await redis.get('CHATGPT:COUNTRY_CODE')) {
|
||||
return await redis.get('CHATGPT:COUNTRY_CODE') === 'CN'
|
||||
} else {
|
||||
let response = await fetch('https://ipinfo.io/country')
|
||||
let countryCode = await response.text()
|
||||
await redis.set('CHATGPT:COUNTRY_CODE', countryCode, { EX: 3600 * 24 * 7 })
|
||||
if (countryCode !== 'CN') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue