mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50: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) =>
|
||||
ipcErrorWrapper(async (overlay): Promise<void> => {
|
||||
mainWindow?.setTitleBarOverlay(overlay)
|
||||
if (mainWindow && typeof mainWindow.setTitleBarOverlay === 'function') {
|
||||
mainWindow.setTitleBarOverlay(overlay)
|
||||
}
|
||||
})(overlay)
|
||||
)
|
||||
ipcMain.handle('setAlwaysOnTop', (_e, alwaysOnTop) => {
|
||||
|
||||
@ -2,12 +2,13 @@ import React from 'react'
|
||||
import { cn, Switch, SwitchProps } from '@heroui/react'
|
||||
import './border-switch.css'
|
||||
|
||||
interface SiderSwitchProps extends SwitchProps {
|
||||
interface BorderSwitchProps extends Omit<SwitchProps, 'isSelected'> {
|
||||
isShowBorder?: boolean
|
||||
isSelected?: boolean
|
||||
}
|
||||
|
||||
const BorderSwitch: React.FC<SiderSwitchProps> = (props) => {
|
||||
const { isShowBorder = false, classNames, ...switchProps } = props
|
||||
const BorderSwitch: React.FC<BorderSwitchProps> = (props) => {
|
||||
const { isShowBorder = false, isSelected = false, classNames, ...switchProps } = props
|
||||
|
||||
return (
|
||||
<Switch
|
||||
@ -21,6 +22,7 @@ const BorderSwitch: React.FC<SiderSwitchProps> = (props) => {
|
||||
...classNames
|
||||
}}
|
||||
size="sm"
|
||||
isSelected={isSelected}
|
||||
{...switchProps}
|
||||
/>
|
||||
)
|
||||
|
||||
@ -95,7 +95,7 @@ const SysproxySwitcher: React.FC<Props> = (props) => {
|
||||
</Button>
|
||||
<BorderSwitch
|
||||
isShowBorder={match && enable}
|
||||
isSelected={enable}
|
||||
isSelected={enable ?? false}
|
||||
onValueChange={onChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -98,7 +98,7 @@ const TunSwitcher: React.FC<Props> = (props) => {
|
||||
</Button>
|
||||
<BorderSwitch
|
||||
isShowBorder={match && enable}
|
||||
isSelected={enable}
|
||||
isSelected={enable ?? false}
|
||||
onValueChange={onChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -276,7 +276,11 @@ export async function webdavDelete(filename: string): 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> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user