fix: 修复系统代理开关状态不会实时显示的bug,增加更新版本进度条
parent
5e80350827
commit
0c3be78ba3
|
@ -21,7 +21,7 @@ const ProxyPlugin = function (context) {
|
|||
async unsetProxy () {
|
||||
try {
|
||||
await shell.setSystemProxy()
|
||||
event.fire('status', { key: 'proxy.enabled', vlaue: false })
|
||||
event.fire('status', { key: 'proxy.enabled', value: false })
|
||||
log.info('关闭系统代理成功')
|
||||
return true
|
||||
} catch (err) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@docmirror/dev-sidecar-gui",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.0",
|
||||
"private": false,
|
||||
"license": "MPL-2.0",
|
||||
"scripts": {
|
||||
|
|
|
@ -190,8 +190,8 @@ if (!isFirstInstance) {
|
|||
return true
|
||||
}
|
||||
})
|
||||
// updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
|
||||
updateUrl = 'http://localhost/dev-sidecar/'
|
||||
updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
|
||||
// updateUrl = 'http://localhost/dev-sidecar/'
|
||||
}
|
||||
// 自动更新
|
||||
updateHandle(app, win, beforeQuit, updateUrl)
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
let updateParams = { }
|
||||
|
||||
function install (app, api) {
|
||||
const updateParams = app.$global.update = { fromUser: false, autoDownload: true, progress: 0, downloading: false, newVersion: false }
|
||||
api.ipc.on('update', (event, message) => {
|
||||
console.log('on message', event, message)
|
||||
handleUpdateMessage(message, app)
|
||||
})
|
||||
|
||||
api.update = {
|
||||
checkForUpdate (params) {
|
||||
updateParams = params || { fromUser: false, autoDownload: true, progress: 0 }
|
||||
checkForUpdate (fromUser) {
|
||||
if (fromUser != null) {
|
||||
updateParams.fromUser = fromUser
|
||||
}
|
||||
api.ipc.send('update', { key: 'checkForUpdate' })
|
||||
},
|
||||
downloadUpdate () {
|
||||
|
@ -26,6 +29,8 @@ function install (app, api) {
|
|||
noNewVersion()
|
||||
} else if (type === 'downloaded') {
|
||||
// 更新包已下载完成,让用户确认是否更新
|
||||
updateParams.downloading = false
|
||||
console.log('updateParams', updateParams)
|
||||
newUpdateIsReady(message.value)
|
||||
} else if (type === 'progress') {
|
||||
progressUpdate(message.value)
|
||||
|
@ -50,6 +55,7 @@ function install (app, api) {
|
|||
|
||||
if (updateParams.autoDownload !== false) {
|
||||
app.$message.info('发现新版本,正在下载中...')
|
||||
updateParams.downloading = true
|
||||
api.update.downloadUpdate()
|
||||
return
|
||||
}
|
||||
|
@ -70,6 +76,7 @@ function install (app, api) {
|
|||
}
|
||||
|
||||
function newUpdateIsReady (value) {
|
||||
updateParams.downloading = false
|
||||
app.$confirm({
|
||||
title: '新版本已准备好',
|
||||
content: `是否立即升级安装v${value.version}?`,
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
<a-badge :count="_rootCaSetuped?0:1" dot>安装根证书 </a-badge>
|
||||
</a-button>
|
||||
|
||||
<a-button style="margin-right:10px" @click="doCheckUpdate" :title="'当前版本:'+info.version">
|
||||
<a-button style="margin-right:10px" @click="doCheckUpdate(true)" :loading="update.downloading" :title="'当前版本:'+info.version">
|
||||
<a-badge :count="update.newVersion?1:0" dot>
|
||||
检查更新
|
||||
<span v-if="update.downloading">{{update.progress}}%</span>{{update.downloading?'新版本下载中':'检查更新'}}
|
||||
</a-badge>
|
||||
</a-button>
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
|||
<a-form style="margin-top:20px" :label-col="{ span: 12 }" :wrapper-col="{ span: 12 }">
|
||||
|
||||
<a-form-item v-for=" (item, key) in switchBtns" :key="key" :label="item.label">
|
||||
<a-switch style="margin-left:10px" :loading="item.loading" v-model="item.status[key].enabled" default-checked v-on:click="item.doClick">
|
||||
<a-switch style="margin-left:10px" :loading="item.loading" :checked="item.status()" default-checked @change="item.doClick">
|
||||
<a-icon slot="checkedChildren" type="check"/>
|
||||
<a-icon slot="unCheckedChildren" type="close"/>
|
||||
</a-switch>
|
||||
|
@ -57,7 +57,6 @@
|
|||
import lodash from 'lodash'
|
||||
import setupCa from '../components/setup-ca'
|
||||
import DsContainer from '../components/container'
|
||||
|
||||
export default {
|
||||
name: 'Index',
|
||||
components: {
|
||||
|
@ -89,6 +88,7 @@ export default {
|
|||
}
|
||||
},
|
||||
info: {},
|
||||
newVersionDownloading: false,
|
||||
setting: undefined,
|
||||
server: {
|
||||
key: '代理服务',
|
||||
|
@ -102,30 +102,20 @@ export default {
|
|||
setupCa: {
|
||||
visible: false
|
||||
},
|
||||
update: {}
|
||||
update: { downloading: false, progress: 0, newVersion: false }
|
||||
}
|
||||
},
|
||||
async created () {
|
||||
this.doCheckRootCa()
|
||||
console.log('index created', this.status, this.$status)
|
||||
await this.reloadConfig()
|
||||
const status = await this.$api.status.get()
|
||||
console.log('status', status)
|
||||
this.$set(this, 'status', status)
|
||||
this.$set(this, 'status', this.$status)
|
||||
this.switchBtns = this.createSwitchBtns()
|
||||
console.log('switchBtns', this.switchBtns)
|
||||
if (this.$global.update == null) {
|
||||
this.$global.update = {
|
||||
fromUser: false,
|
||||
autoDownload: true,
|
||||
progress: 0,
|
||||
newVersion: false
|
||||
}
|
||||
this.update = this.$global.update
|
||||
this.$set(this, 'update', this.$global.update)
|
||||
if (!this.update.autoChecked) {
|
||||
this.update.autoChecked = true
|
||||
this.doCheckUpdate(false)
|
||||
}
|
||||
this.update = this.$global.update
|
||||
|
||||
this.$api.info.get().then(ret => {
|
||||
this.info = ret
|
||||
})
|
||||
|
@ -190,7 +180,9 @@ export default {
|
|||
loading: false,
|
||||
key: key,
|
||||
label: label,
|
||||
status: statusParent,
|
||||
status: () => {
|
||||
return statusParent[key].enabled
|
||||
},
|
||||
doClick: (checked) => {
|
||||
this.onSwitchClick(this.switchBtns[key], apiTarget.start, apiTarget.close, checked)
|
||||
}
|
||||
|
@ -235,7 +227,7 @@ export default {
|
|||
},
|
||||
doCheckUpdate (fromUser = true) {
|
||||
this.update.fromUser = fromUser
|
||||
this.$api.update.checkForUpdate(this.update)
|
||||
this.$api.update.checkForUpdate(this)
|
||||
},
|
||||
openExternal (url) {
|
||||
this.$api.ipc.openExternal(url)
|
||||
|
|
Loading…
Reference in New Issue