From 4239498f57258dbaa5816762b4a727726e36b82e Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Wed, 28 Aug 2024 21:23:53 +0800 Subject: [PATCH] delete last profile --- src/main/config/profile.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/config/profile.ts b/src/main/config/profile.ts index 7949dc3..279e2e4 100644 --- a/src/main/config/profile.ts +++ b/src/main/config/profile.ts @@ -76,7 +76,9 @@ export async function addProfileItem(item: Partial): Promise export async function removeProfileItem(id: string): Promise { const config = await getProfileConfig() config.items = config.items?.filter((item) => item.id !== id) + let shouldRestart = false if (config.current === id) { + shouldRestart = true if (config.items.length > 0) { config.current = config.items[0].id } else { @@ -87,6 +89,9 @@ export async function removeProfileItem(id: string): Promise { if (existsSync(profilePath(id))) { await rm(profilePath(id)) } + if (shouldRestart) { + await restartCore() + } } export async function getCurrentProfileItem(): Promise {