chore: fix lint and type errors from feature bundle implementation

This commit is contained in:
2026-04-29 00:54:39 +08:00
parent 2101dfef08
commit fcfcce614a
5 changed files with 19 additions and 18 deletions
+2 -2
View File
@@ -64,8 +64,8 @@ export default function ComparePage() {
} }
const data = await res.json() const data = await res.json()
setComparisonData(data.games || []) setComparisonData(data.games || [])
} catch (err: any) { } catch (err: unknown) {
setError(err.message || "Failed to load comparison") setError(err instanceof Error ? err.message : "Failed to load comparison")
} finally { } finally {
setLoading(false) setLoading(false)
} }
@@ -49,6 +49,7 @@ export function StabilityScatterChart({ data, deviceNames }: { data: ScatterPoin
const option = { const option = {
tooltip: { tooltip: {
trigger: "item" as const, trigger: "item" as const,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
formatter: (params: any) => { formatter: (params: any) => {
if (params.seriesName === "Perfect Stability") return "" if (params.seriesName === "Perfect Stability") return ""
return `${params.seriesName}<br/>Avg: ${params.value[0]} fps<br/>1% Low: ${params.value[1]} fps` return `${params.seriesName}<br/>Avg: ${params.value[0]} fps<br/>1% Low: ${params.value[1]} fps`
+13 -13
View File
@@ -3,6 +3,7 @@
import { useState, useEffect, useRef } from "react" import { useState, useEffect, useRef } from "react"
import Image from "next/image" import Image from "next/image"
import { SearchIcon, XIcon, Gamepad2Icon } from "lucide-react" import { SearchIcon, XIcon, Gamepad2Icon } from "lucide-react"
import { useDebounce } from "@/lib/hooks/useDebounce"
interface SearchResult { interface SearchResult {
id: string id: string
@@ -25,28 +26,28 @@ export function GameSelector({ selectedGames, onSelect, onRemove, maxSelections
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
const wrapperRef = useRef<HTMLDivElement>(null) const wrapperRef = useRef<HTMLDivElement>(null)
const debouncedQuery = useDebounce(query, 300)
useEffect(() => { useEffect(() => {
if (query.length < 2) { if (debouncedQuery.length < 2) {
setResults([])
return return
} }
let cancelled = false let cancelled = false
const timeout = setTimeout(async () => { async function fetchResults() {
setLoading(true) setLoading(true)
try { try {
const res = await fetch(`/api/search/unified?q=${encodeURIComponent(query)}`) const res = await fetch(`/api/search/unified?q=${encodeURIComponent(debouncedQuery)}`)
if (!res.ok) throw new Error("Search failed") if (!res.ok) throw new Error("Search failed")
const data = await res.json() const data = await res.json() as { results: Array<{ id?: string; appId?: number; title: string; image: string | null; source: string }> }
if (!cancelled) { if (!cancelled) {
setResults( setResults(
(data.results || []) (data.results || [])
.filter((r: any) => !selectedGames.some(sg => sg.id === (r.id || `steam-${r.appId}`))) .filter((r) => !selectedGames.some(sg => sg.id === (r.id || `steam-${r.appId}`)))
.slice(0, 8) .slice(0, 8)
.map((r: any) => ({ .map((r) => ({
id: r.id || `steam-${r.appId}`, id: r.id || `steam-${r.appId}`,
appId: r.appId, appId: r.appId ?? null,
title: r.title, title: r.title,
image: r.image, image: r.image,
source: r.source, source: r.source,
@@ -58,13 +59,12 @@ export function GameSelector({ selectedGames, onSelect, onRemove, maxSelections
} finally { } finally {
if (!cancelled) setLoading(false) if (!cancelled) setLoading(false)
} }
}, 300) }
fetchResults()
return () => { return () => {
cancelled = true cancelled = true
clearTimeout(timeout)
} }
}, [query, selectedGames]) }, [debouncedQuery, selectedGames])
// Close dropdown on outside click // Close dropdown on outside click
useEffect(() => { useEffect(() => {
@@ -122,7 +122,7 @@ export function GameSelector({ selectedGames, onSelect, onRemove, maxSelections
</div> </div>
{/* Dropdown results */} {/* Dropdown results */}
{open && (query.length >= 2) && ( {open && (debouncedQuery.length >= 2) && (
<div className="absolute z-50 top-full left-0 right-0 mt-1 rounded-lg border border-border bg-background shadow-lg max-h-64 overflow-y-auto"> <div className="absolute z-50 top-full left-0 right-0 mt-1 rounded-lg border border-border bg-background shadow-lg max-h-64 overflow-y-auto">
{loading && ( {loading && (
<div className="px-4 py-3 text-xs text-text/40">Searching...</div> <div className="px-4 py-3 text-xs text-text/40">Searching...</div>
+2 -2
View File
@@ -98,8 +98,8 @@ export function NonSteamEditForm({ game, platformSupport, hardwareList, isOwner,
} }
router.push(`/game/${game.id}`) router.push(`/game/${game.id}`)
router.refresh() router.refresh()
} catch (err: any) { } catch (err: unknown) {
setError(err.message || "Failed to update game") setError(err instanceof Error ? err.message : "Failed to update game")
} finally { } finally {
setLoading(false) setLoading(false)
} }
@@ -1,6 +1,6 @@
"use client" "use client"
import { ImageIcon, Monitor, Info, FileText, Link, Calendar } from "lucide-react" import { ImageIcon, Monitor, Info, FileText, Link } from "lucide-react"
import { BasicInfoData } from "./non-steam-basic-info-step" import { BasicInfoData } from "./non-steam-basic-info-step"
import { PlatformSupportItem } from "./non-steam-platform-step" import { PlatformSupportItem } from "./non-steam-platform-step"