Feature(custom): add watch for dontShowAgain to manage update tip visibility

ISSUES CLOSED: #484
This commit is contained in:
Kuingsmile
2026-04-01 16:56:07 +08:00
parent c8771cfedc
commit 64c59a4b55

View File

@@ -97,7 +97,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { DownloadIcon, Link2Icon, XIcon } from 'lucide-vue-next' import { DownloadIcon, Link2Icon, XIcon } from 'lucide-vue-next'
import { marked } from 'marked' import { marked } from 'marked'
import { onBeforeUnmount, onMounted, ref } from 'vue' import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { SHOW_UPDATE_INFO, UPDATE_PROGRESS } from '@/utils/constant' import { SHOW_UPDATE_INFO, UPDATE_PROGRESS } from '@/utils/constant'
import { IRPCActionType } from '@/utils/enum' import { IRPCActionType } from '@/utils/enum'
@@ -118,6 +118,10 @@ const updateInfo = ref<UpdateInfo>({
const dontShowAgain = ref(false) const dontShowAgain = ref(false)
const downloadProgress = ref<number | null>(null) const downloadProgress = ref<number | null>(null)
watch(dontShowAgain, (newVal: boolean) => {
window.electron.sendRPC(IRPCActionType.SET_SHOW_UPDATE_TIP, !newVal)
})
function handleUpdateInfo(info: UpdateInfo) { function handleUpdateInfo(info: UpdateInfo) {
updateInfo.value = info updateInfo.value = info
if (info.type !== 'downloading') { if (info.type !== 'downloading') {
@@ -137,16 +141,10 @@ function downloadUpdate() {
updateInfo.value.type = 'downloading' updateInfo.value.type = 'downloading'
downloadProgress.value = 0 downloadProgress.value = 0
window.electron.sendRPC(IRPCActionType.DOWNLOAD_UPDATE) window.electron.sendRPC(IRPCActionType.DOWNLOAD_UPDATE)
if (dontShowAgain.value) {
window.electron.sendRPC(IRPCActionType.SET_SHOW_UPDATE_TIP, false)
}
} }
function goToDownloadPage() { function goToDownloadPage() {
window.electron.sendRPC(IRPCActionType.GO_TO_DOWNLOAD_PAGE) window.electron.sendRPC(IRPCActionType.GO_TO_DOWNLOAD_PAGE)
if (dontShowAgain.value) {
window.electron.sendRPC(IRPCActionType.SET_SHOW_UPDATE_TIP, false)
}
closeWindow() closeWindow()
} }
@@ -155,9 +153,6 @@ function installUpdate() {
} }
function closeWindow() { function closeWindow() {
if (dontShowAgain.value && updateInfo.value.type === 'update-available') {
window.electron.sendRPC(IRPCActionType.SET_SHOW_UPDATE_TIP, false)
}
window.electron.sendRPC(IRPCActionType.CLOSE_CURRENT_WINDOW) window.electron.sendRPC(IRPCActionType.CLOSE_CURRENT_WINDOW)
} }