[feat] basic steam user parse
todo: steamid32 + avatar
This commit is contained in:
@@ -37,6 +37,9 @@ export const useSteamStore = () => {
|
||||
checkSteamDirValid,
|
||||
checkCs2DirValid,
|
||||
currentUser,
|
||||
getUsers,
|
||||
selectUser,
|
||||
switchLoginUser,
|
||||
resetSteamStore,
|
||||
}
|
||||
}
|
||||
@@ -61,29 +64,29 @@ const setCs2DirValid = (valid: boolean) => {
|
||||
steamStore.state.cs2DirValid = valid
|
||||
}
|
||||
|
||||
const SetSteamDirChecking = (checking: boolean) => {
|
||||
const setSteamDirChecking = (checking: boolean) => {
|
||||
steamStore.state.steamDirChecking = checking
|
||||
}
|
||||
|
||||
const SetCs2DirChecking = (checking: boolean) => {
|
||||
const setCs2DirChecking = (checking: boolean) => {
|
||||
steamStore.state.cs2DirChecking = checking
|
||||
}
|
||||
|
||||
const checkSteamDirValid = async () => {
|
||||
SetSteamDirChecking(true)
|
||||
setSteamDirChecking(true)
|
||||
const pathExist = await invoke<boolean>("check_path", { path: steamStore.state.steamDir })
|
||||
setSteamDirValid(pathExist)
|
||||
setTimeout(() => {
|
||||
SetSteamDirChecking(false)
|
||||
setSteamDirChecking(false)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
const checkCs2DirValid = async () => {
|
||||
SetCs2DirChecking(true)
|
||||
setCs2DirChecking(true)
|
||||
const pathExist = await invoke<boolean>("check_path", { path: steamStore.state.cs2Dir })
|
||||
setCs2DirValid(pathExist)
|
||||
setTimeout(() => {
|
||||
SetCs2DirChecking(false)
|
||||
setCs2DirChecking(false)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
@@ -91,12 +94,37 @@ const currentUser = () => {
|
||||
return steamStore.state.users.at(0) || undefined
|
||||
}
|
||||
|
||||
const getUsers = async () => {
|
||||
const users = await invoke<SteamUser[]>("get_steam_users", { steamDir: steamStore.state.steamDir })
|
||||
console.log(users)
|
||||
setUsers(users)
|
||||
}
|
||||
|
||||
const selectUser = async (index: number) => {
|
||||
const user = steamStore.state.users.at(index)
|
||||
console.log(index, user)
|
||||
if (user) {
|
||||
setUsers([
|
||||
user,
|
||||
...steamStore.state.users.slice(0, index),
|
||||
...steamStore.state.users.slice(index + 1),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
const switchLoginUser = async (index: number) => {
|
||||
const user = steamStore.state.users.at(index)
|
||||
if (user) {
|
||||
await invoke<SteamUser[]>("set_auto_login_user", { user: user.account_name })
|
||||
}
|
||||
}
|
||||
|
||||
const resetSteamStore = () => {
|
||||
setDir(defaultValue.steamDir)
|
||||
setCsDir(defaultValue.cs2Dir)
|
||||
setUsers(defaultValue.users)
|
||||
setSteamDirValid(defaultValue.steamDirValid)
|
||||
setCs2DirValid(defaultValue.cs2DirValid)
|
||||
SetSteamDirChecking(defaultValue.steamDirChecking)
|
||||
SetCs2DirChecking(defaultValue.cs2DirChecking)
|
||||
setSteamDirChecking(defaultValue.steamDirChecking)
|
||||
setCs2DirChecking(defaultValue.cs2DirChecking)
|
||||
}
|
||||
Reference in New Issue
Block a user