mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
delete last profile
This commit is contained in:
parent
cf6642d2e8
commit
4239498f57
|
@ -76,7 +76,9 @@ export async function addProfileItem(item: Partial<IProfileItem>): Promise<void>
|
||||||
export async function removeProfileItem(id: string): Promise<void> {
|
export async function removeProfileItem(id: string): Promise<void> {
|
||||||
const config = await getProfileConfig()
|
const config = await getProfileConfig()
|
||||||
config.items = config.items?.filter((item) => item.id !== id)
|
config.items = config.items?.filter((item) => item.id !== id)
|
||||||
|
let shouldRestart = false
|
||||||
if (config.current === id) {
|
if (config.current === id) {
|
||||||
|
shouldRestart = true
|
||||||
if (config.items.length > 0) {
|
if (config.items.length > 0) {
|
||||||
config.current = config.items[0].id
|
config.current = config.items[0].id
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,6 +89,9 @@ export async function removeProfileItem(id: string): Promise<void> {
|
||||||
if (existsSync(profilePath(id))) {
|
if (existsSync(profilePath(id))) {
|
||||||
await rm(profilePath(id))
|
await rm(profilePath(id))
|
||||||
}
|
}
|
||||||
|
if (shouldRestart) {
|
||||||
|
await restartCore()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCurrentProfileItem(): Promise<IProfileItem> {
|
export async function getCurrentProfileItem(): Promise<IProfileItem> {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user