2024-11-11 10:04:00 +08:00
|
|
|
import type { SteamUser } from "@/types/steam"
|
2025-03-12 22:20:06 +08:00
|
|
|
import { store } from "tauri-plugin-valtio"
|
|
|
|
|
import { DEFAULT_STORE_CONFIG } from "."
|
2024-09-21 02:25:23 +08:00
|
|
|
|
2025-03-12 11:22:32 +08:00
|
|
|
const defaultValue = {
|
|
|
|
|
dir: "C:\\Program Files (x86)\\Steam",
|
|
|
|
|
csDir: "",
|
2025-03-12 22:20:06 +08:00
|
|
|
users: [
|
|
|
|
|
{
|
|
|
|
|
steamID64: "76561198052315353",
|
|
|
|
|
steamID32: "STEAM_0:0:46157676",
|
|
|
|
|
accountName: "wrr",
|
|
|
|
|
personaName: "wrr",
|
|
|
|
|
recent: 0,
|
|
|
|
|
avatar: "",
|
|
|
|
|
},
|
|
|
|
|
] as SteamUser[],
|
2025-03-12 11:22:32 +08:00
|
|
|
isDirValid: false,
|
2025-03-12 22:20:06 +08:00
|
|
|
isCsDirValid: false,
|
2024-09-21 02:25:23 +08:00
|
|
|
}
|
2025-03-12 22:20:06 +08:00
|
|
|
export const steamStore = store(
|
|
|
|
|
"steam",
|
|
|
|
|
{ ...defaultValue },
|
|
|
|
|
DEFAULT_STORE_CONFIG,
|
|
|
|
|
)
|
2024-09-21 02:25:23 +08:00
|
|
|
|
2025-03-12 22:20:06 +08:00
|
|
|
export const setDir = (dir: string) => {
|
|
|
|
|
steamStore.state.dir = dir
|
|
|
|
|
}
|
|
|
|
|
export const setCsDir = (dir: string) => {
|
|
|
|
|
steamStore.state.csDir = dir
|
|
|
|
|
}
|
|
|
|
|
export const setUsers = (users: SteamUser[]) => {
|
|
|
|
|
steamStore.state.users = users
|
|
|
|
|
}
|
|
|
|
|
export const setIsDirValid = (valid: boolean) => {
|
|
|
|
|
steamStore.state.isDirValid = valid
|
|
|
|
|
}
|
|
|
|
|
export const setIsCsDirValid = (valid: boolean) => {
|
|
|
|
|
steamStore.state.isCsDirValid = valid
|
|
|
|
|
}
|
2024-09-21 02:25:23 +08:00
|
|
|
|
2025-03-12 11:22:32 +08:00
|
|
|
export const currentUser = () => {
|
|
|
|
|
return steamStore.state.users[0] || defaultValue.users[0]
|
2024-09-27 10:38:40 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-12 11:22:32 +08:00
|
|
|
export const resetSteamStore = () => {
|
|
|
|
|
setDir(defaultValue.dir)
|
|
|
|
|
setCsDir(defaultValue.csDir)
|
|
|
|
|
setUsers(defaultValue.users)
|
|
|
|
|
setIsDirValid(defaultValue.isDirValid)
|
|
|
|
|
setIsCsDirValid(defaultValue.isCsDirValid)
|
2025-03-12 22:20:06 +08:00
|
|
|
}
|