From 6803dffc21f5947b1b83350644f0902adae98f42 Mon Sep 17 00:00:00 2001
From: Purp1e <47248616+Purple-CSGO@users.noreply.github.com>
Date: Mon, 17 Mar 2025 01:17:35 +0800
Subject: [PATCH] [feat] basic path selection + common dir notification
---
src-tauri/gen/schemas/windows-schema.json | 25 +++++++++
src/app/(main)/console/cfgx/page.tsx | 10 ++--
src/app/(main)/console/layout.tsx | 2 +-
src/app/(main)/preference/layout.tsx | 2 +-
src/app/(main)/users/layout.tsx | 64 +++++++++++++++++++++++
src/components/cstb/CommonDir.tsx | 4 +-
src/components/cstb/Prepare.tsx | 10 ++--
src/components/cstb/SteamUsers.tsx | 24 +++++++++
src/components/window/Card.tsx | 7 ++-
src/components/window/Nav.tsx | 47 ++++++-----------
10 files changed, 150 insertions(+), 45 deletions(-)
create mode 100644 src/app/(main)/users/layout.tsx
create mode 100644 src/components/cstb/SteamUsers.tsx
diff --git a/src-tauri/gen/schemas/windows-schema.json b/src-tauri/gen/schemas/windows-schema.json
index bf054d0..b535d26 100644
--- a/src-tauri/gen/schemas/windows-schema.json
+++ b/src-tauri/gen/schemas/windows-schema.json
@@ -5924,6 +5924,31 @@
"type": "string",
"const": "system-info:deny-used-swap"
},
+ {
+ "description": "Allow all",
+ "type": "string",
+ "const": "theme:default"
+ },
+ {
+ "description": "Enables the get_theme command without any pre-configured scope.",
+ "type": "string",
+ "const": "theme:allow-get-theme"
+ },
+ {
+ "description": "Enables the set_theme command without any pre-configured scope.",
+ "type": "string",
+ "const": "theme:allow-set-theme"
+ },
+ {
+ "description": "Denies the get_theme command without any pre-configured scope.",
+ "type": "string",
+ "const": "theme:deny-get-theme"
+ },
+ {
+ "description": "Denies the set_theme command without any pre-configured scope.",
+ "type": "string",
+ "const": "theme:deny-set-theme"
+ },
{
"description": "Default permissions for tauri-plugin-valtio.",
"type": "string",
diff --git a/src/app/(main)/console/cfgx/page.tsx b/src/app/(main)/console/cfgx/page.tsx
index d1a56f1..38560f0 100644
--- a/src/app/(main)/console/cfgx/page.tsx
+++ b/src/app/(main)/console/cfgx/page.tsx
@@ -70,20 +70,20 @@ interface CfgxCardProps {
function CfgxCard(props: CfgxCardProps) {
return (
-
+
{props.title}
-
+
{props.version}
-
+
{props.author}
- {props.description}
+ {props.description}
{props.content}
{props.alias_list && (
-
+
{props.alias_list.id} {props.alias_list.info} {props.alias_list.value}
)}
diff --git a/src/app/(main)/console/layout.tsx b/src/app/(main)/console/layout.tsx
index 6189fbb..8ec77ed 100644
--- a/src/app/(main)/console/layout.tsx
+++ b/src/app/(main)/console/layout.tsx
@@ -11,7 +11,7 @@ export default function PreferenceLayout({
const pathname = usePathname()
return (
-
+
+
+
+
+ router.push("/preference/general")}
+ className={cn(pathname === "/preference/general" && "bg-black/5")}
+ >
+ 通用
+
+ router.push("/preference/path")}
+ className={cn(pathname === "/preference/path" && "bg-black/5")}
+ >
+ 路径
+
+
+
+
+
+ 云同步
+
+ {/*
+
+ 保存
+ */}
+
+
+ {children}
+
+ {/* Steam用户区域 */}
+
+
+ )
+}
diff --git a/src/components/cstb/CommonDir.tsx b/src/components/cstb/CommonDir.tsx
index bc1c18a..3095eaa 100644
--- a/src/components/cstb/CommonDir.tsx
+++ b/src/components/cstb/CommonDir.tsx
@@ -1,6 +1,7 @@
import { addToast } from "@heroui/react"
import { FolderFocusOne } from "@icon-park/react"
import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
+import { open } from "@tauri-apps/plugin-fs"
interface RoundedButtonProps {
children?: React.ReactNode
@@ -33,7 +34,8 @@ const CommonDir = () => {
{
- alert("hello")
+ // 调用 tauri api open steam.Dir
+ addToast({ title: "Steam安装位置" })
}}
>
Steam安装位置
diff --git a/src/components/cstb/Prepare.tsx b/src/components/cstb/Prepare.tsx
index d2c718d..a6be2b1 100644
--- a/src/components/cstb/Prepare.tsx
+++ b/src/components/cstb/Prepare.tsx
@@ -2,7 +2,7 @@ import { Button, Spinner } from "@heroui/react"
import { useRouter } from "next/navigation"
import React, { useEffect, useState } from "react"
import { useSnapshot } from "valtio"
-import { steamStore } from "@/store/steam"
+import { setCsDir, setDir, steamStore } from "@/store/steam"
import { open } from "@tauri-apps/plugin-dialog"
export function Prepare() {
@@ -31,18 +31,18 @@ export function Prepare() {
if (selected) {
const dir = selected.replace(/\\[^\\]+$/, "")
setSteamDir(dir)
- steamStore.state.dir = dir
+ setDir(dir)
}
}
const handleSelectCs2Dir = async () => {
const selected = await open({
- title: "选择 CS2 文件夹",
- directory: true,
+ title: "选择 CS2.exe 文件",
+ filters: [{ name: "Cs2", extensions: ["exe"] }],
})
if (selected) {
setCs2Dir(selected)
- steamStore.state.csDir = selected
+ setCsDir(selected)
}
}
diff --git a/src/components/cstb/SteamUsers.tsx b/src/components/cstb/SteamUsers.tsx
new file mode 100644
index 0000000..286b37f
--- /dev/null
+++ b/src/components/cstb/SteamUsers.tsx
@@ -0,0 +1,24 @@
+import { User } from "@icon-park/react"
+import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
+import { cn } from "@heroui/react"
+
+const SteamUsers = ({className}: {className?: string}) => {
+ return (
+
+
+
+ Steam用户
+
+
+
+
+
+
+ )
+}
+
+export default SteamUsers
\ No newline at end of file
diff --git a/src/components/window/Card.tsx b/src/components/window/Card.tsx
index d18c3fd..5877f8f 100644
--- a/src/components/window/Card.tsx
+++ b/src/components/window/Card.tsx
@@ -8,11 +8,14 @@ interface CardProps {
onClick?: () => void
}
-const Card = ({ children }: CardProps) => {
+const Card = ({ children, className, ...props }: CardProps) => {
return (
{children}
diff --git a/src/components/window/Nav.tsx b/src/components/window/Nav.tsx
index 237da41..5fbe105 100644
--- a/src/components/window/Nav.tsx
+++ b/src/components/window/Nav.tsx
@@ -3,15 +3,7 @@ import { setTheme as setTauriTheme } from "@/hooks/tauri/theme"
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 { Close, Minus, Moon, Refresh, RocketOne, Square, SunOne } from "@icon-park/react"
import { type Theme, getCurrentWindow } from "@tauri-apps/api/window"
import { /* relaunch, */ exit } from "@tauri-apps/plugin-process"
import { useTheme } from "next-themes"
@@ -49,13 +41,10 @@ const Nav = () => {
const pathname = usePathname()
return (
-