-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
150 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
name: 'Git代理', | ||
enabled: false, | ||
setting: { | ||
sslVerify: false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const pluginConfig = require('./config') | ||
const Plugin = function (context) { | ||
const { config, shell, event, log } = context | ||
const pluginApi = { | ||
async start () { | ||
const ip = '127.0.0.1' | ||
const port = config.get().server.port | ||
await pluginApi.setProxy(ip, port) | ||
return { ip, port } | ||
}, | ||
|
||
async close () { | ||
return pluginApi.unsetProxy() | ||
}, | ||
|
||
async restart () { | ||
await pluginApi.close() | ||
await pluginApi.start() | ||
}, | ||
|
||
async save (newConfig) { | ||
|
||
}, | ||
|
||
async setProxy (ip, port) { | ||
const cmds = [ | ||
`git config --global http.proxy http://${ip}:${port}`, | ||
`git config --global https.proxy http://${ip}:${port}` | ||
] | ||
if (pluginConfig.setting.sslVerify === false) { | ||
cmds.push('git config http.sslVerify "false"') | ||
} | ||
|
||
const ret = await shell.exec(cmds, { type: 'cmd' }) | ||
event.fire('status', { key: 'plugin.git.enabled', value: true }) | ||
log.info('开启【Git】代理成功') | ||
|
||
return ret | ||
}, | ||
|
||
async unsetProxy () { | ||
const cmds = [ | ||
'git config --global --unset https.proxy', | ||
'git config --global --unset http.proxy' | ||
] | ||
if (pluginConfig.setting.sslVerify === false) { | ||
cmds.push('git config --unset http.sslVerify ') | ||
} | ||
const ret = await shell.exec(cmds, { type: 'cmd' }) | ||
event.fire('status', { key: 'plugin.git.enabled', value: false }) | ||
log.info('关闭【Git】代理成功') | ||
return ret | ||
} | ||
} | ||
return pluginApi | ||
} | ||
|
||
module.exports = { | ||
key: 'git', | ||
config: pluginConfig, | ||
status: { | ||
enabled: false | ||
}, | ||
plugin: Plugin | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
const node = require('./node') | ||
const git = require('./git') | ||
const overwall = require('./overwall') | ||
|
||
module.exports = { | ||
node, overwall | ||
node, git, overwall | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template> | ||
<ds-container> | ||
<template slot="header"> | ||
Git代理设置 | ||
<span> | ||
</span> | ||
</template> | ||
|
||
<div v-if="config"> | ||
<a-form layout="horizontal"> | ||
<a-form-item label="启用Git代理" :label-col="labelCol" :wrapper-col="wrapperCol"> | ||
<a-checkbox v-model="config.plugin.git.enabled"> | ||
随应用启动 | ||
</a-checkbox> | ||
<a-tag v-if="status.plugin.git.enabled" color="green"> | ||
当前已启动 | ||
</a-tag> | ||
<a-tag v-else color="red"> | ||
当前未启动 | ||
</a-tag> | ||
</a-form-item> | ||
<a-form-item label="SSL校验" :label-col="labelCol" :wrapper-col="wrapperCol"> | ||
<a-checkbox v-model="config.plugin.git.setting.sslVerify"> | ||
关闭sslVerify | ||
</a-checkbox> | ||
安装Git时未选择使用系统证书管理服务时必须关闭 | ||
</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: 'Git', | ||
mixins: [Plugin], | ||
data () { | ||
return { | ||
key: 'plugin.git' | ||
} | ||
}, | ||
created () { | ||
console.log('status:', this.status) | ||
}, | ||
mounted () { | ||
}, | ||
methods: { | ||
ready () { | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters