mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-10 19:50:28 +08:00
adjust
This commit is contained in:
parent
d0a6d515a1
commit
8fe1f4f86b
@ -41,11 +41,10 @@ export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>):
|
||||
controledMihomoConfig.dns = controledMihomoConfig.dns || {}
|
||||
controledMihomoConfig.dns['nameserver-policy'] = patch.dns['nameserver-policy']
|
||||
}
|
||||
controledMihomoConfig = deepMerge(controledMihomoConfig, patch)
|
||||
if (patch.hosts && patch.dns?.['use-hosts']) {
|
||||
delete controledMihomoConfig.hosts
|
||||
if (patch.dns?.['use-hosts']) {
|
||||
controledMihomoConfig.hosts = patch.hosts
|
||||
}
|
||||
controledMihomoConfig = deepMerge(controledMihomoConfig, patch)
|
||||
if (!useNameserverPolicy) {
|
||||
delete controledMihomoConfig?.dns?.['nameserver-policy']
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ const ProxyProvider: React.FC = () => {
|
||||
if (showDetails.title) {
|
||||
const fetchProviderPath = async (name: string): Promise<void> => {
|
||||
try {
|
||||
const providers= await getRuntimeConfig()
|
||||
const providers = await getRuntimeConfig()
|
||||
const provider = providers['proxy-providers'][name]
|
||||
if (provider) {
|
||||
setShowDetails((prev) => ({
|
||||
@ -48,6 +48,20 @@ const ProxyProvider: React.FC = () => {
|
||||
const providers = useMemo(() => {
|
||||
if (!data) return []
|
||||
return Object.values(data.providers)
|
||||
.map(provider => {
|
||||
if (provider.vehicleType === 'Inline' || (provider.subscriptionInfo &&
|
||||
provider.subscriptionInfo.Upload === 0 &&
|
||||
provider.subscriptionInfo.Download === 0 &&
|
||||
provider.subscriptionInfo.Total === 0 &&
|
||||
provider.subscriptionInfo.Expire === 0)) {
|
||||
return {
|
||||
...provider,
|
||||
subscriptionInfo: null
|
||||
}
|
||||
}
|
||||
return provider
|
||||
})
|
||||
|
||||
.filter(provider => 'subscriptionInfo' in provider)
|
||||
.sort((a, b) => {
|
||||
if (a.vehicleType === 'File' && b.vehicleType !== 'File') {
|
||||
@ -122,26 +136,28 @@ const ProxyProvider: React.FC = () => {
|
||||
{/* <Button isIconOnly className="ml-2" size="sm">
|
||||
<IoMdEye className="text-lg" />
|
||||
</Button> */}
|
||||
<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>
|
||||
{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="更新"
|
||||
|
||||
@ -117,7 +117,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.format !== 'MrsRule' && provider.vehicleType !== 'Inline' && (
|
||||
<Button
|
||||
isIconOnly
|
||||
title={provider.vehicleType == 'File' ? '编辑' : '查看'}
|
||||
|
||||
@ -12,7 +12,7 @@ const DNS: React.FC = () => {
|
||||
const { controledMihomoConfig, patchControledMihomoConfig } = useControledMihomoConfig()
|
||||
const { appConfig, patchAppConfig } = useAppConfig()
|
||||
const { nameserverPolicy, useNameserverPolicy } = appConfig || {}
|
||||
const { dns, hosts } = controledMihomoConfig || {}
|
||||
const { dns } = controledMihomoConfig || {}
|
||||
const {
|
||||
ipv6 = false,
|
||||
'fake-ip-range': fakeIPRange = '198.18.0.1/16',
|
||||
@ -54,7 +54,7 @@ const DNS: React.FC = () => {
|
||||
domain,
|
||||
value
|
||||
})),
|
||||
hosts: Object.entries(hosts || {}).map(([domain, value]) => ({ domain, value }))
|
||||
hosts: useHosts ? [] : undefined
|
||||
})
|
||||
|
||||
const setValues = (v: typeof values): void => {
|
||||
@ -140,7 +140,7 @@ const DNS: React.FC = () => {
|
||||
className="app-nodrag"
|
||||
color="primary"
|
||||
onPress={() => {
|
||||
const hostsObject = values.useHosts
|
||||
const hostsObject = values.useHosts && values.hosts && values.hosts.length > 0
|
||||
? Object.fromEntries(values.hosts.map(({ domain, value }) => [domain, value]))
|
||||
: undefined
|
||||
const dnsConfig = {
|
||||
@ -187,7 +187,7 @@ const DNS: React.FC = () => {
|
||||
<Tab key="normal" title="取消映射" />
|
||||
</Tabs>
|
||||
</SettingItem>
|
||||
{values.enhancedMode === 'fake-ip' ? (
|
||||
{values.enhancedMode === 'fake-ip' && (
|
||||
<>
|
||||
<SettingItem title="回应范围" divider>
|
||||
<Input
|
||||
@ -205,7 +205,7 @@ const DNS: React.FC = () => {
|
||||
</div>
|
||||
<Divider className="my-2" />
|
||||
</>
|
||||
) : null}
|
||||
)}
|
||||
<SettingItem title="IPv6" divider>
|
||||
<Switch
|
||||
size="sm"
|
||||
@ -320,14 +320,14 @@ const DNS: React.FC = () => {
|
||||
size="sm"
|
||||
isSelected={values.useHosts}
|
||||
onValueChange={(v) => {
|
||||
setValues({ ...values, useHosts: v })
|
||||
setValues({ ...values, useHosts: v, hosts: v ? [] : undefined })
|
||||
}}
|
||||
/>
|
||||
</SettingItem>
|
||||
{values.useHosts && (
|
||||
<div className="flex flex-col items-stretch">
|
||||
<h3 className="mb-2"></h3>
|
||||
{[...values.hosts, { domain: '', value: '' }].map(({ domain, value }, index) => (
|
||||
{[...(values.hosts || []), { domain: '', value: '' }].map(({ domain, value }, index) => (
|
||||
<div key={index} className="flex mb-2">
|
||||
<div className="flex-[4]">
|
||||
<Input
|
||||
@ -354,7 +354,7 @@ const DNS: React.FC = () => {
|
||||
value={Array.isArray(value) ? value.join(',') : value}
|
||||
onValueChange={(v) => handleSubkeyChange('hosts', domain, v, index)}
|
||||
/>
|
||||
{index < values.hosts.length && (
|
||||
{index < (values.hosts || []).length && (
|
||||
<Button
|
||||
size="sm"
|
||||
color="warning"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user