Skip to content

Commit

Permalink
优化更新提示
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Apr 1, 2022
1 parent 91f4b2f commit 7749fac
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
42 changes: 24 additions & 18 deletions resources/assets/js/components/RightBottom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@
</template>
<Modal
v-model="updateShow"
:cancel-text="$L('稍后')"
:ok-text="$L('立即升级')"
:closable="false"
:mask-closable="false"
@on-ok="updateQuitAndInstall"
class-name="common-right-bottom-notification">
<div slot="header" class="notification-head">
<div class="notification-title">{{$L('发现新版本')}}</div>
<Tag color="volcano">v{{systemVersion}} -&gt; v{{updateVersion}}</Tag>
<div slot="header">
<div class="notification-head">
<div class="notification-title">{{$L('发现新版本')}}</div>
<Tag color="volcano">v{{systemVersion}} -&gt; v{{updateVersion}}</Tag>
</div>
<div class="notification-tip">{{$L('离最新版本只有一步之遥了!重新启动应用即可完成更新。')}}</div>
</div>
<MarkdownPreview class="notification-body overlay-y" :initialValue="updateNote"/>
<div slot="footer" class="adaption">
<Button type="default" @click="updateShow=false">{{$L('稍后')}}</Button>
<Button type="primary" @click="updateQuitAndInstall">{{$L('重新启动')}}</Button>
</div>
</Modal>
</div>
</template>
Expand Down Expand Up @@ -59,9 +63,16 @@ export default {
mounted() {
this.checkVersion()
//
this.subscribe = Store.subscribe('updateNotification', _ => {
this.updateShow = true
})
if (this.$Electron) {
this.subscribe = Store.subscribe('updateNotification', _ => {
this.updateShow = true
})
this.$Electron.registerMsgListener('updateDownloaded', info => {
this.updateVersion = info.version;
this.updateNote = info.releaseNotes || this.$L('没有更新描述。');
this.updateShow = true;
})
}
},
beforeDestroy() {
Expand Down Expand Up @@ -92,11 +103,6 @@ export default {
this.apiVersion = data.version || ''
if (this.$Electron) {
// 客户端提示更新
this.$Electron.registerMsgListener('updateDownloaded', info => {
this.updateVersion = info.version;
this.updateNote = info.releaseNotes || this.$L('没有更新描述。');
this.updateShow = true;
})
this.$Electron.sendMessage('updateCheckAndDownload', {
apiVersion: this.apiVersion
})
Expand All @@ -107,7 +113,10 @@ export default {
}
}).catch(_ => {
});
})
//
this.__checkVersion && clearTimeout(this.__checkVersion)
this.__checkVersion = setTimeout(this.checkVersion, 600 * 1000)
},
getDownloadUrl(publish) {
Expand All @@ -126,7 +135,6 @@ export default {
let timeout = 600;
if (cache.time && cache.time + timeout > Math.round(new Date().getTime() / 1000)) {
this.downloadUrl = cache.data.html_url;
setTimeout(this.checkVersion, timeout * 1000)
return;
}
//
Expand All @@ -142,10 +150,8 @@ export default {
$A.setStorage(key, cache);
this.downloadUrl = cache.data.html_url;
}
setTimeout(this.checkVersion, timeout * 1000)
}).catch(() => {
this.loadIng--;
setTimeout(this.checkVersion, timeout * 1000)
});
break;
}
Expand Down
10 changes: 10 additions & 0 deletions resources/assets/sass/components/right-bottom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
}

.common-right-bottom-notification {
.ivu-modal-header {
padding-bottom: 8px !important;
}
.notification-head {
display: flex;
align-items: center;
Expand Down Expand Up @@ -70,6 +73,13 @@
}
}
}
.notification-tip {
display: inline-block;
color: #999999;
line-height: 22px;
padding-top: 4px;
font-size: 12px;
}
.notification-link {
margin-top: 20px;
text-align: right;
Expand Down

0 comments on commit 7749fac

Please sign in to comment.