From 91a003d0164310e95d34269a9568cd2a2bcc6b63 Mon Sep 17 00:00:00 2001 From: Purp1e <47248616+Purple-CSGO@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:16:25 +0800 Subject: [PATCH] [feat] adapt steam store + adjust dark mode styles --- src/app/(main)/preference/general/page.tsx | 8 +++++++- src/app/(main)/preference/path/page.tsx | 13 ++++++++++--- src/app/prepare/page.tsx | 15 +++++++++++---- src/app/providers.tsx | 2 +- src/components/cstb/CommonDir.tsx | 2 +- src/components/cstb/Notice.tsx | 6 ++++++ src/components/window/Card.tsx | 2 +- src/components/window/Nav.tsx | 3 ++- src/components/window/SideBar.tsx | 15 ++++++++++++--- 9 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/app/(main)/preference/general/page.tsx b/src/app/(main)/preference/general/page.tsx index aa92dcb..0db2888 100644 --- a/src/app/(main)/preference/general/page.tsx +++ b/src/app/(main)/preference/general/page.tsx @@ -1,12 +1,18 @@ "use client" import { appStore } from "@/store/app" +import { useEffect } from "react" import { useSnapshot } from "valtio" export default function Page() { + useEffect(() => { + ;async () => { + appStore.start() + } + }, []) const app = useSnapshot(appStore.state) return ( -
+

版本号:{app.version}

是否有更新:{app.hasUpdate ? "有" : "无"}

初始化:{app.inited ? "是" : "否"}

diff --git a/src/app/(main)/preference/path/page.tsx b/src/app/(main)/preference/path/page.tsx index de889b4..3df5a18 100644 --- a/src/app/(main)/preference/path/page.tsx +++ b/src/app/(main)/preference/path/page.tsx @@ -1,8 +1,15 @@ "use client" -import SteamStore from "@/store/steam" +import { currentUser, steamStore } from "@/store/steam" +import { useEffect } from "react" +import { useSnapshot } from "valtio" export default function Page() { - const steam = SteamStore() + useEffect(() => { + ;async () => { + steamStore.start() + } + }, []) + const steam = useSnapshot(steamStore.state) return (
@@ -10,7 +17,7 @@ export default function Page() {

游戏路径:{steam.csDir}

Steam路径有效:{steam.isDirValid ? "是" : "否"}

游戏路径有效:{steam.isCsDirValid ? "是" : "否"}

-

Steam账号:{steam.currentUser().accountName}

+

Steam账号:{currentUser().accountName}

) } diff --git a/src/app/prepare/page.tsx b/src/app/prepare/page.tsx index 339b6e0..3c933f8 100644 --- a/src/app/prepare/page.tsx +++ b/src/app/prepare/page.tsx @@ -1,8 +1,15 @@ "use client" -import useSteamStore from "@/store/steam" +import { steamStore, setDir, setCsDir, currentUser } from "@/store/steam" +import { useEffect } from "react" +import { useSnapshot } from "valtio" export default function Page() { - const { dir, setDir, csDir, setCsDir, currentUser } = useSteamStore() + useEffect(() => { + ;async () => { + steamStore.start() + } + }, []) + const steam = useSnapshot(steamStore.state) return (
setDir(e.target.value)} /> setCsDir(e.target.value)} /> diff --git a/src/app/providers.tsx b/src/app/providers.tsx index 46eb2b3..df47df3 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -6,7 +6,7 @@ import { ThemeProvider as NextThemesProvider } from "next-themes" export default function Providers({ children }: { children: React.ReactNode }) { return ( - + {children} diff --git a/src/components/cstb/CommonDir.tsx b/src/components/cstb/CommonDir.tsx index 8be9d35..e37f379 100644 --- a/src/components/cstb/CommonDir.tsx +++ b/src/components/cstb/CommonDir.tsx @@ -9,7 +9,7 @@ const RoundedButton = ({ children }: RoundedButtonProps) => { return ( diff --git a/src/components/cstb/Notice.tsx b/src/components/cstb/Notice.tsx index 0c8225d..63a812a 100644 --- a/src/components/cstb/Notice.tsx +++ b/src/components/cstb/Notice.tsx @@ -3,8 +3,14 @@ import { appStore } from "@/store/app" import { Refresh, VolumeNotice } from "@icon-park/react" import { ToolButton } from "../window/ToolButton" import { useSnapshot } from "valtio" +import { useEffect } from "react" const Notice = () => { + useEffect(() => { + ;async () => { + appStore.start() + } + }, []) appStore.start() const app = useSnapshot(appStore.state) diff --git a/src/components/window/Card.tsx b/src/components/window/Card.tsx index e286197..2eaaaac 100644 --- a/src/components/window/Card.tsx +++ b/src/components/window/Card.tsx @@ -51,7 +51,7 @@ const CardTool = ({ children }: CardProps) => { const CardBody = ({ children }: CardProps) => { return ( -
+
{children}
) diff --git a/src/components/window/Nav.tsx b/src/components/window/Nav.tsx index 33f9a01..4938309 100644 --- a/src/components/window/Nav.tsx +++ b/src/components/window/Nav.tsx @@ -50,7 +50,8 @@ const Nav = () => { resetToolStore() addToast({ title: "重置成功", - description: "已重置所有设置,请重新启动程序", + color: 'success' + // description: "已重置所有设置", }) }} > diff --git a/src/components/window/SideBar.tsx b/src/components/window/SideBar.tsx index fb58cf5..78b74c0 100644 --- a/src/components/window/SideBar.tsx +++ b/src/components/window/SideBar.tsx @@ -2,7 +2,7 @@ import { Home, MonitorOne, Movie, Setting, Terminal, Toolkit } from "@icon-park/react" import { Button, cn } from "@heroui/react" import { usePathname, useRouter } from "next/navigation" -import type { ReactNode } from "react" +import { useEffect, type ReactNode } from "react" // import { platform } from "@tauri-apps/plugin-os" import { appStore, setVersion } from "@/store/app" @@ -63,7 +63,11 @@ const Avatar = () => { } const SideBar = () => { - appStore.start() + useEffect(() => { + ;async () => { + appStore.start() + } + }, []) const { version } = useSnapshot(appStore.state) return ( @@ -104,7 +108,12 @@ const SideBar = () => {

版本号

-