[feat] solve common dir
todo: local cfg dir after resolving steam users
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
import { ToolButton } from "@/components/window/ToolButton"
|
||||
import { Chip } from "@heroui/react"
|
||||
import { Refresh, SettingConfig } from "@icon-park/react"
|
||||
import { version } from "@tauri-apps/plugin-os"
|
||||
// import { version } from "@tauri-apps/plugin-os"
|
||||
import { useEffect, useState } from "react"
|
||||
import { type AllSystemInfo, allSysInfo } from "tauri-plugin-system-info-api"
|
||||
export default function Page() {
|
||||
@@ -43,7 +43,6 @@ function HardwareInfo() {
|
||||
// const [staticData, setStaticData] = useState("")
|
||||
// const [cpuData, setCpuData] = useState("")
|
||||
// const [batteryData, setBatteryData] = useState("")
|
||||
const osVersion = version()
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -65,7 +64,7 @@ function HardwareInfo() {
|
||||
<Chip>CPU型号: {allSysData?.cpus[0]?.brand}</Chip>
|
||||
<Chip>线程数: {allSysData?.cpu_count}</Chip>
|
||||
<Chip>
|
||||
系统: {allSysData?.name} {allSysData?.os_version} {osVersion}
|
||||
系统: {allSysData?.name} {allSysData?.os_version}
|
||||
</Chip>
|
||||
<Chip>
|
||||
内存:
|
||||
|
||||
@@ -50,7 +50,7 @@ const CommonDir = () => {
|
||||
<RoundedButton
|
||||
onClick={async () => {
|
||||
await invoke("open_path", {
|
||||
path: path.join(steam.state.cs2Dir, "game", "csgo", "cfg"),
|
||||
path: steam.cs2BaseDir(),
|
||||
})
|
||||
addToast({ title: "CS2游戏目录" })
|
||||
}}
|
||||
@@ -60,7 +60,7 @@ const CommonDir = () => {
|
||||
<RoundedButton
|
||||
onClick={async () => {
|
||||
await invoke("open_path", {
|
||||
path: path.join(steam.state.cs2Dir, "game", "csgo", "maps"),
|
||||
path: path.resolve(steam.cs2BaseDir(), "game", "csgo", "maps"),
|
||||
})
|
||||
addToast({ title: "地图文件" })
|
||||
}}
|
||||
@@ -70,7 +70,7 @@ const CommonDir = () => {
|
||||
<RoundedButton
|
||||
onClick={async () => {
|
||||
await invoke("open_path", {
|
||||
path: path.join(steam.state.cs2Dir, "game", "csgo", "cfg"),
|
||||
path: path.resolve(steam.cs2BaseDir(), "game", "csgo", "cfg"),
|
||||
})
|
||||
addToast({ title: "游戏CFG目录" })
|
||||
}}
|
||||
@@ -80,7 +80,8 @@ const CommonDir = () => {
|
||||
<RoundedButton
|
||||
onClick={async () => {
|
||||
await invoke("open_path", {
|
||||
path: path.join(steam.state.steamDir, "userdata"),
|
||||
// TODO 导航到 steamid32/730/local/cfg
|
||||
path: path.resolve(steam.state.steamDir, "userdata"),
|
||||
})
|
||||
addToast({ title: "个人CFG目录" })
|
||||
}}
|
||||
@@ -89,8 +90,7 @@ const CommonDir = () => {
|
||||
</RoundedButton>
|
||||
<RoundedButton
|
||||
onClick={async () => {
|
||||
const appDataDirPath = await configDir()
|
||||
await invoke("open_path", { path: `${appDataDirPath}/Wmpvp/demo` })
|
||||
await invoke("open_path", { path: `%appdata%/Wmpvp/demo` })
|
||||
addToast({ title: "完美平台录像" })
|
||||
}}
|
||||
>
|
||||
@@ -98,8 +98,7 @@ const CommonDir = () => {
|
||||
</RoundedButton>
|
||||
<RoundedButton
|
||||
onClick={async () => {
|
||||
const appDataDirPath = await configDir()
|
||||
await invoke("open_path", { path: `${appDataDirPath}/5E对战平台/demo` })
|
||||
await invoke("open_path", { path: `%appdata%/5E对战平台/demo` })
|
||||
addToast({ title: "5E平台录像" })
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -66,7 +66,7 @@ const Avatar = () => {
|
||||
const SideBar = () => {
|
||||
const app = useAppStore()
|
||||
|
||||
getVersion().then((Value) => {
|
||||
void getVersion().then((Value) => {
|
||||
app.setVersion(Value)
|
||||
})
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { store } from "@tauri-store/valtio"
|
||||
import { DEFAULT_STORE_CONFIG } from "./config"
|
||||
import { useSnapshot } from "valtio"
|
||||
import { invoke } from "@tauri-apps/api/core"
|
||||
import path from "path"
|
||||
|
||||
const defaultValue = {
|
||||
steamDir: "C:\\Program Files (x86)\\Steam",
|
||||
@@ -36,6 +37,7 @@ export const useSteamStore = () => {
|
||||
return {
|
||||
state,
|
||||
store: steamStore,
|
||||
cs2BaseDir,
|
||||
setDir,
|
||||
setCsDir,
|
||||
setUsers,
|
||||
@@ -48,6 +50,10 @@ export const useSteamStore = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const cs2BaseDir = () => {
|
||||
return path.normalize(steamStore.state.cs2Dir.replaceAll("\\", "/") + "/../../..")
|
||||
}
|
||||
|
||||
const setDir = (dir: string) => {
|
||||
steamStore.state.steamDir = dir
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user