fix: add defensive checks for undefined arrays to prevent find/filter errors

This commit is contained in:
xmk23333 2026-01-15 18:06:37 +08:00
parent ccaabb7b1a
commit 9d5d2bb73d
3 changed files with 4 additions and 4 deletions

View File

@ -105,14 +105,14 @@ export const mihomoGroups = async (): Promise<IMihomoMixedGroup[]> => {
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 })
}
}

View File

@ -13,7 +13,7 @@ async function updateProfile(id: string): Promise<void> {
}
export async function initProfileUpdater(): Promise<void> {
const { items, current } = await getProfileConfig()
const { items = [], current } = await getProfileConfig()
const currentItem = await getCurrentProfileItem()
for (const item of items.filter((i) => i.id !== current)) {

View File

@ -23,7 +23,7 @@ async function listGists(token: string): Promise<GistInfo[]> {
},
responseType: 'json'
})
return res.data as GistInfo[]
return Array.isArray(res.data) ? res.data : []
}
async function createGist(token: string, content: string): Promise<void> {