try to fix unknown error
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run

This commit is contained in:
pompurin404 2024-09-14 20:38:23 +08:00
parent 5f1a46b481
commit c8ae4d89f2
No known key found for this signature in database
5 changed files with 12 additions and 4 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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
}