36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
"use client"
|
||
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">
|
||
<p>版本号:{app.state.version}</p>
|
||
<p>是否有更新:{app.state.hasUpdate ? "有" : "无"}</p>
|
||
<p>是否使用镜像源:{app.state.useMirror ? "是" : "否"}</p>
|
||
<Switch
|
||
checked={autoStartEnabled}
|
||
size="sm"
|
||
onChange={(e) => {
|
||
if (e.target.checked) {
|
||
void enable().then(() => setAutoStartEnabled(true))
|
||
} else {
|
||
void disable().then(() => setAutoStartEnabled(false))
|
||
}
|
||
}}
|
||
>
|
||
开机自启动
|
||
</Switch>
|
||
</div>
|
||
)
|
||
}
|