- Welcome to{" "}
+ 欢迎使用{" "}
- Get started by editing{" "}
+ 开始编辑{" "}
src/pages/index.tsx
@@ -48,7 +48,7 @@ export default function Page() {
diff --git a/src/components/cstb/FpsTest.tsx b/src/components/cstb/FpsTest.tsx
index 9793d4a..4df7487 100644
--- a/src/components/cstb/FpsTest.tsx
+++ b/src/components/cstb/FpsTest.tsx
@@ -26,11 +26,17 @@ import {
ModalFooter,
Textarea,
useDisclosure,
+ Dropdown,
+ DropdownTrigger,
+ DropdownMenu,
+ DropdownItem,
} from "@heroui/react"
import { useState, useEffect, useRef, useCallback } from "react"
-import { TestTube, Power, List, Delete, Play, Edit, Check, Close, Square } from "@icon-park/react"
+import { TestTube, Power, List, Delete, Play, Edit, Check, Close, Square, DownloadOne } from "@icon-park/react"
import { allSysInfo, type AllSystemInfo } from "tauri-plugin-system-info-api"
import { ToolButton } from "../window/ToolButton"
+import { save } from "@tauri-apps/plugin-dialog"
+import { writeTextFile } from "@tauri-apps/plugin-fs"
const BENCHMARK_MAPS = [
{
@@ -49,6 +55,19 @@ const BENCHMARK_MAPS = [
const TEST_TIMEOUT = 200000 // 200秒超时时间(毫秒)
+// 预设分辨率列表
+const PRESET_RESOLUTIONS = [
+ { width: "800", height: "600", label: "800x600" },
+ { width: "1024", height: "768", label: "1024x768" },
+ { width: "1280", height: "960", label: "1280x960" },
+ { width: "1440", height: "1080", label: "1440x1080" },
+ { width: "1920", height: "1080", label: "1920x1080" },
+ { width: "1920", height: "1440", label: "1920x1440" },
+ { width: "2560", height: "1440", label: "2560x1440" },
+ { width: "2880", height: "2160", label: "2880x2160" },
+ { width: "3840", height: "2160", label: "3840x2160" },
+] as const
+
// 解析性能报告,提取时间戳和性能数据
function parseVProfReport(rawReport: string): { timestamp: string; data: string } | null {
if (!rawReport) return null
@@ -191,6 +210,11 @@ export function FpsTest() {
const [testNote, setTestNote] = useState("") // 测试备注
const [editingNoteId, setEditingNoteId] = useState(null) // 正在编辑的备注ID
const [editingNoteValue, setEditingNoteValue] = useState("") // 正在编辑的备注内容
+ const [customLaunchOption, setCustomLaunchOption] = useState("") // 自定义启动项
+ const [isResolutionEnabled, setIsResolutionEnabled] = useState(true) // 是否启用分辨率和全屏设置
+ const [resolutionWidth, setResolutionWidth] = useState("") // 分辨率宽度
+ const [resolutionHeight, setResolutionHeight] = useState("") // 分辨率高度
+ const [isFullscreen, setIsFullscreen] = useState(true) // 全屏模式(默认全屏)
const { isOpen: isNoteModalOpen, onOpen: onNoteModalOpen, onClose: onNoteModalClose } = useDisclosure()
const monitoringIntervalRef = useRef(null)
const timeoutRef = useRef(null)
@@ -223,6 +247,15 @@ export function FpsTest() {
return () => clearInterval(interval)
}, [checkGameRunning])
+ // 同步当前分辨率到状态(初始化时)
+ useEffect(() => {
+ if (tool.state.videoSetting) {
+ setResolutionWidth(tool.state.videoSetting.defaultres || "")
+ setResolutionHeight(tool.state.videoSetting.defaultresheight || "")
+ setIsFullscreen(tool.state.videoSetting.fullscreen === "1")
+ }
+ }, [tool.state.videoSetting])
+
// 获取硬件信息
useEffect(() => {
const fetchHardwareInfo = async () => {
@@ -515,9 +548,30 @@ export function FpsTest() {
testStartVideoSettingRef.current = { ...tool.store.state.videoSetting }
try {
- const launchOption = `-allow_third_party_software -condebug -conclearlog +map_workshop ${mapConfig.workshopId} ${mapConfig.map}`
+ // 构建启动参数:基础参数 + 分辨率和全屏设置 + 自定义启动项(如果有)
+ let baseLaunchOption = `-allow_third_party_software -condebug -conclearlog +map_workshop ${mapConfig.workshopId} ${mapConfig.map}`
+
+ // 只有在启用分辨率和全屏设置时才添加相关参数
+ if (isResolutionEnabled) {
+ // 添加分辨率设置(如果有设置)
+ if (resolutionWidth && resolutionHeight) {
+ baseLaunchOption += ` -w ${resolutionWidth} -h ${resolutionHeight}`
+ }
+
+ // 添加全屏/窗口化设置
+ if (isFullscreen) {
+ baseLaunchOption += ` -fullscreen`
+ } else {
+ baseLaunchOption += ` -sw`
+ }
+ }
+
+ // 添加自定义启动项(如果有,开头加空格避免粘连)
+ const launchOption = customLaunchOption.trim()
+ ? `${baseLaunchOption} ${customLaunchOption.trim()}`
+ : baseLaunchOption
- // 启动游戏
+ // 启动游戏(强制使用worldwide国际服)
await invoke("launch_game", {
steamPath: `${steam.state.steamDir}\\steam.exe`,
launchOption: launchOption,
@@ -574,11 +628,104 @@ export function FpsTest() {
}
}
+ // 导出CSV
+ const handleExportCSV = async () => {
+ if (fpsTest.state.results.length === 0) {
+ addToast({ title: "没有测试数据可导出", color: "warning" })
+ return
+ }
+
+ try {
+ // 构建CSV内容
+ const headers = [
+ "测试时间",
+ "测试地图",
+ "AVG平均帧",
+ "P1低帧",
+ "CPU",
+ "系统版本",
+ "GPU",
+ "内存(GB)",
+ "分辨率",
+ "视频设置",
+ "备注",
+ ]
+
+ const csvRows = [headers.join(",")]
+
+ for (const result of fpsTest.state.results) {
+ const row = [
+ `"${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"}"`,
+ `"${result.hardwareInfo?.os || "N/A"}"`,
+ `"${result.hardwareInfo?.gpu || "N/A"}"`,
+ result.hardwareInfo?.memory ? result.hardwareInfo.memory.toString() : "N/A",
+ result.videoSetting
+ ? `${result.videoSetting.defaultres}x${result.videoSetting.defaultresheight}`
+ : "N/A",
+ `"${formatVideoSettingSummary(result.videoSetting)}"`,
+ `"${result.note || ""}"`,
+ ]
+ csvRows.push(row.join(","))
+ }
+
+ const csvContent = csvRows.join("\n")
+
+ // 使用文件保存对话框
+ const filePath = await save({
+ filters: [
+ {
+ name: "CSV",
+ extensions: ["csv"],
+ },
+ ],
+ defaultPath: `fps_test_results_${new Date().toISOString().split("T")[0]}.csv`,
+ })
+
+ if (filePath) {
+ await writeTextFile(filePath, csvContent)
+ addToast({ title: "导出成功", color: "success" })
+ }
+ } catch (error) {
+ console.error("导出CSV失败:", error)
+ addToast({
+ title: `导出失败: ${error instanceof Error ? error.message : String(error)}`,
+ color: "danger",
+ })
+ }
+ }
+
+ // 切换全屏/窗口化(仅更新本地状态,不修改视频配置文件)
+ const handleToggleFullscreen = () => {
+ setIsFullscreen(!isFullscreen)
+ }
+
+ // 设置分辨率(仅更新本地状态,不修改视频配置文件)
+ const handleSetResolution = (width: string, height: string) => {
+ setResolutionWidth(width)
+ setResolutionHeight(height)
+ }
+
+ // 应用预设分辨率
+ const handlePresetResolution = (preset: { width: string; height: string; label: string }) => {
+ void handleSetResolution(preset.width, preset.height)
+ }
+
return (
- 帧数测试
+
+
+ 帧数测试
+
+
{isGameRunning && !tool.state.autoCloseGame && (
游戏运行中 关闭游戏后从这里启动
@@ -587,6 +734,12 @@ export function FpsTest() {
+ {showResultsTable && (
+
+ )}
src/pages/index.tsx
@@ -48,7 +48,7 @@ export default function Page() {
+ 帧数测试
+
+
+ {showResultsTable && (
+
+ )}