fix: AudioContext 复用 + 盲盒加载错误提示 + icon 按钮 aria-label

- #27: panic/blindbox/ShareCardModal/AuthModal 中 icon-only 按钮补 aria-label
- #28: playChime 缓存复用单个 AudioContext,避免超出浏览器 ~6 个上限
- #29: 已完成(上一批次 ApiError.name = "ApiError")
- #30: blindbox lobby fetchRooms 失败时显示"加载失败/点击重试"
- #31: 已完成(theme.ts VALID_THEMES 校验)
This commit is contained in:
2026-02-26 20:25:56 +08:00
parent f4a8fd7fee
commit deba7ab2bb
6 changed files with 41 additions and 5 deletions
+21 -2
View File
@@ -42,6 +42,7 @@ export default function BlindboxLobbyPage() {
const [joinCode, setJoinCode] = useState("");
const [joining, setJoining] = useState(false);
const [error, setError] = useState("");
const [loadError, setLoadError] = useState(false);
useEffect(() => {
const registered = isRegistered();
@@ -65,12 +66,14 @@ export default function BlindboxLobbyPage() {
const p = getCachedProfile();
if (!p) return;
setLoading(true);
setLoadError(false);
try {
const res = await fetch(`/api/blindbox/rooms?userId=${p.id}`);
if (!res.ok) throw new Error();
const data = await res.json();
setRooms(data.rooms ?? []);
setRooms(Array.isArray(data.rooms) ? data.rooms : []);
} catch {
/* ignore */
setLoadError(true);
} finally {
setLoading(false);
}
@@ -219,6 +222,22 @@ export default function BlindboxLobbyPage() {
</motion.div>
) : loading ? (
<BlindboxListSkeleton />
) : loadError ? (
<motion.div
key="load-error"
className="mt-16 flex flex-col items-center gap-3"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
>
<Package size={36} className="text-purple-400/30" strokeWidth={1.5} />
<p className="text-sm text-muted"></p>
<button
onClick={fetchRooms}
className="mt-1 text-xs font-medium text-purple-400 active:text-purple-300"
>
</button>
</motion.div>
) : rooms.length === 0 ? (
/* ============ Layer 2: Logged in, no rooms — Create first ============ */
<motion.div