mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
Fix repeated reboots when useWindowFrame switch (#457)
- add debounce / statelock(isRelaunching) to avoid multiple restarts due to rapid consecutive clicks.
This commit is contained in:
parent
df7066a5f4
commit
749ac64698
@ -23,6 +23,7 @@ import {
|
|||||||
writeTheme
|
writeTheme
|
||||||
} from '@renderer/utils/ipc'
|
} from '@renderer/utils/ipc'
|
||||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||||
|
import debounce from '@renderer/utils/debounce'
|
||||||
import { platform } from '@renderer/utils/init'
|
import { platform } from '@renderer/utils/init'
|
||||||
import { useTheme } from 'next-themes'
|
import { useTheme } from 'next-themes'
|
||||||
import { IoIosHelpCircle, IoMdCloudDownload } from 'react-icons/io'
|
import { IoIosHelpCircle, IoMdCloudDownload } from 'react-icons/io'
|
||||||
@ -35,6 +36,7 @@ const GeneralConfig: React.FC = () => {
|
|||||||
const [customThemes, setCustomThemes] = useState<{ key: string; label: string }[]>()
|
const [customThemes, setCustomThemes] = useState<{ key: string; label: string }[]>()
|
||||||
const [openCSSEditor, setOpenCSSEditor] = useState(false)
|
const [openCSSEditor, setOpenCSSEditor] = useState(false)
|
||||||
const [fetching, setFetching] = useState(false)
|
const [fetching, setFetching] = useState(false)
|
||||||
|
const [isRelaunching, setIsRelaunching] = useState(false)
|
||||||
const { setTheme } = useTheme()
|
const { setTheme } = useTheme()
|
||||||
const {
|
const {
|
||||||
silentStart = false,
|
silentStart = false,
|
||||||
@ -270,10 +272,18 @@ const GeneralConfig: React.FC = () => {
|
|||||||
<Switch
|
<Switch
|
||||||
size="sm"
|
size="sm"
|
||||||
isSelected={useWindowFrame}
|
isSelected={useWindowFrame}
|
||||||
onValueChange={async (v) => {
|
isDisabled={isRelaunching}
|
||||||
await patchAppConfig({ useWindowFrame: v })
|
onValueChange={debounce(async (v) => {
|
||||||
await relaunchApp()
|
if (isRelaunching) return
|
||||||
}}
|
setIsRelaunching(true)
|
||||||
|
try {
|
||||||
|
await patchAppConfig({ useWindowFrame: v })
|
||||||
|
await relaunchApp()
|
||||||
|
} catch (e) {
|
||||||
|
alert(e)
|
||||||
|
setIsRelaunching(false)
|
||||||
|
}
|
||||||
|
}, 1000)}
|
||||||
/>
|
/>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem title="背景色" divider>
|
<SettingItem title="背景色" divider>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user