mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-04-13 08:00:30 +08:00
Compare commits
2 Commits
f8057746e4
...
e4110f65c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4110f65c2 | ||
|
|
93d552870e |
@ -11,7 +11,7 @@ import { patchMihomoConfig } from '../core/mihomoApi'
|
|||||||
import { quitWithoutCore, restartCore } from '../core/manager'
|
import { quitWithoutCore, restartCore } from '../core/manager'
|
||||||
import i18next from '../../shared/i18n'
|
import i18next from '../../shared/i18n'
|
||||||
import { floatingWindow, triggerFloatingWindow } from './floatingWindow'
|
import { floatingWindow, triggerFloatingWindow } from './floatingWindow'
|
||||||
import { updateTrayIcon } from './tray'
|
import { copyEnv, updateTrayIcon } from './tray'
|
||||||
|
|
||||||
export async function registerShortcut(
|
export async function registerShortcut(
|
||||||
oldShortcut: string,
|
oldShortcut: string,
|
||||||
@ -133,6 +133,15 @@ export async function registerShortcut(
|
|||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
case 'copyEnvShortcut': {
|
||||||
|
return globalShortcut.register(newShortcut, async () => {
|
||||||
|
const shellType = process.platform === 'win32' ? 'powershell' : 'bash'
|
||||||
|
await copyEnv(shellType)
|
||||||
|
new Notification({
|
||||||
|
title: i18next.t('common.notification.copyEnvSuccess')
|
||||||
|
}).show()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw new Error('Unknown action')
|
throw new Error('Unknown action')
|
||||||
}
|
}
|
||||||
@ -147,7 +156,8 @@ export async function initShortcut(): Promise<void> {
|
|||||||
globalModeShortcut,
|
globalModeShortcut,
|
||||||
directModeShortcut,
|
directModeShortcut,
|
||||||
quitWithoutCoreShortcut,
|
quitWithoutCoreShortcut,
|
||||||
restartAppShortcut
|
restartAppShortcut,
|
||||||
|
copyEnvShortcut
|
||||||
} = await getAppConfig()
|
} = await getAppConfig()
|
||||||
if (showWindowShortcut) {
|
if (showWindowShortcut) {
|
||||||
try {
|
try {
|
||||||
@ -212,4 +222,11 @@ export async function initShortcut(): Promise<void> {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (copyEnvShortcut) {
|
||||||
|
try {
|
||||||
|
await registerShortcut('', copyEnvShortcut, 'copyEnvShortcut')
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,8 @@ const ShortcutConfig: React.FC = () => {
|
|||||||
globalModeShortcut = '',
|
globalModeShortcut = '',
|
||||||
directModeShortcut = '',
|
directModeShortcut = '',
|
||||||
quitWithoutCoreShortcut = '',
|
quitWithoutCoreShortcut = '',
|
||||||
restartAppShortcut = ''
|
restartAppShortcut = '',
|
||||||
|
copyEnvShortcut = ''
|
||||||
} = appConfig || {}
|
} = appConfig || {}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -130,7 +131,7 @@ const ShortcutConfig: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem title={t('shortcuts.restartApp')}>
|
<SettingItem title={t('shortcuts.restartApp')} divider>
|
||||||
<div className="flex justify-end w-[60%]">
|
<div className="flex justify-end w-[60%]">
|
||||||
<ShortcutInput
|
<ShortcutInput
|
||||||
value={restartAppShortcut}
|
value={restartAppShortcut}
|
||||||
@ -139,6 +140,15 @@ const ShortcutConfig: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
<SettingItem title={t('shortcuts.copyEnv')}>
|
||||||
|
<div className="flex justify-end w-[60%]">
|
||||||
|
<ShortcutInput
|
||||||
|
value={copyEnvShortcut}
|
||||||
|
patchAppConfig={patchAppConfig}
|
||||||
|
action="copyEnvShortcut"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</SettingItem>
|
||||||
</SettingCard>
|
</SettingCard>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
"common.notification.restartRequired": "Restart required for changes to take effect",
|
"common.notification.restartRequired": "Restart required for changes to take effect",
|
||||||
"common.notification.systemProxyEnabled": "System proxy enabled",
|
"common.notification.systemProxyEnabled": "System proxy enabled",
|
||||||
"common.notification.systemProxyDisabled": "System proxy disabled",
|
"common.notification.systemProxyDisabled": "System proxy disabled",
|
||||||
|
"common.notification.copyEnvSuccess": "Shell env command copied",
|
||||||
"common.notification.tunEnabled": "TUN enabled",
|
"common.notification.tunEnabled": "TUN enabled",
|
||||||
"common.notification.tunDisabled": "TUN disabled",
|
"common.notification.tunDisabled": "TUN disabled",
|
||||||
"common.notification.ruleMode": "Rule Mode",
|
"common.notification.ruleMode": "Rule Mode",
|
||||||
@ -294,6 +295,7 @@
|
|||||||
"shortcuts.toggleDirectMode": "Toggle Direct Mode",
|
"shortcuts.toggleDirectMode": "Toggle Direct Mode",
|
||||||
"shortcuts.toggleLightMode": "Toggle Light Mode",
|
"shortcuts.toggleLightMode": "Toggle Light Mode",
|
||||||
"shortcuts.restartApp": "Restart App",
|
"shortcuts.restartApp": "Restart App",
|
||||||
|
"shortcuts.copyEnv": "Copy Shell Env Command",
|
||||||
"shortcuts.input.placeholder": "Click to input shortcut",
|
"shortcuts.input.placeholder": "Click to input shortcut",
|
||||||
"sider.title": "Sidebar Settings",
|
"sider.title": "Sidebar Settings",
|
||||||
"sider.cards.systemProxy": "Sys Proxy",
|
"sider.cards.systemProxy": "Sys Proxy",
|
||||||
@ -471,7 +473,7 @@
|
|||||||
"dns.customHosts.title": "Custom Hosts",
|
"dns.customHosts.title": "Custom Hosts",
|
||||||
"dns.customHosts.list": "Hosts List",
|
"dns.customHosts.list": "Hosts List",
|
||||||
"dns.customHosts.domainPlaceholder": "Domain",
|
"dns.customHosts.domainPlaceholder": "Domain",
|
||||||
"dns.customHosts.valuePlaceholder": "Domain or IP",
|
"dns.customHosts.valuePlaceholder": "Domain or IP, separate multiple with commas",
|
||||||
"dns.saveOnly": "Save Only",
|
"dns.saveOnly": "Save Only",
|
||||||
"profiles.title": "Profile Management",
|
"profiles.title": "Profile Management",
|
||||||
"profiles.input.placeholder": "Enter your subscription URL",
|
"profiles.input.placeholder": "Enter your subscription URL",
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
"common.notification.restartRequired": "برای اعمال تغییرات نیاز به راهاندازی مجدد است",
|
"common.notification.restartRequired": "برای اعمال تغییرات نیاز به راهاندازی مجدد است",
|
||||||
"common.notification.systemProxyEnabled": "پراکسی سیستم فعال شد",
|
"common.notification.systemProxyEnabled": "پراکسی سیستم فعال شد",
|
||||||
"common.notification.systemProxyDisabled": "پراکسی سیستم غیرفعال شد",
|
"common.notification.systemProxyDisabled": "پراکسی سیستم غیرفعال شد",
|
||||||
|
"common.notification.copyEnvSuccess": "دستور محیطی کپی شد",
|
||||||
"common.notification.tunEnabled": "TUN فعال شد",
|
"common.notification.tunEnabled": "TUN فعال شد",
|
||||||
"common.notification.tunDisabled": "TUN غیرفعال شد",
|
"common.notification.tunDisabled": "TUN غیرفعال شد",
|
||||||
"common.notification.ruleMode": "حالت قانون",
|
"common.notification.ruleMode": "حالت قانون",
|
||||||
@ -269,6 +270,7 @@
|
|||||||
"shortcuts.toggleDirectMode": "تغییر وضعیت حالت مستقیم",
|
"shortcuts.toggleDirectMode": "تغییر وضعیت حالت مستقیم",
|
||||||
"shortcuts.toggleLightMode": "تغییر وضعیت حالت روشن",
|
"shortcuts.toggleLightMode": "تغییر وضعیت حالت روشن",
|
||||||
"shortcuts.restartApp": "راهاندازی مجدد برنامه",
|
"shortcuts.restartApp": "راهاندازی مجدد برنامه",
|
||||||
|
"shortcuts.copyEnv": "کپی دستور محیطی",
|
||||||
"shortcuts.input.placeholder": "برای ورود میانبر کلیک کنید",
|
"shortcuts.input.placeholder": "برای ورود میانبر کلیک کنید",
|
||||||
"sider.title": "تنظیمات نوار کناری",
|
"sider.title": "تنظیمات نوار کناری",
|
||||||
"sider.cards.systemProxy": "پراکسی سیستم",
|
"sider.cards.systemProxy": "پراکسی سیستم",
|
||||||
@ -443,7 +445,7 @@
|
|||||||
"dns.customHosts.title": "Hosts سفارشی",
|
"dns.customHosts.title": "Hosts سفارشی",
|
||||||
"dns.customHosts.list": "لیست Hosts",
|
"dns.customHosts.list": "لیست Hosts",
|
||||||
"dns.customHosts.domainPlaceholder": "دامنه",
|
"dns.customHosts.domainPlaceholder": "دامنه",
|
||||||
"dns.customHosts.valuePlaceholder": "دامنه یا IP",
|
"dns.customHosts.valuePlaceholder": "دامنه یا IP، چندین مورد با کاما جدا کنید",
|
||||||
"dns.saveOnly": "فقط ذخیره",
|
"dns.saveOnly": "فقط ذخیره",
|
||||||
"profiles.title": "مدیریت پروفایل",
|
"profiles.title": "مدیریت پروفایل",
|
||||||
"profiles.input.placeholder": "آدرس اشتراک خود را وارد کنید",
|
"profiles.input.placeholder": "آدرس اشتراک خود را وارد کنید",
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
"common.notification.restartRequired": "Требуется перезапуск для применения изменений",
|
"common.notification.restartRequired": "Требуется перезапуск для применения изменений",
|
||||||
"common.notification.systemProxyEnabled": "Системный прокси включен",
|
"common.notification.systemProxyEnabled": "Системный прокси включен",
|
||||||
"common.notification.systemProxyDisabled": "Системный прокси отключен",
|
"common.notification.systemProxyDisabled": "Системный прокси отключен",
|
||||||
|
"common.notification.copyEnvSuccess": "Команда env скопирована",
|
||||||
"common.notification.tunEnabled": "TUN включен",
|
"common.notification.tunEnabled": "TUN включен",
|
||||||
"common.notification.tunDisabled": "TUN отключен",
|
"common.notification.tunDisabled": "TUN отключен",
|
||||||
"common.notification.ruleMode": "Правило",
|
"common.notification.ruleMode": "Правило",
|
||||||
@ -271,6 +272,7 @@
|
|||||||
"shortcuts.toggleDirectMode": "Переключить прямое подключение",
|
"shortcuts.toggleDirectMode": "Переключить прямое подключение",
|
||||||
"shortcuts.toggleLightMode": "Переключить облегченный режим",
|
"shortcuts.toggleLightMode": "Переключить облегченный режим",
|
||||||
"shortcuts.restartApp": "Перезапустить приложение",
|
"shortcuts.restartApp": "Перезапустить приложение",
|
||||||
|
"shortcuts.copyEnv": "Копировать команду env",
|
||||||
"shortcuts.input.placeholder": "Нажмите для ввода комбинации",
|
"shortcuts.input.placeholder": "Нажмите для ввода комбинации",
|
||||||
"sider.title": "Настройки боковой панели",
|
"sider.title": "Настройки боковой панели",
|
||||||
"sider.cards.systemProxy": "Системный прокси",
|
"sider.cards.systemProxy": "Системный прокси",
|
||||||
@ -445,7 +447,7 @@
|
|||||||
"dns.customHosts.title": "Пользовательский Hosts",
|
"dns.customHosts.title": "Пользовательский Hosts",
|
||||||
"dns.customHosts.list": "Список Hosts",
|
"dns.customHosts.list": "Список Hosts",
|
||||||
"dns.customHosts.domainPlaceholder": "Домен",
|
"dns.customHosts.domainPlaceholder": "Домен",
|
||||||
"dns.customHosts.valuePlaceholder": "Домен или IP",
|
"dns.customHosts.valuePlaceholder": "Домен или IP, несколько через запятую",
|
||||||
"dns.saveOnly": "Только сохранить",
|
"dns.saveOnly": "Только сохранить",
|
||||||
"profiles.title": "Управление профилями",
|
"profiles.title": "Управление профилями",
|
||||||
"profiles.input.placeholder": "Введите URL вашей подписки",
|
"profiles.input.placeholder": "Введите URL вашей подписки",
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
"common.notification.restartRequired": "需要重启应用以使更改生效",
|
"common.notification.restartRequired": "需要重启应用以使更改生效",
|
||||||
"common.notification.systemProxyEnabled": "系统代理已启用",
|
"common.notification.systemProxyEnabled": "系统代理已启用",
|
||||||
"common.notification.systemProxyDisabled": "系统代理已关闭",
|
"common.notification.systemProxyDisabled": "系统代理已关闭",
|
||||||
|
"common.notification.copyEnvSuccess": "命令行命令已复制",
|
||||||
"common.notification.tunEnabled": "TUN 已启用",
|
"common.notification.tunEnabled": "TUN 已启用",
|
||||||
"common.notification.tunDisabled": "TUN 已关闭",
|
"common.notification.tunDisabled": "TUN 已关闭",
|
||||||
"common.notification.ruleMode": "规则模式",
|
"common.notification.ruleMode": "规则模式",
|
||||||
@ -294,6 +295,7 @@
|
|||||||
"shortcuts.toggleDirectMode": "切换直连模式",
|
"shortcuts.toggleDirectMode": "切换直连模式",
|
||||||
"shortcuts.toggleLightMode": "切换轻量模式",
|
"shortcuts.toggleLightMode": "切换轻量模式",
|
||||||
"shortcuts.restartApp": "重启应用",
|
"shortcuts.restartApp": "重启应用",
|
||||||
|
"shortcuts.copyEnv": "复制命令行命令",
|
||||||
"shortcuts.input.placeholder": "点击输入快捷键",
|
"shortcuts.input.placeholder": "点击输入快捷键",
|
||||||
"sider.title": "侧边栏设置",
|
"sider.title": "侧边栏设置",
|
||||||
"sider.cards.systemProxy": "系统代理",
|
"sider.cards.systemProxy": "系统代理",
|
||||||
@ -462,7 +464,7 @@
|
|||||||
"dns.customHosts.title": "自定义 Hosts",
|
"dns.customHosts.title": "自定义 Hosts",
|
||||||
"dns.customHosts.list": "Hosts 列表",
|
"dns.customHosts.list": "Hosts 列表",
|
||||||
"dns.customHosts.domainPlaceholder": "域名",
|
"dns.customHosts.domainPlaceholder": "域名",
|
||||||
"dns.customHosts.valuePlaceholder": "域名或 IP",
|
"dns.customHosts.valuePlaceholder": "域名或 IP,多个用逗号分隔",
|
||||||
"dns.fallback": "回退服务器",
|
"dns.fallback": "回退服务器",
|
||||||
"dns.fallbackPlaceholder": "例:https://dns.alidns.com/dns-query",
|
"dns.fallbackPlaceholder": "例:https://dns.alidns.com/dns-query",
|
||||||
"dns.fallbackFilter.title": "回退过滤设置",
|
"dns.fallbackFilter.title": "回退过滤设置",
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
"common.notification.restartRequired": "需要重新啟動應用以使更改生效",
|
"common.notification.restartRequired": "需要重新啟動應用以使更改生效",
|
||||||
"common.notification.systemProxyEnabled": "系統代理已啟用",
|
"common.notification.systemProxyEnabled": "系統代理已啟用",
|
||||||
"common.notification.systemProxyDisabled": "系統代理已關閉",
|
"common.notification.systemProxyDisabled": "系統代理已關閉",
|
||||||
|
"common.notification.copyEnvSuccess": "命令行命令已複製",
|
||||||
"common.notification.tunEnabled": "TUN 已啟用",
|
"common.notification.tunEnabled": "TUN 已啟用",
|
||||||
"common.notification.tunDisabled": "TUN 已關閉",
|
"common.notification.tunDisabled": "TUN 已關閉",
|
||||||
"common.notification.ruleMode": "規則模式",
|
"common.notification.ruleMode": "規則模式",
|
||||||
@ -294,6 +295,7 @@
|
|||||||
"shortcuts.toggleDirectMode": "切換直連模式",
|
"shortcuts.toggleDirectMode": "切換直連模式",
|
||||||
"shortcuts.toggleLightMode": "切換輕量模式",
|
"shortcuts.toggleLightMode": "切換輕量模式",
|
||||||
"shortcuts.restartApp": "重啟應用",
|
"shortcuts.restartApp": "重啟應用",
|
||||||
|
"shortcuts.copyEnv": "複製命令行命令",
|
||||||
"shortcuts.input.placeholder": "點擊輸入快捷鍵",
|
"shortcuts.input.placeholder": "點擊輸入快捷鍵",
|
||||||
"sider.title": "側邊欄設置",
|
"sider.title": "側邊欄設置",
|
||||||
"sider.cards.systemProxy": "系統代理",
|
"sider.cards.systemProxy": "系統代理",
|
||||||
@ -462,7 +464,7 @@
|
|||||||
"dns.customHosts.title": "自定義 Hosts",
|
"dns.customHosts.title": "自定義 Hosts",
|
||||||
"dns.customHosts.list": "Hosts 列表",
|
"dns.customHosts.list": "Hosts 列表",
|
||||||
"dns.customHosts.domainPlaceholder": "域名",
|
"dns.customHosts.domainPlaceholder": "域名",
|
||||||
"dns.customHosts.valuePlaceholder": "域名或 IP",
|
"dns.customHosts.valuePlaceholder": "域名或 IP,多個用逗號分隔",
|
||||||
"dns.fallback": "回退伺服器",
|
"dns.fallback": "回退伺服器",
|
||||||
"dns.fallbackPlaceholder": "例:https://dns.alidns.com/dns-query",
|
"dns.fallbackPlaceholder": "例:https://dns.alidns.com/dns-query",
|
||||||
"dns.fallbackFilter.title": "回退過濾設置",
|
"dns.fallbackFilter.title": "回退過濾設置",
|
||||||
|
|||||||
@ -123,10 +123,11 @@ const DNS: React.FC = () => {
|
|||||||
|
|
||||||
const handleSubkeyChange = (type: string, domain: string, value: string, index: number): void => {
|
const handleSubkeyChange = (type: string, domain: string, value: string, index: number): void => {
|
||||||
const list = [...values[type]]
|
const list = [...values[type]]
|
||||||
const processedValue = value.includes(',')
|
const parts = value.split(',').map((s: string) => s.trim()).filter(Boolean)
|
||||||
? value.split(',').map((s: string) => s.trim())
|
const processedValue = type === 'hosts'
|
||||||
: value.trim()
|
? parts
|
||||||
if (domain || processedValue) list[index] = { domain: domain.trim(), value: processedValue }
|
: (parts.length > 1 ? parts : value.trim())
|
||||||
|
if (domain || parts.length > 0) list[index] = { domain: domain.trim(), value: processedValue }
|
||||||
else list.splice(index, 1)
|
else list.splice(index, 1)
|
||||||
setValues({ ...values, [type]: list })
|
setValues({ ...values, [type]: list })
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -338,6 +338,7 @@ interface IAppConfig {
|
|||||||
directModeShortcut?: string
|
directModeShortcut?: string
|
||||||
restartAppShortcut?: string
|
restartAppShortcut?: string
|
||||||
quitWithoutCoreShortcut?: string
|
quitWithoutCoreShortcut?: string
|
||||||
|
copyEnvShortcut?: string
|
||||||
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ru-RU' | 'fa-IR'
|
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ru-RU' | 'fa-IR'
|
||||||
triggerMainWindowBehavior?: 'show' | 'toggle'
|
triggerMainWindowBehavior?: 'show' | 'toggle'
|
||||||
showMixedPort?: number
|
showMixedPort?: number
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user