diff --git a/src/main/core/mihomoApi.ts b/src/main/core/mihomoApi.ts index 3534daf..4c9aeb5 100644 --- a/src/main/core/mihomoApi.ts +++ b/src/main/core/mihomoApi.ts @@ -105,14 +105,14 @@ export const mihomoGroups = async (): Promise => { if (proxies.proxies[name] && 'all' in proxies.proxies[name] && !proxies.proxies[name].hidden) { const newGroup = proxies.proxies[name] newGroup.testUrl = url - const newAll = newGroup.all.map((name) => proxies.proxies[name]) + const newAll = (newGroup.all || []).map((name) => proxies.proxies[name]) groups.push({ ...newGroup, all: newAll }) } }) if (!groups.find((group) => group.name === 'GLOBAL')) { const newGlobal = proxies.proxies['GLOBAL'] as IMihomoGroup if (!newGlobal.hidden) { - const newAll = newGlobal.all.map((name) => proxies.proxies[name]) + const newAll = (newGlobal.all || []).map((name) => proxies.proxies[name]) groups.push({ ...newGlobal, all: newAll }) } } diff --git a/src/main/core/profileUpdater.ts b/src/main/core/profileUpdater.ts index 511b03c..0b62134 100644 --- a/src/main/core/profileUpdater.ts +++ b/src/main/core/profileUpdater.ts @@ -13,7 +13,7 @@ async function updateProfile(id: string): Promise { } export async function initProfileUpdater(): Promise { - const { items, current } = await getProfileConfig() + const { items = [], current } = await getProfileConfig() const currentItem = await getCurrentProfileItem() for (const item of items.filter((i) => i.id !== current)) { diff --git a/src/main/resolve/gistApi.ts b/src/main/resolve/gistApi.ts index a144e60..cdf8e99 100644 --- a/src/main/resolve/gistApi.ts +++ b/src/main/resolve/gistApi.ts @@ -23,7 +23,7 @@ async function listGists(token: string): Promise { }, responseType: 'json' }) - return res.data as GistInfo[] + return Array.isArray(res.data) ? res.data : [] } async function createGist(token: string, content: string): Promise {