diff --git a/electron/api/github.ts b/electron/api/github.ts index f6adcb4..d545b88 100644 --- a/electron/api/github.ts +++ b/electron/api/github.ts @@ -1,5 +1,5 @@ import electron, {app, BrowserWindow, ipcMain, net, shell} from "electron"; -import {deleteVersionById, insertVersion} from "../storage/version"; +import {deleteVersionById, insertVersion, listVersion} from "../storage/version"; const fs = require("fs"); const path = require("path"); @@ -178,8 +178,11 @@ export const initGitHubApi = () => { version["frpcVersionPath"] = frpcVersionPath; insertVersion(version, (err, document) => { if (!err) { - event.reply("Download.frpVersionDownloadOnCompleted", args); - version.download_completed = true; + listVersion((err, doc) => { + event.reply("Config.versions.hook", { err, data: doc }); + event.reply("Download.frpVersionDownloadOnCompleted", args); + version.download_completed = true; + }); } }); } @@ -196,9 +199,9 @@ export const initGitHubApi = () => { fs.unlinkSync(absPath) }) } - event.reply("Download.deleteVersion.hook", { - err: null, - data: "删除成功" + listVersion((err, doc) => { + event.reply("Config.versions.hook", { err, data: doc }); + event.reply("Download.deleteVersion.hook", { err: null, data: "删除成功" }); }); }) diff --git a/src/views/config/index.vue b/src/views/config/index.vue index 8450321..c6add58 100644 --- a/src/views/config/index.vue +++ b/src/views/config/index.vue @@ -166,6 +166,13 @@ const handleAuthMethodChange = e => { } } +const checkAndResetVersion = () => { + const currentVersion = formData.value.currentVersion; + if (currentVersion && !versions.value.some(item => item.id === currentVersion)) { + formData.value.currentVersion = ""; + } +} + onMounted(() => { ipcRenderer.send("config.getConfig"); handleLoadVersions(); @@ -197,6 +204,7 @@ onMounted(() => { const {err, data} = args; if (!err) { versions.value = data; + checkAndResetVersion(); } }); });