Merge pull request #1983 from rommapp/romm-1952

feat: Readded stats summary as a display option in the home page
This commit is contained in:
Zurdi
2025-06-13 16:22:50 +02:00
committed by GitHub
15 changed files with 145 additions and 9 deletions

View File

@@ -0,0 +1,93 @@
<script setup lang="ts">
import api from "@/services/api/index";
import { formatBytes } from "@/utils";
import { onBeforeMount, ref } from "vue";
import { useI18n } from "vue-i18n";
// Props
const { t } = useI18n();
const stats = ref({
PLATFORMS: 0,
ROMS: 0,
SAVES: 0,
STATES: 0,
SCREENSHOTS: 0,
TOTAL_FILESIZE_BYTES: 0,
});
// Functions
onBeforeMount(() => {
api.get("/stats").then(({ data }) => {
stats.value = data;
});
});
</script>
<template>
<v-card class="ma-2">
<v-card-text class="pa-1">
<v-row no-gutters class="flex-nowrap overflow-x-auto text-center">
<v-col>
<v-chip
class="text-overline"
prepend-icon="mdi-controller"
variant="text"
label
>
{{ t("common.platforms-n", stats.PLATFORMS) }}
</v-chip>
</v-col>
<v-col>
<v-chip
class="text-overline"
prepend-icon="mdi-disc"
variant="text"
label
>
{{ t("common.games-n", stats.ROMS) }}
</v-chip>
</v-col>
<v-col>
<v-chip
class="text-overline"
prepend-icon="mdi-content-save"
variant="text"
label
>
{{ t("common.saves-n", stats.SAVES) }}
</v-chip>
</v-col>
<v-col>
<v-chip
class="text-overline"
prepend-icon="mdi-file"
variant="text"
label
>
{{ t("common.states-n", stats.STATES) }}
</v-chip>
</v-col>
<v-col>
<v-chip
class="text-overline"
prepend-icon="mdi-image-area"
variant="text"
label
>
{{ t("common.screenshots-n", stats.SCREENSHOTS) }}
</v-chip>
</v-col>
<v-col>
<v-chip
class="text-overline"
prepend-icon="mdi-harddisk"
variant="text"
label
>
{{ t("common.size-on-disk") }}:
{{ formatBytes(stats.TOTAL_FILESIZE_BYTES, 1) }}
</v-chip>
</v-col>
</v-row>
</v-card-text>
</v-card>
</template>

View File

