mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
feat: switch triggerMainWindow behavior
This commit is contained in:
parent
99a5505d16
commit
6832db788a
@ -434,10 +434,16 @@ export async function createWindow(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function triggerMainWindow(): void {
|
export function triggerMainWindow(): void {
|
||||||
if (mainWindow?.isVisible()) {
|
if (mainWindow) {
|
||||||
closeMainWindow()
|
getAppConfig()
|
||||||
} else {
|
.then(({ triggerMainWindowBehavior = 'show' }) => {
|
||||||
showMainWindow()
|
if (triggerMainWindowBehavior === 'toggle' && mainWindow?.isVisible()) {
|
||||||
|
closeMainWindow()
|
||||||
|
} else {
|
||||||
|
showMainWindow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(showMainWindow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,8 @@ export const defaultConfig: IAppConfig = {
|
|||||||
'substore'
|
'substore'
|
||||||
],
|
],
|
||||||
siderWidth: 250,
|
siderWidth: 250,
|
||||||
sysProxy: { enable: false, mode: 'manual' }
|
sysProxy: { enable: false, mode: 'manual' },
|
||||||
|
triggerMainWindowBehavior: 'show' // 添加默认值
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
|
export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
|
||||||
|
|||||||
@ -63,7 +63,8 @@ const GeneralConfig: React.FC = () => {
|
|||||||
envType = [platform === 'win32' ? 'powershell' : 'bash'],
|
envType = [platform === 'win32' ? 'powershell' : 'bash'],
|
||||||
autoCheckUpdate,
|
autoCheckUpdate,
|
||||||
appTheme = 'system',
|
appTheme = 'system',
|
||||||
language = 'zh-CN'
|
language = 'zh-CN',
|
||||||
|
triggerMainWindowBehavior = 'show' // 添加这一行
|
||||||
} = appConfig || {}
|
} = appConfig || {}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -398,6 +399,19 @@ const GeneralConfig: React.FC = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
<SettingItem title={t('settings.triggerMainWindowBehavior')} divider>
|
||||||
|
<Tabs
|
||||||
|
size="sm"
|
||||||
|
color="primary"
|
||||||
|
selectedKey={triggerMainWindowBehavior}
|
||||||
|
onSelectionChange={(key) => {
|
||||||
|
patchAppConfig({ triggerMainWindowBehavior: key as 'show' | 'toggle' })
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tab key="show" title={t('settings.triggerMainWindowBehaviorShow')} />
|
||||||
|
<Tab key="toggle" title={t('settings.triggerMainWindowBehaviorToggle')} />
|
||||||
|
</Tabs>
|
||||||
|
</SettingItem>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
title={t('settings.disableHardwareAcceleration')}
|
title={t('settings.disableHardwareAcceleration')}
|
||||||
actions={
|
actions={
|
||||||
|
|||||||
@ -71,6 +71,9 @@
|
|||||||
"settings.showTraffic_mac": "Show Network Speed in Status Bar",
|
"settings.showTraffic_mac": "Show Network Speed in Status Bar",
|
||||||
"settings.showDockIcon": "Show Dock Icon",
|
"settings.showDockIcon": "Show Dock Icon",
|
||||||
"settings.useWindowFrame": "Use System Title Bar",
|
"settings.useWindowFrame": "Use System Title Bar",
|
||||||
|
"settings.triggerMainWindowBehavior": "Window Trigger Behavior",
|
||||||
|
"settings.triggerMainWindowBehaviorShow": "Always Show",
|
||||||
|
"settings.triggerMainWindowBehaviorToggle": "Toggle Show/Hide",
|
||||||
"settings.disableHardwareAcceleration": "Disable Hardware Acceleration",
|
"settings.disableHardwareAcceleration": "Disable Hardware Acceleration",
|
||||||
"settings.disableHardwareAccelerationTooltip": "Disabling hardware acceleration can resolve rendering issues or crashes caused by graphics driver problems, but may reduce performance. Requires app restart to take effect",
|
"settings.disableHardwareAccelerationTooltip": "Disabling hardware acceleration can resolve rendering issues or crashes caused by graphics driver problems, but may reduce performance. Requires app restart to take effect",
|
||||||
"settings.hardwareAcceleration.confirm.title": "Confirm App Restart",
|
"settings.hardwareAcceleration.confirm.title": "Confirm App Restart",
|
||||||
|
|||||||
@ -71,6 +71,9 @@
|
|||||||
"settings.showTraffic_mac": "在状态栏显示网速",
|
"settings.showTraffic_mac": "在状态栏显示网速",
|
||||||
"settings.showDockIcon": "显示 Dock 图标",
|
"settings.showDockIcon": "显示 Dock 图标",
|
||||||
"settings.useWindowFrame": "使用系统标题栏",
|
"settings.useWindowFrame": "使用系统标题栏",
|
||||||
|
"settings.triggerMainWindowBehavior": "窗口触发行为",
|
||||||
|
"settings.triggerMainWindowBehaviorShow": "总是显示",
|
||||||
|
"settings.triggerMainWindowBehaviorToggle": "切换显示/隐藏",
|
||||||
"settings.disableHardwareAcceleration": "禁用硬件加速",
|
"settings.disableHardwareAcceleration": "禁用硬件加速",
|
||||||
"settings.disableHardwareAccelerationTooltip": "禁用硬件加速可以解决某些显卡驱动问题导致的渲染异常或崩溃,但可能会降低性能。修改后需要重启应用生效",
|
"settings.disableHardwareAccelerationTooltip": "禁用硬件加速可以解决某些显卡驱动问题导致的渲染异常或崩溃,但可能会降低性能。修改后需要重启应用生效",
|
||||||
"settings.hardwareAcceleration.confirm.title": "确认重启应用",
|
"settings.hardwareAcceleration.confirm.title": "确认重启应用",
|
||||||
|
|||||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -309,6 +309,7 @@ interface IAppConfig {
|
|||||||
restartAppShortcut?: string
|
restartAppShortcut?: string
|
||||||
quitWithoutCoreShortcut?: string
|
quitWithoutCoreShortcut?: string
|
||||||
language?: 'zh-CN' | 'en-US' | 'ru-RU' | 'fa-IR'
|
language?: 'zh-CN' | 'en-US' | 'ru-RU' | 'fa-IR'
|
||||||
|
triggerMainWindowBehavior?: 'show' | 'toggle'
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IMihomoTunConfig {
|
interface IMihomoTunConfig {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user