mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-04-12 23:50:31 +08:00
feat: 新增全局快捷键 复制命令行命令
Co-authored-by: YangChengxxyy <yangc27@trip.com>
This commit is contained in:
parent
f8057746e4
commit
93d552870e
@ -11,7 +11,7 @@ import { patchMihomoConfig } from '../core/mihomoApi'
|
||||
import { quitWithoutCore, restartCore } from '../core/manager'
|
||||
import i18next from '../../shared/i18n'
|
||||
import { floatingWindow, triggerFloatingWindow } from './floatingWindow'
|
||||
import { updateTrayIcon } from './tray'
|
||||
import { copyEnv, updateTrayIcon } from './tray'
|
||||
|
||||
export async function registerShortcut(
|
||||
oldShortcut: string,
|
||||
@ -133,6 +133,15 @@ export async function registerShortcut(
|
||||
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')
|
||||
}
|
||||
@ -147,7 +156,8 @@ export async function initShortcut(): Promise<void> {
|
||||
globalModeShortcut,
|
||||
directModeShortcut,
|
||||
quitWithoutCoreShortcut,
|
||||
restartAppShortcut
|
||||
restartAppShortcut,
|
||||
copyEnvShortcut
|
||||
} = await getAppConfig()
|
||||
if (showWindowShortcut) {
|
||||
try {
|
||||
@ -212,4 +222,11 @@ export async function initShortcut(): Promise<void> {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (copyEnvShortcut) {
|
||||
try {
|
||||
await registerShortcut('', copyEnvShortcut, 'copyEnvShortcut')
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,8 @@ const ShortcutConfig: React.FC = () => {
|
||||
globalModeShortcut = '',
|
||||
directModeShortcut = '',
|
||||
quitWithoutCoreShortcut = '',
|
||||
restartAppShortcut = ''
|
||||
restartAppShortcut = '',
|
||||
copyEnvShortcut = ''
|
||||
} = appConfig || {}
|
||||
|
||||
return (
|
||||
@ -130,7 +131,7 @@ const ShortcutConfig: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
</SettingItem>
|
||||
<SettingItem title={t('shortcuts.restartApp')}>
|
||||
<SettingItem title={t('shortcuts.restartApp')} divider>
|
||||
<div className="flex justify-end w-[60%]">
|
||||
<ShortcutInput
|
||||
value={restartAppShortcut}
|
||||
@ -139,6 +140,15 @@ const ShortcutConfig: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
</SettingItem>
|
||||
<SettingItem title={t('shortcuts.copyEnv')}>
|
||||
<div className="flex justify-end w-[60%]">
|
||||
<ShortcutInput
|
||||
value={copyEnvShortcut}
|
||||
patchAppConfig={patchAppConfig}
|
||||
action="copyEnvShortcut"
|
||||
/>
|
||||
</div>
|
||||
</SettingItem>
|
||||
</SettingCard>
|
||||
)
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
"common.notification.restartRequired": "Restart required for changes to take effect",
|
||||
"common.notification.systemProxyEnabled": "System proxy enabled",
|
||||
"common.notification.systemProxyDisabled": "System proxy disabled",
|
||||
"common.notification.copyEnvSuccess": "Shell env command copied",
|
||||
"common.notification.tunEnabled": "TUN enabled",
|
||||
"common.notification.tunDisabled": "TUN disabled",
|
||||
"common.notification.ruleMode": "Rule Mode",
|
||||
@ -294,6 +295,7 @@
|
||||
"shortcuts.toggleDirectMode": "Toggle Direct Mode",
|
||||
"shortcuts.toggleLightMode": "Toggle Light Mode",
|
||||
"shortcuts.restartApp": "Restart App",
|
||||
"shortcuts.copyEnv": "Copy Shell Env Command",
|
||||
"shortcuts.input.placeholder": "Click to input shortcut",
|
||||
"sider.title": "Sidebar Settings",
|
||||
"sider.cards.systemProxy": "Sys Proxy",
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
"common.notification.restartRequired": "برای اعمال تغییرات نیاز به راهاندازی مجدد است",
|
||||
"common.notification.systemProxyEnabled": "پراکسی سیستم فعال شد",
|
||||
"common.notification.systemProxyDisabled": "پراکسی سیستم غیرفعال شد",
|
||||
"common.notification.copyEnvSuccess": "دستور محیطی کپی شد",
|
||||
"common.notification.tunEnabled": "TUN فعال شد",
|
||||
"common.notification.tunDisabled": "TUN غیرفعال شد",
|
||||
"common.notification.ruleMode": "حالت قانون",
|
||||
@ -269,6 +270,7 @@
|
||||
"shortcuts.toggleDirectMode": "تغییر وضعیت حالت مستقیم",
|
||||
"shortcuts.toggleLightMode": "تغییر وضعیت حالت روشن",
|
||||
"shortcuts.restartApp": "راهاندازی مجدد برنامه",
|
||||
"shortcuts.copyEnv": "کپی دستور محیطی",
|
||||
"shortcuts.input.placeholder": "برای ورود میانبر کلیک کنید",
|
||||
"sider.title": "تنظیمات نوار کناری",
|
||||
"sider.cards.systemProxy": "پراکسی سیستم",
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
"common.notification.restartRequired": "Требуется перезапуск для применения изменений",
|
||||
"common.notification.systemProxyEnabled": "Системный прокси включен",
|
||||
"common.notification.systemProxyDisabled": "Системный прокси отключен",
|
||||
"common.notification.copyEnvSuccess": "Команда env скопирована",
|
||||
"common.notification.tunEnabled": "TUN включен",
|
||||
"common.notification.tunDisabled": "TUN отключен",
|
||||
"common.notification.ruleMode": "Правило",
|
||||
@ -271,6 +272,7 @@
|
||||
"shortcuts.toggleDirectMode": "Переключить прямое подключение",
|
||||
"shortcuts.toggleLightMode": "Переключить облегченный режим",
|
||||
"shortcuts.restartApp": "Перезапустить приложение",
|
||||
"shortcuts.copyEnv": "Копировать команду env",
|
||||
"shortcuts.input.placeholder": "Нажмите для ввода комбинации",
|
||||
"sider.title": "Настройки боковой панели",
|
||||
"sider.cards.systemProxy": "Системный прокси",
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
"common.notification.restartRequired": "需要重启应用以使更改生效",
|
||||
"common.notification.systemProxyEnabled": "系统代理已启用",
|
||||
"common.notification.systemProxyDisabled": "系统代理已关闭",
|
||||
"common.notification.copyEnvSuccess": "命令行命令已复制",
|
||||
"common.notification.tunEnabled": "TUN 已启用",
|
||||
"common.notification.tunDisabled": "TUN 已关闭",
|
||||
"common.notification.ruleMode": "规则模式",
|
||||
@ -294,6 +295,7 @@
|
||||
"shortcuts.toggleDirectMode": "切换直连模式",
|
||||
"shortcuts.toggleLightMode": "切换轻量模式",
|
||||
"shortcuts.restartApp": "重启应用",
|
||||
"shortcuts.copyEnv": "复制命令行命令",
|
||||
"shortcuts.input.placeholder": "点击输入快捷键",
|
||||
"sider.title": "侧边栏设置",
|
||||
"sider.cards.systemProxy": "系统代理",
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
"common.notification.restartRequired": "需要重新啟動應用以使更改生效",
|
||||
"common.notification.systemProxyEnabled": "系統代理已啟用",
|
||||
"common.notification.systemProxyDisabled": "系統代理已關閉",
|
||||
"common.notification.copyEnvSuccess": "命令行命令已複製",
|
||||
"common.notification.tunEnabled": "TUN 已啟用",
|
||||
"common.notification.tunDisabled": "TUN 已關閉",
|
||||
"common.notification.ruleMode": "規則模式",
|
||||
@ -294,6 +295,7 @@
|
||||
"shortcuts.toggleDirectMode": "切換直連模式",
|
||||
"shortcuts.toggleLightMode": "切換輕量模式",
|
||||
"shortcuts.restartApp": "重啟應用",
|
||||
"shortcuts.copyEnv": "複製命令行命令",
|
||||
"shortcuts.input.placeholder": "點擊輸入快捷鍵",
|
||||
"sider.title": "側邊欄設置",
|
||||
"sider.cards.systemProxy": "系統代理",
|
||||
|
||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -338,6 +338,7 @@ interface IAppConfig {
|
||||
directModeShortcut?: string
|
||||
restartAppShortcut?: string
|
||||
quitWithoutCoreShortcut?: string
|
||||
copyEnvShortcut?: string
|
||||
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ru-RU' | 'fa-IR'
|
||||
triggerMainWindowBehavior?: 'show' | 'toggle'
|
||||
showMixedPort?: number
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user