mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
Inline support
This commit is contained in:
parent
8fe1f4f86b
commit
bc17f4aa30
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mihomo-party",
|
||||
"version": "1.5.12",
|
||||
"version": "1.5.13",
|
||||
"description": "Mihomo Party",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "mihomo-party-org",
|
||||
|
||||
@ -33,7 +33,8 @@ export const defaultConfig: IAppConfig = {
|
||||
'substore'
|
||||
],
|
||||
siderWidth: 250,
|
||||
sysProxy: { enable: false, mode: 'manual' }
|
||||
sysProxy: { enable: false, mode: 'manual' },
|
||||
updateChannel: "release"
|
||||
}
|
||||
|
||||
export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
|
||||
@ -74,8 +75,9 @@ export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
|
||||
'fake-ip-filter': ['*', '+.lan', '+.local', 'time.*.com', 'ntp.*.com', '+.market.xiaomi.com'],
|
||||
'use-hosts': false,
|
||||
'use-system-hosts': false,
|
||||
nameserver: ['https://120.53.53.53/dns-query', 'https://223.5.5.5/dns-query'],
|
||||
'proxy-server-nameserver': ['https://120.53.53.53/dns-query', 'https://223.5.5.5/dns-query'],
|
||||
'default-nameserver': ['tls://223.5.5.5'],
|
||||
nameserver: ['https://doh.pub/dns-query', 'https://dns.alidns.com/dns-query'],
|
||||
'proxy-server-nameserver': ['https://doh.pub/dns-query', 'https://dns.alidns.com/dns-query'],
|
||||
'direct-nameserver': []
|
||||
},
|
||||
sniffer: {
|
||||
|
||||
@ -21,7 +21,8 @@ const ProxyProvider: React.FC = () => {
|
||||
show: false,
|
||||
path: '',
|
||||
type: '',
|
||||
title: ''
|
||||
title: '',
|
||||
privderType: ''
|
||||
})
|
||||
useEffect(() => {
|
||||
if (showDetails.title) {
|
||||
@ -104,7 +105,8 @@ const ProxyProvider: React.FC = () => {
|
||||
path={showDetails.path}
|
||||
type={showDetails.type}
|
||||
title={showDetails.title}
|
||||
onClose={() => setShowDetails({ show: false, path: '', type: '', title: '' })}
|
||||
privderType={showDetails.privderType}
|
||||
onClose={() => setShowDetails({ show: false, path: '', type: '', title: '', privderType: '' })}
|
||||
/>
|
||||
)}
|
||||
<SettingItem title="代理集合" divider>
|
||||
@ -136,28 +138,27 @@ const ProxyProvider: React.FC = () => {
|
||||
{/* <Button isIconOnly className="ml-2" size="sm">
|
||||
<IoMdEye className="text-lg" />
|
||||
</Button> */}
|
||||
{provider.vehicleType !== 'Inline' && (
|
||||
<Button
|
||||
isIconOnly
|
||||
title={provider.vehicleType == 'File' ? '编辑' : '查看'}
|
||||
className="ml-2"
|
||||
size="sm"
|
||||
onPress={() => {
|
||||
setShowDetails({
|
||||
show: false,
|
||||
path: provider.name,
|
||||
type: provider.vehicleType,
|
||||
title: provider.name
|
||||
})
|
||||
}}
|
||||
>
|
||||
{provider.vehicleType == 'File' ? (
|
||||
<MdEditDocument className={`text-lg`} />
|
||||
) : (
|
||||
<CgLoadbarDoc className={`text-lg`} />
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
isIconOnly
|
||||
title={provider.vehicleType == 'File' ? '编辑' : '查看'}
|
||||
className="ml-2"
|
||||
size="sm"
|
||||
onPress={() => {
|
||||
setShowDetails({
|
||||
show: false,
|
||||
privderType: 'proxy-providers',
|
||||
path: provider.name,
|
||||
type: provider.vehicleType,
|
||||
title: provider.name
|
||||
})
|
||||
}}
|
||||
>
|
||||
{provider.vehicleType == 'File' ? (
|
||||
<MdEditDocument className={`text-lg`} />
|
||||
) : (
|
||||
<CgLoadbarDoc className={`text-lg`} />
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
isIconOnly
|
||||
title="更新"
|
||||
|
||||
@ -21,7 +21,8 @@ const RuleProvider: React.FC = () => {
|
||||
path: '',
|
||||
type: '',
|
||||
title: '',
|
||||
format: ''
|
||||
format: '',
|
||||
privderType: ''
|
||||
})
|
||||
useEffect(() => {
|
||||
if (showDetails.title) {
|
||||
@ -89,7 +90,8 @@ const RuleProvider: React.FC = () => {
|
||||
type={showDetails.type}
|
||||
title={showDetails.title}
|
||||
format={showDetails.format}
|
||||
onClose={() => setShowDetails({ show: false, path: '', type: '', title: '', format: '' })}
|
||||
privderType={showDetails.privderType}
|
||||
onClose={() => setShowDetails({ show: false, path: '', type: '', title: '', format: '', privderType: '' })}
|
||||
/>
|
||||
)}
|
||||
<SettingItem title="规则集合" divider>
|
||||
@ -117,7 +119,7 @@ const RuleProvider: React.FC = () => {
|
||||
>
|
||||
<div className="flex h-[32px] leading-[32px] text-foreground-500">
|
||||
<div>{dayjs(provider.updatedAt).fromNow()}</div>
|
||||
{provider.format !== 'MrsRule' && provider.vehicleType !== 'Inline' && (
|
||||
{provider.format !== 'MrsRule' && (
|
||||
<Button
|
||||
isIconOnly
|
||||
title={provider.vehicleType == 'File' ? '编辑' : '查看'}
|
||||
@ -126,6 +128,7 @@ const RuleProvider: React.FC = () => {
|
||||
onPress={() => {
|
||||
setShowDetails({
|
||||
show: false,
|
||||
privderType: 'rule-providers',
|
||||
path: provider.name,
|
||||
type: provider.vehicleType,
|
||||
title: provider.name,
|
||||
|
||||
@ -2,6 +2,7 @@ import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { BaseEditor } from '../base/base-editor'
|
||||
import { getFileStr, setFileStr } from '@renderer/utils/ipc'
|
||||
import yaml from 'js-yaml'
|
||||
type Language = 'yaml' | 'javascript' | 'css' | 'json' | 'text'
|
||||
|
||||
interface Props {
|
||||
@ -9,15 +10,36 @@ interface Props {
|
||||
path: string
|
||||
type: string
|
||||
title: string
|
||||
privderType: string
|
||||
format?: string
|
||||
}
|
||||
const Viewer: React.FC<Props> = (props) => {
|
||||
const { type, path, title, format, onClose } = props
|
||||
const { type, path, title, format, privderType, onClose } = props
|
||||
const [currData, setCurrData] = useState('')
|
||||
const language: Language = !format || format === 'YamlRule' ? 'yaml' : 'text'
|
||||
let language: Language = !format || format === 'YamlRule' ? 'yaml' : 'text'
|
||||
|
||||
const getContent = async (): Promise<void> => {
|
||||
setCurrData(await getFileStr(path))
|
||||
let fileContent: React.SetStateAction<string>
|
||||
if (type === 'Inline') {
|
||||
fileContent = await getFileStr('config.yaml')
|
||||
language = 'yaml'
|
||||
} else {
|
||||
fileContent = await getFileStr(path)
|
||||
}
|
||||
try {
|
||||
const parsedYaml = yaml.load(fileContent)
|
||||
if (privderType === 'proxy-providers') {
|
||||
setCurrData(yaml.dump({
|
||||
'proxies': parsedYaml[privderType][title].payload
|
||||
}))
|
||||
} else {
|
||||
setCurrData(yaml.dump({
|
||||
'rules': parsedYaml[privderType][title].payload
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
setCurrData(fileContent)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user