@@ -15,6 +15,10 @@ const collectionsStore = storeCollections();
// Initializing refs from localStorage
// Home
const storedShowStats = localStorage.getItem("settings.showStats");
const showStatsRef = ref(
isNull(storedShowStats) ? true : storedShowStats === "true",
);
const storedShowRecentRoms = localStorage.getItem("settings.showRecentRoms");
const showRecentRomsRef = ref(
isNull(storedShowRecentRoms) ? true : storedShowRecentRoms === "true",
@@ -93,6 +97,14 @@ const enable3DEffectRef = ref(
);
const homeOptions = computed(() => [
{
title: t("settings.show-stats"),
description: t("settings.show-stats-desc"),
iconEnabled: "mdi-thermostat-box",
iconDisabled: "mdi-thermostat-box",
model: showStatsRef,
modelTrigger: toggleShowStats,
},
{
title: t("settings.show-recently-added"),
description: t("settings.show-recently-added-desc"),
@@ -230,6 +242,11 @@ const setVirtualCollectionType = async (value: string) => {
});
};
const toggleShowStats = (value: boolean) => {
showStatsRef.value = value;
localStorage.setItem("settings.showStats", value.toString());
};
const toggleShowRecentRoms = (value: boolean) => {
showRecentRomsRef.value = value;
localStorage.setItem("settings.showRecentRoms", value.toString());

View File

@@ -49,7 +49,8 @@
"show-siblings-desc": "Die Anzahl der verschiedenen Versionen einen Roms wird in der Galerie angezeigt, wenn die \"Roms gruppieren\" Option aktiviert ist",
"show-status": "Zeige Status",
"show-status-desc": "Ziegt den aktuellen Status eines Roms als Icons in der Galerie an (Vorgemerkt, derzeit gespielt, durchgespielt, etc)",
"show-actionbar": "Show action bar",
"show-stats": "Zeige Statistiken",
"show-stats-desc": "Zeige Statistiken auf der Startseite an",
"show-actionbar": "Aktionsleiste anzeigen",
"show-actionbar-desc": "Aktionsleiste immer auf der Spielkarte anzeigen",
"show-virtual-collections": "Zeige automatisch generierte Sammlungen",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "Show siblings count in the gallery when \"Group roms\" option is enabled",
"show-status": "Show status",
"show-status-desc": "Show status icons in the gallery (backlogged, playing, completed, etc)",
"show-stats": "Show stats",
"show-stats-desc": "Show stats summary at the home page",
"show-actionbar": "Show action bar",
"show-actionbar-desc": "Show action bar in the game card always",
"show-virtual-collections": "Show autogenerated collections",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "Show siblings count in the gallery when \"Group roms\" option is enabled",
"show-status": "Show status",
"show-status-desc": "Show status icons in the gallery (backlogged, playing, completed, etc)",
"show-stats": "Show stats",
"show-stats-desc": "Show stats summary at the home page",
"show-actionbar": "Show action bar",
"show-actionbar-desc": "Show action bar in the game card always",
"show-virtual-collections": "Show autogenerated collections",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "Mostrar el número de \"hermanos\" en la galería cuando la opción \"Agrupar roms\" está habilitada",
"show-status": "Mostrar estado",
"show-status-desc": "Mostrar icono de estado en la galería (backlogged, playing, completed, etc)",
"show-stats": "Mostrar estadísticas",
"show-stats-desc": "Mostrar resumen de estadísticas en la página principal",
"show-actionbar": "Mostrar barra de acciones",
"show-actionbar-desc": "Mostrar siempre la barra de acciones en la tarjeta del juego",
"show-virtual-collections": "Mostrar colecciones generadas automáticamente",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "Afficher le nombre de frères et sœurs dans la galerie lorsque l'option \"Grouper les roms\" est activée",
"show-status": "Afficher le statut",
"show-status-desc": "Afficher les icônes de statut dans la galerie (en attente, en cours de lecture, terminé, etc.)",
"show-stats": "Afficher les statistiques",
"show-stats-desc": "Afficher le résumé des statistiques sur la page d'accueil",
"show-actionbar": "Afficher la barre d'actions",
"show-actionbar-desc": "Toujours afficher la barre d'actions sur la carte du jeu",
"show-virtual-collections": "Afficher les collections générées automatiquement",

View File

@@ -50,6 +50,8 @@
"show-siblings-desc": "Mostra il numero di versioni correlate nella galleria quando l'opzione \"Raggruppa rom\" è attivata",
"show-status": "Mostra stato",
"show-status-desc": "Mostra le icone di stato nella galleria (in attesa, in gioco, completato, ecc.)",
"show-stats": "Mostra statistiche",
"show-stats-desc": "Mostra il riepilogo delle statistiche nella home",
"show-actionbar": "Mostra barra delle azioni",
"show-actionbar-desc": "Mostra sempre la barra delle azioni nella scheda del gioco",
"show-virtual-collections": "Mostra collezioni autogenerate",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "\"Group roms\" オプションが有効な場合、キャラリーに系列数を表示",
"show-status": "ステータを表示",
"show-status-desc": "ギャラリーにステータスアイコンを表示 (未プレイ, プレイ中, 完了済, その他)",
"show-stats": "統計を表示",
"show-stats-desc": "ホームに統計の概要を表示",
"show-actionbar": "アクションバーを表示",
"show-actionbar-desc": "ゲームカードに常にアクションバーを表示",
"show-virtual-collections": "自動生成されたコレクションを表示",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "\"롬 묶음\" 옵션이 활성화되었을 때 파생롬의 개수를 갤러리에서 보여줍니다",
"show-status": "상태 보이기",
"show-status-desc": "갤러리에서 상태 아이콘을 보여줍니다(플레이중, 완료됨 등)",
"show-stats": "통계 보이기",
"show-stats-desc": "홈페이지에 통계 요약을 보여줍니다",
"show-actionbar": "작업 표시줄 표시",
"show-actionbar-desc": "게임 카드에서 항상 작업 표시줄을 표시",
"show-virtual-collections": "자동 생성된 모음집 보이기",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "Mostrar contagem de irmãos na galeria quando a opção \"Agrupar roms\" estiver ativada",
"show-status": "Mostrar status",
"show-status-desc": "Mostrar ícones de status na galeria (em espera, jogando, concluído, etc)",
"show-stats": "Mostrar estatísticas",
"show-stats-desc": "Mostrar resumo de estatísticas na página inicial",
"show-actionbar": "Mostrar barra de ações",
"show-actionbar-desc": "Sempre mostrar a barra de ações no cartão do jogo",
"show-virtual-collections": "Mostrar coleções geradas automaticamente",

View File

@@ -52,6 +52,8 @@
"show-status-desc": "Afișează pictogramele de status în galerie (în așteptare, în curs de joc, finalizat etc.)",
"show-actionbar": "Afișează bara de acțiuni",
"show-actionbar-desc": "Afișează întotdeauna bara de acțiuni în cardul jocului",
"show-stats": "Afișează statistici",
"show-stats-desc": "Afișează rezumatul statisticilor pe pagina principală",
"show-virtual-collections": "Afișează colecțiile generate automat",
"show-virtual-collections-desc": "Afișate pe pagina principală și în bara laterală a colecțiilor.",
"theme": "Temă",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "Показать количество родственных в галерее, когда включена опция \"Группировать ромы\"",
"show-status": "Показать статус",
"show-status-desc": "Показать иконки статуса в галерее (в ожидании, играется, завершено и т.д.)",
"show-stats": "Показать статистику",
"show-stats-desc": "Показать сводку статистики на главной странице",
"show-actionbar": "Показать панель действий",
"show-actionbar-desc": "Всегда показывать панель действий на карточке игры",
"show-virtual-collections": "Показать автоматически созданные коллекции",

View File

@@ -49,6 +49,8 @@
"show-siblings-desc": "在启用\"Rom 文件组\"选项时将会在游戏库中显示已分组 Rom 的版本数量",
"show-status": "显示状态",
"show-status-desc": "在游戏库中显示状态标识(积压、游玩中、已完成等)",
"show-stats": "显示统计信息",
"show-stats-desc": "在主页上显示统计信息摘要",
"show-actionbar": "显示操作栏",
"show-actionbar-desc": "始终在游戏卡片中显示操作栏",
"show-virtual-collections": "显示自动生成的收藏",

View File

@@ -2,6 +2,7 @@
import { onMounted, ref, computed } from "vue";
import { storeToRefs } from "pinia";
import { useI18n } from "vue-i18n";
import Stats from "@/components/Home/Stats.vue";
import Collections from "@/components/Home/Collections.vue";
import VirtualCollections from "@/components/Home/VirtualCollections.vue";
import Platforms from "@/components/Home/Platforms.vue";
@@ -28,6 +29,7 @@ function getSettingValue(key: string, defaultValue: boolean = true): boolean {
return stored === null ? defaultValue : stored === "true";
}
const showStats = getSettingValue("showStats");
const showRecentRoms = getSettingValue("showRecentRoms");
const showContinuePlaying = getSettingValue("showContinuePlaying");
const showPlatforms = getSettingValue("showPlatforms");
@@ -95,32 +97,33 @@ onMounted(async () => {
</script>
<template>
<RecentSkeletonLoader
<stats v-if="showStats" />
<recent-skeleton-loader
v-if="showRecentSkeleton"
:title="t('home.recently-added')"
class="ma-2"
/>
<RecentAdded
<recent-added
v-else-if="recentRoms.length > 0 && showRecentRoms"
class="ma-2"
/>
<RecentSkeletonLoader
<recent-skeleton-loader
v-if="showContinuePlayingSkeleton"
:title="t('home.continue-playing')"
class="ma-2"
/>
<ContinuePlaying
<continue-playing
v-else-if="recentPlayedRoms.length > 0 && showContinuePlaying"
class="ma-2"
/>
<Platforms v-if="filledPlatforms.length > 0 && showPlatforms" class="ma-2" />
<Collections
<platforms v-if="filledPlatforms.length > 0 && showPlatforms" class="ma-2" />
<collections
v-if="allCollections.length > 0 && showCollections"
class="ma-2"
/>
<VirtualCollections
<virtual-collections
v-if="virtualCollections.length > 0 && showVirtualCollections"
class="ma-2"
/>
<EmptyHome v-if="isEmpty" class="ma-2" />
<empty-home v-if="isEmpty" class="ma-2" />
</template>