Merge remote-tracking branch 'origin/master'

# Conflicts:
#	packages/core/src/config/index.js
pull/192/head
xiaojunnuo 3 years ago
commit e7b4b485c9

1
.gitignore vendored

@ -6,3 +6,4 @@ gen
node_modules/
*.lock
*.log
pnpm-lock.yaml

@ -325,11 +325,19 @@ npm run electron:build
## 九、联系作者
欢迎bug反馈需求建议技术交流等请备注dev-sidecar或简称DS
1、 加群
<div style="display: flex; justify-content:space-around;">
<img height="230px" src="https://gitee.com/docmirror/dev-sidecar/raw/master/doc/me.png">
<img height="280px" src="http://wxgroup.docmirror.cn/weixin/group/dev-sidecar/qrcode.png">
<img height="230px" src="https://gitee.com/docmirror/dev-sidecar/raw/master/doc/qq_group.png">
</div>
2、 加作者好友
<div style="display: flex; justify-content:space-around;">
<img height="200px" src="https://gitee.com/docmirror/dev-sidecar/raw/master/doc/me.png">
</div>

@ -14,5 +14,5 @@
"ignore": []
}
},
"version": "1.6.2"
"version": "1.7.1"
}

@ -6,5 +6,6 @@
"devDependencies": {
"lerna": "^3.22.1"
},
"dependencies": {}
"dependencies": {
}
}

