mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
default prepend rules and proxies
This commit is contained in:
parent
5b5cbd8130
commit
5b7958f2c7
|
@ -31,9 +31,20 @@ async function overrideProfile(
|
|||
case 'js':
|
||||
profile = runOverrideScript(profile, content)
|
||||
break
|
||||
case 'yaml':
|
||||
profile = deepMerge(profile, yaml.parse(content))
|
||||
case 'yaml': {
|
||||
const patch = yaml.parse(content)
|
||||
if (patch.rules) {
|
||||
patch.rules = [...patch.rules, ...(profile.rules || [])]
|
||||
}
|
||||
if (patch.proxies) {
|
||||
patch.proxies = [...patch.proxies, ...(profile.proxies || [])]
|
||||
}
|
||||
if (patch['proxy-groups']) {
|
||||
patch['proxy-groups'] = [...patch['proxy-groups'], ...(profile['proxy-groups'] || [])]
|
||||
}
|
||||
profile = deepMerge(profile, patch)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@nextui-org/react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { BaseEditor } from '../base/base-editor'
|
||||
import { getOverride, setOverride } from '@renderer/utils/ipc'
|
||||
import { getOverride, restartCore, setOverride } from '@renderer/utils/ipc'
|
||||
interface Props {
|
||||
id: string
|
||||
language: 'javascript' | 'yaml'
|
||||
|
@ -47,6 +47,7 @@ const EditFileModal: React.FC<Props> = (props) => {
|
|||
color="primary"
|
||||
onPress={async () => {
|
||||
await setOverride(id, language === 'javascript' ? 'js' : 'yaml', currData)
|
||||
await restartCore()
|
||||
onClose()
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -14,6 +14,7 @@ import React, { useState } from 'react'
|
|||
import SettingItem from '../base/base-setting-item'
|
||||
import dayjs from 'dayjs'
|
||||
import { useOverrideConfig } from '@renderer/hooks/use-override-config'
|
||||
import { restartCore } from '@renderer/utils/ipc'
|
||||
interface Props {
|
||||
item: IProfileItem
|
||||
updateProfileItem: (item: IProfileItem) => Promise<void>
|
||||
|
@ -27,6 +28,7 @@ const EditInfoModal: React.FC<Props> = (props) => {
|
|||
|
||||
const onSave = async (): Promise<void> => {
|
||||
await updateProfileItem(values)
|
||||
await restartCore()
|
||||
onClose()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user