refactor: 1

pull/192/head
xiaojunnuo 2021-11-21 21:18:38 +08:00
parent 3423b74ac3
commit 454674bf56
9 changed files with 37 additions and 26 deletions

View File

@ -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 (打开拉到最下面)

View File

@ -6,7 +6,8 @@ module.exports = {
startup: {
},
setting: {
command: 'pip',
trustedHost: 'pypi.org',
registry: ''// 可以选择切换官方或者淘宝镜像
registry: 'https://pypi.org/simple/'// 可以选择切换官方或者淘宝镜像
}
}

View File

@ -19,7 +19,8 @@ const PipPlugin = function (context) {
await api.setVariables()
},
async getPipEnv () {
let ret = await shell.exec(['pip config list'], { type: 'cmd' })
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')
@ -41,12 +42,13 @@ const PipPlugin = function (context) {
},
async setPipEnv (list) {
const command = config.get().plugin.pip.setting.command
const cmds = []
for (const item of list) {
if (item.value != null) {
cmds.push(`pip config set global.${item.key} ${item.value}`)
cmds.push(`${command} config set global.${item.key} ${item.value}`)
} else {
cmds.push(`pip config unset global.${item.key}`)
cmds.push(`${command} config unset global.${item.key}`)
}
}
const ret = await shell.exec(cmds, { type: 'cmd' })
@ -54,9 +56,10 @@ const PipPlugin = function (context) {
},
async unsetPipEnv (list) {
const command = config.get().plugin.pip.setting.command
const cmds = []
for (const item of list) {
cmds.push(`pip config unset global.${item} `)
cmds.push(`${command} config unset global.${item} `)
}
const ret = await shell.exec(cmds, { type: 'cmd' })
return ret

View File

@ -11,7 +11,8 @@ export default {
status: {},
labelCol: { span: 4 },
wrapperCol: { span: 20 },
applyLoading: false
applyLoading: false,
systemPlatform: ''
}
},
created () {
@ -26,15 +27,14 @@ 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.systemPlatform = await this.$api.info.getSystemPlatform()
this.config = await this.$api.config.reload()
console.log('config', this.config)
if (this.ready) {
return this.ready(this.config)
}
},
async apply () {
this.applyLoading = true

View File

@ -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>
@ -74,7 +79,7 @@
<div slot="footer">
<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>
@ -208,7 +213,7 @@ export default {
},
wantOW () {
this.$success({
title: '彩蛋',
title: '彩蛋(增强模式)',
content: (
<div>
我把它藏在了源码里感兴趣的话可以找一找它线索提示 // TODO

View File

@ -19,7 +19,11 @@
<!-- 当前未启动-->
<!-- </a-tag>-->
<!-- </a-form-item>-->
<a-form-item label="设置环境变量" :label-col="labelCol" :wrapper-col="wrapperCol">
<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="systemPlatform ==='win'" label="设置环境变量" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-checkbox v-model="config.proxy.setEnv" >
开启系统代理时是否同时修改HTTPS_PROXY环境变量
</a-checkbox>

View File

@ -18,14 +18,14 @@
当前未启动
</a-tag>
</a-form-item>
<a-form-item label="设置环境变量" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-item v-if="systemPlatform ==='win'" 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-form-item v-if="systemPlatform ==='win'" label="设置loopback" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-button @click="loopbackVisible=true"></a-button>
<div class="form-help">解决OneNote微软应用商店微软邮箱等系统自带应用开启代理后无法访问网络的问题</div>
</a-form-item>
@ -70,13 +70,10 @@ export default {
data () {
return {
key: 'proxy',
loopbackVisible: false,
systemPlatform: ''
loopbackVisible: false
}
},
async created () {
const platform = await this.$api.info.getSystemPlatform()
this.systemPlatform = platform
},
mounted () {
},

View File

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

View File

@ -2,7 +2,7 @@ export default function createMenus (app) {
const plugins = [
{ title: 'NPM加速', path: '/plugin/node', icon: 'like' },
{ title: 'Git.exe代理', path: '/plugin/git', icon: 'github' },
{ title: 'pip代理', path: '/plugin/pip', icon: 'bulb' }
{ title: 'pip加速', path: '/plugin/pip', icon: 'bulb' }
]
const menus = [
{ title: '首页', path: '/index', icon: 'home' },