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()
|
app.quit()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
case 'quitAppShortcut': {
|
|
||||||
return globalShortcut.register(newShortcut, () => {
|
|
||||||
app.quit()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw new Error('Unknown action')
|
throw new Error('Unknown action')
|
||||||
}
|
}
|
||||||
@ -103,8 +98,7 @@ export async function initShortcut(): Promise<void> {
|
|||||||
ruleModeShortcut,
|
ruleModeShortcut,
|
||||||
globalModeShortcut,
|
globalModeShortcut,
|
||||||
directModeShortcut,
|
directModeShortcut,
|
||||||
restartAppShortcut,
|
restartAppShortcut
|
||||||
quitAppShortcut
|
|
||||||
} = await getAppConfig()
|
} = await getAppConfig()
|
||||||
if (showWindowShortcut) {
|
if (showWindowShortcut) {
|
||||||
try {
|
try {
|
||||||
@ -155,11 +149,4 @@ export async function initShortcut(): Promise<void> {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quitAppShortcut) {
|
|
||||||
try {
|
|
||||||
await registerShortcut('', quitAppShortcut, 'quitAppShortcut')
|
|
||||||
} catch {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,7 @@ const buildContextMenu = async (): Promise<Menu> => {
|
|||||||
ruleModeShortcut = '',
|
ruleModeShortcut = '',
|
||||||
globalModeShortcut = '',
|
globalModeShortcut = '',
|
||||||
directModeShortcut = '',
|
directModeShortcut = '',
|
||||||
restartAppShortcut = '',
|
restartAppShortcut = ''
|
||||||
quitAppShortcut = ''
|
|
||||||
} = await getAppConfig()
|
} = await getAppConfig()
|
||||||
let groupsMenu: Electron.MenuItemConstructorOptions[] = []
|
let groupsMenu: Electron.MenuItemConstructorOptions[] = []
|
||||||
if (proxyInTray && process.platform !== 'linux') {
|
if (proxyInTray && process.platform !== 'linux') {
|
||||||
@ -209,7 +208,7 @@ const buildContextMenu = async (): Promise<Menu> => {
|
|||||||
id: 'quit',
|
id: 'quit',
|
||||||
label: '退出应用',
|
label: '退出应用',
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
accelerator: quitAppShortcut,
|
accelerator: 'CommandOrControl+Q',
|
||||||
click: (): void => app.quit()
|
click: (): void => app.quit()
|
||||||
}
|
}
|
||||||
] as Electron.MenuItemConstructorOptions[]
|
] as Electron.MenuItemConstructorOptions[]
|
||||||
|
|||||||
@ -48,8 +48,7 @@ const ShortcutConfig: React.FC = () => {
|
|||||||
ruleModeShortcut = '',
|
ruleModeShortcut = '',
|
||||||
globalModeShortcut = '',
|
globalModeShortcut = '',
|
||||||
directModeShortcut = '',
|
directModeShortcut = '',
|
||||||
restartAppShortcut = '',
|
restartAppShortcut = ''
|
||||||
quitAppShortcut = ''
|
|
||||||
} = appConfig || {}
|
} = appConfig || {}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -108,7 +107,7 @@ const ShortcutConfig: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem title="重启应用" divider>
|
<SettingItem title="重启应用">
|
||||||
<div className="flex justify-end w-[60%]">
|
<div className="flex justify-end w-[60%]">
|
||||||
<ShortcutInput
|
<ShortcutInput
|
||||||
value={restartAppShortcut}
|
value={restartAppShortcut}
|
||||||
@ -117,15 +116,6 @@ const ShortcutConfig: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem title="退出应用">
|
|
||||||
<div className="flex justify-end w-[60%]">
|
|
||||||
<ShortcutInput
|
|
||||||
value={quitAppShortcut}
|
|
||||||
patchAppConfig={patchAppConfig}
|
|
||||||
action="quitAppShortcut"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</SettingItem>
|
|
||||||
</SettingCard>
|
</SettingCard>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,23 @@ import ReactDOM from 'react-dom/client'
|
|||||||
import { HashRouter } from 'react-router-dom'
|
import { HashRouter } from 'react-router-dom'
|
||||||
import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
||||||
import { NextUIProvider } from '@nextui-org/react'
|
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 '@renderer/assets/main.css'
|
||||||
import App from '@renderer/App'
|
import App from '@renderer/App'
|
||||||
import BaseErrorBoundary from './components/base/base-error-boundary'
|
import BaseErrorBoundary from './components/base/base-error-boundary'
|
||||||
|
import { quitApp } from './utils/ipc'
|
||||||
|
|
||||||
init().then(() => {
|
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(
|
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<NextUIProvider>
|
<NextUIProvider>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user