mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
do not register quit app as global shortcuts
This commit is contained in:
parent
d9200962bf
commit
5ee45233a8
@ -86,11 +86,6 @@ export async function registerShortcut(
|
||||
app.quit()
|
||||
})
|
||||
}
|
||||
case 'quitAppShortcut': {
|
||||
return globalShortcut.register(newShortcut, () => {
|
||||
app.quit()
|
||||
})
|
||||
}
|
||||
}
|
||||
throw new Error('Unknown action')
|
||||
}
|
||||
@ -103,8 +98,7 @@ export async function initShortcut(): Promise<void> {
|
||||
ruleModeShortcut,
|
||||
globalModeShortcut,
|
||||
directModeShortcut,
|
||||
restartAppShortcut,
|
||||
quitAppShortcut
|
||||
restartAppShortcut
|
||||
} = await getAppConfig()
|
||||
if (showWindowShortcut) {
|
||||
try {
|
||||
@ -155,11 +149,4 @@ export async function initShortcut(): Promise<void> {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (quitAppShortcut) {
|
||||
try {
|
||||
await registerShortcut('', quitAppShortcut, 'quitAppShortcut')
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,8 +32,7 @@ const buildContextMenu = async (): Promise<Menu> => {
|
||||
ruleModeShortcut = '',
|
||||
globalModeShortcut = '',
|
||||
directModeShortcut = '',
|
||||
restartAppShortcut = '',
|
||||
quitAppShortcut = ''
|
||||
restartAppShortcut = ''
|
||||
} = await getAppConfig()
|
||||
let groupsMenu: Electron.MenuItemConstructorOptions[] = []
|
||||
if (proxyInTray && process.platform !== 'linux') {
|
||||
@ -209,7 +208,7 @@ const buildContextMenu = async (): Promise<Menu> => {
|
||||
id: 'quit',
|
||||
label: '退出应用',
|
||||
type: 'normal',
|
||||
accelerator: quitAppShortcut,
|
||||
accelerator: 'CommandOrControl+Q',
|
||||
click: (): void => app.quit()
|
||||
}
|
||||
] as Electron.MenuItemConstructorOptions[]
|
||||
|
||||
@ -48,8 +48,7 @@ const ShortcutConfig: React.FC = () => {
|
||||
ruleModeShortcut = '',
|
||||
globalModeShortcut = '',
|
||||
directModeShortcut = '',
|
||||
restartAppShortcut = '',
|
||||
quitAppShortcut = ''
|
||||
restartAppShortcut = ''
|
||||
} = appConfig || {}
|
||||
|
||||
return (
|
||||
@ -108,7 +107,7 @@ const ShortcutConfig: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
</SettingItem>
|
||||
<SettingItem title="重启应用" divider>
|
||||
<SettingItem title="重启应用">
|
||||
<div className="flex justify-end w-[60%]">
|
||||
<ShortcutInput
|
||||
value={restartAppShortcut}
|
||||
@ -117,15 +116,6 @@ const ShortcutConfig: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
</SettingItem>
|
||||
<SettingItem title="退出应用">
|
||||
<div className="flex justify-end w-[60%]">
|
||||
<ShortcutInput
|
||||
value={quitAppShortcut}
|
||||
patchAppConfig={patchAppConfig}
|
||||
action="quitAppShortcut"
|
||||
/>
|
||||
</div>
|
||||
</SettingItem>
|
||||
</SettingCard>
|
||||
)
|
||||
}
|
||||
|
||||
@ -3,12 +3,23 @@ import ReactDOM from 'react-dom/client'
|
||||
import { HashRouter } from 'react-router-dom'
|
||||
import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
||||
import { NextUIProvider } from '@nextui-org/react'
|
||||
import { init } from '@renderer/utils/init'
|
||||
import { init, platform } from '@renderer/utils/init'
|
||||
import '@renderer/assets/main.css'
|
||||
import App from '@renderer/App'
|
||||
import BaseErrorBoundary from './components/base/base-error-boundary'
|
||||
import { quitApp } from './utils/ipc'
|
||||
|
||||
init().then(() => {
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (platform !== 'darwin' && e.ctrlKey && e.key === 'q') {
|
||||
e.preventDefault()
|
||||
quitApp()
|
||||
}
|
||||
if (platform === 'darwin' && e.metaKey && e.key === 'q') {
|
||||
e.preventDefault()
|
||||
quitApp()
|
||||
}
|
||||
})
|
||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<NextUIProvider>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user