From 19c6e208a6c6b12e613f705559b65e1276ed57f5 Mon Sep 17 00:00:00 2001 From: forestxieCode <1397798719@qq.com> Date: Mon, 12 Aug 2024 23:15:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E4=B8=8B=E8=BD=BD=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=95=B0=E6=8D=AE=EF=BC=8C=20=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=88=A0=E9=99=A4=E7=89=88=E6=9C=AC=EF=BC=8C=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=BD=93=E5=89=8D=E9=80=89=E6=8B=A9=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/api/github.ts | 15 +++++++++------ src/views/config/index.vue | 8 ++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) 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 529cdd4..76b19bb 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(); } }); });