fix: 兼容5和7的proxy依赖

This commit is contained in:
ikechan8370 2023-09-12 11:08:14 +08:00
parent 5e7d73908f
commit f620e10abb
8 changed files with 727 additions and 334 deletions

View file

@ -1,14 +1,8 @@
import { Config } from './config.js'
import { ChatGPTAPI } from 'chatgpt'
import fetch from 'node-fetch'
let proxy
if (Config.proxy) {
try {
proxy = (await import('https-proxy-agent')).default
} catch (e) {
console.warn('未安装https-proxy-agent请在插件目录下执行pnpm add https-proxy-agent')
}
}
import { getProxy } from './proxy.js'
let proxy = getProxy()
const newFetch = (url, options = {}) => {
const defaultOptions = Config.proxy
? {