mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
fix: resolve titlebar overlay and controlled component warnings
This commit is contained in:
parent
a69d24b29c
commit
4a48445043
@ -213,7 +213,9 @@ export function registerIpcMainHandlers(): void {
|
|||||||
})
|
})
|
||||||
ipcMain.handle('setTitleBarOverlay', (_e, overlay) =>
|
ipcMain.handle('setTitleBarOverlay', (_e, overlay) =>
|
||||||
ipcErrorWrapper(async (overlay): Promise<void> => {
|
ipcErrorWrapper(async (overlay): Promise<void> => {
|
||||||
mainWindow?.setTitleBarOverlay(overlay)
|
if (mainWindow && typeof mainWindow.setTitleBarOverlay === 'function') {
|
||||||
|
mainWindow.setTitleBarOverlay(overlay)
|
||||||
|
}
|
||||||
})(overlay)
|
})(overlay)
|
||||||
)
|
)
|
||||||
ipcMain.handle('setAlwaysOnTop', (_e, alwaysOnTop) => {
|
ipcMain.handle('setAlwaysOnTop', (_e, alwaysOnTop) => {
|
||||||
|
|||||||
@ -2,12 +2,13 @@ import React from 'react'
|
|||||||
import { cn, Switch, SwitchProps } from '@heroui/react'
|
import { cn, Switch, SwitchProps } from '@heroui/react'
|
||||||
import './border-switch.css'
|
import './border-switch.css'
|
||||||
|
|
||||||
interface SiderSwitchProps extends SwitchProps {
|
interface BorderSwitchProps extends Omit<SwitchProps, 'isSelected'> {
|
||||||
isShowBorder?: boolean
|
isShowBorder?: boolean
|
||||||
|
isSelected?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const BorderSwitch: React.FC<SiderSwitchProps> = (props) => {
|
const BorderSwitch: React.FC<BorderSwitchProps> = (props) => {
|
||||||
const { isShowBorder = false, classNames, ...switchProps } = props
|
const { isShowBorder = false, isSelected = false, classNames, ...switchProps } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch
|
<Switch
|
||||||
@ -21,6 +22,7 @@ const BorderSwitch: React.FC<SiderSwitchProps> = (props) => {
|
|||||||
...classNames
|
...classNames
|
||||||
}}
|
}}
|
||||||
size="sm"
|
size="sm"
|
||||||
|
isSelected={isSelected}
|
||||||
{...switchProps}
|
{...switchProps}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -95,7 +95,7 @@ const SysproxySwitcher: React.FC<Props> = (props) => {
|
|||||||
</Button>
|
</Button>
|
||||||
<BorderSwitch
|
<BorderSwitch
|
||||||
isShowBorder={match && enable}
|
isShowBorder={match && enable}
|
||||||
isSelected={enable}
|
isSelected={enable ?? false}
|
||||||
onValueChange={onChange}
|
onValueChange={onChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -98,7 +98,7 @@ const TunSwitcher: React.FC<Props> = (props) => {
|
|||||||
</Button>
|
</Button>
|
||||||
<BorderSwitch
|
<BorderSwitch
|
||||||
isShowBorder={match && enable}
|
isShowBorder={match && enable}
|
||||||
isSelected={enable}
|
isSelected={enable ?? false}
|
||||||
onValueChange={onChange}
|
onValueChange={onChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -276,7 +276,11 @@ export async function webdavDelete(filename: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function setTitleBarOverlay(overlay: TitleBarOverlayOptions): Promise<void> {
|
export async function setTitleBarOverlay(overlay: TitleBarOverlayOptions): Promise<void> {
|
||||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('setTitleBarOverlay', overlay))
|
try {
|
||||||
|
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('setTitleBarOverlay', overlay))
|
||||||
|
} catch (error) {
|
||||||
|
console.debug('setTitleBarOverlay not supported on this platform')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setAlwaysOnTop(alwaysOnTop: boolean): Promise<void> {
|
export async function setAlwaysOnTop(alwaysOnTop: boolean): Promise<void> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user