mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
Compare commits
3 Commits
a81f970baa
...
f7b9eb2113
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7b9eb2113 | ||
|
|
d8aeb63584 | ||
|
|
f153217372 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ out
|
||||
*.log*
|
||||
.idea
|
||||
*.ttf
|
||||
party.md
|
||||
@ -54,8 +54,9 @@ pkg:
|
||||
file: build/background.png
|
||||
linux:
|
||||
desktop:
|
||||
Name: Mihomo Party
|
||||
MimeType: 'x-scheme-handler/clash;x-scheme-handler/mihomo'
|
||||
entry:
|
||||
Name: Mihomo Party
|
||||
MimeType: 'x-scheme-handler/clash;x-scheme-handler/mihomo'
|
||||
target:
|
||||
- deb
|
||||
- rpm
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { resolve } from 'path'
|
||||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
// https://github.com/vdesjs/vite-plugin-monaco-editor/issues/21#issuecomment-1827562674
|
||||
import monacoEditorPluginModule from 'vite-plugin-monaco-editor'
|
||||
const isObjectWithDefaultFunction = (
|
||||
@ -37,6 +38,7 @@ export default defineConfig({
|
||||
},
|
||||
plugins: [
|
||||
react(),
|
||||
tailwindcss(),
|
||||
monacoEditorPlugin({
|
||||
languageWorkers: ['editorWorkerService', 'typescript', 'css'],
|
||||
customDistPath: (_, out) => `${out}/monacoeditorwork`,
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
|
||||
"@electron-toolkit/eslint-config-ts": "^3.1.0",
|
||||
"@electron-toolkit/tsconfig": "^1.0.1",
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/node": "^24.1.0",
|
||||
@ -59,7 +60,6 @@
|
||||
"@types/react-dom": "^19.1.7",
|
||||
"@types/ws": "^8.18.1",
|
||||
"@vitejs/plugin-react": "^4.7.0",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"cron-validator": "^1.4.0",
|
||||
"driver.js": "^1.3.6",
|
||||
"electron": "^37.2.5",
|
||||
@ -87,7 +87,7 @@
|
||||
"react-router-dom": "^7.7.1",
|
||||
"react-virtuoso": "^4.13.0",
|
||||
"swr": "^2.3.4",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"tar": "^7.4.3",
|
||||
"tsx": "^4.20.3",
|
||||
"types-pac": "^1.0.3",
|
||||
|
||||
1230
pnpm-lock.yaml
generated
1230
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {}
|
||||
}
|
||||
}
|
||||
@ -20,15 +20,22 @@ export async function getControledMihomoConfig(force = false): Promise<Partial<I
|
||||
|
||||
export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>): Promise<void> {
|
||||
const { useNameserverPolicy, controlDns = true, controlSniff = true } = await getAppConfig()
|
||||
if (!controlDns) {
|
||||
|
||||
// DNS 配置覆写逻辑
|
||||
if (controlDns) {
|
||||
if (!controledMihomoConfig.dns || controledMihomoConfig.dns?.ipv6 === undefined) {
|
||||
controledMihomoConfig.dns = { ...defaultControledMihomoConfig.dns }
|
||||
}
|
||||
const originalEnable = controledMihomoConfig.dns?.enable
|
||||
controledMihomoConfig.dns = deepMerge(controledMihomoConfig.dns || {}, defaultControledMihomoConfig.dns || {})
|
||||
if (originalEnable !== undefined) {
|
||||
controledMihomoConfig.dns.enable = originalEnable
|
||||
}
|
||||
} else {
|
||||
delete controledMihomoConfig.dns
|
||||
delete controledMihomoConfig.hosts
|
||||
} else {
|
||||
// 从不接管状态恢复
|
||||
if (controledMihomoConfig.dns?.ipv6 === undefined) {
|
||||
controledMihomoConfig.dns = defaultControledMihomoConfig.dns
|
||||
}
|
||||
}
|
||||
|
||||
if (!controlSniff) {
|
||||
delete controledMihomoConfig.sniffer
|
||||
} else {
|
||||
@ -37,6 +44,7 @@ export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>):
|
||||
controledMihomoConfig.sniffer = defaultControledMihomoConfig.sniffer
|
||||
}
|
||||
}
|
||||
|
||||
if (patch.hosts) {
|
||||
controledMihomoConfig.hosts = patch.hosts
|
||||
}
|
||||
@ -44,7 +52,9 @@ export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>):
|
||||
controledMihomoConfig.dns = controledMihomoConfig.dns || {}
|
||||
controledMihomoConfig.dns['nameserver-policy'] = patch.dns['nameserver-policy']
|
||||
}
|
||||
|
||||
controledMihomoConfig = deepMerge(controledMihomoConfig, patch)
|
||||
|
||||
if (!useNameserverPolicy) {
|
||||
delete controledMihomoConfig?.dns?.['nameserver-policy']
|
||||
}
|
||||
|
||||
@ -37,15 +37,21 @@ export async function getProfileItem(id: string | undefined): Promise<IProfileIt
|
||||
export async function changeCurrentProfile(id: string): Promise<void> {
|
||||
const config = await getProfileConfig()
|
||||
const current = config.current
|
||||
|
||||
if (current === id) {
|
||||
return
|
||||
}
|
||||
|
||||
config.current = id
|
||||
await setProfileConfig(config)
|
||||
|
||||
try {
|
||||
await restartCore()
|
||||
} catch (e) {
|
||||
// 如果重启失败,恢复原来的配置
|
||||
config.current = current
|
||||
throw e
|
||||
} finally {
|
||||
await setProfileConfig(config)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -212,7 +212,12 @@ export async function restartCore(): Promise<void> {
|
||||
try {
|
||||
await startCore()
|
||||
} catch (e) {
|
||||
dialog.showErrorBox(i18next.t('mihomo.error.coreStartFailed'), `${e}`)
|
||||
// 记录错误到日志而不是显示阻塞对话框
|
||||
await writeFile(logPath(), `[Manager]: restart core failed, ${e}\n`, {
|
||||
flag: 'a'
|
||||
})
|
||||
// 重新抛出错误,让调用者处理
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -79,8 +79,10 @@ 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'],
|
||||
'respect-rules': false,
|
||||
'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: {
|
||||
|
||||
@ -373,13 +373,13 @@ const App: React.FC = () => {
|
||||
setSiderWidthValue(e.clientX)
|
||||
}
|
||||
}}
|
||||
className={`w-full h-[100vh] flex ${resizing ? 'cursor-ew-resize' : ''}`}
|
||||
className={`w-full h-screen flex ${resizing ? 'cursor-ew-resize' : ''}`}
|
||||
>
|
||||
{siderWidthValue === narrowWidth ? (
|
||||
<div style={{ width: `${narrowWidth}px` }} className="side h-full">
|
||||
<div className="app-drag flex justify-center items-center z-40 bg-transparent h-[49px]">
|
||||
{platform !== 'darwin' && (
|
||||
<MihomoIcon className="h-[32px] leading-[32px] text-lg mx-[1px]" />
|
||||
<MihomoIcon className="h-[32px] leading-[32px] text-lg mx-px" />
|
||||
)}
|
||||
<UpdaterButton iconOnly={true} />
|
||||
</div>
|
||||
@ -417,7 +417,7 @@ const App: React.FC = () => {
|
||||
className={`flex justify-between p-2 ${!useWindowFrame && platform === 'darwin' ? 'ml-[60px]' : ''}`}
|
||||
>
|
||||
<div className="flex ml-1">
|
||||
<MihomoIcon className="h-[32px] leading-[32px] text-lg mx-[1px]" />
|
||||
<MihomoIcon className="h-[32px] leading-[32px] text-lg mx-px" />
|
||||
<h3 className="text-lg font-bold leading-[32px]">ihomo Party</h3>
|
||||
</div>
|
||||
<UpdaterButton />
|
||||
|
||||
@ -59,9 +59,9 @@ const FloatingApp: React.FC = () => {
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="app-drag h-[100vh] w-[100vw] overflow-hidden">
|
||||
<div className="floating-bg border-1 border-divider flex rounded-full bg-content1 h-[calc(100%-2px)] w-[calc(100%-2px)]">
|
||||
<div className="flex justify-center items-center h-[100%] aspect-square">
|
||||
<div className="app-drag h-screen w-screen overflow-hidden">
|
||||
<div className="floating-bg border border-divider flex rounded-full bg-content1 h-[calc(100%-2px)] w-[calc(100%-2px)]">
|
||||
<div className="flex justify-center items-center h-full aspect-square">
|
||||
<div
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault()
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@import 'tailwindcss';
|
||||
@plugin './hero.ts';
|
||||
|
||||
@source '../**/*.{js,ts,jsx,tsx}';
|
||||
@source '../../../../node_modules/@heroui/theme/dist/**/*.{js,ts,jsx,tsx}';
|
||||
|
||||
.floating-text {
|
||||
font-family:
|
||||
|
||||
2
src/renderer/src/assets/hero.ts
Normal file
2
src/renderer/src/assets/hero.ts
Normal file
@ -0,0 +1,2 @@
|
||||
import { heroui } from '@heroui/react'
|
||||
export default heroui()
|
||||
@ -1,6 +1,12 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@import 'tailwindcss';
|
||||
@plugin './hero.ts';
|
||||
|
||||
@source '../**/*.{js,ts,jsx,tsx}';
|
||||
@source '../../../../node_modules/@heroui/theme/dist/**/*.{js,ts,jsx,tsx}';
|
||||
|
||||
@theme {
|
||||
--default-font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Noto Color Emoji';
|
||||
|
||||
@ -39,7 +39,7 @@ const ConnectionItem: React.FC<Props> = (props) => {
|
||||
<Chip
|
||||
color={`${info.isActive ? 'primary' : 'danger'}`}
|
||||
size="sm"
|
||||
radius="sm"
|
||||
radius="xs"
|
||||
variant="dot"
|
||||
>
|
||||
{info.metadata.type}({info.metadata.network.toUpperCase()})
|
||||
@ -65,16 +65,16 @@ const ConnectionItem: React.FC<Props> = (props) => {
|
||||
<Chip
|
||||
className="flag-emoji text-ellipsis whitespace-nowrap overflow-hidden"
|
||||
size="sm"
|
||||
radius="sm"
|
||||
radius="xs"
|
||||
variant="bordered"
|
||||
>
|
||||
{info.chains[0]}
|
||||
</Chip>
|
||||
<Chip size="sm" radius="sm" variant="bordered">
|
||||
<Chip size="sm" radius="xs" variant="bordered">
|
||||
↑ {calcTraffic(info.upload)} ↓ {calcTraffic(info.download)}
|
||||
</Chip>
|
||||
{info.uploadSpeed !== 0 || info.downloadSpeed !== 0 ? (
|
||||
<Chip color="primary" size="sm" radius="sm" variant="bordered">
|
||||
<Chip color="primary" size="sm" radius="xs" variant="bordered">
|
||||
↑ {calcTraffic(info.uploadSpeed || 0)}/s ↓ {calcTraffic(info.downloadSpeed || 0)}
|
||||
/s
|
||||
</Chip>
|
||||
|
||||
@ -14,7 +14,7 @@ import {
|
||||
import { calcPercent, calcTraffic } from '@renderer/utils/calc'
|
||||
import { IoMdMore, IoMdRefresh } from 'react-icons/io'
|
||||
import dayjs from '@renderer/utils/dayjs'
|
||||
import React, { Key, useEffect, useMemo, useState } from 'react'
|
||||
import React, { Key, useMemo, useState } from 'react'
|
||||
import EditFileModal from './edit-file-modal'
|
||||
import EditInfoModal from './edit-info-modal'
|
||||
import { useSortable } from '@dnd-kit/sortable'
|
||||
@ -72,7 +72,8 @@ const ProfileItem: React.FC<Props> = (props) => {
|
||||
id: info.id
|
||||
})
|
||||
const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null
|
||||
const [disableSelect, setDisableSelect] = useState(false)
|
||||
const [isActuallyDragging, setIsActuallyDragging] = useState(false)
|
||||
const [clickStartPos, setClickStartPos] = useState<{ x: number; y: number } | null>(null)
|
||||
|
||||
const menuItems: MenuItem[] = useMemo(() => {
|
||||
const list = [
|
||||
@ -150,19 +151,35 @@ const ProfileItem: React.FC<Props> = (props) => {
|
||||
setDropdownOpen(true)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isDragging) {
|
||||
setTimeout(() => {
|
||||
setDisableSelect(true)
|
||||
}, 200)
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
setDisableSelect(false)
|
||||
}, 200)
|
||||
// 智能区分点击和拖拽的事件处理
|
||||
const handleMouseDown = (e: React.MouseEvent) => {
|
||||
setClickStartPos({ x: e.clientX, y: e.clientY })
|
||||
setIsActuallyDragging(false)
|
||||
}
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent) => {
|
||||
if (clickStartPos) {
|
||||
const dx = e.clientX - clickStartPos.x
|
||||
const dy = e.clientY - clickStartPos.y
|
||||
// 移动距离超过 5px 认为是拖拽
|
||||
if (dx * dx + dy * dy > 25) {
|
||||
setIsActuallyDragging(true)
|
||||
}
|
||||
}
|
||||
}, [isDragging])
|
||||
}
|
||||
|
||||
const handleMouseUp = () => {
|
||||
// 如果没有拖拽,则处理为点击事件
|
||||
if (!isActuallyDragging && !isDragging && clickStartPos) {
|
||||
setSelecting(true)
|
||||
onPress().finally(() => {
|
||||
setSelecting(false)
|
||||
})
|
||||
}
|
||||
|
||||
setClickStartPos(null)
|
||||
setTimeout(() => setIsActuallyDragging(false), 100)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
@ -186,18 +203,19 @@ const ProfileItem: React.FC<Props> = (props) => {
|
||||
<Card
|
||||
as="div"
|
||||
fullWidth
|
||||
isPressable
|
||||
onPress={() => {
|
||||
if (disableSelect) return
|
||||
setSelecting(true)
|
||||
onPress().finally(() => {
|
||||
setSelecting(false)
|
||||
})
|
||||
}}
|
||||
isPressable={false}
|
||||
onContextMenu={handleContextMenu}
|
||||
className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`}
|
||||
className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''} cursor-pointer`}
|
||||
>
|
||||
<div ref={setNodeRef} {...attributes} {...listeners} className="w-full h-full">
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
className="w-full h-full"
|
||||
onMouseDownCapture={handleMouseDown}
|
||||
onMouseMoveCapture={handleMouseMove}
|
||||
onMouseUpCapture={handleMouseUp}
|
||||
>
|
||||
<CardBody className="pb-1">
|
||||
<div className="flex justify-between h-[32px]">
|
||||
<h3
|
||||
|
||||
@ -60,7 +60,7 @@ const ProxyItem: React.FC<Props> = (props) => {
|
||||
onPress={() => onSelect(group.name, proxy.name)}
|
||||
isPressable
|
||||
fullWidth
|
||||
shadow="sm"
|
||||
shadow="xs"
|
||||
className={`${
|
||||
fixed
|
||||
? 'bg-secondary/30 border-r-2 border-r-secondary border-l-2 border-l-secondary'
|
||||
@ -68,7 +68,7 @@ const ProxyItem: React.FC<Props> = (props) => {
|
||||
? 'bg-primary/30 border-r-2 border-r-primary border-l-2 border-l-primary'
|
||||
: 'bg-content2'
|
||||
}`}
|
||||
radius="sm"
|
||||
radius="xs"
|
||||
>
|
||||
<CardBody className="p-1">
|
||||
{proxyDisplayMode === 'full' ? (
|
||||
|
||||
@ -3,7 +3,7 @@ import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-c
|
||||
import BorderSwitch from '@renderer/components/base/border-swtich'
|
||||
import { LuServer } from 'react-icons/lu'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { patchMihomoConfig } from '@renderer/utils/ipc'
|
||||
import { restartCore } from '@renderer/utils/ipc'
|
||||
import { useSortable } from '@dnd-kit/sortable'
|
||||
import { CSS } from '@dnd-kit/utilities'
|
||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||
@ -15,15 +15,14 @@ interface Props {
|
||||
}
|
||||
const DNSCard: React.FC<Props> = (props) => {
|
||||
const { t } = useTranslation()
|
||||
const { appConfig } = useAppConfig()
|
||||
const { appConfig, patchAppConfig } = useAppConfig()
|
||||
const { iconOnly } = props
|
||||
const { dnsCardStatus = 'col-span-1', controlDns = true } = appConfig || {}
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const match = location.pathname.includes('/dns')
|
||||
const { controledMihomoConfig, patchControledMihomoConfig } = useControledMihomoConfig()
|
||||
const { dns, tun } = controledMihomoConfig || {}
|
||||
const { enable = true } = dns || {}
|
||||
const { tun } = controledMihomoConfig || {}
|
||||
const {
|
||||
attributes,
|
||||
listeners,
|
||||
@ -35,20 +34,33 @@ const DNSCard: React.FC<Props> = (props) => {
|
||||
id: 'dns'
|
||||
})
|
||||
const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null
|
||||
const onChange = async (enable: boolean): Promise<void> => {
|
||||
await patchControledMihomoConfig({ dns: { enable } })
|
||||
await patchMihomoConfig({ dns: { enable } })
|
||||
const onChange = async (controlDnsEnabled: boolean): Promise<void> => {
|
||||
try {
|
||||
await patchAppConfig({ controlDns: controlDnsEnabled })
|
||||
await patchControledMihomoConfig({})
|
||||
await restartCore()
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
}
|
||||
}
|
||||
|
||||
if (iconOnly) {
|
||||
return (
|
||||
<div className={`${dnsCardStatus} ${!controlDns ? 'hidden' : ''} flex justify-center`}>
|
||||
<Tooltip content={t('sider.cards.dns')} placement="right">
|
||||
<div className={`${dnsCardStatus} flex justify-center`}>
|
||||
<Tooltip
|
||||
content={
|
||||
controlDns
|
||||
? `${t('sider.cards.dns')} (${t('sider.cards.dns.overrideMode')})`
|
||||
: `${t('sider.cards.dns')} (${t('sider.cards.dns.originalConfig')})`
|
||||
}
|
||||
placement="right"
|
||||
>
|
||||
<Button
|
||||
size="sm"
|
||||
isIconOnly
|
||||
color={match ? 'primary' : 'default'}
|
||||
variant={match ? 'solid' : 'light'}
|
||||
className={!controlDns ? 'opacity-60' : ''}
|
||||
onPress={() => {
|
||||
navigate('/dns')
|
||||
}}
|
||||
@ -68,14 +80,14 @@ const DNSCard: React.FC<Props> = (props) => {
|
||||
transition,
|
||||
zIndex: isDragging ? 'calc(infinity)' : undefined
|
||||
}}
|
||||
className={`${dnsCardStatus} ${!controlDns ? 'hidden' : ''} dns-card`}
|
||||
className={`${dnsCardStatus} dns-card`}
|
||||
>
|
||||
<Card
|
||||
fullWidth
|
||||
ref={setNodeRef}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''}`}
|
||||
className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''} ${!controlDns ? 'opacity-60' : ''}`}
|
||||
>
|
||||
<CardBody className="pb-1 pt-0 px-0">
|
||||
<div className="flex justify-between">
|
||||
@ -90,8 +102,8 @@ const DNSCard: React.FC<Props> = (props) => {
|
||||
/>
|
||||
</Button>
|
||||
<BorderSwitch
|
||||
isShowBorder={match && enable}
|
||||
isSelected={enable}
|
||||
isShowBorder={match && controlDns}
|
||||
isSelected={controlDns}
|
||||
isDisabled={tun?.enable}
|
||||
onValueChange={onChange}
|
||||
/>
|
||||
|
||||
@ -42,13 +42,14 @@ const SniffCard: React.FC<Props> = (props) => {
|
||||
|
||||
if (iconOnly) {
|
||||
return (
|
||||
<div className={`${sniffCardStatus} ${!controlSniff ? 'hidden' : ''} flex justify-center`}>
|
||||
<div className={`${sniffCardStatus} flex justify-center`}>
|
||||
<Tooltip content={t('sider.cards.sniff')} placement="right">
|
||||
<Button
|
||||
size="sm"
|
||||
isIconOnly
|
||||
color={match ? 'primary' : 'default'}
|
||||
variant={match ? 'solid' : 'light'}
|
||||
className={!enable ? 'opacity-60' : ''}
|
||||
onPress={() => {
|
||||
navigate('/sniffer')
|
||||
}}
|
||||
@ -68,14 +69,14 @@ const SniffCard: React.FC<Props> = (props) => {
|
||||
transition,
|
||||
zIndex: isDragging ? 'calc(infinity)' : undefined
|
||||
}}
|
||||
className={`${sniffCardStatus} ${!controlSniff ? 'hidden' : ''} sniff-card`}
|
||||
className={`${sniffCardStatus} sniff-card`}
|
||||
>
|
||||
<Card
|
||||
fullWidth
|
||||
ref={setNodeRef}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''}`}
|
||||
className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''} ${!enable ? 'opacity-60' : ''}`}
|
||||
>
|
||||
<CardBody className="pb-1 pt-0 px-0">
|
||||
<div className="flex justify-between">
|
||||
|
||||
@ -58,6 +58,7 @@ const SysproxySwitcher: React.FC<Props> = (props) => {
|
||||
isIconOnly
|
||||
color={match ? 'primary' : 'default'}
|
||||
variant={match ? 'solid' : 'light'}
|
||||
className={!enable ? 'opacity-60' : ''}
|
||||
onPress={() => {
|
||||
navigate('/sysproxy')
|
||||
}}
|
||||
@ -84,7 +85,7 @@ const SysproxySwitcher: React.FC<Props> = (props) => {
|
||||
ref={setNodeRef}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''}`}
|
||||
className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''} ${!enable ? 'opacity-60' : ''}`}
|
||||
>
|
||||
<CardBody className="pb-1 pt-0 px-0">
|
||||
<div className="flex justify-between">
|
||||
|
||||
@ -56,6 +56,7 @@ const TunSwitcher: React.FC<Props> = (props) => {
|
||||
isIconOnly
|
||||
color={match ? 'primary' : 'default'}
|
||||
variant={match ? 'solid' : 'light'}
|
||||
className={!enable ? 'opacity-60' : ''}
|
||||
onPress={() => {
|
||||
navigate('/tun')
|
||||
}}
|
||||
@ -82,7 +83,7 @@ const TunSwitcher: React.FC<Props> = (props) => {
|
||||
ref={setNodeRef}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''}`}
|
||||
className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''} ${!enable ? 'opacity-60' : ''}`}
|
||||
>
|
||||
<CardBody className="pb-1 pt-0 px-0">
|
||||
<div className="flex justify-between">
|
||||
|
||||
@ -71,13 +71,34 @@ export const ProfileConfigProvider: React.FC<{ children: ReactNode }> = ({ child
|
||||
}
|
||||
|
||||
const changeCurrentProfile = async (id: string): Promise<void> => {
|
||||
if (profileConfig?.current === id) {
|
||||
return
|
||||
}
|
||||
|
||||
// 乐观更新:立即更新 UI 状态,提供即时反馈
|
||||
if (profileConfig) {
|
||||
const optimisticUpdate = { ...profileConfig, current: id }
|
||||
mutateProfileConfig(optimisticUpdate, false)
|
||||
}
|
||||
|
||||
try {
|
||||
await change(id)
|
||||
// 异步执行后台切换,不阻塞 UI
|
||||
change(id).then(() => {
|
||||
window.electron.ipcRenderer.send('updateTrayMenu')
|
||||
mutateProfileConfig()
|
||||
}).catch((e) => {
|
||||
const errorMsg = e?.message || String(e)
|
||||
// 处理 IPC 超时错误
|
||||
if (errorMsg.includes('reply was never sent')) {
|
||||
setTimeout(() => mutateProfileConfig(), 1000)
|
||||
} else {
|
||||
alert(`切换 Profile 失败: ${errorMsg}`)
|
||||
mutateProfileConfig()
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
} finally {
|
||||
alert(`切换 Profile 失败: ${e}`)
|
||||
mutateProfileConfig()
|
||||
window.electron.ipcRenderer.send('updateTrayMenu')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
"mihomo.cpuPriority.low": "Low",
|
||||
"mihomo.workDir.title": "Separate Work Directory for Different Subscriptions",
|
||||
"mihomo.workDir.tooltip": "Enable to avoid conflicts when different subscriptions have proxy groups with the same name",
|
||||
"mihomo.controlDns": "Control DNS Settings",
|
||||
"mihomo.controlDns": "Override DNS Settings",
|
||||
"mihomo.controlSniff": "Control Domain Sniffing",
|
||||
"mihomo.autoCloseConnection": "Auto Close Connection",
|
||||
"mihomo.pauseSSID.title": "Direct Connection for Specific WiFi SSIDs",
|
||||
@ -216,7 +216,9 @@
|
||||
"sider.cards.override": "Override",
|
||||
"sider.cards.connections": "Connections",
|
||||
"sider.cards.core": "Core Settings",
|
||||
"sider.cards.dns": "DNS",
|
||||
"sider.cards.dns": "DNS OVR",
|
||||
"sider.cards.dns.originalConfig": "Using Original Config",
|
||||
"sider.cards.dns.overrideMode": "Override Mode",
|
||||
"sider.cards.sniff": "Sniffing",
|
||||
"sider.cards.logs": "Logs",
|
||||
"sider.cards.substore": "Sub-Store",
|
||||
@ -316,6 +318,7 @@
|
||||
"tun.notifications.firewallResetSuccess": "Firewall Reset Successful",
|
||||
"tun.error.tunPermissionDenied": "TUN interface start failed, please try to manually grant core permissions",
|
||||
"dns.title": "DNS Settings",
|
||||
"dns.enable.title": "Enable DNS",
|
||||
"dns.enhancedMode.title": "Domain Mapping Mode",
|
||||
"dns.enhancedMode.fakeIp": "Fake IP",
|
||||
"dns.enhancedMode.redirHost": "Real IP",
|
||||
@ -513,7 +516,7 @@
|
||||
"guide.override.title": "Override",
|
||||
"guide.override.description": "Mihomo Party provides powerful override functionality to customize your imported subscription configurations, such as adding rules and customizing proxy groups. You can directly import override files written by others or write your own. <b>Remember to enable the override file on the subscription you want to override</b>. For override file syntax, please refer to the <a href=\"https://mihomo.party/docs/guide/override\" target=\"_blank\">official documentation</a>.",
|
||||
"guide.dns.title": "DNS",
|
||||
"guide.dns.description": "The software takes control of the core's DNS settings by default. If you need to use the DNS settings from your subscription configuration, you can disable 'Control DNS Settings' in the application settings. The same applies to domain sniffing.",
|
||||
"guide.dns.description": "The software overrides subscription DNS settings with application DNS settings by default. If you need to use the DNS settings from your subscription configuration, you can disable 'Override DNS Settings' in the application settings. The same applies to domain sniffing.",
|
||||
"guide.end.title": "Tutorial Complete",
|
||||
"guide.end.description": "Now that you understand the basic usage of the software, import your subscription and start using it. Enjoy!\nYou can also join our official <a href=\"https://t.me/mihomo_party_group\" target=\"_blank\">Telegram group</a> for the latest news."
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@
|
||||
"mihomo.cpuPriority.low": "低",
|
||||
"mihomo.workDir.title": "不同订阅使用独立工作目录",
|
||||
"mihomo.workDir.tooltip": "启用后可避免不同订阅中存在相同名称的代理组时发生冲突",
|
||||
"mihomo.controlDns": "控制 DNS 设置",
|
||||
"mihomo.controlDns": "覆写 DNS 设置",
|
||||
"mihomo.controlSniff": "控制域名嗅探",
|
||||
"mihomo.autoCloseConnection": "自动关闭连接",
|
||||
"mihomo.pauseSSID.title": "指定 WiFi SSID 直连",
|
||||
@ -216,7 +216,9 @@
|
||||
"sider.cards.override": "覆写",
|
||||
"sider.cards.connections": "连接",
|
||||
"sider.cards.core": "内核设置",
|
||||
"sider.cards.dns": "DNS",
|
||||
"sider.cards.dns": "DNS覆写",
|
||||
"sider.cards.dns.originalConfig": "使用原始配置",
|
||||
"sider.cards.dns.overrideMode": "覆写模式",
|
||||
"sider.cards.sniff": "域名嗅探",
|
||||
"sider.cards.logs": "日志",
|
||||
"sider.cards.substore": "Sub-Store",
|
||||
@ -316,6 +318,7 @@
|
||||
"tun.notifications.firewallResetSuccess": "防火墙重设成功",
|
||||
"tun.error.tunPermissionDenied": "虚拟网卡启动失败,请尝试手动授予内核权限",
|
||||
"dns.title": "DNS 设置",
|
||||
"dns.enable.title": "启用 DNS",
|
||||
"dns.enhancedMode.title": "域名映射模式",
|
||||
"dns.enhancedMode.fakeIp": "虚假 IP",
|
||||
"dns.enhancedMode.redirHost": "真实 IP",
|
||||
@ -513,7 +516,7 @@
|
||||
"guide.override.title": "覆写",
|
||||
"guide.override.description": "Mihomo Party 提供强大的覆写功能,可以对您导入的订阅配置进行个性化修改,如添加规则、自定义代理组等,您可以直接导入别人写好的覆写文件,也可以自己动手编写,<b>编辑好覆写文件一定要记得在需要覆写的订阅上启用</b>,覆写文件的语法请参考 <a href=\"https://mihomo.party/docs/guide/override\" target=\"_blank\">官方文档</a>",
|
||||
"guide.dns.title": "DNS",
|
||||
"guide.dns.description": "软件默认接管了内核的 DNS 设置,如果您需要使用订阅配置中的 DNS 设置,可以到应用设置中关闭\"接管 DNS 设置\",域名嗅探同理",
|
||||
"guide.dns.description": "软件默认使用应用的 DNS 设置覆写订阅配置,如果您需要使用订阅配置中的 DNS 设置,可以到应用设置中关闭\"覆写 DNS 设置\",域名嗅探同理",
|
||||
"guide.end.title": "教程结束",
|
||||
"guide.end.description": "现在您已经了解了软件的基本用法,导入您的订阅开始使用吧,祝您使用愉快!\n您还可以加入我们的官方 <a href=\"https://t.me/mihomo_party_group\" target=\"_blank\">Telegram 群组</a> 获取最新资讯"
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ const Connections: React.FC = () => {
|
||||
</div>
|
||||
<Divider />
|
||||
</div>
|
||||
<div className="h-[calc(100vh-100px)] mt-[1px]">
|
||||
<div className="h-[calc(100vh-100px)] mt-px">
|
||||
<Virtuoso
|
||||
data={filteredConnections}
|
||||
itemContent={(i, connection) => (
|
||||
|
||||
@ -16,6 +16,7 @@ const DNS: React.FC = () => {
|
||||
const { nameserverPolicy, useNameserverPolicy } = appConfig || {}
|
||||
const { dns, hosts } = controledMihomoConfig || {}
|
||||
const {
|
||||
enable = true,
|
||||
ipv6 = false,
|
||||
'fake-ip-range': fakeIPRange = '198.18.0.1/16',
|
||||
'fake-ip-filter': fakeIPFilter = [
|
||||
@ -40,6 +41,7 @@ const DNS: React.FC = () => {
|
||||
} = dns || {}
|
||||
const [changed, setChanged] = useState(false)
|
||||
const [values, originSetValues] = useState({
|
||||
enable,
|
||||
ipv6,
|
||||
useHosts,
|
||||
enhancedMode,
|
||||
@ -143,6 +145,7 @@ const DNS: React.FC = () => {
|
||||
color="primary"
|
||||
onPress={() => {
|
||||
const dnsConfig = {
|
||||
enable: values.enable,
|
||||
ipv6: values.ipv6,
|
||||
'fake-ip-range': values.fakeIPRange,
|
||||
'fake-ip-filter': values.fakeIPFilter,
|
||||
@ -177,6 +180,15 @@ const DNS: React.FC = () => {
|
||||
}
|
||||
>
|
||||
<SettingCard>
|
||||
<SettingItem title={t('dns.enable.title')} divider>
|
||||
<Switch
|
||||
size="sm"
|
||||
isSelected={values.enable}
|
||||
onValueChange={(v) => {
|
||||
setValues({ ...values, enable: v })
|
||||
}}
|
||||
/>
|
||||
</SettingItem>
|
||||
<SettingItem title={t('dns.enhancedMode.title')} divider>
|
||||
<Tabs
|
||||
size="sm"
|
||||
@ -264,7 +276,7 @@ const DNS: React.FC = () => {
|
||||
{[...values.nameserverPolicy, { domain: '', value: '' }].map(
|
||||
({ domain, value }, index) => (
|
||||
<div key={index} className="flex mb-2">
|
||||
<div className="flex-[4]">
|
||||
<div className="flex-4">
|
||||
<Input
|
||||
size="sm"
|
||||
fullWidth
|
||||
@ -281,7 +293,7 @@ const DNS: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
<span className="mx-2">:</span>
|
||||
<div className="flex-[6] flex">
|
||||
<div className="flex-6 flex">
|
||||
<Input
|
||||
size="sm"
|
||||
fullWidth
|
||||
@ -332,7 +344,7 @@ const DNS: React.FC = () => {
|
||||
<h3 className="mb-2">{t('dns.customHosts.list')}</h3>
|
||||
{[...values.hosts, { domain: '', value: '' }].map(({ domain, value }, index) => (
|
||||
<div key={index} className="flex mb-2">
|
||||
<div className="flex-[4]">
|
||||
<div className="flex-4">
|
||||
<Input
|
||||
size="sm"
|
||||
fullWidth
|
||||
@ -349,7 +361,7 @@ const DNS: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
<span className="mx-2">:</span>
|
||||
<div className="flex-[6] flex">
|
||||
<div className="flex-6 flex">
|
||||
<Input
|
||||
size="sm"
|
||||
fullWidth
|
||||
|
||||
@ -109,7 +109,7 @@ const Logs: React.FC = () => {
|
||||
</div>
|
||||
<Divider />
|
||||
</div>
|
||||
<div className="h-[calc(100vh-100px)] mt-[1px]">
|
||||
<div className="h-[calc(100vh-100px)] mt-px">
|
||||
<Virtuoso
|
||||
ref={virtuosoRef}
|
||||
data={filteredLogs}
|
||||
|
||||
@ -652,7 +652,7 @@ const Mihomo: React.FC = () => {
|
||||
const [user, pass] = auth.split(':')
|
||||
return (
|
||||
<div key={index} className="flex mb-2">
|
||||
<div className="flex-[4]">
|
||||
<div className="flex-4">
|
||||
<Input
|
||||
size="sm"
|
||||
fullWidth
|
||||
@ -672,7 +672,7 @@ const Mihomo: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
<span className="mx-2">:</span>
|
||||
<div className="flex-[6] flex">
|
||||
<div className="flex-6 flex">
|
||||
<Input
|
||||
size="sm"
|
||||
fullWidth
|
||||
|
||||
@ -85,7 +85,7 @@ const Profiles: React.FC = () => {
|
||||
<div>
|
||||
{sub.tag?.map((tag) => {
|
||||
return (
|
||||
<Chip key={tag} size="sm" className="ml-1" radius="sm">
|
||||
<Chip key={tag} size="sm" className="ml-1" radius="xs">
|
||||
{tag}
|
||||
</Chip>
|
||||
)
|
||||
@ -108,7 +108,7 @@ const Profiles: React.FC = () => {
|
||||
<div>
|
||||
{sub.tag?.map((tag) => {
|
||||
return (
|
||||
<Chip key={tag} size="sm" className="ml-1" radius="sm">
|
||||
<Chip key={tag} size="sm" className="ml-1" radius="xs">
|
||||
{tag}
|
||||
</Chip>
|
||||
)
|
||||
|
||||
@ -324,7 +324,7 @@ const Proxies: React.FC = () => {
|
||||
<Avatar
|
||||
className="bg-transparent mr-2"
|
||||
size="sm"
|
||||
radius="sm"
|
||||
radius="xs"
|
||||
src={
|
||||
groups[index].icon.startsWith('<svg')
|
||||
? `data:image/svg+xml;utf8,${groups[index].icon}`
|
||||
|
||||
@ -38,7 +38,7 @@ const Rules: React.FC = () => {
|
||||
</div>
|
||||
<Divider />
|
||||
</div>
|
||||
<div className="h-[calc(100vh-100px)] mt-[1px]">
|
||||
<div className="h-[calc(100vh-100px)] mt-px">
|
||||
<Virtuoso
|
||||
data={filteredRules}
|
||||
itemContent={(i, rule) => (
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
const { heroui } = require('@heroui/react')
|
||||
|
||||
module.exports = {
|
||||
content: [
|
||||
'./src/renderer/src/**/*.{js,ts,jsx,tsx}',
|
||||
'./node_modules/@heroui/theme/dist/**/*.{js,ts,jsx,tsx}'
|
||||
],
|
||||
theme: {
|
||||
extend: {}
|
||||
},
|
||||
darkMode: 'class',
|
||||
plugins: [heroui()]
|
||||
}
|
||||
@ -3,6 +3,7 @@
|
||||
"include": ["electron.vite.config.*", "src/main/**/*", "src/preload/**/*", "src/shared/**/*"],
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"types": ["electron-vite/node"]
|
||||
"types": ["electron-vite/node"],
|
||||
"moduleResolution": "bundler"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user