mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 19:56:10 +08:00
merge yaml anchor
This commit is contained in:
parent
2406cb0180
commit
81be995911
|
@ -9,7 +9,7 @@ let appConfig: IAppConfig // config.yaml
|
|||
export async function getAppConfig(force = false): Promise<IAppConfig> {
|
||||
if (force || !appConfig) {
|
||||
const data = await readFile(appConfigPath(), 'utf-8')
|
||||
appConfig = yaml.parse(data) || defaultConfig
|
||||
appConfig = yaml.parse(data, { merge: true }) || defaultConfig
|
||||
}
|
||||
if (typeof appConfig !== 'object') appConfig = defaultConfig
|
||||
return appConfig
|
||||
|
|
|
@ -12,7 +12,7 @@ let controledMihomoConfig: Partial<IMihomoConfig> // mihomo.yaml
|
|||
export async function getControledMihomoConfig(force = false): Promise<Partial<IMihomoConfig>> {
|
||||
if (force || !controledMihomoConfig) {
|
||||
const data = await readFile(controledMihomoConfigPath(), 'utf-8')
|
||||
controledMihomoConfig = yaml.parse(data) || defaultControledMihomoConfig
|
||||
controledMihomoConfig = yaml.parse(data, { merge: true }) || defaultControledMihomoConfig
|
||||
}
|
||||
if (typeof controledMihomoConfig !== 'object')
|
||||
controledMihomoConfig = defaultControledMihomoConfig
|
||||
|
|
|
@ -10,7 +10,7 @@ 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) || { items: [] }
|
||||
overrideConfig = yaml.parse(data, { merge: true }) || { items: [] }
|
||||
}
|
||||
if (typeof overrideConfig !== 'object') overrideConfig = { items: [] }
|
||||
return overrideConfig
|
||||
|
|
|
@ -14,7 +14,7 @@ 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) || { items: [] }
|
||||
profileConfig = yaml.parse(data, { merge: true }) || { items: [] }
|
||||
}
|
||||
if (typeof profileConfig !== 'object') profileConfig = { items: [] }
|
||||
return profileConfig
|
||||
|
@ -169,7 +169,7 @@ export async function setProfileStr(id: string, content: string): Promise<void>
|
|||
|
||||
export async function getProfile(id: string | undefined): Promise<IMihomoConfig> {
|
||||
const profile = await getProfileStr(id)
|
||||
let result = yaml.parse(profile) || {}
|
||||
let result = yaml.parse(profile, { merge: true }) || {}
|
||||
if (typeof result !== 'object') result = {}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ async function overrideProfile(
|
|||
profile = runOverrideScript(profile, content, item)
|
||||
break
|
||||
case 'yaml': {
|
||||
let patch = yaml.parse(content) || {}
|
||||
let patch = yaml.parse(content, { merge: true }) || {}
|
||||
if (typeof patch !== 'object') patch = {}
|
||||
profile = deepMerge(profile, patch)
|
||||
break
|
||||
|
|
|
@ -83,7 +83,6 @@ export const mihomoGroups = async (): Promise<IMihomoMixedGroup[]> => {
|
|||
const runtime = await getRuntimeConfig()
|
||||
const groups: IMihomoMixedGroup[] = []
|
||||
runtime?.['proxy-groups']?.forEach((group: { name: string; url?: string }) => {
|
||||
group = Object.assign(group, group['<<'])
|
||||
const { name, url } = group
|
||||
if (proxies.proxies[name] && 'all' in proxies.proxies[name] && !proxies.proxies[name].hidden) {
|
||||
const newGroup = proxies.proxies[name]
|
||||
|
|
|
@ -21,7 +21,7 @@ export async function checkUpdate(): Promise<IAppVersion | undefined> {
|
|||
}
|
||||
}
|
||||
)
|
||||
const latest = yaml.parse(res.data) as IAppVersion
|
||||
const latest = yaml.parse(res.data, { merge: true }) as IAppVersion
|
||||
const currentVersion = app.getVersion()
|
||||
if (latest.version !== currentVersion) {
|
||||
return latest
|
||||
|
|
Loading…
Reference in New Issue
Block a user