From ce410f7a2699aedad5de9682e77b427e25049a2c Mon Sep 17 00:00:00 2001 From: purp1e Date: Wed, 5 Nov 2025 13:20:50 +0800 Subject: [PATCH] [feat] fps test results gathering --- src/app/(main)/console/cfgx/page.tsx | 6 +- src/app/(main)/dynamic/page.tsx | 2 +- src/app/(main)/gear/page.tsx | 7 +- src/app/(main)/home/page.tsx | 2 +- src/app/(main)/preference/general/page.tsx | 22 +- src/app/(main)/preference/path/page.tsx | 16 +- src/app/(main)/preference/replay/page.tsx | 6 +- src/app/(main)/tool/page.tsx | 8 +- src/app/(main)/users/page.tsx | 6 +- src/components/auth/AuthProvider.tsx | 5 +- src/components/cstb/CommonDir.tsx | 2 +- src/components/cstb/FpsTest.tsx | 288 ++++++++++++++++----- src/components/cstb/UpdateChecker.tsx | 12 +- src/components/cstb/VideoSetting.tsx | 28 +- src/components/window/ToolButton.tsx | 2 +- src/store/fpsTest.ts | 65 +++++ src/store/index.ts | 2 + 17 files changed, 363 insertions(+), 116 deletions(-) create mode 100644 src/store/fpsTest.ts diff --git a/src/app/(main)/console/cfgx/page.tsx b/src/app/(main)/console/cfgx/page.tsx index 38560f0..050d8c7 100644 --- a/src/app/(main)/console/cfgx/page.tsx +++ b/src/app/(main)/console/cfgx/page.tsx @@ -5,7 +5,11 @@ import { Chip, Code, Skeleton } from "@heroui/react" import useSWR from "swr" export default function Page() { - return + return ( +
+ +
+ ) } function CfgxList() { diff --git a/src/app/(main)/dynamic/page.tsx b/src/app/(main)/dynamic/page.tsx index 53338bb..382f577 100644 --- a/src/app/(main)/dynamic/page.tsx +++ b/src/app/(main)/dynamic/page.tsx @@ -28,7 +28,7 @@ export default function Page() { radius="full" classNames={{ base: "min-w-0", - tabList: "gap-1", + tabList: "gap-0 p-0", tab: "min-w-0 px-3", tabContent: "text-xs", }} diff --git a/src/app/(main)/gear/page.tsx b/src/app/(main)/gear/page.tsx index 0e748d4..60d45e4 100644 --- a/src/app/(main)/gear/page.tsx +++ b/src/app/(main)/gear/page.tsx @@ -12,12 +12,12 @@ import { Refresh, SettingConfig } from "@icon-park/react" // import { version } from "@tauri-apps/plugin-os" import { useEffect, useState } from "react" import { type AllSystemInfo, allSysInfo } from "tauri-plugin-system-info-api" -import { FpsTest } from "@/components/cstb/FpsTest" + export default function Page() { return (
-
- +
+ 硬件 @@ -37,7 +37,6 @@ export default function Page() { -
) diff --git a/src/app/(main)/home/page.tsx b/src/app/(main)/home/page.tsx index 8a70f48..844bd59 100644 --- a/src/app/(main)/home/page.tsx +++ b/src/app/(main)/home/page.tsx @@ -10,7 +10,7 @@ import SmartTransfer from "@/components/cstb/SmartTranser" const Home = () => { return ( -
+
diff --git a/src/app/(main)/preference/general/page.tsx b/src/app/(main)/preference/general/page.tsx index d125eec..85150ee 100644 --- a/src/app/(main)/preference/general/page.tsx +++ b/src/app/(main)/preference/general/page.tsx @@ -12,42 +12,44 @@ export default function Page() { const githubRepo = process.env.NEXT_PUBLIC_GITHUB_REPO || "" return ( -
+
+

版本号:{app.state.version}

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

是否使用镜像源:{app.state.useMirror ? "是" : "否"}

-
-

更新检查

+ {/*
+

更新检查

-
+
*/} -
-

启动设置

+
+

启动设置

app.setAutoStart(e.target.checked)} > - 开机自启动 {app.state.autoStart ? "开" : "关"} + 开机自启动 app.setStartHidden(e.target.checked)} > - 静默启动 {app.state.startHidden ? "开" : "关"} + 静默启动 app.setHiddenOnClose(e.target.checked)} > - 关闭时最小化到托盘 {app.state.hiddenOnClose ? "开" : "关"} + 关闭时最小化到托盘
-
+
+
) } diff --git a/src/app/(main)/preference/path/page.tsx b/src/app/(main)/preference/path/page.tsx index 40d0d43..87ae138 100644 --- a/src/app/(main)/preference/path/page.tsx +++ b/src/app/(main)/preference/path/page.tsx @@ -5,12 +5,14 @@ export default function Page() { const steam = useSteamStore() return ( -
-

Steam路径:{steam.state.steamDir}

-

游戏路径:{steam.state.cs2Dir}

-

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

-

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

-

Steam账号:{steam.currentUser()?.account_name || " "}

-
+
+
+

Steam路径:{steam.state.steamDir}

+

游戏路径:{steam.state.cs2Dir}

+

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

+

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

+

Steam账号:{steam.currentUser()?.account_name || " "}

+
+
) } diff --git a/src/app/(main)/preference/replay/page.tsx b/src/app/(main)/preference/replay/page.tsx index a337332..eb0d8b2 100644 --- a/src/app/(main)/preference/replay/page.tsx +++ b/src/app/(main)/preference/replay/page.tsx @@ -1,4 +1,8 @@ "use client" export default function Page() { - return <>Replay + return ( +
+ <>Replay +
+ ) } diff --git a/src/app/(main)/tool/page.tsx b/src/app/(main)/tool/page.tsx index 33b8ba1..81f30e5 100644 --- a/src/app/(main)/tool/page.tsx +++ b/src/app/(main)/tool/page.tsx @@ -1,11 +1,15 @@ "use client" import VideoSetting from "@/components/cstb/VideoSetting" +import { FpsTest } from "@/components/cstb/FpsTest" export default function Page() { return ( -
- +
+
+ + +
) } diff --git a/src/app/(main)/users/page.tsx b/src/app/(main)/users/page.tsx index 03e12b6..7004fb3 100644 --- a/src/app/(main)/users/page.tsx +++ b/src/app/(main)/users/page.tsx @@ -1,4 +1,8 @@ "use client" export default function Page() { - return
Users
+ return ( +
+
Users
+
+ ) } diff --git a/src/components/auth/AuthProvider.tsx b/src/components/auth/AuthProvider.tsx index 80c91db..913bdf8 100644 --- a/src/components/auth/AuthProvider.tsx +++ b/src/components/auth/AuthProvider.tsx @@ -36,7 +36,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { addToast({ title: "登录失败", description: "无法验证登录信息,请重试", - variant: "danger", + + severity: "danger", }) } } catch (error) { @@ -44,7 +45,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { addToast({ title: "登录失败", description: error instanceof Error ? error.message : "未知错误", - variant: "danger", + severity: "danger", }) } finally { setLoading(false) diff --git a/src/components/cstb/CommonDir.tsx b/src/components/cstb/CommonDir.tsx index f523c7b..98acb0f 100644 --- a/src/components/cstb/CommonDir.tsx +++ b/src/components/cstb/CommonDir.tsx @@ -16,7 +16,7 @@ const RoundedButton = ({ return ( + -
-
- {BENCHMARK_MAPS.map((mapConfig) => ( + {showResultsTable ? ( +
+
+ + + 测试时间 + 测试地图 + 平均帧数 + P1帧数 + CPU + 操作 + + + {fpsTest.state.results.map((result) => ( + + {result.testTime} + {result.mapLabel} + + {result.avg !== null ? `${result.avg.toFixed(1)}` : "N/A"} + + + {result.p1 !== null ? `${result.p1.toFixed(1)}` : "N/A"} + + + {result.hardwareInfo?.cpu || "N/A"} + + + + + + ))} + +
+
+
+ ) : ( +
+
+ {BENCHMARK_MAPS.map((mapConfig) => ( + + ))} - ))} - - - - 测试完成自动关闭游戏 - - {isMonitoring && ( - - 正在监听中... - + + + 测试完成自动关闭游戏 + + {isMonitoring && ( + + 正在监听中... + + )} +
+ + {testResult && ( +
+
+ {testTimestamp && ( + + 测试时间: {testTimestamp} + + )} +
+
+                  {testResult}
+                
+
)}
- - {testResult && ( -
-
- 测试结果 - {testTimestamp && ( - - 测试时间: {testTimestamp} - - )} -
-
-                {testResult}
-              
-
- )} -
+ )} ) diff --git a/src/components/cstb/UpdateChecker.tsx b/src/components/cstb/UpdateChecker.tsx index 5097320..b9bd460 100644 --- a/src/components/cstb/UpdateChecker.tsx +++ b/src/components/cstb/UpdateChecker.tsx @@ -2,9 +2,9 @@ import { useState } from "react" import { Button, Progress, Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, useDisclosure } from "@heroui/react" -import { Download, Refresh, CheckCircle } from "@icon-park/react" +import { Download, Refresh, CheckCorrect } from "@icon-park/react" import { invoke } from "@tauri-apps/api/core" -import { relaunch } from "@tauri-apps/api/process" +import { relaunch } from "@tauri-apps/plugin-process" import { addToast } from "@heroui/react" import { useAppStore } from "@/store/app" @@ -159,8 +159,8 @@ export function UpdateChecker({ customEndpoint, githubRepo }: UpdateCheckerProps {checking ? "检查中..." : "检查更新"} {app.state.hasUpdate && ( - - + + 有新版本可用 )} @@ -192,8 +192,8 @@ export function UpdateChecker({ customEndpoint, githubRepo }: UpdateCheckerProps
-

更新说明:

-
+

更新说明:

+
{formatNotes(updateInfo?.notes)}
diff --git a/src/components/cstb/VideoSetting.tsx b/src/components/cstb/VideoSetting.tsx index 376d5c4..8470ead 100644 --- a/src/components/cstb/VideoSetting.tsx +++ b/src/components/cstb/VideoSetting.tsx @@ -20,7 +20,9 @@ const VideoSetting = () => { const checkGameRunning = useCallback(async () => { try { // 尝试检测cs2.exe进程 - const result = await invoke("check_process_running", { processName: "cs2.exe" }).catch(() => false) + const result = await invoke("check_process_running", { + processName: "cs2.exe", + }).catch(() => false) setIsGameRunning(result) return result } catch { @@ -310,12 +312,7 @@ const VideoSetting = () => { 视频设置 {isGameRunning && ( - + 游戏运行中 )} @@ -354,10 +351,10 @@ const VideoSetting = () => { // 检查游戏是否运行 const gameRunning = await checkGameRunning() if (gameRunning) { - addToast({ - title: "无法应用设置", + addToast({ + title: "无法应用设置", description: "检测到游戏正在运行,请先关闭游戏后再应用设置", - color: "warning" + color: "warning", }) return } @@ -373,7 +370,7 @@ const VideoSetting = () => { setEdit(false) addToast({ title: "应用设置成功" }) }} - isDisabled={isGameRunning} + disabled={isGameRunning} > 应用 @@ -404,11 +401,7 @@ const VideoSetting = () => { )} - - 读取 - + 读取 setHide(!hide)}> {hide ? ( <> @@ -500,7 +493,8 @@ const VideoSetting = () => {
分辨率 - {tool.state.videoSetting.defaultres} × {tool.state.videoSetting.defaultresheight} + {tool.state.videoSetting.defaultres} ×{" "} + {tool.state.videoSetting.defaultresheight}
{videoSettings(tool.state.videoSetting).map((vid, index) => ( diff --git a/src/components/window/ToolButton.tsx b/src/components/window/ToolButton.tsx index 56770bc..933cc6b 100644 --- a/src/components/window/ToolButton.tsx +++ b/src/components/window/ToolButton.tsx @@ -11,7 +11,7 @@ export const ToolButton = ({ children, className, selected, ...rest }: ToolButto