mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
try to fix unknown error
This commit is contained in:
parent
b355675e03
commit
d9694d868e
@ -11,6 +11,7 @@ export async function getAppConfig(force = false): Promise<IAppConfig> {
|
||||
const data = await readFile(appConfigPath(), 'utf-8')
|
||||
appConfig = yaml.parse(data) || defaultConfig
|
||||
}
|
||||
if (typeof appConfig !== 'object') appConfig = defaultConfig
|
||||
return appConfig
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,8 @@ export async function getControledMihomoConfig(force = false): Promise<Partial<I
|
||||
const data = await readFile(controledMihomoConfigPath(), 'utf-8')
|
||||
controledMihomoConfig = yaml.parse(data) || defaultControledMihomoConfig
|
||||
}
|
||||
if (typeof controledMihomoConfig !== 'object')
|
||||
controledMihomoConfig = defaultControledMihomoConfig
|
||||
return controledMihomoConfig
|
||||
}
|
||||
|
||||
|
||||
@ -10,8 +10,9 @@ let overrideConfig: IOverrideConfig // override.yaml
|
||||
export async function getOverrideConfig(force = false): Promise<IOverrideConfig> {
|
||||
if (force || !overrideConfig) {
|
||||
const data = await readFile(overrideConfigPath(), 'utf-8')
|
||||
overrideConfig = yaml.parse(data) || {}
|
||||
overrideConfig = yaml.parse(data) || { items: [] }
|
||||
}
|
||||
if (typeof overrideConfig !== 'object') overrideConfig = { items: [] }
|
||||
return overrideConfig
|
||||
}
|
||||
|
||||
|
||||
@ -14,8 +14,9 @@ let profileConfig: IProfileConfig // profile.yaml
|
||||
export async function getProfileConfig(force = false): Promise<IProfileConfig> {
|
||||
if (force || !profileConfig) {
|
||||
const data = await readFile(profileConfigPath(), 'utf-8')
|
||||
profileConfig = yaml.parse(data)
|
||||
profileConfig = yaml.parse(data) || { items: [] }
|
||||
}
|
||||
if (typeof profileConfig !== 'object') profileConfig = { items: [] }
|
||||
return profileConfig
|
||||
}
|
||||
|
||||
@ -168,7 +169,9 @@ export async function setProfileStr(id: string, content: string): Promise<void>
|
||||
|
||||
export async function getProfile(id: string | undefined): Promise<IMihomoConfig> {
|
||||
const profile = await getProfileStr(id)
|
||||
return yaml.parse(profile) || {}
|
||||
let result = yaml.parse(profile) || {}
|
||||
if (typeof result !== 'object') result = {}
|
||||
return result
|
||||
}
|
||||
|
||||
// attachment;filename=xxx.yaml; filename*=UTF-8''%xx%xx%xx
|
||||
|
||||
@ -44,7 +44,8 @@ async function overrideProfile(
|
||||
profile = runOverrideScript(profile, content, item)
|
||||
break
|
||||
case 'yaml': {
|
||||
const patch = yaml.parse(content) || {}
|
||||
let patch = yaml.parse(content) || {}
|
||||
if (typeof patch !== 'object') patch = {}
|
||||
profile = deepMerge(profile, patch)
|
||||
break
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user