mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-11 04:00:32 +08:00
fix: add defensive checks for undefined arrays to prevent find/filter errors
This commit is contained in:
parent
ccaabb7b1a
commit
9d5d2bb73d
@ -105,14 +105,14 @@ export const mihomoGroups = async (): Promise<IMihomoMixedGroup[]> => {
|
|||||||
if (proxies.proxies[name] && 'all' in proxies.proxies[name] && !proxies.proxies[name].hidden) {
|
if (proxies.proxies[name] && 'all' in proxies.proxies[name] && !proxies.proxies[name].hidden) {
|
||||||
const newGroup = proxies.proxies[name]
|
const newGroup = proxies.proxies[name]
|
||||||
newGroup.testUrl = url
|
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 })
|
groups.push({ ...newGroup, all: newAll })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (!groups.find((group) => group.name === 'GLOBAL')) {
|
if (!groups.find((group) => group.name === 'GLOBAL')) {
|
||||||
const newGlobal = proxies.proxies['GLOBAL'] as IMihomoGroup
|
const newGlobal = proxies.proxies['GLOBAL'] as IMihomoGroup
|
||||||
if (!newGlobal.hidden) {
|
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 })
|
groups.push({ ...newGlobal, all: newAll })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ async function updateProfile(id: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function initProfileUpdater(): Promise<void> {
|
export async function initProfileUpdater(): Promise<void> {
|
||||||
const { items, current } = await getProfileConfig()
|
const { items = [], current } = await getProfileConfig()
|
||||||
const currentItem = await getCurrentProfileItem()
|
const currentItem = await getCurrentProfileItem()
|
||||||
|
|
||||||
for (const item of items.filter((i) => i.id !== current)) {
|
for (const item of items.filter((i) => i.id !== current)) {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ async function listGists(token: string): Promise<GistInfo[]> {
|
|||||||
},
|
},
|
||||||
responseType: 'json'
|
responseType: 'json'
|
||||||
})
|
})
|
||||||
return res.data as GistInfo[]
|
return Array.isArray(res.data) ? res.data : []
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createGist(token: string, content: string): Promise<void> {
|
async function createGist(token: string, content: string): Promise<void> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user