[feat] solve common dir
todo: local cfg dir after resolving steam users
This commit is contained in:
1764
src-tauri/Cargo.lock
generated
1764
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -18,13 +18,13 @@ strip = true # Remove debug symbols
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.6", features = [] }
|
||||
tauri-build = { version = "2.1.0", features = [] }
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.26"
|
||||
serde_json = "1.0.140"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
tauri = { version = "2.3.1", features = [ "macos-private-api",
|
||||
tauri = { version = "2.4.0", features = [ "macos-private-api",
|
||||
"tray-icon"
|
||||
] }
|
||||
window-vibrancy = "0.6.0"
|
||||
@@ -56,4 +56,4 @@ custom-protocol = [ "tauri/custom-protocol" ]
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-global-shortcut = "2.2.0"
|
||||
tauri-plugin-single-instance = "2"
|
||||
tauri-plugin-single-instance = "2.2.2"
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -37,7 +37,7 @@
|
||||
],
|
||||
"definitions": {
|
||||
"Capability": {
|
||||
"description": "A grouping and boundary mechanism developers can use to isolate access to the IPC layer.\n\nIt controls application windows fine grained access to the Tauri core, application, or plugin commands. If a window is not matching any capability then it has no access to the IPC layer at all.\n\nThis can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities.\n\n## Example\n\n```json { \"identifier\": \"main-user-files-write\", \"description\": \"This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programatic access to files selected by the user.\", \"windows\": [ \"main\" ], \"permissions\": [ \"core:default\", \"dialog:open\", { \"identifier\": \"fs:allow-write-text-file\", \"allow\": [{ \"path\": \"$HOME/test.txt\" }] }, ], \"platforms\": [\"macOS\",\"windows\"] } ```",
|
||||
"description": "A grouping and boundary mechanism developers can use to isolate access to the IPC layer.\n\nIt controls application windows' and webviews' fine grained access to the Tauri core, application, or plugin commands. If a webview or its window is not matching any capability then it has no access to the IPC layer at all.\n\nThis can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities.\n\n## Example\n\n```json { \"identifier\": \"main-user-files-write\", \"description\": \"This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programatic access to files selected by the user.\", \"windows\": [ \"main\" ], \"permissions\": [ \"core:default\", \"dialog:open\", { \"identifier\": \"fs:allow-write-text-file\", \"allow\": [{ \"path\": \"$HOME/test.txt\" }] }, ], \"platforms\": [\"macOS\",\"windows\"] } ```",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier",
|
||||
@@ -70,14 +70,14 @@
|
||||
"type": "boolean"
|
||||
},
|
||||
"windows": {
|
||||
"description": "List of windows that are affected by this capability. Can be a glob pattern.\n\nOn multiwebview windows, prefer [`Self::webviews`] for a fine grained access control.\n\n## Example\n\n`[\"main\"]`",
|
||||
"description": "List of windows that are affected by this capability. Can be a glob pattern.\n\nIf a window label matches any of the patterns in this list, the capability will be enabled on all the webviews of that window, regardless of the value of [`Self::webviews`].\n\nOn multiwebview windows, prefer specifying [`Self::webviews`] and omitting [`Self::windows`] for a fine grained access control.\n\n## Example\n\n`[\"main\"]`",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"webviews": {
|
||||
"description": "List of webviews that are affected by this capability. Can be a glob pattern.\n\nThis is only required when using on multiwebview contexts, by default all child webviews of a window that matches [`Self::windows`] are linked.\n\n## Example\n\n`[\"sub-webview-one\", \"sub-webview-two\"]`",
|
||||
"description": "List of webviews that are affected by this capability. Can be a glob pattern.\n\nThe capability will be enabled on all the webviews whose label matches any of the patterns in this list, regardless of whether the webview's window label matches a pattern in [`Self::windows`].\n\n## Example\n\n`[\"sub-webview-one\", \"sub-webview-two\"]`",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -2094,11 +2094,26 @@
|
||||
"type": "string",
|
||||
"const": "core:app:allow-default-window-icon"
|
||||
},
|
||||
{
|
||||
"description": "Enables the fetch_data_store_identifiers command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-fetch-data-store-identifiers"
|
||||
},
|
||||
{
|
||||
"description": "Enables the identifier command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-identifier"
|
||||
},
|
||||
{
|
||||
"description": "Enables the name command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-name"
|
||||
},
|
||||
{
|
||||
"description": "Enables the remove_data_store command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-remove-data-store"
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_app_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2129,11 +2144,26 @@
|
||||
"type": "string",
|
||||
"const": "core:app:deny-default-window-icon"
|
||||
},
|
||||
{
|
||||
"description": "Denies the fetch_data_store_identifiers command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-fetch-data-store-identifiers"
|
||||
},
|
||||
{
|
||||
"description": "Denies the identifier command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-identifier"
|
||||
},
|
||||
{
|
||||
"description": "Denies the name command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-name"
|
||||
},
|
||||
{
|
||||
"description": "Denies the remove_data_store command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-remove-data-store"
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_app_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2929,6 +2959,11 @@
|
||||
"type": "string",
|
||||
"const": "core:window:allow-internal-toggle-maximize"
|
||||
},
|
||||
{
|
||||
"description": "Enables the is_always_on_top command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:allow-is-always-on-top"
|
||||
},
|
||||
{
|
||||
"description": "Enables the is_closable command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -3294,6 +3329,11 @@
|
||||
"type": "string",
|
||||
"const": "core:window:deny-internal-toggle-maximize"
|
||||
},
|
||||
{
|
||||
"description": "Denies the is_always_on_top command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:deny-is-always-on-top"
|
||||
},
|
||||
{
|
||||
"description": "Denies the is_closable command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
],
|
||||
"definitions": {
|
||||
"Capability": {
|
||||
"description": "A grouping and boundary mechanism developers can use to isolate access to the IPC layer.\n\nIt controls application windows fine grained access to the Tauri core, application, or plugin commands. If a window is not matching any capability then it has no access to the IPC layer at all.\n\nThis can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities.\n\n## Example\n\n```json { \"identifier\": \"main-user-files-write\", \"description\": \"This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programatic access to files selected by the user.\", \"windows\": [ \"main\" ], \"permissions\": [ \"core:default\", \"dialog:open\", { \"identifier\": \"fs:allow-write-text-file\", \"allow\": [{ \"path\": \"$HOME/test.txt\" }] }, ], \"platforms\": [\"macOS\",\"windows\"] } ```",
|
||||
"description": "A grouping and boundary mechanism developers can use to isolate access to the IPC layer.\n\nIt controls application windows' and webviews' fine grained access to the Tauri core, application, or plugin commands. If a webview or its window is not matching any capability then it has no access to the IPC layer at all.\n\nThis can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities.\n\n## Example\n\n```json { \"identifier\": \"main-user-files-write\", \"description\": \"This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programatic access to files selected by the user.\", \"windows\": [ \"main\" ], \"permissions\": [ \"core:default\", \"dialog:open\", { \"identifier\": \"fs:allow-write-text-file\", \"allow\": [{ \"path\": \"$HOME/test.txt\" }] }, ], \"platforms\": [\"macOS\",\"windows\"] } ```",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier",
|
||||
@@ -70,14 +70,14 @@
|
||||
"type": "boolean"
|
||||
},
|
||||
"windows": {
|
||||
"description": "List of windows that are affected by this capability. Can be a glob pattern.\n\nOn multiwebview windows, prefer [`Self::webviews`] for a fine grained access control.\n\n## Example\n\n`[\"main\"]`",
|
||||
"description": "List of windows that are affected by this capability. Can be a glob pattern.\n\nIf a window label matches any of the patterns in this list, the capability will be enabled on all the webviews of that window, regardless of the value of [`Self::webviews`].\n\nOn multiwebview windows, prefer specifying [`Self::webviews`] and omitting [`Self::windows`] for a fine grained access control.\n\n## Example\n\n`[\"main\"]`",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"webviews": {
|
||||
"description": "List of webviews that are affected by this capability. Can be a glob pattern.\n\nThis is only required when using on multiwebview contexts, by default all child webviews of a window that matches [`Self::windows`] are linked.\n\n## Example\n\n`[\"sub-webview-one\", \"sub-webview-two\"]`",
|
||||
"description": "List of webviews that are affected by this capability. Can be a glob pattern.\n\nThe capability will be enabled on all the webviews whose label matches any of the patterns in this list, regardless of whether the webview's window label matches a pattern in [`Self::windows`].\n\n## Example\n\n`[\"sub-webview-one\", \"sub-webview-two\"]`",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -2094,11 +2094,26 @@
|
||||
"type": "string",
|
||||
"const": "core:app:allow-default-window-icon"
|
||||
},
|
||||
{
|
||||
"description": "Enables the fetch_data_store_identifiers command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-fetch-data-store-identifiers"
|
||||
},
|
||||
{
|
||||
"description": "Enables the identifier command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-identifier"
|
||||
},
|
||||
{
|
||||
"description": "Enables the name command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-name"
|
||||
},
|
||||
{
|
||||
"description": "Enables the remove_data_store command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-remove-data-store"
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_app_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2129,11 +2144,26 @@
|
||||
"type": "string",
|
||||
"const": "core:app:deny-default-window-icon"
|
||||
},
|
||||
{
|
||||
"description": "Denies the fetch_data_store_identifiers command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-fetch-data-store-identifiers"
|
||||
},
|
||||
{
|
||||
"description": "Denies the identifier command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-identifier"
|
||||
},
|
||||
{
|
||||
"description": "Denies the name command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-name"
|
||||
},
|
||||
{
|
||||
"description": "Denies the remove_data_store command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-remove-data-store"
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_app_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2929,6 +2959,11 @@
|
||||
"type": "string",
|
||||
"const": "core:window:allow-internal-toggle-maximize"
|
||||
},
|
||||
{
|
||||
"description": "Enables the is_always_on_top command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:allow-is-always-on-top"
|
||||
},
|
||||
{
|
||||
"description": "Enables the is_closable command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -3294,6 +3329,11 @@
|
||||
"type": "string",
|
||||
"const": "core:window:deny-internal-toggle-maximize"
|
||||
},
|
||||
{
|
||||
"description": "Denies the is_always_on_top command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:deny-is-always-on-top"
|
||||
},
|
||||
{
|
||||
"description": "Denies the is_closable command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
use std::process::Command;
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||
// const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
|
||||
pub fn kill(name: &str) -> String {
|
||||
Command::new("taskkill")
|
||||
@@ -36,10 +40,30 @@ pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
|
||||
}
|
||||
|
||||
pub fn open_path(path: &str) -> Result<(), std::io::Error> {
|
||||
let p = format!("file:///{}", path);
|
||||
Command::new("explorer")
|
||||
.args([p])
|
||||
// path中所有/ 转换为 \
|
||||
let path = path.replace("/", "\\");
|
||||
Command::new("cmd.exe")
|
||||
.args(["/c", "start", "", &path])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.spawn()
|
||||
.expect("Failed to open path");
|
||||
.unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn test_open_path() {
|
||||
let path = "D:\\Programs\\Steam";
|
||||
println!("test open path: {}", path);
|
||||
open_path(path).unwrap();
|
||||
|
||||
let path = "D:\\Programs\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\game\\bin\\win64";
|
||||
println!("test open path: {}", path);
|
||||
open_path(path).unwrap();
|
||||
|
||||
let path = "%appdata%/Wmpvp/demo";
|
||||
println!("test open path: {}", path);
|
||||
open_path(path).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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