Skip to content

Commit

Permalink
fix: 🐛 修复检查更新失败没有提示的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Oct 12, 2023
1 parent 510adab commit 6f733ea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/main/ipc/updater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export default (mainWindow) => {
autoUpdater.autoDownload = false
// 检测下载错误
autoUpdater.on('error', (error) => {
console.error('update-error', error)
console.error('update-error')
mainWindow.webContents.send('update-error', error)
})

// 检测是否需要更新
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
prop: 'Advanced',
},
{
label: '关于我们',
label: '关于',
prop: 'AboutUs',
},
],
Expand Down
44 changes: 32 additions & 12 deletions src/renderer/src/components/AboutUs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
</div>
<div class="pt-4 text-xl text-center italic text-gray-700">
📱 使用图形化的
<a
class="hover:underline text-primary-500"
href="https://github.com/viarotel-org/escrcpy"
target="_blank"
>Scrcpy</a>
<a class="hover:underline text-primary-500" :href="escrcpyURL" target="_blank">Scrcpy</a>
显示和控制您的 Android 设备,由 Electron 驱动
</div>
<div class="pt-16 pb-4">
Expand All @@ -34,21 +30,45 @@ export default {
loading: false,
version,
percent: 0,
escrcpyURL: 'https://github.com/viarotel-org/escrcpy',
}
},
created() {
this.onUpdateNotAvailable()
this.onUpdateAvailable()
this.onDownloadProgress()
this.onUpdateDownloaded()
this.$electron.ipcRenderer.on('update-not-available', () => {
this.loading = false
this.$message.success('已经是最新版本')
})
this.$electron.ipcRenderer.on('error', () => {
this.loading = false
})
this.onUpdateError()
},
methods: {
onUpdateNotAvailable() {
this.$electron.ipcRenderer.on('update-not-available', () => {
this.loading = false
this.$message.success('已经是最新版本')
})
},
onUpdateError() {
this.$electron.ipcRenderer.on('update-error', async (event, ret) => {
this.loading = false
console.log('ret', ret)
try {
await this.$confirm(
'你可能需要科学上网,是否前往发布页面手动下载更新?',
'检查更新失败',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
closeOnClickModal: false,
type: 'error',
},
)
window.open(`${this.escrcpyURL}/releases`)
}
catch (error) {
console.warn(error.message)
}
})
},
handleUpdate() {
this.loading = true
this.$electron.ipcRenderer.send('check-for-update')
Expand Down

0 comments on commit 6f733ea

Please sign in to comment.