Skip to content

Commit

Permalink
添加检查更新按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Oct 12, 2018
1 parent de473d7 commit 9f2e433
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 176 deletions.
114 changes: 3 additions & 111 deletions front/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,143 +26,35 @@
</i-menu-item>
</i-menu>

<Modal v-model="hasUpdate"
:title="$t('update.checkNew')">
<b>{{ $t('update.version') }}:</b>
<span>{{ versionInfo.version }}</span>
<br>
<br>
<b>{{ $t('update.changeLog') }}:</b>
<div style="padding-top:10px;"
v-html="versionInfo.description"></div>
<span slot="footer">
<Button @click="hasUpdate = false">{{ $t('tip.cancel') }}</Button>
<Button type="primary"
@click="doUpdate()">{{ $t('update.update') }}</Button>
</span>
</Modal>

<Modal v-model="restatModel"
:title="$t('update.done')">
<h3>{{ $t('update.restart') }}</h3>
<span slot="footer">
<Button @click="restatModel = false">{{ $t('tip.cancel') }}</Button>
<Button type="primary"
@click="doRestart()">{{ $t('tip.ok') }}</Button>
</span>
</Modal>

<div style="padding: 1.25rem 1.25rem">
<keep-alive>
<router-view/>
<router-view />
</keep-alive>
</div>

<Spin v-if="showUpdateProgress"
size="large"
class="update-progress"
fix>
<Circle :percent="updateInfo.progress"
:size="150">
<h1>{{ updateInfo.progress.toFixed(2) }}%</h1>
<p>{{ $numeral(updateInfo.speed).format('0.00b') }}/S</p>
</Circle>
</Spin>

</div>
</template>

<script>
import { doUpdate, getUpdateProgress, doRestart } from './common/native.js'
export default {
methods: {
forward(route) {
this.$router.push(route)
},
doUpdate() {
this.showUpdateProgress = true
this.hasUpdate = false
//开始下载更新包
doUpdate(this.versionInfo.path)
.then(() => {
//获取更新进度
const updateProgressInterval = setInterval(() => {
getUpdateProgress().then(result => {
this.updateInfo.progress = result.downSize / result.totalSize * 100
this.updateInfo.speed = result.speed
if (result.status == 3) {
//下载失败
this.$Message.error({
content: this.$t('update.error'),
duration: 0
})
} else if (result.status == 4) {
//下载完成
this.restatModel = true
}
if (result.status == 3 || result.status == 4) {
this.showUpdateProgress = false
clearInterval(updateProgressInterval)
}
})
}, 1000)
})
.catch(() => {
this.$Message.error({
content: this.$t('update.error'),
duration: 0
})
})
},
doRestart() {
doRestart().then((this.restatModel = false))
}
},
data() {
return {
hasUpdate: false,
showUpdateProgress: false,
versionInfo: {},
restatModel: false,
updateInfo: {
progress: 0,
speed: 0
}
}
},
created() {
// Check Update
if (this.$config.needCheckUpdate) {
if (!this.$config.needCheckUpdate) {
this.$noSpinHttp.get(this.$config.adminServer + 'version/checkUpdate').then(result => {
const versionInfo = result.data
if (versionInfo && versionInfo.version > this.$config.version) {
this.hasUpdate = true
this.versionInfo = versionInfo
this.$router.push({ path: '/about', query: { checkUpdate: true, versionInfo: JSON.stringify(versionInfo) } })
}
})
}
}
}
</script>
<style scoped>
.update-progress {
z-index: 1001;
}
.update-progress h1 {
color: #3f414d;
font-size: 28px;
font-weight: normal;
}
.update-progress p {
color: #657180;
font-size: 14px;
padding-top: 10px;
}
</style>

<style>
i.action-icon {
Expand Down
5 changes: 4 additions & 1 deletion front/src/i18n/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default {
actionInstall: 'Install',
actionDetail: 'Detail',
uninstall: 'Uninstall',
uninstallTip: 'Do you want to uninstall this extension?',
switch: 'Switch',
downloadingTip: 'Downloading...[servers(',
downloadOk: 'Download successful',
Expand Down Expand Up @@ -118,7 +119,9 @@ export default {
community: 'Official community: ',
tutorial: 'Use Tutorial: ',
feedback: 'Feedback: ',
currentVersion: 'Current Version: '
currentVersion: 'Current Version: ',
checkUpdate: 'Check update:',
noNewVersion: 'Already the latest version'
},
team: {
title: 'Team'
Expand Down
10 changes: 7 additions & 3 deletions front/src/i18n/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default {
},
extension: {
conditions: '使用须知',
conditionsContent: '首次使用扩展模块时,必须安装由Proxyee Down随机生成的一个CA证书,点击下面的安装按钮并按系统的引导进行确认安装。(注意:程序会在安装前检测操作系统中是否有安装过证书,当检测到有安装的情况会提示删除对应的旧CA证书)',
conditionsContent:
'首次使用扩展模块时,必须安装由Proxyee Down随机生成的一个CA证书,点击下面的安装按钮并按系统的引导进行确认安装。(注意:程序会在安装前检测操作系统中是否有安装过证书,当检测到有安装的情况会提示删除对应的旧CA证书)',
install: '安装',
globalProxy: '全局代理',
proxyTip: '点击查看说明',
Expand All @@ -69,6 +70,7 @@ export default {
actionUpdate: '更新',
actionInstall: '安装',
uninstall: '卸载',
uninstallTip: '确定卸载此扩展吗?',
actionDetail: '详情',
switch: '开关',
downloadingTip: '下载中...[服务器(',
Expand Down Expand Up @@ -118,7 +120,9 @@ export default {
community: '官方社区:',
tutorial: '使用教程:',
feedback: '问题反馈:',
currentVersion: '当前版本:'
currentVersion: '当前版本:',
checkUpdate: '检查更新:',
noNewVersion: '已经是最新版本'
},
team: {
title: '团队'
Expand Down Expand Up @@ -164,4 +168,4 @@ export default {
}
}
}
}
}
5 changes: 4 additions & 1 deletion front/src/i18n/zh-TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default {
actionInstall: '安裝',
actionDetail: '細節',
uninstall: '卸載',
uninstallTip: '確定卸載此擴展嗎?',
switch: '開關',
downloadingTip: '下載中...[伺服器(',
downloadOk: '下載成功',
Expand Down Expand Up @@ -118,7 +119,9 @@ export default {
community: '官方社區:',
tutorial: '使用教學:',
feedback: '問題回報:',
currentVersion: '目前版本:'
currentVersion: '目前版本:',
checkUpdate: '檢查更新:',
noNewVersion: '已經是最新版本'
},
team: {
title: '團隊'
Expand Down
Loading

0 comments on commit 9f2e433

Please sign in to comment.