Add Steam integration showing online status and recent games
Deploy with Docker Compose / deploy (push) Has been cancelled
Deploy with Docker Compose / deploy (push) Has been cancelled
Fetches player summary and recently played games from Steam API with 5-minute server-side caching. Displays in the home sidebar with online indicator and game artwork. Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref, watch } from "vue";
|
||||
import { gql } from "@/graphql";
|
||||
import { useHomeDataStore } from "@/stores/homeData";
|
||||
|
||||
export const useSteamStore = defineStore("steam", () => {
|
||||
const steamStatus = ref({ online: false, recentGames: [] });
|
||||
|
||||
const homeData = useHomeDataStore();
|
||||
watch(
|
||||
() => homeData.steamStatus,
|
||||
(newStatus) => {
|
||||
if (newStatus) {
|
||||
steamStatus.value = newStatus;
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
async function fetchSteam() {
|
||||
try {
|
||||
const data = await gql(`
|
||||
query {
|
||||
steamStatus {
|
||||
online
|
||||
recentGames { appId name playtime2Weeks playtimeForever headerImageUrl }
|
||||
}
|
||||
}
|
||||
`);
|
||||
if (data.steamStatus) {
|
||||
steamStatus.value = data.steamStatus;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to fetch Steam status", err);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
steamStatus,
|
||||
fetchSteam,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user