@ -1,6 +1,7 @@
module.exports = require('./src')
// TODO 这是个彩蛋 ↓ ↓ ↓ ↓ ↓ ↓ ,如果你破解了它,请不要公开,好好用它来学习和查资料吧。
// TODO 这是一个解谜游戏 ↓ ↓ ↓ ↓ ↓ ↓ ,如果你破解了它,请不要公开,好好用它来学习和查资料吧。
/**
\u0061\u0048\u0052\u0030\u0063\u0044\u006f\u0076\u004c\u0032\u0052\u006c\u0064\u0069\u0031\u007a\u0061\u0057\u0052\u006c\u0059\u0032\u0046\u0079\u004c\u006d\u0052\u0076\u0059\u0032\u0031\u0070\u0063\u006e\u004a\u0076\u0063\u0069\u0035\u006a\u0062\u0069\u0039\u0035\u0062\u0033\u0056\u006d\u0061\u0057\u0035\u006b\u0061\u0058\u0051\u0076\u0061\u0057\u0035\u006b\u005a\u0058\u0067\u0075\u0061\u0048\u0052\u0074\u0062\u0041\u003d\u003d
**/
// 这个项目里有一点点解谜提示: https://github.com/fast-crud/fast-crud (打开拉到最下面)

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar",
"version": "1.6.2",
"version": "1.7.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar",
"version": "1.6.2",
"version": "1.7.1",
"description": "给开发者的加速代理工具",
"main": "src/index.js",
"keywords": [
@ -17,7 +17,7 @@
"test": "mocha"
},
"dependencies": {
"@docmirror/mitmproxy": "^1.6.2",
"@docmirror/mitmproxy": "^1.7.1",
"agentkeepalive": "^2.1.1",
"babel-preset-es2020": "^1.0.2",
"charset": "^1.0.0",

@ -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': {
@ -159,7 +163,7 @@ module.exports = {
'www.googleapis.com': { '.*': { abort: false, desc: '设置aborttrue可以快速失败节省时间' } },
'lh*.googleusercontent.com': { '.*': { abort: false, desc: '设置aborttrue可以快速失败节省时间' } },
// mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.0/napi-v3-win32-x64.tar.gz
'*.s3.amazonaws.com': {
'*.s3.1amazonaws1.com': {
'/sqlite3/.*': {
redirect: 'npm.taobao.org/mirrors'
}

@ -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,13 @@
module.exports = {
name: 'PIP加速',
statusOff: true,
enabled: null, // 没有开关
tip: '如果你没有安装pip则不需要启动它',
startup: {
},
setting: {
command: 'pip',
trustedHost: 'pypi.org',
registry: 'https://pypi.org/simple/'// 可以选择切换官方或者淘宝镜像
}
}

@ -0,0 +1,96 @@
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 () {
const command = config.get().plugin.pip.setting.command
let ret = await shell.exec([command + ' 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 command = config.get().plugin.pip.setting.command
const cmds = []
for (const item of list) {
if (item.value != null) {
cmds.push(`${command} config set global.${item.key} ${item.value}`)
} else {
cmds.push(`${command} config unset global.${item.key}`)
}
}
const ret = await shell.exec(cmds, { type: 'cmd' })
return ret
},
async unsetPipEnv (list) {
const command = config.get().plugin.pip.setting.command
const cmds = []
for (const item of list) {
cmds.push(`${command} 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,70 @@ 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.get('HTTPS_PROXY', (err) => {
if (!err) {
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) {
log.info('同时设置 https_proxy')
try {
await exec('echo \'test\'')
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)
log.info('设置代理', ip, port, setEnv)
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 +122,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 +139,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==

@ -1,6 +1,6 @@
// ==UserScript==
// @name Github 增强 - 高速下载
// @version 1.5.7
// @version 1.6.8
// @author X.I.U
// @description 高速下载 Git Clone/SSH、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁)
// @match *://github.com/*
@ -17,43 +17,32 @@
// @namespace https://greasyfork.org/scripts/412245
// @supportURL https://github.com/XIU2/UserScript
// @homepageURL https://github.com/XIU2/UserScript
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
var backColor = '#ffffff';
var fontColor = '#888888';
var backColor = '#ffffff', fontColor = '#888888';
if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'dark') { // 黑暗模式判断
if (document.getElementsByTagName('html')[0].getAttribute('data-dark-theme') === 'dark_dimmed') {
backColor = '#272e37';
fontColor = '#768390';
backColor = '#272e37'; fontColor = '#768390';
} else {
backColor = '#161a21';
fontColor = '#97a0aa';
backColor = '#161a21'; fontColor = '#97a0aa';
}
} else if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'auto') {
console.log(window.getComputedStyle(document.body).backgroundColor)
if (window.getComputedStyle(document.body).backgroundColor === 'rgb(34, 39, 46)') {
backColor = '#272e37';
fontColor = '#768390';
backColor = '#272e37'; fontColor = '#768390';
} else if (window.getComputedStyle(document.body).backgroundColor === 'rgb(13, 17, 23)') {
backColor = '#161a21';
fontColor = '#97a0aa';
backColor = '#161a21'; fontColor = '#97a0aa';
}
}
//['https://gh.66ccff.work', '美国'],
//['https://github.91chifun.workers.dev', '美国'],
//['https://github.rc1844.workers.dev', '美国'],
const download_url = [
['https://gh.api.99988866.xyz', '美国'],
['https://gh.msx.workers.dev', '美国'],
['https://gh.xiu2.xyz', '美国'],
['https://gh.argv.cc', '美国费利蒙'],
['https://git.yumenaka.net', '美国洛杉矶'],
['https://download.fastgit.org', '日本东京'],
['https://ghproxy.com', '韩国首尔'],
['https://pd.zwc365.com/seturl', '中国香港']
['https://gh.api.99988866.xyz/https://github.com', '美国 1'],
['https://github.91chifun.workers.dev/https://github.com', '美国 2'],
['https://gh.xiu2.xyz/https://github.com', '美国 3'],
['https://github.rc1844.workers.dev', '美国 4'],
['https://pd.zwc365.com/seturl/https://github.com', '美国 5'],
['https://download.fastgit.org', '日本'],
['https://ghproxy.com/https://github.com/', '韩国']
],
clone_url = [
['https://hub.fastgit.org', '中国香港'],
@ -68,8 +57,7 @@
['https://raw.githubusercontent.com', 'Github 原生',''],
['https://cdn.jsdelivr.net','中国国内', '注意该加速源存在缓存机制24小时所以文件可能不是最新。&#10;注意:当前分支所有文件总文件大小超过 50MB 时,该加速源不可用。&#10;注意:当前分支名为版本号格式时(如 v1.2.3),该高速下载链接因格式限制不可用。'],
['https://raw.fastgit.org','中国香港', '注意:单个文件太大时可能会提示超时(实时获取中),请重试。'],
['https://cdn.staticaly.com','日本东京', '注意:该加速是全球 Anycast CDN国内一般分配到日本节点。'],
['https://ghproxy.com','韩国首尔', '']
['https://cdn.staticaly.com','日本东京', '注意:该加速是全球 Anycast CDN国内一般分配到日本节点。']
],
svg = [
'<svg class="octicon octicon-file-zip mr-2" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true"><path fill-rule="evenodd" d="M3.5 1.75a.25.25 0 01.25-.25h3a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h2.086a.25.25 0 01.177.073l2.914 2.914a.25.25 0 01.073.177v8.586a.25.25 0 01-.25.25h-.5a.75.75 0 000 1.5h.5A1.75 1.75 0 0014 13.25V4.664c0-.464-.184-.909-.513-1.237L10.573.513A1.75 1.75 0 009.336 0H3.75A1.75 1.75 0 002 1.75v11.5c0 .649.353 1.214.874 1.515a.75.75 0 10.752-1.298.25.25 0 01-.126-.217V1.75zM8.75 3a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h-.5zM6 5.25a.75.75 0 01.75-.75h.5a.75.75 0 010 1.5h-.5A.75.75 0 016 5.25zm2 1.5A.75.75 0 018.75 6h.5a.75.75 0 010 1.5h-.5A.75.75 0 018 6.75zm-1.25.75a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h-.5zM8 9.75A.75.75 0 018.75 9h.5a.75.75 0 010 1.5h-.5A.75.75 0 018 9.75zm-.75.75a1.75 1.75 0 00-1.75 1.75v3c0 .414.336.75.75.75h2.5a.75.75 0 00.75-.75v-3a1.75 1.75 0 00-1.75-1.75h-.5zM7 12.25a.25.25 0 01.25-.25h.5a.25.25 0 01.25.25v2.25H7v-2.25z"></path></svg>',
@ -114,19 +102,19 @@
return ['0⃣','1⃣','2⃣','3⃣','4⃣','5⃣','6⃣','7⃣','8⃣','9⃣','🔟'][num]
}
addRelease(); // Release 加速
addDownloadZIP(); // Download ZIP 加速
addGitClone(); // Git Clone 加速
addGitCloneSSH(); // Git Clone SSH 加速
addRawFile(); // Raw 加速
addRelease(); // Release 加速
setTimeout(addDownloadZIP, 2000); // Download ZIP 加速
setTimeout(addGitClone, 2000); // Git Clone 加速
setTimeout(addGitCloneSSH, 2000); // Git Clone SSH 加速
addRawFile(); // Raw 加速
setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉
document.addEventListener('pjax:success',function(){ // pjax 事件发生后
addRelease(); // Release 加速
addDownloadZIP(); // Download ZIP 加速
addGitClone(); // Git Clone 加速
addGitCloneSSH(); // Git Clone SSH 加速
addRawFile(); // Raw 加速
addRelease(); // Release 加速
setTimeout(addDownloadZIP, 2000); // Download ZIP 加速
setTimeout(addGitClone, 2000); // Git Clone 加速
setTimeout(addGitCloneSSH, 2000); // Git Clone SSH 加速
addRawFile(); // Raw 加速
setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉
});
@ -138,53 +126,21 @@
// Release
function addRelease() {
let html = document.getElementsByClassName('Box Box--condensed');if (!html) return
let divDisplay;
if (document.documentElement.clientWidth > 1000) {
divDisplay = 'display: flex;';
} else {
divDisplay = 'display: block;';
}
let html = document.getElementsByClassName('Box-footer'); if (html.length == 0) return
let divDisplay = '';
if (document.documentElement.clientWidth > 1000) {divDisplay = 'float: right;margin-top: -3px;margin-left: 8px;';}; // 调整小屏幕时的样式
Array.from(html).forEach(function (current) {
current.querySelectorAll('.d-flex.Box-body > a').forEach(function (_this) {
current.querySelectorAll('li.Box-row > a').forEach(function (_this) {
let href = _this.href.split(location.host),
url = [],
_html = `<div style="${divDisplay}justify-content: flex-end;">`;
_html = `<div style="${divDisplay}">`;
// 循环组合 URL 链接
for (let i=0;i<download_url.length;i++){
if (download_url[i][0] === 'https://download.fastgit.org') {
url[i] = download_url[i][0] + href[1]
} else {
url[i] = download_url[i][0] + '/' + _this.href
}
url[i] = download_url[i][0] + href[1]
if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com')
if (download_url[i][0] === 'https://download.fastgit.org' && url[i].indexOf('/archive/') > -1) url[i] = url[i].replace('https://download.fastgit.org','https://archive.fastgit.org')
}
for (let i=0;i<url.length;i++) {
_html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>`
}
_html += `</div>`
_this.nextElementSibling.insertAdjacentHTML('afterend', _html);
});
// 修改[文件大小]元素样式
document.querySelectorAll('small.pl-2.color-text-secondary.flex-shrink-0').forEach(el=>{el.style.cssText='display: flex; justify-content: flex-end; flex-grow: 1; margin-right: 8px;'});
// Source Code
current.querySelectorAll('.d-block.Box-body > a').forEach(function (_this) {
let href = _this.href.split(location.host),
url = [],
_html = `<div style="${divDisplay}justify-content: flex-end;flex-grow: 1;">`;
for (let i=0;i<download_url.length;i++){
if (download_url[i][0] === 'https://download.fastgit.org') {
url[i] = download_url[i][0] + href[1]
} else {
url[i] = download_url[i][0] + '/' + _this.href
}
if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com')
}
// 循环生成 HTML 标签
for (let i=0;i<url.length;i++) {
_html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>`
}
@ -192,29 +148,25 @@
_this.insertAdjacentHTML('afterend', _html);
});
});
// 修改 Source code 样式,使其和加速按钮并列一排
document.querySelectorAll('div.d-block.py-1.py-md-2.Box-body.px-2').forEach(el=>{el.className='d-flex py-1 py-md-2 Box-body px-2'});
}
// Download ZIP
function addDownloadZIP() {
if (document.querySelector('.XIU2-DZ')) return
let html = document.querySelector('.dropdown-menu.dropdown-menu-sw.p-0 ul li:last-child');if (!html) return
let href = html.getElementsByTagName('a')[0].href,
url = [],
_html = ``;
for (let i=0;i<download_url.length;i++){
if (download_url[i][0] === 'https://download.fastgit.org') {
url[i] = download_url[i][0] + href.split(location.host)[1]
} else {
url[i] = download_url[i][0] + '/' + href
}
url[i] = download_url[i][0] + href.split(location.host)[1]
if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com')
if (download_url[i][0] === 'https://download.fastgit.org' && url[i].indexOf('/archive/') > -1) url[i] = url[i].replace('https://download.fastgit.org','https://archive.fastgit.org')
}
for (let i=0;i<url.length;i++) {
_html += `<li class="Box-row Box-row--hover-gray p-3 mt-0"><a class="d-flex flex-items-center color-text-primary text-bold no-underline" rel="nofollow" href="${url[i]}">${svg[0]}Download ZIP ${download_url[i][1]}</a></li>`
_html += `<li class="Box-row Box-row--hover-gray p-3 mt-0 XIU2-DZ"><a class="d-flex flex-items-center color-text-primary text-bold no-underline" rel="nofollow" href="${url[i]}">${svg[0]}Download ZIP ${download_url[i][1]}</a></li>`
}
html.insertAdjacentHTML('afterend', _html);
}
@ -222,6 +174,7 @@
// Git Clone
function addGitClone() {
if (document.querySelector('.XIU2-GC')) return
let html = document.querySelector('[role="tabpanel"]:nth-child(2) div.input-group');if (!html) return
let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split(location.host),
url = [],
@ -236,7 +189,7 @@
}
for (let i=0;i<url.length;i++) {
_html += `<div class="input-group" style="margin-top: 4px;" title="加速源:${clone_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm color-bg-secondary" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm js-clipboard-copy tooltipped-no-delay ClipboardButton" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>`
_html += `<div class="input-group XIU2-GC" style="margin-top: 4px;" title="加速源:${clone_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm color-bg-secondary" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm js-clipboard-copy tooltipped-no-delay ClipboardButton" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>`
}
html.insertAdjacentHTML('afterend', _html);
}
@ -244,6 +197,7 @@
// Git Clone SSH
function addGitCloneSSH() {
if (document.querySelector('.XIU2-GCS')) return
let html = document.querySelector('[role="tabpanel"]:nth-child(3) div.input-group');if (!html) return
let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split(':'),
url = [],
@ -252,11 +206,11 @@
if (href_split[0] != 'git@github.com') return
for (let i=0;i<clone_ssh_url.length;i++){
url[i] = clone_ssh_url[i][0] + ':' + href_split[1]
url[i] = clone_ssh_url[i][0] + ':' + href_split[1]
}
for (let i=0;i<url.length;i++) {
_html += `<div class="input-group" style="margin-top: 4px;" title="加速源:${clone_ssh_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm color-bg-secondary" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm js-clipboard-copy tooltipped-no-delay ClipboardButton" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>`
_html += `<div class="input-group XIU2-GCS" style="margin-top: 4px;" title="加速源:${clone_ssh_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm color-bg-secondary" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm js-clipboard-copy tooltipped-no-delay ClipboardButton" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>`
}
html.insertAdjacentHTML('afterend', _html);
}
@ -264,18 +218,18 @@
// Raw
function addRawFile() {
if (document.querySelector('.XIU2-RF')) return
let html = document.getElementById('raw-url');if (!html) return
let href = location.href.replace(`https://${location.host}`,''),
href2 = href.replace('/blob/','/'),
url = [
raw_url[1][0] + "/gh" + href.replace('/blob/','@'),
raw_url[1][0] + '/gh' + href.replace('/blob/','@'),
raw_url[2][0] + href2,
raw_url[3][0] + "/gh" + href.replace('/blob/','/'),
raw_url[4][0] + "/" + raw_url[0][0] + href2
raw_url[3][0] + '/gh' + href.replace('/blob/','/')
],
_html = ``;
for (let i=0;i<url.length;i++) {
_html += `<a href="${url[i]}" title="${raw_url[i+1][2]}" target="_blank" role="button" rel="noreferrer noopener nofollow" class="btn btn-sm BtnGroup-item">${raw_url[i+1][1]}</a>`
_html += `<a href="${url[i]}" title="${raw_url[i+1][2]}" target="_blank" role="button" rel="noreferrer noopener nofollow" class="btn btn-sm BtnGroup-item XIU2-RF">${raw_url[i+1][1]}</a>`
}
html.insertAdjacentHTML('afterend', _html);
}
@ -284,14 +238,14 @@
// 添加 Raw 下载链接(☁)
function addRawDownLink() {
// 如果不是项目文件页面,就返回,如果网页有 Raw 下载链接(☁)就返回
let files = document.querySelectorAll('div.Box-row svg.octicon.octicon-file');if(files.length === 0) return;
let files = document.querySelectorAll('div.Box-row svg.octicon.octicon-file');if(files.length === 0) return;if (location.pathname.indexOf('/tags') > -1) return
let files1 = document.querySelectorAll('a.fileDownLink');if(files1.length > 0) return;
// 鼠标指向则显示
var mouseOverHandler = function(evt) {
let elem = evt.currentTarget,
aElm_new = elem.querySelectorAll('.fileDownLink'),
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary');
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file');
aElm_new.forEach(el=>{el.style.cssText = 'display: inline'});
aElm_now.forEach(el=>{el.style.cssText = 'display: none'});
};
@ -300,7 +254,7 @@
var mouseOutHandler = function(evt) {
let elem = evt.currentTarget,
aElm_new = elem.querySelectorAll('.fileDownLink'),
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary');
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file');
aElm_new.forEach(el=>{el.style.cssText = 'display: none'});
aElm_now.forEach(el=>{el.style.cssText = 'display: inline'});
};
@ -309,32 +263,22 @@
files.forEach(function(fileElm, i) {
let trElm = fileElm.parentNode.parentNode,
cntElm_a = trElm.querySelector('.css-truncate.css-truncate-target.d-block.width-fit a'),
cntElm_svg = trElm.querySelector('.mr-3.flex-shrink-0 svg.octicon.octicon-file.color-icon-tertiary'),
cntElm_svg = trElm.querySelector('.mr-3.flex-shrink-0 svg.octicon.octicon-file'),
Name = cntElm_a.innerText,
href = cntElm_a.attributes.href.nodeValue.replace(`https://${location.host}`,'');
let href2 = href.replace('/blob/','/'), url, url_name, url_tip = '';
switch(menu_raw_fast) {
case 0:
case 2:
url = raw_url[menu_raw_fast][0] + href2; break;
case 1:
url = raw_url[1][0] + '/gh' + href.replace('/blob/','@');
url_name = raw_url[1][1];
url_tip = raw_url[1][2];
break;
url = raw_url[menu_raw_fast][0] + '/gh' + href.replace('/blob/','@'); break;
case 3:
url = raw_url[3][0] + '/gh' + href.replace('/blob/','/');
url_name = raw_url[3][1];
url_tip = raw_url[3][2];
break;
case 4:
url = raw_url[4][0] + "/" + raw_url[0][0] + href2;
url_name = raw_url[4][1];
url_tip = raw_url[4][2];
break;
url = raw_url[menu_raw_fast][0] + '/gh' + href.replace('/blob/','/'); break;
default:
url = raw_url[menu_raw_fast][0] + href2;
url_name = raw_url[menu_raw_fast][1];
url_tip = raw_url[menu_raw_fast][2];
break;
url = raw_url[menu_raw_fast][0] + '/' + raw_url[0][0] + href2;
}
url_name = raw_url[menu_raw_fast][1]; url_tip = raw_url[menu_raw_fast][2];
let _html = ` <a href="${url}" download="${Name}" target="_blank" rel="noreferrer noopener nofollow" class="fileDownLink" style="display: none;" title="「${url_name}」&#10;&#10;[Alt + 左键] 或 [右键 - 另存为...] 下载文件。&#10;注意:鼠标点击 [☁] 图标,而不是左侧的文件名!&#10;&#10;${url_tip}提示:点击浏览器右上角 Tampermonkey 扩展图标 - [ ${raw_url[menu_raw_fast][1]} ] 加速源 (☁) 即可切换。">${svg[2]}</a>`;
cntElm_svg.insertAdjacentHTML('afterend', _html);
// 绑定鼠标事件
@ -363,7 +307,7 @@
var mouseOverHandler = function(evt) {
let elem = evt.currentTarget,
aElm_new = elem.querySelectorAll('.fileDownLink'),
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary');
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file');
aElm_new.forEach(el=>{el.style.cssText = 'display: inline'});
aElm_now.forEach(el=>{el.style.cssText = 'display: none'});
};
@ -372,7 +316,7 @@
var mouseOutHandler = function(evt) {
let elem = evt.currentTarget,
aElm_new = elem.querySelectorAll('.fileDownLink'),
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary');
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file');
aElm_new.forEach(el=>{el.style.cssText = 'display: none'});
aElm_now.forEach(el=>{el.style.cssText = 'display: inline'});
};

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar-gui",
"version": "1.6.2",
"version": "1.7.1",
"private": false,
"license": "MPL-2.0",
"main": "background.js",
@ -21,8 +21,8 @@
"name": "Greper"
},
"dependencies": {
"@docmirror/dev-sidecar": "^1.6.2",
"@docmirror/mitmproxy": "^1.6.2",
"@docmirror/dev-sidecar": "^1.7.1",
"@docmirror/mitmproxy": "^1.7.1",
"adm-zip": "^0.5.5",
"ant-design-vue": "^1.6.5",
"compressing": "^1.5.1",

@ -26,10 +26,20 @@ protocol.registerSchemesAsPrivileged([
])
// 隐藏主窗口,并创建托盘,绑定关闭事件
function setTray () {
// const topMenu = Menu.buildFromTemplate({})
// Menu.setApplicationMenu(topMenu)
// 用一个 Tray 来表示一个图标,这个图标处于正在运行的系统的通知区
// 通常被添加到一个 context menu 上.
// 系统托盘右键菜单
const trayMenuTemplate = [
{
// 系统托盘图标目录
label: 'DevTools',
click: () => {
win.webContents.openDevTools()
}
},
{
// 系统托盘图标目录
label: '退出',
@ -109,7 +119,9 @@ function showWin () {
if (win) {
win.show()
}
app.dock.show()
if (app.dock) {
app.dock.show()
}
}
function changeAppConfig (config) {
@ -128,6 +140,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
@ -138,6 +151,9 @@ function createWindow (startHideWindow) {
icon: path.join(__static, 'icon.png')
})
Menu.setApplicationMenu(null)
win.setMenu(null)
if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)

@ -54,7 +54,7 @@ export default {
},
data () {
return {
systemPlatform: 'win'
systemPlatform: ''
}
},
async created () {

@ -11,7 +11,8 @@ export default {
status: {},
labelCol: { span: 4 },
wrapperCol: { span: 20 },
applyLoading: false
applyLoading: false,
systemPlatform: ''
}
},
created () {
@ -26,15 +27,17 @@ export default {
}
throw new Error('请设置key')
},
init () {
async init () {
this.status = this.$status
return this.$api.config.reload().then(ret => {
this.config = ret
console.log('config', this.config)
if (this.ready) {
return this.ready(this.config)
}
})
this.config = await this.$api.config.reload()
this.systemPlatform = await this.$api.info.getSystemPlatform()
console.log('config', this.config, this.systemPlatform)
// eslint-disable-next-line no-debugger
if (this.ready) {
return this.ready(this.config)
}
},
async apply () {
this.applyLoading = true
@ -84,6 +87,15 @@ export default {
return {}
}
return value
},
isWindows () {
return this.systemPlatform === 'windows'
},
isMac () {
return this.systemPlatform === 'mac'
},
isLinux () {
return this.systemPlatform === 'linux'
}
}
}

@ -36,6 +36,11 @@
增强模式
</a-radio-button>
</a-tooltip>
<a-tooltip v-else placement="topLeft" title="这个页面有个彩蛋">
<a-radio-button :disabled="true" value="ow">
彩蛋
</a-radio-button>
</a-tooltip>
</a-radio-group>
</div>
@ -72,9 +77,9 @@
<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="彩蛋">
<a-tooltip placement="topLeft" title="彩蛋,点我">
<span style="display: block;width:100px;height:50px;" @click="wantOW()"></span>
</a-tooltip>
</div>
@ -163,7 +168,7 @@ export default {
}
},
async created () {
this.doCheckRootCa()
await this.doCheckRootCa()
await this.reloadConfig()
this.$set(this, 'status', this.$status)
this.switchBtns = this.createSwitchBtns()
@ -208,7 +213,7 @@ export default {
},
wantOW () {
this.$success({
title: '彩蛋',
title: '彩蛋(增强模式)',
content: (
<div>
我把它藏在了源码里感兴趣的话可以找一找它线索提示 // TODO
@ -216,28 +221,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 +269,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,104 @@
<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="pip命令名" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-input v-model="config.plugin.pip.setting.command"></a-input>
<div class="form-help">如果你的pip命令改成了其他名字如pip3可以在此处修改</div>
</a-form-item>
<a-form-item v-if="isWindows()" 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-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="https://mirrors.aliyun.com/pypi/simple/">
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">
<a-input v-model="config.plugin.pip.setting.trustedHost"></a-input>
<div class="form-help">注意切换仓库镜像同时会修改pip.ini中的trusted-host配置</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 }) {
this.config.plugin.pip.setting.registry = registry
const domain = registry.substring(registry.indexOf('//') + 2, registry.indexOf('/', 8))
this.config.plugin.pip.setting.trustedHost = domain
await this.apply()
}
}
}
</script>
<style lang="sass">
</style>

@ -18,9 +18,16 @@
当前未启动
</a-tag>
</a-form-item>
<a-form-item label="设置loopback" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-item v-if="isWindows()" 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 v-if="isWindows()" 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">解决OneNoteMicrosoftStoreOutlook等UWP应用开启代理后无法访问网络的问题</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此设置用于解决OneNoteMicrosoftStoreOutlook等UWP应用无法访问网络的问题</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>
@ -65,12 +73,14 @@ export default {
loopbackVisible: false
}
},
created () {
async created () {
},
mounted () {
},
methods: {
async applyAfter () {
await this.$api.proxy.restart()
},
async openEnableLoopback () {
try {
await this.$api.proxy.setEnableLoopback()

@ -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">

@ -15,7 +15,7 @@
windows下建议开启开机自启<a @click="openExternal('https://gitee.com/docmirror/dev-sidecar/blob/master/doc/recover.md')"></a>
</div>
</a-form-item>
<a-form-item label="隐藏Dock图标" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-item v-if="systemPlatform ==='mac'" label="隐藏Dock图标" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-checkbox v-model="config.app.dock.hideWhenWinClose" >
关闭窗口时隐藏Dock图标(仅限Mac)
</a-checkbox>

@ -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' },

@ -1,6 +1,6 @@
{
"name": "@docmirror/mitmproxy",
"version": "1.6.2",
"version": "1.7.1",
"description": "",
"main": "src/index.js",
"keywords": [

@ -8,6 +8,9 @@ function matched (hostname, regexpMap) {
if (ret1) {
return true
}
if (pacClient == null) {
return false
}
const ret = pacClient.FindProxyForURL('https://' + hostname, hostname)
if (ret && ret.indexOf('PROXY ') === 0) {
return true
@ -19,7 +22,7 @@ module.exports = function createOverWallIntercept (overWallConfig) {
if (!overWallConfig || overWallConfig.enabled !== true) {
return null
}
if (overWallConfig.pac) {
if (overWallConfig.pac && overWallConfig.pac.enabled) {
// 初始化pac
pacClient = pac.createPacClient(overWallConfig.pac.pacFileAbsolutePath)
}

Loading…
Cancel
Save