mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-10 19:50:28 +08:00
fix: ensure items array exists in profile and override config
This commit is contained in:
parent
bab949e16a
commit
5f5ca0fd27
@ -47,6 +47,7 @@ export async function updateProfileConfig(
|
|||||||
const data = await readFile(profileConfigPath(), 'utf-8')
|
const data = await readFile(profileConfigPath(), 'utf-8')
|
||||||
profileConfig = parse(data) || { items: [] }
|
profileConfig = parse(data) || { items: [] }
|
||||||
if (typeof profileConfig !== 'object') profileConfig = { items: [] }
|
if (typeof profileConfig !== 'object') profileConfig = { items: [] }
|
||||||
|
if (!Array.isArray(profileConfig.items)) profileConfig.items = []
|
||||||
profileConfig = await updater(structuredClone(profileConfig))
|
profileConfig = await updater(structuredClone(profileConfig))
|
||||||
result = profileConfig
|
result = profileConfig
|
||||||
await writeFile(profileConfigPath(), stringify(profileConfig), 'utf-8')
|
await writeFile(profileConfigPath(), stringify(profileConfig), 'utf-8')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user