feat: share button uses steamAppId/slug instead of UUID

This commit is contained in:
2026-05-20 02:23:09 +08:00
parent 1929572060
commit e61071007e
2 changed files with 19 additions and 1 deletions
+4
View File
@@ -61,6 +61,7 @@ interface Game {
capsuleImage: string | null capsuleImage: string | null
storeUrl: string | null storeUrl: string | null
source: string source: string
slug: string | null
lastSync: string | null lastSync: string | null
syncStatus: string | null syncStatus: string | null
createdAt: string createdAt: string
@@ -1901,6 +1902,9 @@ export function GamePageClient({
<PresetDetailModal <PresetDetailModal
preset={preset} preset={preset}
gameId={gameId} gameId={gameId}
gameSource={game.source}
gameSteamAppId={game.steamAppId}
gameSlug={game.slug ?? null}
onClose={handlePresetClose} onClose={handlePresetClose}
onDelete={handleDeletePreset} onDelete={handleDeletePreset}
onReport={handleReportPreset} onReport={handleReportPreset}
+15 -1
View File
@@ -73,6 +73,9 @@ interface Preset {
interface PresetDetailModalProps { interface PresetDetailModalProps {
preset: Preset preset: Preset
gameId: string gameId: string
gameSource: string
gameSteamAppId: number | null
gameSlug: string | null
onClose: () => void onClose: () => void
onDelete: (presetId: string) => void onDelete: (presetId: string) => void
onReport: ( onReport: (
@@ -140,6 +143,9 @@ function hasGameInfoData(p: Preset): boolean {
export function PresetDetailModal({ export function PresetDetailModal({
preset, preset,
gameId, gameId,
gameSource,
gameSteamAppId,
gameSlug,
onClose, onClose,
onDelete, onDelete,
onReport, onReport,
@@ -169,7 +175,15 @@ export function PresetDetailModal({
const isAuthenticated = !!session?.user const isAuthenticated = !!session?.user
const handleShare = () => { const handleShare = () => {
const url = `${window.location.origin}/game/${gameId}?preset=${preset.id}` let identifier: string
if (gameSource === "steam" && gameSteamAppId != null) {
identifier = String(gameSteamAppId)
} else if (gameSlug) {
identifier = gameSlug
} else {
identifier = gameId // fallback for edge cases
}
const url = `${window.location.origin}/game/${identifier}?preset=${preset.id}`
navigator.clipboard.writeText(url) navigator.clipboard.writeText(url)
setCopied(true) setCopied(true)
setTimeout(() => setCopied(false), 2000) setTimeout(() => setCopied(false), 2000)