2024-09-27 15:28:32 +08:00
|
|
|
|
"use client"
|
2025-11-08 18:09:35 +08:00
|
|
|
|
import { useEffect } from "react"
|
2025-03-17 11:48:30 +08:00
|
|
|
|
import { useAppStore } from "@/store/app"
|
2025-11-08 18:09:35 +08:00
|
|
|
|
import { Switch, Chip } from "@heroui/react"
|
2025-11-05 11:19:43 +08:00
|
|
|
|
import { UpdateChecker } from "@/components/cstb/UpdateChecker"
|
2025-11-08 18:09:35 +08:00
|
|
|
|
import { getVersion } from "@tauri-apps/api/app"
|
2024-09-27 15:28:32 +08:00
|
|
|
|
|
2024-10-28 10:42:42 +08:00
|
|
|
|
export default function Page() {
|
2025-03-17 11:48:30 +08:00
|
|
|
|
const app = useAppStore()
|
2024-09-27 15:28:32 +08:00
|
|
|
|
|
2025-11-08 18:09:35 +08:00
|
|
|
|
// 初始化版本号(如果还没有设置)
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (typeof window !== "undefined" && (!app.state.version || app.state.version === "0.0.1")) {
|
|
|
|
|
|
void getVersion().then((version) => {
|
|
|
|
|
|
app.setVersion(version)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
2025-11-05 11:19:43 +08:00
|
|
|
|
// 从环境变量或配置中获取更新服务器地址
|
|
|
|
|
|
const customEndpoint = process.env.NEXT_PUBLIC_UPDATE_ENDPOINT || ""
|
|
|
|
|
|
|
2024-09-27 15:28:32 +08:00
|
|
|
|
return (
|
2025-11-05 13:20:50 +08:00
|
|
|
|
<section className="flex flex-col gap-4 overflow-hidden">
|
|
|
|
|
|
<div className="flex flex-col items-start gap-4 pt-2 pb-1">
|
2025-11-05 11:19:43 +08:00
|
|
|
|
<div className="space-y-2">
|
2025-11-08 18:09:35 +08:00
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
|
<p className="text-sm">版本号:{app.state.version}</p>
|
|
|
|
|
|
{app.state.hasUpdate && app.state.latestVersion && (
|
|
|
|
|
|
<Chip size="sm" color="success" variant="flat">
|
|
|
|
|
|
{app.state.latestVersion}
|
|
|
|
|
|
</Chip>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{/* <p className="text-sm">是否有更新:{app.state.hasUpdate ? "有" : "无"}</p> */}
|
|
|
|
|
|
{/* <p className="text-sm">是否使用镜像源:{app.state.useMirror ? "是" : "否"}</p> */}
|
2025-11-05 11:19:43 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-08 18:09:35 +08:00
|
|
|
|
<div className="w-full pt-4 border-t border-zinc-200 dark:border-zinc-800">
|
2025-11-05 13:20:50 +08:00
|
|
|
|
<h3 className="mb-3 text-sm font-semibold">更新检查</h3>
|
2025-11-08 18:09:35 +08:00
|
|
|
|
<div className="mb-3 space-y-3">
|
|
|
|
|
|
{/* <Switch
|
|
|
|
|
|
isSelected={app.state.useMirror}
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
onChange={(e) => app.setUseMirror(e.target.checked)}
|
|
|
|
|
|
>
|
|
|
|
|
|
使用镜像源
|
|
|
|
|
|
</Switch> */}
|
|
|
|
|
|
{/* <p className="text-xs text-zinc-500">
|
|
|
|
|
|
{app.state.useMirror
|
|
|
|
|
|
? "使用自建更新服务检查更新"
|
|
|
|
|
|
: "使用 GitHub Release 检查更新"}
|
|
|
|
|
|
</p> */}
|
|
|
|
|
|
<Switch
|
|
|
|
|
|
isSelected={app.state.includePrerelease}
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
onChange={(e) => app.setIncludePrerelease(e.target.checked)}
|
|
|
|
|
|
>
|
|
|
|
|
|
包含测试版
|
|
|
|
|
|
</Switch>
|
|
|
|
|
|
<p className="text-xs text-zinc-500">
|
|
|
|
|
|
{app.state.includePrerelease
|
|
|
|
|
|
? "检查更新时会包含预发布版本(beta、alpha等)"
|
|
|
|
|
|
: "仅检查正式版本"}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<UpdateChecker
|
|
|
|
|
|
useMirror={app.state.useMirror}
|
|
|
|
|
|
customEndpoint={customEndpoint || undefined}
|
|
|
|
|
|
includePrerelease={app.state.includePrerelease}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2025-11-05 11:19:43 +08:00
|
|
|
|
|
2025-11-05 13:20:50 +08:00
|
|
|
|
<div className="flex flex-col w-full pt-4 space-y-3 border-t border-zinc-200 dark:border-zinc-800">
|
|
|
|
|
|
<h3 className="mb-3 text-sm font-semibold">启动设置</h3>
|
2025-11-05 11:19:43 +08:00
|
|
|
|
<Switch
|
|
|
|
|
|
isSelected={app.state.autoStart}
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
onChange={(e) => app.setAutoStart(e.target.checked)}
|
|
|
|
|
|
>
|
2025-11-05 13:20:50 +08:00
|
|
|
|
开机自启动
|
2025-11-05 11:19:43 +08:00
|
|
|
|
</Switch>
|
|
|
|
|
|
<Switch
|
|
|
|
|
|
isSelected={app.state.startHidden}
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
onChange={(e) => app.setStartHidden(e.target.checked)}
|
|
|
|
|
|
>
|
2025-11-05 13:20:50 +08:00
|
|
|
|
静默启动
|
2025-11-05 11:19:43 +08:00
|
|
|
|
</Switch>
|
|
|
|
|
|
<Switch
|
|
|
|
|
|
isSelected={app.state.hiddenOnClose}
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
onChange={(e) => app.setHiddenOnClose(e.target.checked)}
|
|
|
|
|
|
>
|
2025-11-05 13:20:50 +08:00
|
|
|
|
关闭时最小化到托盘
|
2025-11-05 11:19:43 +08:00
|
|
|
|
</Switch>
|
|
|
|
|
|
</div>
|
2025-11-05 13:20:50 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
2024-09-27 15:28:32 +08:00
|
|
|
|
)
|
2024-10-28 10:42:42 +08:00
|
|
|
|
}
|