[feat] global watch dir and set better check logic

todo: first time check failed should let user manually click
This commit is contained in:
Purp1e
2025-03-21 02:42:49 +08:00
parent a9a48d2aba
commit c2c1a4c368
9 changed files with 99 additions and 60 deletions

View File

@@ -1,14 +1,27 @@
"use client"
import { steamStore } from "@/store/steam"
import { steamStore, useSteamStore } from "@/store/steam"
import { useEffect } from "react"
import "./globals.css"
import Providers from "./providers"
import { init } from "@/store"
import { useDebounce } from "@uidotdev/usehooks"
export default function RootLayout({ children }: { children: React.ReactNode }) {
useEffect(() => {
void init()
})
// 检测steam路径和游戏路径是否有效
const steam = useSteamStore()
const debounceSteamDir = useDebounce(steam.state.steamDir, 500)
const debounceCs2Dir = useDebounce(steam.state.cs2Dir, 500)
useEffect(() => {
steam.checkSteamDirValid()
}, [debounceSteamDir])
useEffect(() => {
steam.checkCs2DirValid()
}, [debounceCs2Dir])
return (
<html lang="en">
<body>