do not register quit app as global shortcuts
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run

This commit is contained in:
pompurin404 2024-08-21 07:51:50 +08:00
parent d9200962bf
commit 5ee45233a8
No known key found for this signature in database
4 changed files with 17 additions and 30 deletions

View File

@ -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
}
}
}

View File

@ -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[]

View File

@ -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>
)
}

View File

@ -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>