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