Fixed: #116 || added proxy option

This commit is contained in:
PiEgg
2018-12-20 22:30:08 +08:00
parent 405548426a
commit 778c910436
5 changed files with 95 additions and 9 deletions
+1 -1
View File
@@ -81,7 +81,7 @@
"lowdb": "^1.0.0", "lowdb": "^1.0.0",
"md5": "^2.2.1", "md5": "^2.2.1",
"melody.css": "^1.0.2", "melody.css": "^1.0.2",
"picgo": "^1.1.12", "picgo": "^1.1.13",
"qiniu": "^7.1.1", "qiniu": "^7.1.1",
"request": "^2.83.0", "request": "^2.83.0",
"request-promise": "^4.2.2", "request-promise": "^4.2.2",
+15 -2
View File
@@ -82,7 +82,7 @@ const handlePluginInstall = (ipcMain, STORE_PATH, CONFIG_PATH) => {
picgo.on('installSuccess', notice => { picgo.on('installSuccess', notice => {
event.sender.send('installSuccess', notice.body[0].replace(/picgo-plugin-/, '')) event.sender.send('installSuccess', notice.body[0].replace(/picgo-plugin-/, ''))
}) })
pluginHandler.install([`picgo-plugin-${msg}`]) pluginHandler.install([msg])
picgo.cmd.program.removeAllListeners() picgo.cmd.program.removeAllListeners()
}) })
} }
@@ -94,7 +94,19 @@ const handlePluginUninstall = (ipcMain, STORE_PATH, CONFIG_PATH) => {
picgo.on('uninstallSuccess', notice => { picgo.on('uninstallSuccess', notice => {
event.sender.send('uninstallSuccess', notice.body[0].replace(/picgo-plugin-/, '')) event.sender.send('uninstallSuccess', notice.body[0].replace(/picgo-plugin-/, ''))
}) })
pluginHandler.uninstall([`picgo-plugin-${msg}`]) pluginHandler.uninstall([msg])
picgo.cmd.program.removeAllListeners()
})
}
const handlePluginUpdate = (ipcMain, STORE_PATH, CONFIG_PATH) => {
ipcMain.on('updatePlugin', (event, msg) => {
const picgo = new PicGo(CONFIG_PATH)
const pluginHandler = new PluginHandler(picgo)
picgo.on('updateSuccess', notice => {
event.sender.send('updateSuccess', notice.body[0].replace(/picgo-plugin-/, ''))
})
pluginHandler.update([msg])
picgo.cmd.program.removeAllListeners() picgo.cmd.program.removeAllListeners()
}) })
} }
@@ -105,4 +117,5 @@ export default (app, ipcMain) => {
handleGetPluginList(ipcMain, STORE_PATH, CONFIG_PATH) handleGetPluginList(ipcMain, STORE_PATH, CONFIG_PATH)
handlePluginInstall(ipcMain, STORE_PATH, CONFIG_PATH) handlePluginInstall(ipcMain, STORE_PATH, CONFIG_PATH)
handlePluginUninstall(ipcMain, STORE_PATH, CONFIG_PATH) handlePluginUninstall(ipcMain, STORE_PATH, CONFIG_PATH)
handlePluginUpdate(ipcMain, STORE_PATH, CONFIG_PATH)
} }
+50 -2
View File
@@ -26,6 +26,11 @@
> >
<el-button type="primary" round size="mini" @click="customLinkVisible = true">点击设置</el-button> <el-button type="primary" round size="mini" @click="customLinkVisible = true">点击设置</el-button>
</el-form-item> </el-form-item>
<el-form-item
label="设置代理"
>
<el-button type="primary" round size="mini" @click="proxyVisible = true">点击设置</el-button>
</el-form-item>
<el-form-item <el-form-item
label="检查更新" label="检查更新"
> >
@@ -163,6 +168,33 @@
<el-button type="primary" @click="confirmCustomLink">确定</el-button> <el-button type="primary" @click="confirmCustomLink">确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog
title="设置代理"
:visible.sync="proxyVisible"
:modal-append-to-body="false"
>
<el-form
label-position="right"
:model="customLink"
ref="customLink"
:rules="rules"
label-width="80px"
>
<el-form-item
label="代理地址"
>
<el-input
v-model="proxy"
:autofocus="true"
placeholder="例如:http://127.0.0.1:1080"
></el-input>
</el-form-item>
</el-form>
<span slot="footer">
<el-button @click="cancelProxy" round>取消</el-button>
<el-button type="primary" @click="confirmProxy" round>确定</el-button>
</span>
</el-dialog>
<el-dialog <el-dialog
title="检查更新" title="检查更新"
:visible.sync="checkUpdateVisible" :visible.sync="checkUpdateVisible"
@@ -178,8 +210,8 @@
PicGo更新啦请点击确定打开下载页面 PicGo更新啦请点击确定打开下载页面
</div> </div>
<span slot="footer"> <span slot="footer">
<el-button @click="cancelCheckVersion">取消</el-button> <el-button @click="cancelCheckVersion" round>取消</el-button>
<el-button type="primary" @click="confirmCheckVersion">确定</el-button> <el-button type="primary" @click="confirmCheckVersion" round>确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
@@ -223,12 +255,14 @@ export default {
keyBindingVisible: false, keyBindingVisible: false,
customLinkVisible: false, customLinkVisible: false,
checkUpdateVisible: false, checkUpdateVisible: false,
proxyVisible: false,
customLink: { customLink: {
value: this.$db.read().get('settings.customLink').value() || '$url' value: this.$db.read().get('settings.customLink').value() || '$url'
}, },
shortKey: { shortKey: {
upload: this.$db.read().get('settings.shortKey.upload').value() upload: this.$db.read().get('settings.shortKey.upload').value()
}, },
proxy: this.$db.read().get('picBed.proxy').value() || undefined,
rules: { rules: {
value: [ value: [
{ validator: customLinkRule, trigger: 'blur' } { validator: customLinkRule, trigger: 'blur' }
@@ -280,6 +314,20 @@ export default {
} }
}) })
}, },
cancelProxy () {
this.proxyVisible = false
this.proxy = this.$db.read().get('picBed.proxy').value() || undefined
},
confirmProxy () {
this.proxyVisible = false
this.$db.read().set('picBed.proxy', this.proxy).write()
const successNotification = new window.Notification('设置代理', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
},
updateHelperChange (val) { updateHelperChange (val) {
this.$db.read().set('settings.showUpdateTip', val).write() this.$db.read().set('settings.showUpdateTip', val).write()
}, },
+25 -1
View File
@@ -48,7 +48,7 @@
</template> </template>
<template v-else> <template v-else>
<span v-if="item.ing" class="config-button ing"> <span v-if="item.ing" class="config-button ing">
卸载 进行
</span> </span>
<template v-else> <template v-else>
<i <i
@@ -145,6 +145,16 @@ export default {
} }
}) })
}) })
this.$electron.ipcRenderer.on('updateSuccess', (evt, plugin) => {
this.loading = false
this.pluginList.forEach(item => {
if (item.name === plugin) {
item.ing = false
item.hasInstall = true
}
})
this.getPluginList()
})
this.$electron.ipcRenderer.on('uninstallSuccess', (evt, plugin) => { this.$electron.ipcRenderer.on('uninstallSuccess', (evt, plugin) => {
this.loading = false this.loading = false
this.pluginList = this.pluginList.filter(item => { this.pluginList = this.pluginList.filter(item => {
@@ -185,6 +195,11 @@ export default {
click () { click () {
_this.uninstallPlugin(plugin.name) _this.uninstallPlugin(plugin.name)
} }
}, {
label: '更新插件',
click () {
_this.updatePlugin(plugin.name)
}
}] }]
for (let i in plugin.config) { for (let i in plugin.config) {
if (plugin.config[i].config.length > 0) { if (plugin.config[i].config.length > 0) {
@@ -218,6 +233,14 @@ export default {
}) })
this.$electron.ipcRenderer.send('uninstallPlugin', val) this.$electron.ipcRenderer.send('uninstallPlugin', val)
}, },
updatePlugin (val) {
this.pluginList.forEach(item => {
if (item.name === val) {
item.ing = true
}
})
this.$electron.ipcRenderer.send('updatePlugin', val)
},
reloadApp () { reloadApp () {
this.$electron.remote.app.relaunch() this.$electron.remote.app.relaunch()
this.$electron.remote.app.exit(0) this.$electron.remote.app.exit(0)
@@ -296,6 +319,7 @@ export default {
this.$electron.ipcRenderer.removeAllListeners('pluginList') this.$electron.ipcRenderer.removeAllListeners('pluginList')
this.$electron.ipcRenderer.removeAllListeners('installSuccess') this.$electron.ipcRenderer.removeAllListeners('installSuccess')
this.$electron.ipcRenderer.removeAllListeners('uninstallSuccess') this.$electron.ipcRenderer.removeAllListeners('uninstallSuccess')
this.$electron.ipcRenderer.removeAllListeners('updateSuccess')
} }
} }
</script> </script>
+4 -3
View File
@@ -6196,9 +6196,10 @@ performance-now@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
picgo@^1.1.12: picgo@^1.1.13:
version "1.1.12" version "1.1.13"
resolved "http://registry.npm.taobao.org/picgo/download/picgo-1.1.12.tgz#264f54f3b8d5712d912fc64c051421da8dad2390" resolved "https://registry.yarnpkg.com/picgo/-/picgo-1.1.13.tgz#77b6c8ac74a49edc3932c9de9d441e34e31adfd1"
integrity sha512-gLRCGeeeTEdRN+gXMOtIsr3Y0sdOKsyU6HRLwEWAgPCAEulXTNr5mTi8eBOp3RNxfwxnmh4jz+0N2jeZ4XPeyA==
dependencies: dependencies:
chalk "^2.4.1" chalk "^2.4.1"
commander "^2.17.0" commander "^2.17.0"