[fix] lint errors due to autostart frontend

This commit is contained in:
Purp1e
2025-03-23 23:29:15 +08:00
parent 6613174241
commit a3c7e688bb

View File

@@ -2,9 +2,15 @@
import { useAppStore } from "@/store/app"
import { Switch } from "@heroui/react"
import { enable, isEnabled, disable } from "@tauri-apps/plugin-autostart"
import { useEffect, useState } from "react"
export default function Page() {
const app = useAppStore()
const [autoStartEnabled, setAutoStartEnabled] = useState(false)
useEffect(() => {
void isEnabled().then(setAutoStartEnabled)
}, [])
return (
<div className="flex flex-col items-start gap-3 pt-2 pb-1">
@@ -12,13 +18,13 @@ export default function Page() {
<p>{app.state.hasUpdate ? "有" : "无"}</p>
<p>使{app.state.useMirror ? "是" : "否"}</p>
<Switch
// checked={() => isEnabled()}
checked={autoStartEnabled}
size="sm"
onChange={(e) => {
if (e.target.checked) {
enable()
void enable().then(() => setAutoStartEnabled(true))
} else {
disable()
void disable().then(() => setAutoStartEnabled(false))
}
}}
>