feature: pip支持
							parent
							
								
									311e3f0034
								
							
						
					
					
						commit
						e6ef700dab
					
				| 
						 | 
				
			
			@ -6,5 +6,6 @@
 | 
			
		|||
  "devDependencies": {
 | 
			
		||||
    "lerna": "^3.22.1"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {}
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,11 @@ module.exports = {
 | 
			
		|||
      },
 | 
			
		||||
      'github.githubassets.com': {
 | 
			
		||||
        '.*': {
 | 
			
		||||
          proxy: 'assets.fastgit.org'
 | 
			
		||||
          proxy: 'github.githubassets.com',
 | 
			
		||||
          backup: [
 | 
			
		||||
            'assets.fastgit.org'
 | 
			
		||||
          ],
 | 
			
		||||
          sni: 'assets.fastgit.org'
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      'customer-stories-feed.github.com': {
 | 
			
		||||
| 
						 | 
				
			
			@ -237,8 +241,8 @@ module.exports = {
 | 
			
		|||
        '*.vuepress.vuejs.org': 'quad9',
 | 
			
		||||
        'gh.docmirror.top': 'quad9',
 | 
			
		||||
        '*v2ex.com': 'quad9',
 | 
			
		||||
        '*pypi.org':'quad9',
 | 
			
		||||
        '*jetbrains.com':'quad9'
 | 
			
		||||
        '*pypi.org': 'quad9',
 | 
			
		||||
        '*jetbrains.com': 'quad9'
 | 
			
		||||
      },
 | 
			
		||||
      speedTest: {
 | 
			
		||||
        enabled: true,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,6 @@ function setupPlugin (key, plugin, context, config) {
 | 
			
		|||
  if (pluginStatus) {
 | 
			
		||||
    lodash.set(status, key, pluginStatus)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return api
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,8 @@
 | 
			
		|||
const node = require('./node')
 | 
			
		||||
const git = require('./git')
 | 
			
		||||
const overwall = require('./overwall')
 | 
			
		||||
const pip = require('./pip')
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  node, git, overwall
 | 
			
		||||
  node, git, pip, overwall
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
module.exports = {
 | 
			
		||||
  name: 'PIP加速',
 | 
			
		||||
  statusOff: true,
 | 
			
		||||
  enabled: null, // 没有开关
 | 
			
		||||
  tip: '如果你没有安装pip则不需要启动它',
 | 
			
		||||
  startup: {
 | 
			
		||||
  },
 | 
			
		||||
  setting: {
 | 
			
		||||
    trustedHost: 'pypi.org',
 | 
			
		||||
    registry: ''// 可以选择切换官方或者淘宝镜像
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,93 @@
 | 
			
		|||
const pipConfig = require('./config')
 | 
			
		||||
const PipPlugin = function (context) {
 | 
			
		||||
  const { config, shell, event, log } = context
 | 
			
		||||
  const api = {
 | 
			
		||||
    async start () {
 | 
			
		||||
      await api.setRegistry({ registry: config.get().plugin.pip.setting.registry })
 | 
			
		||||
      await api.setTrustedHost(config.get().plugin.pip.setting.trustedHost)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async close () {
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async restart () {
 | 
			
		||||
      await api.close()
 | 
			
		||||
      await api.start()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async save (newConfig) {
 | 
			
		||||
      await api.setVariables()
 | 
			
		||||
    },
 | 
			
		||||
    async getPipEnv () {
 | 
			
		||||
      let ret = await shell.exec(['pip config list'], { type: 'cmd' })
 | 
			
		||||
      if (ret != null) {
 | 
			
		||||
        ret = ret.trim()
 | 
			
		||||
        const lines = ret.split('\n')
 | 
			
		||||
        const vars = {}
 | 
			
		||||
        for (const line of lines) {
 | 
			
		||||
          if (!line.startsWith('global')) {
 | 
			
		||||
            continue
 | 
			
		||||
          }
 | 
			
		||||
          const key = line.substring(0, line.indexOf('='))
 | 
			
		||||
          let value = line.substring(line.indexOf('=') + 1)
 | 
			
		||||
          if (value.startsWith('\'')) {
 | 
			
		||||
            value = value.startsWith(1, value.length - 1)
 | 
			
		||||
          }
 | 
			
		||||
          vars[key] = value
 | 
			
		||||
        }
 | 
			
		||||
        return vars
 | 
			
		||||
      }
 | 
			
		||||
      return {}
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async setPipEnv (list) {
 | 
			
		||||
      const cmds = []
 | 
			
		||||
      for (const item of list) {
 | 
			
		||||
        if (item.value != null) {
 | 
			
		||||
          cmds.push(`pip config set global.${item.key}  ${item.value}`)
 | 
			
		||||
        } else {
 | 
			
		||||
          cmds.push(`pip config unset  global.${item.key}`)
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      const ret = await shell.exec(cmds, { type: 'cmd' })
 | 
			
		||||
      return ret
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async unsetPipEnv (list) {
 | 
			
		||||
      const cmds = []
 | 
			
		||||
      for (const item of list) {
 | 
			
		||||
        cmds.push(`pip config unset  global.${item} `)
 | 
			
		||||
      }
 | 
			
		||||
      const ret = await shell.exec(cmds, { type: 'cmd' })
 | 
			
		||||
      return ret
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async setRegistry ({ registry }) {
 | 
			
		||||
      await api.setPipEnv([{ key: 'index-url', value: registry }])
 | 
			
		||||
      return true
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async setTrustedHost (host) {
 | 
			
		||||
      await api.setPipEnv([{ key: 'trusted-host', value: host }])
 | 
			
		||||
      return true
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async setProxy (ip, port) {
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async unsetProxy () {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return api
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  key: 'pip',
 | 
			
		||||
  config: pipConfig,
 | 
			
		||||
  status: {
 | 
			
		||||
    enabled: false
 | 
			
		||||
  },
 | 
			
		||||
  plugin: PipPlugin
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -9,18 +9,27 @@ const ProxyPlugin = function (context) {
 | 
			
		|||
      return api.unsetProxy()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async restart () {
 | 
			
		||||
      await api.close()
 | 
			
		||||
      await api.start()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async setProxy () {
 | 
			
		||||
      const ip = '127.0.0.1'
 | 
			
		||||
      const port = config.get().server.port
 | 
			
		||||
      await shell.setSystemProxy({ ip, port })
 | 
			
		||||
      const setEnv = config.get().proxy.setEnv
 | 
			
		||||
      await shell.setSystemProxy({ ip, port, setEnv })
 | 
			
		||||
      log.info(`开启系统代理成功:${ip}:${port}`)
 | 
			
		||||
      event.fire('status', { key: 'proxy.enabled', value: true })
 | 
			
		||||
      return { ip, port }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    async unsetProxy () {
 | 
			
		||||
    async unsetProxy (setEnv) {
 | 
			
		||||
      if (setEnv) {
 | 
			
		||||
        setEnv = config.get().proxy.setEnv
 | 
			
		||||
      }
 | 
			
		||||
      try {
 | 
			
		||||
        await shell.setSystemProxy()
 | 
			
		||||
        await shell.setSystemProxy({ setEnv })
 | 
			
		||||
        event.fire('status', { key: 'proxy.enabled', value: false })
 | 
			
		||||
        log.info('关闭系统代理成功')
 | 
			
		||||
        return true
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +53,8 @@ module.exports = {
 | 
			
		|||
    enabled: true,
 | 
			
		||||
    name: '系统代理',
 | 
			
		||||
    use: 'local',
 | 
			
		||||
    other: []
 | 
			
		||||
    other: [],
 | 
			
		||||
    setEnv: false
 | 
			
		||||
  },
 | 
			
		||||
  status: {
 | 
			
		||||
    enabled: false,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,9 +2,10 @@
 | 
			
		|||
 * 获取环境变量
 | 
			
		||||
 */
 | 
			
		||||
const Shell = require('../../shell')
 | 
			
		||||
const Registry = require('winreg')
 | 
			
		||||
 | 
			
		||||
const execute = Shell.execute
 | 
			
		||||
const execFile = Shell.execFile
 | 
			
		||||
const Registry = require('winreg')
 | 
			
		||||
const refreshInternetPs = require('./refresh-internet')
 | 
			
		||||
const PowerShell = require('node-powershell')
 | 
			
		||||
const log = require('../../../utils/util.log')
 | 
			
		||||
| 
						 | 
				
			
			@ -38,49 +39,64 @@ const _lanIP = [
 | 
			
		|||
  '<-loopback>'
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
async function _winUnsetProxy (exec) {
 | 
			
		||||
async function _winUnsetProxy (exec, setEnv) {
 | 
			
		||||
  // eslint-disable-next-line no-constant-condition
 | 
			
		||||
  const proxyPath = extraPath.getProxyExePath()
 | 
			
		||||
  await execFile(proxyPath, ['set', '1'])
 | 
			
		||||
 | 
			
		||||
  try {
 | 
			
		||||
  //  await removeClearScriptIni()
 | 
			
		||||
    await exec('echo \'test\'')
 | 
			
		||||
    const regKey = new Registry({ // new operator is optional
 | 
			
		||||
      hive: Registry.HKCU, // open registry hive HKEY_CURRENT_USER
 | 
			
		||||
      key: '\\Environment' // key containing autostart programs
 | 
			
		||||
    })
 | 
			
		||||
    regKey.remove('HTTPS_PROXY', async (err) => {
 | 
			
		||||
      log.info('删除环境变量https_proxy', err)
 | 
			
		||||
      await exec('setx DS_REFRESH "1"')
 | 
			
		||||
    })
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    log.error(e)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function _winSetProxy (exec, ip, port) {
 | 
			
		||||
async function _winSetProxy (exec, ip, port, setEnv) {
 | 
			
		||||
  let lanIpStr = ''
 | 
			
		||||
  for (const string of _lanIP) {
 | 
			
		||||
    lanIpStr += string + ';'
 | 
			
		||||
  }
 | 
			
		||||
  const proxyPath = extraPath.getProxyExePath()
 | 
			
		||||
  await execFile(proxyPath, ['global', `${ip}:${port}`, lanIpStr])
 | 
			
		||||
  try {
 | 
			
		||||
  //  await addClearScriptIni()
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    log.error(e)
 | 
			
		||||
 | 
			
		||||
  if (setEnv == null) {
 | 
			
		||||
    try {
 | 
			
		||||
      await exec('echo \'test\'')
 | 
			
		||||
      await exec(`setx HTTPS_PROXY "http://${ip}:${port}/"`)
 | 
			
		||||
      //  await addClearScriptIni()
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      log.error(e)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const executor = {
 | 
			
		||||
  async windows (exec, params) {
 | 
			
		||||
    if (params == null) {
 | 
			
		||||
  async windows (exec, params = {}) {
 | 
			
		||||
    const { ip, port, setEnv } = params
 | 
			
		||||
    if (ip == null) {
 | 
			
		||||
      // 清空代理
 | 
			
		||||
      log.info('关闭代理')
 | 
			
		||||
      return _winUnsetProxy(exec)
 | 
			
		||||
      return _winUnsetProxy(exec, setEnv)
 | 
			
		||||
    } else {
 | 
			
		||||
      // 设置代理
 | 
			
		||||
      const { ip, port } = params
 | 
			
		||||
 | 
			
		||||
      log.info('设置代理', ip, port)
 | 
			
		||||
      return _winSetProxy(exec, ip, port)
 | 
			
		||||
      return _winSetProxy(exec, ip, port, setEnv)
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  async linux (exec, params) {
 | 
			
		||||
    if (params != null) {
 | 
			
		||||
      const { ip, port } = params
 | 
			
		||||
  async linux (exec, params = {}) {
 | 
			
		||||
    const { ip, port } = params
 | 
			
		||||
    if (ip != null) {
 | 
			
		||||
      // const local = 'localhost, 127.0.0.0/8, ::1'
 | 
			
		||||
 | 
			
		||||
      const setProxyCmd = [
 | 
			
		||||
| 
						 | 
				
			
			@ -100,13 +116,13 @@ const executor = {
 | 
			
		|||
      await exec(setProxyCmd)
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  async mac (exec, params) {
 | 
			
		||||
  async mac (exec, params = {}) {
 | 
			
		||||
    // exec = _exec
 | 
			
		||||
    let wifiAdaptor = await exec('sh -c "networksetup -listnetworkserviceorder | grep `route -n get 0.0.0.0 | grep \'interface\' | cut -d \':\' -f2` -B 1 | head -n 1 "')
 | 
			
		||||
    wifiAdaptor = wifiAdaptor.trim()
 | 
			
		||||
    wifiAdaptor = wifiAdaptor.substring(wifiAdaptor.indexOf(' ')).trim()
 | 
			
		||||
 | 
			
		||||
    if (params == null) {
 | 
			
		||||
    const { ip, port } = params
 | 
			
		||||
    if (ip == null) {
 | 
			
		||||
      await exec(`networksetup -setwebproxystate '${wifiAdaptor}' off`)
 | 
			
		||||
      await exec(`networksetup -setsecurewebproxystate '${wifiAdaptor}' off`)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -117,7 +133,6 @@ const executor = {
 | 
			
		|||
      // `
 | 
			
		||||
      // await exec(removeEnv)
 | 
			
		||||
    } else {
 | 
			
		||||
      const { ip, port } = params
 | 
			
		||||
      await exec(`networksetup -setwebproxy '${wifiAdaptor}' ${ip} ${port}`)
 | 
			
		||||
      await exec(`networksetup -setsecurewebproxy '${wifiAdaptor}' ${ip} ${port}`)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2637,6 +2637,11 @@ ieee754@^1.1.4:
 | 
			
		|||
  resolved "https://registry.npm.taobao.org/ieee754/download/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
 | 
			
		||||
  integrity sha1-7BaFWOlaoYH9h9N/VcMrvLZwi4Q=
 | 
			
		||||
 | 
			
		||||
if-async@^3.7.4:
 | 
			
		||||
  version "3.7.4"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/if-async/-/if-async-3.7.4.tgz#55868deb0093d3c67bf7166e745353fb9bcb21a2"
 | 
			
		||||
  integrity sha1-VYaN6wCT08Z79xZudFNT+5vLIaI=
 | 
			
		||||
 | 
			
		||||
iferr@^0.1.5:
 | 
			
		||||
  version "0.1.5"
 | 
			
		||||
  resolved "https://registry.npm.taobao.org/iferr/download/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501"
 | 
			
		||||
| 
						 | 
				
			
			@ -2950,6 +2955,11 @@ is-wsl@^1.1.0:
 | 
			
		|||
  resolved "https://registry.npm.taobao.org/is-wsl/download/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
 | 
			
		||||
  integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=
 | 
			
		||||
 | 
			
		||||
isarray@0.0.1:
 | 
			
		||||
  version "0.0.1"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
 | 
			
		||||
  integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=
 | 
			
		||||
 | 
			
		||||
isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
 | 
			
		||||
  version "1.0.0"
 | 
			
		||||
  resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
 | 
			
		||||
| 
						 | 
				
			
			@ -4154,6 +4164,16 @@ read-pkg@^5.1.1:
 | 
			
		|||
    string_decoder "~1.1.1"
 | 
			
		||||
    util-deprecate "~1.0.1"
 | 
			
		||||
 | 
			
		||||
"readable-stream@>=1.0.33-1 <1.1.0-0":
 | 
			
		||||
  version "1.0.34"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c"
 | 
			
		||||
  integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=
 | 
			
		||||
  dependencies:
 | 
			
		||||
    core-util-is "~1.0.0"
 | 
			
		||||
    inherits "~2.0.1"
 | 
			
		||||
    isarray "0.0.1"
 | 
			
		||||
    string_decoder "~0.10.x"
 | 
			
		||||
 | 
			
		||||
readable-stream@^3.6.0:
 | 
			
		||||
  version "3.6.0"
 | 
			
		||||
  resolved "https://registry.npm.taobao.org/readable-stream/download/readable-stream-3.6.0.tgz?cache=0&sync_timestamp=1589682741447&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freadable-stream%2Fdownload%2Freadable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198"
 | 
			
		||||
| 
						 | 
				
			
			@ -4179,6 +4199,16 @@ readdirp@~3.5.0:
 | 
			
		|||
  dependencies:
 | 
			
		||||
    picomatch "^2.2.1"
 | 
			
		||||
 | 
			
		||||
regedit@^5.0.0:
 | 
			
		||||
  version "5.0.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/regedit/-/regedit-5.0.0.tgz#7ec444ef027cc704e104fae00586f84752291116"
 | 
			
		||||
  integrity sha512-4uSqj6Injwy5TPtXlE+1F/v2lOW/bMfCqNIAXyib4aG1ZwacG69oyK/yb6EF8KQRMhz7YINxkD+/HHc6i7YJtA==
 | 
			
		||||
  dependencies:
 | 
			
		||||
    debug "^4.1.0"
 | 
			
		||||
    if-async "^3.7.4"
 | 
			
		||||
    stream-slicer "0.0.6"
 | 
			
		||||
    through2 "^0.6.3"
 | 
			
		||||
 | 
			
		||||
regenerator-runtime@^0.11.0:
 | 
			
		||||
  version "0.11.1"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
 | 
			
		||||
| 
						 | 
				
			
			@ -4655,6 +4685,11 @@ stream-shift@^1.0.0:
 | 
			
		|||
  resolved "https://registry.npm.taobao.org/stream-shift/download/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d"
 | 
			
		||||
  integrity sha1-1wiCgVWasneEJCebCHfaPDktWj0=
 | 
			
		||||
 | 
			
		||||
stream-slicer@0.0.6:
 | 
			
		||||
  version "0.0.6"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/stream-slicer/-/stream-slicer-0.0.6.tgz#f86b2ac5c2440b7a0a87b71f33665c0788046138"
 | 
			
		||||
  integrity sha1-+GsqxcJEC3oKh7cfM2ZcB4gEYTg=
 | 
			
		||||
 | 
			
		||||
stream-throttle@^0.1.3:
 | 
			
		||||
  version "0.1.3"
 | 
			
		||||
  resolved "https://registry.npmjs.org/stream-throttle/-/stream-throttle-0.1.3.tgz#add57c8d7cc73a81630d31cd55d3961cfafba9c3"
 | 
			
		||||
| 
						 | 
				
			
			@ -4721,6 +4756,11 @@ string_decoder@^1.0.0, string_decoder@^1.1.1:
 | 
			
		|||
  dependencies:
 | 
			
		||||
    safe-buffer "~5.2.0"
 | 
			
		||||
 | 
			
		||||
string_decoder@~0.10.x:
 | 
			
		||||
  version "0.10.31"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"
 | 
			
		||||
  integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=
 | 
			
		||||
 | 
			
		||||
string_decoder@~1.1.1:
 | 
			
		||||
  version "1.1.1"
 | 
			
		||||
  resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
 | 
			
		||||
| 
						 | 
				
			
			@ -4844,6 +4884,14 @@ text-table@^0.2.0:
 | 
			
		|||
  resolved "https://registry.npm.taobao.org/text-table/download/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
 | 
			
		||||
  integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
 | 
			
		||||
 | 
			
		||||
through2@^0.6.3:
 | 
			
		||||
  version "0.6.5"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48"
 | 
			
		||||
  integrity sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=
 | 
			
		||||
  dependencies:
 | 
			
		||||
    readable-stream ">=1.0.33-1 <1.1.0-0"
 | 
			
		||||
    xtend ">=4.0.0 <4.1.0-0"
 | 
			
		||||
 | 
			
		||||
through2@^2.0.0, through2@^2.0.1:
 | 
			
		||||
  version "2.0.5"
 | 
			
		||||
  resolved "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd"
 | 
			
		||||
| 
						 | 
				
			
			@ -5249,7 +5297,7 @@ wide-align@1.1.3:
 | 
			
		|||
 | 
			
		||||
winreg@^1.2.4:
 | 
			
		||||
  version "1.2.4"
 | 
			
		||||
  resolved "https://registry.npm.taobao.org/winreg/download/winreg-1.2.4.tgz#ba065629b7a925130e15779108cf540990e98d1b"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/winreg/-/winreg-1.2.4.tgz#ba065629b7a925130e15779108cf540990e98d1b"
 | 
			
		||||
  integrity sha1-ugZWKbepJRMOFXeRCM9UCZDpjRs=
 | 
			
		||||
 | 
			
		||||
word-wrap@~1.2.3:
 | 
			
		||||
| 
						 | 
				
			
			@ -5290,7 +5338,7 @@ write@1.0.3:
 | 
			
		|||
  dependencies:
 | 
			
		||||
    mkdirp "^0.5.1"
 | 
			
		||||
 | 
			
		||||
xtend@^4.0.0, xtend@~4.0.1:
 | 
			
		||||
"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.1:
 | 
			
		||||
  version "4.0.2"
 | 
			
		||||
  resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
 | 
			
		||||
  integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -128,6 +128,7 @@ function createWindow (startHideWindow) {
 | 
			
		|||
    webPreferences: {
 | 
			
		||||
      enableRemoteModule: true,
 | 
			
		||||
      contextIsolation: false,
 | 
			
		||||
      nativeWindowOpen: true, // ADD THIS
 | 
			
		||||
      // preload: path.join(__dirname, 'preload.js'),
 | 
			
		||||
      // Use pluginOptions.nodeIntegration, leave this alone
 | 
			
		||||
      // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,7 +72,7 @@
 | 
			
		|||
 | 
			
		||||
    <setup-ca title="安装证书" :visible.sync="setupCa.visible" @setup="handleCaSetuped"></setup-ca>
 | 
			
		||||
    <div slot="footer">
 | 
			
		||||
      <div class="star" v-if="!setting.overwall">
 | 
			
		||||
      <div class="star" v-if="setting && !setting.overwall">
 | 
			
		||||
        <div class="donate">
 | 
			
		||||
          <a-tooltip placement="topLeft" title="彩蛋">
 | 
			
		||||
            <span style="display: block;width:100px;height:50px;" @click="wantOW()"></span>
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +163,7 @@ export default {
 | 
			
		|||
    }
 | 
			
		||||
  },
 | 
			
		||||
  async created () {
 | 
			
		||||
    this.doCheckRootCa()
 | 
			
		||||
    await this.doCheckRootCa()
 | 
			
		||||
    await this.reloadConfig()
 | 
			
		||||
    this.$set(this, 'status', this.$status)
 | 
			
		||||
    this.switchBtns = this.createSwitchBtns()
 | 
			
		||||
| 
						 | 
				
			
			@ -216,28 +216,27 @@ export default {
 | 
			
		|||
        )
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    doCheckRootCa () {
 | 
			
		||||
      this.$api.setting.load().then(setting => {
 | 
			
		||||
        console.log('setting', setting)
 | 
			
		||||
        this.setting = setting
 | 
			
		||||
        if (this.setting.rootCa && (this.setting.rootCa.setuped || this.setting.rootCa.noTip)) {
 | 
			
		||||
          return
 | 
			
		||||
    async doCheckRootCa () {
 | 
			
		||||
      const setting = await this.$api.setting.load()
 | 
			
		||||
      console.log('setting', setting)
 | 
			
		||||
      this.setting = setting
 | 
			
		||||
      if (this.setting.rootCa && (this.setting.rootCa.setuped || this.setting.rootCa.noTip)) {
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
      this.$confirm({
 | 
			
		||||
        title: '第一次使用,请先安装CA根证书',
 | 
			
		||||
        content: '本应用正常使用,必须安装和信任CA根证书',
 | 
			
		||||
        cancelText: '下次',
 | 
			
		||||
        okText: '去安装',
 | 
			
		||||
        onOk: () => {
 | 
			
		||||
          this.openSetupCa()
 | 
			
		||||
        },
 | 
			
		||||
        onCancel: () => {
 | 
			
		||||
          this.setting.rootCa = this.setting.rootCa || {}
 | 
			
		||||
          //  const rootCa = this.setting.rootCa
 | 
			
		||||
          // rootCa.noTip = true
 | 
			
		||||
          // this.$api.setting.save(this.setting)
 | 
			
		||||
        }
 | 
			
		||||
        this.$confirm({
 | 
			
		||||
          title: '第一次使用,请先安装CA根证书',
 | 
			
		||||
          content: '本应用正常使用,必须安装和信任CA根证书',
 | 
			
		||||
          cancelText: '下次',
 | 
			
		||||
          okText: '去安装',
 | 
			
		||||
          onOk: () => {
 | 
			
		||||
            this.openSetupCa()
 | 
			
		||||
          },
 | 
			
		||||
          onCancel: () => {
 | 
			
		||||
            this.setting.rootCa = this.setting.rootCa || {}
 | 
			
		||||
            //  const rootCa = this.setting.rootCa
 | 
			
		||||
            // rootCa.noTip = true
 | 
			
		||||
            // this.$api.setting.save(this.setting)
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    openSetupCa () {
 | 
			
		||||
| 
						 | 
				
			
			@ -265,6 +264,9 @@ export default {
 | 
			
		|||
      btns.server = this.createSwitchBtn('server', '代理服务', this.$api.server, status)
 | 
			
		||||
      btns.proxy = this.createSwitchBtn('proxy', '系统代理', this.$api.proxy, status)
 | 
			
		||||
      lodash.forEach(status.plugin, (item, key) => {
 | 
			
		||||
        if (this.config.plugin[key].statusOff) {
 | 
			
		||||
          return
 | 
			
		||||
        }
 | 
			
		||||
        btns[key] = this.createSwitchBtn(key, this.config.plugin[key].name, this.$api.plugin[key], status.plugin, this.config.plugin[key].tip)
 | 
			
		||||
      })
 | 
			
		||||
      return btns
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,27 +26,29 @@
 | 
			
		|||
          </a-checkbox>
 | 
			
		||||
          npm代理启用后必须关闭
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item label="npm registry" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
        <a-form-item label="npm仓库镜像" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
          <a-radio-group v-model="config.plugin.node.setting.registry" @change="onSwitchRegistry"
 | 
			
		||||
                         default-value="https://registry.npmjs.org" button-style="solid">
 | 
			
		||||
            <a-radio-button value="https://registry.npmjs.org">
 | 
			
		||||
              npmjs
 | 
			
		||||
              npmjs原生
 | 
			
		||||
            </a-radio-button>
 | 
			
		||||
            <a-radio-button value="https://registry.npm.taobao.org">
 | 
			
		||||
              taobao
 | 
			
		||||
              taobao镜像
 | 
			
		||||
            </a-radio-button>
 | 
			
		||||
          </a-radio-group>
 | 
			
		||||
          <div class="form-help">设置后立即生效,即使关闭ds也会继续保持</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
 | 
			
		||||
        <a-form-item label="yarn registry" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
        <a-form-item label="yarn仓库镜像" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
          <a-radio-group v-model="config.plugin.node.setting.yarnRegistry" :default-value="null"  @change="onSwitchYarnRegistry" button-style="solid">
 | 
			
		||||
            <a-radio-button :value="null">
 | 
			
		||||
              yarn
 | 
			
		||||
              yarn原生
 | 
			
		||||
            </a-radio-button>
 | 
			
		||||
            <a-radio-button value="https://registry.npm.taobao.org">
 | 
			
		||||
              taobao
 | 
			
		||||
              taobao镜像
 | 
			
		||||
            </a-radio-button>
 | 
			
		||||
          </a-radio-group>
 | 
			
		||||
          <div class="form-help">设置后立即生效,即使关闭ds也会继续保持</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
 | 
			
		||||
        <a-form-item label="镜像变量设置" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,98 @@
 | 
			
		|||
<template>
 | 
			
		||||
  <ds-container>
 | 
			
		||||
    <template slot="header">
 | 
			
		||||
      PIP加速
 | 
			
		||||
      <span style="color:#999;">
 | 
			
		||||
      </span>
 | 
			
		||||
    </template>
 | 
			
		||||
 | 
			
		||||
    <div v-if="config">
 | 
			
		||||
      <a-form layout="horizontal">
 | 
			
		||||
<!--        <a-form-item label="启用PIP加速" :label-col="labelCol" :wrapper-col="wrapperCol">-->
 | 
			
		||||
<!--          <a-checkbox v-model="config.plugin.pip.enabled">-->
 | 
			
		||||
<!--            随应用启动-->
 | 
			
		||||
<!--          </a-checkbox>-->
 | 
			
		||||
<!--          <a-tag v-if="status.plugin.pip.enabled" color="green">-->
 | 
			
		||||
<!--            当前已启动-->
 | 
			
		||||
<!--          </a-tag>-->
 | 
			
		||||
<!--          <a-tag v-else color="red">-->
 | 
			
		||||
<!--            当前未启动-->
 | 
			
		||||
<!--          </a-tag>-->
 | 
			
		||||
<!--        </a-form-item>-->
 | 
			
		||||
        <a-form-item label="设置环境变量" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
          <a-checkbox v-model="config.proxy.setEnv" >
 | 
			
		||||
            开启系统代理时是否同时修改HTTPS_PROXY环境变量
 | 
			
		||||
          </a-checkbox>
 | 
			
		||||
          <div class="form-help">开启ds使用pip命令行时需要勾选此选项,否则会报 wrong version number 异常</div>
 | 
			
		||||
          <div class="form-help">注意:当前已打开的命令行在开关系统代理后并不会实时生效,需要重新打开一个新的命令行窗口</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item label="信任仓库域名" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
          <a-input v-model="config.plugin.pip.setting.trustedHost"></a-input>
 | 
			
		||||
          <div>这里配置信任仓库域名,避免出现ssl校验失败错误</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item label="仓库镜像" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
          <a-radio-group v-model="config.plugin.pip.setting.registry" @change="onSwitchRegistry"
 | 
			
		||||
                         default-value="https://pypi.org/simple/" button-style="solid">
 | 
			
		||||
            <a-radio-button value="https://pypi.org/simple/">
 | 
			
		||||
              原生
 | 
			
		||||
            </a-radio-button>
 | 
			
		||||
            <a-radio-button value="http://mirrors.aliyun.com/pypi/simple/">
 | 
			
		||||
              taobao镜像
 | 
			
		||||
            </a-radio-button>
 | 
			
		||||
          </a-radio-group>
 | 
			
		||||
          <div class="form-help">设置后立即生效,即使关闭ds也会继续保持</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
      </a-form>
 | 
			
		||||
    </div>
 | 
			
		||||
    <template slot="footer">
 | 
			
		||||
      <div class="footer-bar">
 | 
			
		||||
        <a-button class="md-mr-10" icon="sync"   @click="resetDefault()">恢复默认</a-button>
 | 
			
		||||
        <a-button :loading="applyLoading" icon="check" type="primary" @click="apply()">应用</a-button>
 | 
			
		||||
      </div>
 | 
			
		||||
    </template>
 | 
			
		||||
  </ds-container>
 | 
			
		||||
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import Plugin from '../../mixins/plugin'
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'pip',
 | 
			
		||||
  mixins: [Plugin],
 | 
			
		||||
  data () {
 | 
			
		||||
    return {
 | 
			
		||||
      key: 'plugin.pip',
 | 
			
		||||
      npmVariables: undefined,
 | 
			
		||||
      registry: false,
 | 
			
		||||
      trustedHostList: []
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  created () {
 | 
			
		||||
    console.log('status:', this.status)
 | 
			
		||||
  },
 | 
			
		||||
  mounted () {
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    ready () {
 | 
			
		||||
    },
 | 
			
		||||
    async applyBefore () {
 | 
			
		||||
    },
 | 
			
		||||
    async applyAfter () {
 | 
			
		||||
      await this.$api.plugin.pip.start()
 | 
			
		||||
      await this.$api.proxy.restart()
 | 
			
		||||
    },
 | 
			
		||||
    async onSwitchRegistry (event) {
 | 
			
		||||
      await this.setRegistry({ registry: event.target.value })
 | 
			
		||||
      this.$message.success('切换成功')
 | 
			
		||||
    },
 | 
			
		||||
    async setRegistry ({ registry }) {
 | 
			
		||||
      await this.apply()
 | 
			
		||||
      await this.$api.plugin.node.setRegistry({ registry })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="sass">
 | 
			
		||||
</style>
 | 
			
		||||
| 
						 | 
				
			
			@ -18,9 +18,16 @@
 | 
			
		|||
          当前未启动
 | 
			
		||||
        </a-tag>
 | 
			
		||||
      </a-form-item>
 | 
			
		||||
      <a-form-item label="设置环境变量" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
        <a-checkbox v-model="config.proxy.setEnv" >
 | 
			
		||||
          是否同时修改HTTPS_PROXY环境变量
 | 
			
		||||
        </a-checkbox>
 | 
			
		||||
        <div class="form-help">当发现某些应用并没有走加速通道时,可以尝试勾选此选项,并重新开启系统代理开关</div>
 | 
			
		||||
        <div class="form-help">注意:当前已打开的命令行并不会实时生效,需要重新打开一个新的命令行窗口</div>
 | 
			
		||||
      </a-form-item>
 | 
			
		||||
      <a-form-item label="设置loopback" :label-col="labelCol" :wrapper-col="wrapperCol">
 | 
			
		||||
       <a-button @click="loopbackVisible=true">去设置</a-button>
 | 
			
		||||
        <div class="form-help">解决OneNote、微软应用商店、微软邮箱等大部分系统自带应用无法访问网络问题。点击去设置,然后按下图所示操作即可</div>
 | 
			
		||||
        <div class="form-help">解决OneNote、微软应用商店、微软邮箱等系统自带应用开启代理后无法访问网络的问题</div>
 | 
			
		||||
      </a-form-item>
 | 
			
		||||
    </div>
 | 
			
		||||
    <template slot="footer">
 | 
			
		||||
| 
						 | 
				
			
			@ -44,9 +51,10 @@
 | 
			
		|||
        设置Loopback  <a-button style="float:right;margin-right:10px;" @click="openEnableLoopback()">打开EnableLoopback</a-button>
 | 
			
		||||
      </template>
 | 
			
		||||
      <div>
 | 
			
		||||
        <div>解决OneNote、微软应用商店、微软邮箱等大部分系统自带应用无法访问网络问题。点击右上方按钮,然后按下图所示操作即可</div>
 | 
			
		||||
        <div >注意:此操作需要DevSidecar以<b>管理员身份启动</b>,才能打开下面的EnableLoopback设置界面</div>
 | 
			
		||||
        <img style="margin-top:10px;" width="80%" src="loopback.png" />
 | 
			
		||||
        <div>1、此设置用于解决OneNote、微软应用商店、微软邮箱等系统自带应用在开启代理后无法访问网络的问题。</div>
 | 
			
		||||
        <div>2、点击右上方按钮,打开EnableLoopback,然后按下图所示操作即可</div>
 | 
			
		||||
        <div>3、注意:此操作需要<b style="color:red">DevSidecar以管理员身份启动</b>,才能打开下面的EnableLoopback设置界面</div>
 | 
			
		||||
        <img style="margin-top:20px;border:1px solid #eee" width="80%" src="loopback.png" />
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
    </a-drawer>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,7 +79,7 @@
 | 
			
		|||
              </a-col>
 | 
			
		||||
            </a-row>
 | 
			
		||||
            <a-row :gutter="10" style="margin-top: 10px" v-for="(item,index) of whiteList" :key='index'>
 | 
			
		||||
              <a-col :span="14">
 | 
			
		||||
              <a-col :span="19">
 | 
			
		||||
                <a-input :disabled="item.value ===false" v-model="item.key"></a-input>
 | 
			
		||||
              </a-col>
 | 
			
		||||
              <a-col :span="3">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ import Server from '../pages/server'
 | 
			
		|||
import Proxy from '../pages/proxy'
 | 
			
		||||
import Node from '../pages/plugin/node'
 | 
			
		||||
import Git from '../pages/plugin/git'
 | 
			
		||||
import Pip from '../pages/plugin/pip'
 | 
			
		||||
import Overwall from '../pages/plugin/overwall'
 | 
			
		||||
import Setting from '../pages/setting'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -13,6 +14,7 @@ const routes = [
 | 
			
		|||
  { path: '/proxy', component: Proxy },
 | 
			
		||||
  { path: '/plugin/node', component: Node },
 | 
			
		||||
  { path: '/plugin/git', component: Git },
 | 
			
		||||
  { path: '/plugin/pip', component: Pip },
 | 
			
		||||
  { path: '/plugin/overwall', component: Overwall },
 | 
			
		||||
  { path: '/setting', component: Setting }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,8 @@
 | 
			
		|||
export default function createMenus (app) {
 | 
			
		||||
  const plugins = [
 | 
			
		||||
    { title: 'NPM加速', path: '/plugin/node', icon: 'like' },
 | 
			
		||||
    { title: 'Git.exe代理', path: '/plugin/git', icon: 'github' }
 | 
			
		||||
    { title: 'Git.exe代理', path: '/plugin/git', icon: 'github' },
 | 
			
		||||
    { title: 'pip代理', path: '/plugin/pip', icon: 'bulb' }
 | 
			
		||||
  ]
 | 
			
		||||
  const menus = [
 | 
			
		||||
    { title: '首页', path: '/index', icon: 'home' },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue