diff --git a/src/components/cstb/CommonDir.tsx b/src/components/cstb/CommonDir.tsx index e48e4b8..bc1c18a 100644 --- a/src/components/cstb/CommonDir.tsx +++ b/src/components/cstb/CommonDir.tsx @@ -1,6 +1,6 @@ +import { addToast } from "@heroui/react" import { FolderFocusOne } from "@icon-park/react" import { Card, CardBody, CardHeader, CardIcon } from "../window/Card" -import { addToast } from "@heroui/react" interface RoundedButtonProps { children?: React.ReactNode @@ -31,13 +31,55 @@ const CommonDir = () => {
- {alert("hello")}}>Steam安装位置 - {addToast({title: "CS2游戏目录"})}}>CS2游戏目录 - {addToast({title: "地图文件"})}}>地图文件 - {addToast({title: "游戏CFG目录"})}}>游戏CFG目录 - {addToast({title: "个人CFG目录"})}}>个人CFG目录 - {addToast({title: "完美平台录像"})}}>完美平台录像 - {addToast({title: "5E平台录像"})}}>5E平台录像 + { + alert("hello") + }} + > + Steam安装位置 + + { + addToast({ title: "CS2游戏目录" }) + }} + > + CS2游戏目录 + + { + addToast({ title: "地图文件" }) + }} + > + 地图文件 + + { + addToast({ title: "游戏CFG目录" }) + }} + > + 游戏CFG目录 + + { + addToast({ title: "个人CFG目录" }) + }} + > + 个人CFG目录 + + { + addToast({ title: "完美平台录像" }) + }} + > + 完美平台录像 + + { + addToast({ title: "5E平台录像" }) + }} + > + 5E平台录像 +
diff --git a/src/components/cstb/LaunchOption.tsx b/src/components/cstb/LaunchOption.tsx index c2b900f..8a90508 100644 --- a/src/components/cstb/LaunchOption.tsx +++ b/src/components/cstb/LaunchOption.tsx @@ -1,9 +1,14 @@ -import { addLaunchOption, setLaunchIndex, setLaunchOption, toolStore } from "@/store/tool" +import { + addLaunchOption, + setLaunchIndex, + setLaunchOption, + toolStore, +} from "@/store/tool" import { Plus, SettingConfig, Switch } from "@icon-park/react" +import { useEffect, useState } from "react" import { useSnapshot } from "valtio" import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card" import { ToolButton } from "../window/ToolButton" -import { useEffect, useState } from "react" const LaunchOption = () => { void toolStore.start() @@ -22,7 +27,7 @@ const LaunchOption = () => { {launchOptions.map((option, index) => ( - setLaunchIndex(index)}> + setLaunchIndex(index)}> {index + 1} ))} diff --git a/src/components/window/Nav.tsx b/src/components/window/Nav.tsx index 3c4fddf..237da41 100644 --- a/src/components/window/Nav.tsx +++ b/src/components/window/Nav.tsx @@ -1,4 +1,5 @@ "use client" +import { setTheme as setTauriTheme } from "@/hooks/tauri/theme" import { resetAppStore } from "@/store/app" import { resetToolStore } from "@/store/tool" import { addToast } from "@heroui/react" @@ -11,15 +12,18 @@ import { Square, SunOne, } from "@icon-park/react" -import { getCurrentWindow } from "@tauri-apps/api/window" +import { type Theme, 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 { usePathname, useRouter } from "next/navigation" import { saveAllNow } from "tauri-plugin-valtio" const Nav = () => { const { theme, setTheme } = useTheme() + const setAppTheme = async (theme: Theme) => { + setTheme(theme) + await setTauriTheme(theme) + } const close = async () => { // (await window.hideOnClose) ? getCurrent().hide() : exit(); @@ -79,7 +83,7 @@ const Nav = () => { type="button" className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 active:scale-95" onClick={() => - theme === "light" ? setTheme("dark") : setTheme("light") + theme === "light" ? setAppTheme("dark") : setAppTheme("light") } > {theme === "light" ? : } diff --git a/src/hooks/tauri/theme.ts b/src/hooks/tauri/theme.ts new file mode 100644 index 0000000..7fa0fce --- /dev/null +++ b/src/hooks/tauri/theme.ts @@ -0,0 +1,13 @@ +import { invoke } from "@tauri-apps/api/core" + +type Theme = "auto" | "light" | "dark" + +export async function getTheme() { + return invoke("plugin:theme|get_theme") +} + +export function setTheme(theme: Theme) { + return invoke("plugin:theme|set_theme", { + theme: theme, + }) +} diff --git a/src/store/tool.ts b/src/store/tool.ts index 7aeb388..eb2f3df 100644 --- a/src/store/tool.ts +++ b/src/store/tool.ts @@ -42,10 +42,7 @@ export const addLaunchOption = (option: string) => { if (toolStore.state.launchOptions.length >= 10) { return } - toolStore.state.launchOptions = [ - ...toolStore.state.launchOptions, - option, - ] + toolStore.state.launchOptions = [...toolStore.state.launchOptions, option] } export const resetToolStore = () => {