diff --git a/src/app/(main)/preference/layout.tsx b/src/app/(main)/preference/layout.tsx
index d4e3453..7e9958f 100644
--- a/src/app/(main)/preference/layout.tsx
+++ b/src/app/(main)/preference/layout.tsx
@@ -1,12 +1,26 @@
"use client"
-import { Card, CardHeader, CardIcon, CardTool, CardBody } from "@/components/window/Card"
+import {
+ Card,
+ CardBody,
+ CardHeader,
+ CardIcon,
+ CardTool,
+} from "@/components/window/Card"
import { ToolButton } from "@/components/window/ToolButton"
-import { SettingConfig, UploadOne, HardDisk, AssemblyLine, Videocamera } from "@icon-park/react"
-import clsx from "clsx"
+import { cn } from "@heroui/react"
+import {
+ AssemblyLine,
+ HardDisk,
+ SettingConfig,
+ UploadOne,
+ Videocamera,
+} from "@icon-park/react"
import { usePathname, useRouter } from "next/navigation"
// import { platform } from "@tauri-apps/plugin-os"
-export default function PreferenceLayout({ children }: { children: React.ReactNode }) {
+export default function PreferenceLayout({
+ children,
+}: { children: React.ReactNode }) {
const router = useRouter()
const pathname = usePathname()
@@ -16,21 +30,21 @@ export default function PreferenceLayout({ children }: { children: React.ReactNo
router.push("/preference/general")}
- className={clsx(pathname === "/preference/general" && "bg-white/60")}
+ className={cn(pathname === "/preference/general" && "bg-black/5")}
>
通用
router.push("/preference/path")}
- className={clsx(pathname === "/preference/path" && "bg-white/60")}
+ className={cn(pathname === "/preference/path" && "bg-black/5")}
>
路径
router.push("/preference/replay")}
- className={clsx(pathname === "/preference/replay" && "bg-white/60")}
+ className={cn(pathname === "/preference/replay" && "bg-black/5")}
>
录像
diff --git a/src/app/(main)/preference/path/page.tsx b/src/app/(main)/preference/path/page.tsx
index de889b4..3af57bb 100644
--- a/src/app/(main)/preference/path/page.tsx
+++ b/src/app/(main)/preference/path/page.tsx
@@ -1,8 +1,10 @@
"use client"
-import SteamStore from "@/store/steam"
+import { currentUser, steamStore } from "@/store/steam"
+import { useSnapshot } from "valtio"
export default function Page() {
- const steam = SteamStore()
+ void steamStore.start()
+ const steam = useSnapshot(steamStore.state)
return (
@@ -10,7 +12,7 @@ export default function Page() {
游戏路径:{steam.csDir}
Steam路径有效:{steam.isDirValid ? "是" : "否"}
游戏路径有效:{steam.isCsDirValid ? "是" : "否"}
-
Steam账号:{steam.currentUser().accountName}
+
Steam账号:{currentUser().accountName}
)
}
diff --git a/src/app/(main)/tool/page.tsx b/src/app/(main)/tool/page.tsx
index 4048311..92e52d0 100644
--- a/src/app/(main)/tool/page.tsx
+++ b/src/app/(main)/tool/page.tsx
@@ -1,3 +1,3 @@
export default function Page() {
- return
Tool
;
+ return
Tool
}
diff --git a/src/app/_app.tsx b/src/app/_app.tsx
deleted file mode 100644
index e5db131..0000000
--- a/src/app/_app.tsx
+++ /dev/null
@@ -1,8 +0,0 @@
-import "@/styles/globals.css"
-import type { AppProps } from "next/app"
-
-function MyApp({ Component, pageProps }: AppProps) {
- return
-}
-
-export default MyApp
diff --git a/src/app/globals.css b/src/app/globals.css
index 3d924d0..8c70949 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -8,10 +8,8 @@ body {
margin: 0;
width: 100%;
height: 100%;
- font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu,
- Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
- /* background: transparent; */
- background: rgba(242, 241, 243, 0.5);
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
+ Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
border-radius: 10px;
}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 7137574..4a25a88 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -1,10 +1,12 @@
-export const metadata = {
- title: "CS工具箱",
- description: "Generated by Next.js",
- icons: ["/favicon.ico"],
-};
+"use client"
+// export const metadata = {
+// title: "CS工具箱",
+// description: "Generated by Next.js",
+// icons: ["/favicon.ico"],
+// }
-import "./globals.css";
+import "./globals.css"
+import Providers from "./providers"
export default function RootLayout({
children,
@@ -13,7 +15,9 @@ export default function RootLayout({
}) {
return (
- {children}
+
+
{children}
+
)
}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 6d995d1..7771e75 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,20 +1,46 @@
-"use client";
+"use client"
-import { useRouter } from "next/navigation";
+import { open } from "@tauri-apps/plugin-dialog"
+import { useRouter } from "next/navigation"
+import React from "react"
const Home = () => {
- const router = useRouter();
+ const router = useRouter()
+ const [file, setFile] = React.useState
("")
+
+ const openFile = async () => {
+ const filePath = await open({
+ multiple: true,
+ directory: false,
+ })
+
+ setFile(filePath?.join("\n") || " ")
+ }
return (
- CS 工具箱
-
)
-};
+}
-export default Home;
+export default Home
diff --git a/src/app/prepare/layout.tsx b/src/app/prepare/layout.tsx
index c94cc93..caeaf30 100644
--- a/src/app/prepare/layout.tsx
+++ b/src/app/prepare/layout.tsx
@@ -1,6 +1,8 @@
import Nav from "@/components/window/Nav"
-export default function BaseLayout({ children }: { children: React.ReactNode }) {
+export default function BaseLayout({
+ children,
+}: { children: React.ReactNode }) {
return (
diff --git a/src/app/prepare/page.tsx b/src/app/prepare/page.tsx
index 2f56abc..e854e17 100644
--- a/src/app/prepare/page.tsx
+++ b/src/app/prepare/page.tsx
@@ -1,25 +1,29 @@
"use client"
-import useSteamStore from "@/store/steam"
+import { currentUser, setCsDir, setDir, steamStore } from "@/store/steam"
+import { useSnapshot } from "valtio"
export default function Page() {
- const { dir, setDir, csDir, setCsDir, currentUser } = useSteamStore()
+ void steamStore.start()
+ const steam = useSnapshot(steamStore.state)
return (
-
CS工具箱
+
+ CS工具箱
+
准备环节
setDir(e.target.value)}
/>
setCsDir(e.target.value)}
/>
diff --git a/src/app/providers.tsx b/src/app/providers.tsx
new file mode 100644
index 0000000..46eb2b3
--- /dev/null
+++ b/src/app/providers.tsx
@@ -0,0 +1,15 @@
+"use client"
+import { HeroUIProvider } from "@heroui/react"
+import { ToastProvider } from "@heroui/toast"
+import { ThemeProvider as NextThemesProvider } from "next-themes"
+
+export default function Providers({ children }: { children: React.ReactNode }) {
+ return (
+
+
+
+ {children}
+
+
+ )
+}
diff --git a/src/app/test/page.tsx b/src/app/test/page.tsx
index f1fc0ce..f2b8534 100644
--- a/src/app/test/page.tsx
+++ b/src/app/test/page.tsx
@@ -1,27 +1,27 @@
"use client"
-import { CardButton } from "@/components/test/CardButton";
-import { useGlobalShortcut } from "@/hooks/tauri/shortcuts";
-import { invoke } from "@tauri-apps/api/core";
-import { useCallback, useState } from "react";
+import { CardButton } from "@/components/test/CardButton"
+import { useGlobalShortcut } from "@/hooks/tauri/shortcuts"
+import { invoke } from "@tauri-apps/api/core"
+import { useCallback, useState } from "react"
export default function Page() {
const [buttonDesc, setButtonDesc] = useState
(
- "Waiting to be clicked. This calls 'on_button_clicked' from Rust."
- );
+ "Waiting to be clicked. This calls 'on_button_clicked' from Rust.",
+ )
const onButtonClick = () => {
invoke("on_button_clicked")
.then((value) => {
- setButtonDesc(value);
+ setButtonDesc(value)
})
.catch(() => {
- setButtonDesc("Failed to invoke Rust command 'on_button_clicked'");
- });
- };
+ setButtonDesc("Failed to invoke Rust command 'on_button_clicked'")
+ })
+ }
const shortcutHandler = useCallback(() => {
- console.log("Ctrl+P was pressed!");
- }, []);
- useGlobalShortcut("CommandOrControl+P", shortcutHandler);
+ console.log("Ctrl+P was pressed!")
+ }, [])
+ useGlobalShortcut("CommandOrControl+P", shortcutHandler)
return (
@@ -54,5 +54,5 @@ export default function Page() {
- );
+ )
}
diff --git a/src/components/cstb/CommonDir.tsx b/src/components/cstb/CommonDir.tsx
index 6e010aa..e37f379 100644
--- a/src/components/cstb/CommonDir.tsx
+++ b/src/components/cstb/CommonDir.tsx
@@ -1,17 +1,20 @@
-import { FolderFocusOne } from "@icon-park/react";
-import { Card, CardHeader, CardIcon, CardBody } from "../window/Card";
+import { FolderFocusOne } from "@icon-park/react"
+import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
interface RoundedButtonProps {
- children?: React.ReactNode;
+ children?: React.ReactNode
}
const RoundedButton = ({ children }: RoundedButtonProps) => {
return (
-
+
{children}
- );
-};
+ )
+}
const CommonDir = () => {
return (
@@ -33,7 +36,7 @@ const CommonDir = () => {
- );
-};
+ )
+}
-export default CommonDir;
+export default CommonDir
diff --git a/src/components/cstb/FastLaunch.tsx b/src/components/cstb/FastLaunch.tsx
index f808ae0..21b1a40 100644
--- a/src/components/cstb/FastLaunch.tsx
+++ b/src/components/cstb/FastLaunch.tsx
@@ -1,8 +1,17 @@
-import { TakeOff } from "@icon-park/react";
-import { Card, CardHeader, CardIcon, CardBody } from "../window/Card";
+import { steamStore } from "@/store/steam"
+import { toolStore } from "@/store/tool"
+import { TakeOff } from "@icon-park/react"
import { invoke } from "@tauri-apps/api/core"
+import { useSnapshot } from "valtio"
+import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
+// import { addToast } from "@heroui/react"
const FastLaunch = () => {
+ void toolStore.start()
+ void steamStore.start()
+ const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
+ const { dir } = useSnapshot(steamStore.state)
+
return (
@@ -13,26 +22,28 @@ const FastLaunch = () => {
invoke("launch_game", {
- // steamPath: steam.dir + "/steam.exe",
- // launchOption: launchOptions.value[launchIndex.value] || "",
+ steamPath: `${dir}/steam.exe`,
+ launchOption: launchOptions[launchIndex] || "",
server: "perfectworld",
})
}
- className="px-5 font-medium py-1.5 transition bg-red-200 rounded-full"
+ className="px-5 font-medium py-1.5 transition bg-red-200 dark:bg-red-900/60 rounded-full"
>
启动国服
invoke("launch_game", {
- // steamPath: steam.dir + "/steam.exe",
- // launchOption: launchOptions.value[launchIndex.value] || "",
+ steamPath: `${dir}/steam.exe`,
+ launchOption: launchOptions[launchIndex] || "",
server: "worldwide",
})
}
- className="px-5 font-medium py-1.5 transition bg-orange-200 rounded-full"
+ className="px-5 font-medium py-1.5 transition bg-orange-200 dark:bg-orange-900/60 rounded-full"
>
启动国际服
@@ -40,6 +51,6 @@ const FastLaunch = () => {
)
-};
+}
-export default FastLaunch;
+export default FastLaunch
diff --git a/src/components/cstb/ForceQuit.tsx b/src/components/cstb/ForceQuit.tsx
index f4d634b..55cc4ae 100644
--- a/src/components/cstb/ForceQuit.tsx
+++ b/src/components/cstb/ForceQuit.tsx
@@ -1,6 +1,6 @@
-import { Power } from "@icon-park/react";
-import { Card, CardHeader, CardIcon, CardBody } from "../window/Card";
-import { invoke } from "@tauri-apps/api/core";
+import { Power } from "@icon-park/react"
+import { invoke } from "@tauri-apps/api/core"
+import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
const ForceQuit = () => {
return (
@@ -12,12 +12,24 @@ const ForceQuit = () => {
- invoke("kill_steam")} className="px-5 font-medium py-1.5 transition bg-blue-200 rounded-full">关闭Steam
- invoke("kill_game")} className="px-5 font-medium py-1.5 transition bg-orange-200 rounded-full">关闭CS2
+ invoke("kill_steam")}
+ className="px-5 font-medium py-1.5 transition bg-blue-200 dark:bg-blue-900/60 rounded-full"
+ >
+ 关闭Steam
+
+ invoke("kill_game")}
+ className="px-5 font-medium py-1.5 transition bg-orange-200 dark:bg-orange-900/60 rounded-full"
+ >
+ 关闭CS2
+
- );
-};
+ )
+}
-export default ForceQuit;
+export default ForceQuit
diff --git a/src/components/cstb/LaunchOption.tsx b/src/components/cstb/LaunchOption.tsx
index c118f91..ca294a5 100644
--- a/src/components/cstb/LaunchOption.tsx
+++ b/src/components/cstb/LaunchOption.tsx
@@ -1,10 +1,12 @@
-import { Plus, SettingConfig, Switch } from "@icon-park/react";
-import { Card, CardHeader, CardIcon, CardTool, CardBody } from "../window/Card";
-import { ToolButton } from "../window/ToolButton";
-import useToolStore from "@/store/tool";
+import { setLaunchIndex, setLaunchOption, toolStore } from "@/store/tool"
+import { Plus, SettingConfig, Switch } from "@icon-park/react"
+import { useSnapshot } from "valtio"
+import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
+import { ToolButton } from "../window/ToolButton"
const LaunchOption = () => {
- const { launchOptions, setLaunchOption, launchIndex, setLaunchIndex } = useToolStore()
+ void toolStore.start()
+ const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
return (
@@ -29,13 +31,15 @@ const LaunchOption = () => {
- );
-};
+ )
+}
-export default LaunchOption;
+export default LaunchOption
diff --git a/src/components/cstb/Notice.tsx b/src/components/cstb/Notice.tsx
index d03271d..d1a8f82 100644
--- a/src/components/cstb/Notice.tsx
+++ b/src/components/cstb/Notice.tsx
@@ -1,16 +1,19 @@
-import { Refresh, VolumeNotice } from "@icon-park/react";
import {
+ Card,
+ CardBody,
CardHeader,
CardIcon,
CardTool,
- CardBody,
- Card,
-} from "@/components/window/Card";
-import { ToolButton } from "../window/ToolButton";
-import useAppStore from "@/store/app";
+} from "@/components/window/Card"
+import { appStore } from "@/store/app"
+import { Refresh, VolumeNotice } from "@icon-park/react"
+import { useSnapshot } from "valtio"
+import { ToolButton } from "../window/ToolButton"
const Notice = () => {
- const app = useAppStore();
+ void appStore.start()
+ const app = useSnapshot(appStore.state)
+
return (
@@ -24,9 +27,11 @@ const Notice = () => {
- {app.notice || "不会真的有人要更新CSGO工具箱吧,不会吧不会吧 xswl"}
+
+ {app.notice || "不会真的有人要更新CSGO工具箱吧,不会吧不会吧 xswl"}
+
)
-};
+}
-export default Notice;
+export default Notice
diff --git a/src/components/cstb/PowerPlan.tsx b/src/components/cstb/PowerPlan.tsx
index 8fdb9de..edc20f6 100644
--- a/src/components/cstb/PowerPlan.tsx
+++ b/src/components/cstb/PowerPlan.tsx
@@ -1,7 +1,7 @@
-import { BatteryCharge, Refresh } from "@icon-park/react";
-import { Card, CardHeader, CardIcon, CardTool, CardBody } from "../window/Card";
-import { ToolButton } from "../window/ToolButton";
-import { invoke } from "@tauri-apps/api/core";
+import { BatteryCharge, Refresh } from "@icon-park/react"
+import { invoke } from "@tauri-apps/api/core"
+import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
+import { ToolButton } from "../window/ToolButton"
const PowerPlan = () => {
return (
@@ -19,13 +19,31 @@ const PowerPlan = () => {
- invoke("set_power_plan", {index: 1})} className="flex-1 px-2 py-1 transition rounded-full bg-black/5">高性能
- invoke("set_power_plan", {index: 2})} className="flex-1 px-2 py-1 transition rounded-full">平衡
- invoke("set_power_plan", {index: 3})} className="flex-1 px-2 py-1 transition rounded-full">节能
+ invoke("set_power_plan", { index: 1 })}
+ className="flex-1 px-2 py-1 transition rounded-full bg-black/5"
+ >
+ 高性能
+
+ invoke("set_power_plan", { index: 2 })}
+ className="flex-1 px-2 py-1 transition rounded-full"
+ >
+ 平衡
+
+ invoke("set_power_plan", { index: 3 })}
+ className="flex-1 px-2 py-1 transition rounded-full"
+ >
+ 节能
+
- );
-};
+ )
+}
-export default PowerPlan;
+export default PowerPlan
diff --git a/src/components/cstb/SmartTranser.tsx b/src/components/cstb/SmartTranser.tsx
index ada0eeb..7db47d8 100644
--- a/src/components/cstb/SmartTranser.tsx
+++ b/src/components/cstb/SmartTranser.tsx
@@ -1,6 +1,6 @@
-import { FolderConversion, FolderPlus } from "@icon-park/react";
-import { Card, CardHeader, CardIcon, CardTool, CardBody } from "../window/Card";
-import { ToolButton } from "../window/ToolButton";
+import { FolderConversion, FolderPlus } from "@icon-park/react"
+import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
+import { ToolButton } from "../window/ToolButton"
const SmartTransfer = () => {
return (
@@ -22,7 +22,7 @@ const SmartTransfer = () => {
- );
-};
+ )
+}
-export default SmartTransfer;
+export default SmartTransfer
diff --git a/src/components/window/Card.tsx b/src/components/window/Card.tsx
index e76ff16..2eaaaac 100644
--- a/src/components/window/Card.tsx
+++ b/src/components/window/Card.tsx
@@ -1,5 +1,5 @@
-import { ReactNode } from "react"
-import clsx from "clsx"
+import { cn } from "@heroui/react"
+import type { ReactNode } from "react"
interface CardProps {
children?: ReactNode
@@ -11,7 +11,7 @@ interface CardProps {
const Card = ({ children }: CardProps) => {
return (
{children}
@@ -20,23 +20,41 @@ const Card = ({ children }: CardProps) => {
}
const CardHeader = ({ children }: CardProps) => {
- return
{children}
+ return (
+
{children}
+ )
}
const CardIcon = ({ children, type, className, ...rest }: CardProps) => {
return (
-
+
{children}
)
}
const CardTool = ({ children }: CardProps) => {
- return
{children}
+ return (
+
+ {children}
+
+ )
}
const CardBody = ({ children }: CardProps) => {
- return
{children}
+ return (
+
+ {children}
+
+ )
}
export { Card, CardHeader, CardIcon, CardTool, CardBody }
diff --git a/src/components/window/Header.tsx b/src/components/window/Header.tsx
index 9463f4c..fccdb28 100644
--- a/src/components/window/Header.tsx
+++ b/src/components/window/Header.tsx
@@ -8,7 +8,7 @@ const Header = () => {
本周使用CS工具箱 114 小时
- );
-};
+ )
+}
-export default Header;
+export default Header
diff --git a/src/components/window/Nav.tsx b/src/components/window/Nav.tsx
index c8296d3..8e14807 100644
--- a/src/components/window/Nav.tsx
+++ b/src/components/window/Nav.tsx
@@ -1,11 +1,25 @@
"use client"
-import { RocketOne, Minus, Close, Square } from "@icon-park/react"
-import { /* relaunch, */ exit } from "@tauri-apps/plugin-process"
+import { resetAppStore } from "@/store/app"
+import { resetToolStore } from "@/store/tool"
+import { addToast } from "@heroui/react"
+import {
+ Close,
+ Minus,
+ Moon,
+ Refresh,
+ RocketOne,
+ Square,
+ SunOne,
+} from "@icon-park/react"
import { getCurrentWindow } from "@tauri-apps/api/window"
+import { /* relaunch, */ exit } from "@tauri-apps/plugin-process"
+import { useTheme } from "next-themes"
// import { platform } from "@tauri-apps/plugin-os"
-import { useRouter, usePathname } from "next/navigation"
+import { usePathname, useRouter } from "next/navigation"
const Nav = () => {
+ const { theme, setTheme } = useTheme()
+
const close = async () => {
// (await window.hideOnClose) ? getCurrent().hide() : exit();
await exit()
@@ -35,35 +49,70 @@ const Nav = () => {
const pathname = usePathname()
return (
-