From b487ed4346c43b3f2c0f721c4d723025296cece2 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Mon, 9 Jun 2025 13:52:42 +1000 Subject: [PATCH] chore: commit prototype --- components/GameCarousel.vue | 7 +- components/GamePanel.vue | 15 +-- components/LanguageSelector.vue | 5 +- components/Store/BigCarousel.vue | 74 +++++++++++ components/Store/SmallBento.vue | 120 ++++++++++++++++++ components/Store/SmallCarousel.vue | 28 ++++ components/Store/SmallFocused.vue | 70 ++++++++++ composables/store.ts | 42 ++++++ i18n/locales/en_us.json | 1 + package.json | 2 +- pages/store/index.vue | 111 +--------------- .../migration.sql | 32 +++++ prisma/models/content.prisma | 1 + prisma/models/store.prisma | 21 +++ server/api/v1/store/recent.get.ts | 35 ----- server/api/v1/store/released.get.ts | 16 --- server/api/v1/store/source.get.ts | 51 ++++++++ server/api/v1/store/updated.get.ts | 28 ---- server/internal/metadata/giantbomb.ts | 1 + server/internal/metadata/igdb.ts | 1 + server/internal/metadata/index.ts | 1 + server/internal/metadata/pcgamingwiki.ts | 1 + server/internal/metadata/types.d.ts | 1 + server/internal/store/types.ts | 43 +++++++ yarn.lock | 2 +- 25 files changed, 506 insertions(+), 203 deletions(-) create mode 100644 components/Store/BigCarousel.vue create mode 100644 components/Store/SmallBento.vue create mode 100644 components/Store/SmallCarousel.vue create mode 100644 components/Store/SmallFocused.vue create mode 100644 composables/store.ts create mode 100644 prisma/migrations/20250609031527_add_store_changes/migration.sql create mode 100644 prisma/models/store.prisma delete mode 100644 server/api/v1/store/recent.get.ts delete mode 100644 server/api/v1/store/released.get.ts create mode 100644 server/api/v1/store/source.get.ts delete mode 100644 server/api/v1/store/updated.get.ts create mode 100644 server/internal/store/types.ts diff --git a/components/GameCarousel.vue b/components/GameCarousel.vue index 14ab80e..202707c 100644 --- a/components/GameCarousel.vue +++ b/components/GameCarousel.vue @@ -31,11 +31,8 @@ diff --git a/components/Store/SmallBento.vue b/components/Store/SmallBento.vue new file mode 100644 index 0000000..8848314 --- /dev/null +++ b/components/Store/SmallBento.vue @@ -0,0 +1,120 @@ + + + diff --git a/components/Store/SmallCarousel.vue b/components/Store/SmallCarousel.vue new file mode 100644 index 0000000..48eca08 --- /dev/null +++ b/components/Store/SmallCarousel.vue @@ -0,0 +1,28 @@ + + + diff --git a/components/Store/SmallFocused.vue b/components/Store/SmallFocused.vue new file mode 100644 index 0000000..c111521 --- /dev/null +++ b/components/Store/SmallFocused.vue @@ -0,0 +1,70 @@ + + + diff --git a/composables/store.ts b/composables/store.ts new file mode 100644 index 0000000..9231eef --- /dev/null +++ b/composables/store.ts @@ -0,0 +1,42 @@ +import type { SerializeObject } from "nitropack"; +import type { Company, Game } from "~/prisma/client"; +import type { StoreComponentSource } from "~/server/internal/store/types"; + +export type StoreRenderableItem = SerializeObject; + +const internalSourceCache: Map = + new Map(); +const internalGameCache: Map = new Map(); + +async function unpackSource( + source: typeof StoreComponentSource.infer, + amount?: number, +): Promise> { + const gameIds = internalSourceCache.get(source)!.slice(0, amount); + const games = gameIds.map((e) => internalGameCache.get(e)!); + return games; +} +export async function useStoreSource( + source: typeof StoreComponentSource.infer, + amount?: number, +): Promise> { + if (internalSourceCache.has(source)) { + return unpackSource(source, amount); + } + + const results = (await $dropFetch("/api/v1/store/source", { + query: { + ...source, + amount, + }, + })) as Array; + + const gameIds = []; + for (const result of results) { + gameIds.push(result.id); + internalGameCache.set(result.id, result); + } + internalSourceCache.set(source, gameIds); + + return unpackSource(source, amount); +} diff --git a/i18n/locales/en_us.json b/i18n/locales/en_us.json index c7f9bda..939680e 100644 --- a/i18n/locales/en_us.json +++ b/i18n/locales/en_us.json @@ -467,6 +467,7 @@ "settings": "Settings", "store": { "commingSoon": "coming soon", + "explore": "Explore {arrow}", "exploreMore": "Explore more {arrow}", "images": "Game Images", "lookAt": "Check it out", diff --git a/package.json b/package.json index 2fb2212..e993237 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "jdenticon": "^3.3.0", "luxon": "^3.6.1", "micromark": "^4.0.1", - "nuxt": "^3.17.4", + "nuxt": "^3.17.5", "nuxt-security": "2.2.0", "prisma": "^6.7.0", "sanitize-filename": "^1.6.3", diff --git a/pages/store/index.vue b/pages/store/index.vue index b9c1f80..6596204 100644 --- a/pages/store/index.vue +++ b/pages/store/index.vue @@ -1,115 +1,18 @@