Add Steam integration showing online status and recent games
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Some checks failed
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 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ export const useHomeDataStore = defineStore("homeData", () => {
|
||||
const spotifyRecent = ref([]);
|
||||
const rowingSessions = ref([]);
|
||||
const gitFeed = ref(null);
|
||||
const steamStatus = ref(null);
|
||||
const radioLive = ref(false);
|
||||
|
||||
async function fetchAll() {
|
||||
@@ -27,6 +28,7 @@ export const useHomeDataStore = defineStore("homeData", () => {
|
||||
spotifyRecent { track { name album { name images { url } } artists { name } } playedAt }
|
||||
rowingSessions { id date time distance timePer500m calories }
|
||||
giteaFeed { avatarUrl repoUrl repoName opType commitMessage createdAt }
|
||||
steamStatus { online recentGames { appId name playtime2Weeks playtimeForever headerImageUrl } }
|
||||
me { id username admin }
|
||||
}
|
||||
`),
|
||||
@@ -38,6 +40,7 @@ export const useHomeDataStore = defineStore("homeData", () => {
|
||||
spotifyRecent.value = data.spotifyRecent || [];
|
||||
rowingSessions.value = data.rowingSessions;
|
||||
gitFeed.value = data.giteaFeed || null;
|
||||
steamStatus.value = data.steamStatus || null;
|
||||
me.value = data.me || null;
|
||||
loaded.value = true;
|
||||
} catch (err) {
|
||||
@@ -67,6 +70,7 @@ export const useHomeDataStore = defineStore("homeData", () => {
|
||||
spotifyRecent,
|
||||
rowingSessions,
|
||||
gitFeed,
|
||||
steamStatus,
|
||||
radioLive,
|
||||
fetchAll,
|
||||
fetchRadioStatus,
|
||||
|
||||
42
vue/src/stores/steam.js
Normal file
42
vue/src/stores/steam.js
Normal file
@@ -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