fix: 用户配置文件转移到.dev-sidecar

pull/180/head
xiaojunnuo 2020-11-12 14:40:56 +08:00
parent ba787cd10a
commit 87ac9173f9
3 changed files with 10 additions and 5 deletions

View File

@ -127,7 +127,7 @@ start %HOMEPATH%/.dev-sidecar/dev-sidecar.ca.crt
> clone 出来的 remote "origin" 为fastgit的地址需要手动改回来 > clone 出来的 remote "origin" 为fastgit的地址需要手动改回来
> 你也可以直接使用他们的clone加速工具 [fgit-go](https://github.com/FastGitORG/fgit-go) > 你也可以直接使用他们的clone加速工具 [fgit-go](https://github.com/FastGitORG/fgit-go)
2. github.com的镜像网站(注意:不能登录) 2. github.com的镜像网站(注意:不能登录)
>1. [hub.fastgit.org](https://hub.fastgit.org/) (好像已经不行了) >1. [hub.fastgit.org](https://hub.fastgit.org/)
>2. [github.com.cnpmjs.org](https://github.com.cnpmjs.org/) 这个很容易超限 >2. [github.com.cnpmjs.org](https://github.com.cnpmjs.org/) 这个很容易超限

View File

@ -6,6 +6,11 @@ import JSON5 from 'json5'
import path from 'path' import path from 'path'
const pk = require('../../package.json') const pk = require('../../package.json')
const mitmproxyPath = path.join(__dirname, 'mitmproxy.js') const mitmproxyPath = path.join(__dirname, 'mitmproxy.js')
const getDefaultConfigBasePath = function () {
const userHome = process.env.HOME || process.env.USERPROFILE
return path.resolve(userHome, './.dev-sidecar')
}
const localApi = { const localApi = {
/** /**
* 返回所有api列表供vue来ipc调用 * 返回所有api列表供vue来ipc调用
@ -111,14 +116,14 @@ function _deepFindFunction (list, parent, parentKey) {
} }
function _getSettingsPath () { function _getSettingsPath () {
const dir = './config/' const dir = getDefaultConfigBasePath()
if (!fs.existsSync(dir)) { if (!fs.existsSync(dir)) {
fs.mkdirSync(dir) fs.mkdirSync(dir)
} }
return dir + 'setting.json5' return dir + 'setting.json5'
} }
function _getConfigPath () { function _getConfigPath () {
const dir = './config/' const dir = getDefaultConfigBasePath()
if (!fs.existsSync(dir)) { if (!fs.existsSync(dir)) {
fs.mkdirSync(dir) fs.mkdirSync(dir)
} }

View File

@ -100,14 +100,14 @@ module.exports = function createRequestHandler (requestInterceptor, responseInte
reject(new Error(`${rOptions.host}:${rOptions.port}, 代理请求超时`)) reject(new Error(`${rOptions.host}:${rOptions.port}, 代理请求超时`))
}) })
proxyReq.on('error', (e, req, res) => { proxyReq.on('error', (e) => {
const end = new Date().getTime() const end = new Date().getTime()
if (isDnsIntercept) { if (isDnsIntercept) {
const { dns, ip, hostname } = isDnsIntercept const { dns, ip, hostname } = isDnsIntercept
dns.count(hostname, ip, true) dns.count(hostname, ip, true)
console.error('记录ip失败次数,用于优选ip', hostname, ip) console.error('记录ip失败次数,用于优选ip', hostname, ip)
} }
console.error('代理请求错误', e.errno, rOptions.hostname, rOptions.path, (end - start) + 'ms') console.error('代理请求错误', e.errno, rOptions.hostname, rOptions.path, (end - start) + 'ms', e)
reject(e) reject(e)
}) })