aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/ui/src/pages/home-view.tsx
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2026-03-29 00:54:21 +0800
committer苏向夜 <fu050409@163.com>2026-03-29 00:54:21 +0800
commit97fe5046f68b5e4ee5f750945bcc39a27f5eb37b (patch)
treeb5263ff32f888a0631fe4ae8a22bcbb7a80ed1f7 /packages/ui/src/pages/home-view.tsx
parent2412f7a3a626fc3b9e7b59ce1fc900468b792972 (diff)
downloadDropOut-97fe5046f68b5e4ee5f750945bcc39a27f5eb37b.tar.gz
DropOut-97fe5046f68b5e4ee5f750945bcc39a27f5eb37b.zip
chore(ui): refactor effect instance check
Diffstat (limited to 'packages/ui/src/pages/home-view.tsx')
-rw-r--r--packages/ui/src/pages/home-view.tsx94
1 files changed, 11 insertions, 83 deletions
diff --git a/packages/ui/src/pages/home-view.tsx b/packages/ui/src/pages/home-view.tsx
index 4f80cb0..6060370 100644
--- a/packages/ui/src/pages/home-view.tsx
+++ b/packages/ui/src/pages/home-view.tsx
@@ -1,18 +1,11 @@
-import { useEffect, useState } from "react";
+import { useState } from "react";
import { BottomBar } from "@/components/bottom-bar";
-import type { SaturnEffect } from "@/lib/effects/SaturnEffect";
-import { useGameStore } from "../stores/game-store";
-import { useReleasesStore } from "../stores/releases-store";
+import { useSaturnEffect } from "@/components/particle-background";
export function HomeView() {
- const gameStore = useGameStore();
- const releasesStore = useReleasesStore();
const [mouseX, setMouseX] = useState(0);
const [mouseY, setMouseY] = useState(0);
-
- useEffect(() => {
- releasesStore.loadReleases();
- }, [releasesStore.loadReleases]);
+ const saturn = useSaturnEffect();
const handleMouseMove = (e: React.MouseEvent) => {
const x = (e.clientX / window.innerWidth) * 2 - 1;
@@ -21,100 +14,42 @@ export function HomeView() {
setMouseY(y);
// Forward mouse move to SaturnEffect (if available) for parallax/rotation interactions
- try {
- const saturn = (
- window as unknown as {
- getSaturnEffect?: () => SaturnEffect;
- }
- ).getSaturnEffect?.();
- if (saturn?.handleMouseMove) {
- saturn.handleMouseMove(e.clientX);
- }
- } catch {
- /* best-effort, ignore errors from effect */
- }
+ saturn?.handleMouseMove(e.clientX);
};
const handleSaturnMouseDown = (e: React.MouseEvent) => {
- try {
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleMouseDown) {
- saturn.handleMouseDown(e.clientX);
- }
- } catch {
- /* ignore */
- }
+ saturn?.handleMouseDown(e.clientX);
};
const handleSaturnMouseUp = () => {
- try {
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleMouseUp) {
- saturn.handleMouseUp();
- }
- } catch {
- /* ignore */
- }
+ saturn?.handleMouseUp();
};
const handleSaturnMouseLeave = () => {
// Treat leaving the area as mouse-up for the effect
- try {
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleMouseUp) {
- saturn.handleMouseUp();
- }
- } catch {
- /* ignore */
- }
+ saturn?.handleMouseUp();
};
const handleSaturnTouchStart = (e: React.TouchEvent) => {
if (e.touches && e.touches.length === 1) {
- try {
const clientX = e.touches[0].clientX;
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleTouchStart) {
- saturn.handleTouchStart(clientX);
- }
- } catch {
- /* ignore */
- }
+ saturn?.handleTouchStart(clientX);
}
};
const handleSaturnTouchMove = (e: React.TouchEvent) => {
if (e.touches && e.touches.length === 1) {
- try {
const clientX = e.touches[0].clientX;
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleTouchMove) {
- saturn.handleTouchMove(clientX);
- }
- } catch {
- /* ignore */
- }
+ saturn?.handleTouchMove(clientX);
}
};
const handleSaturnTouchEnd = () => {
- try {
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleTouchEnd) {
- saturn.handleTouchEnd();
- }
- } catch {
- /* ignore */
- }
+ saturn?.handleTouchEnd();
};
return (
- <div
- className="relative z-10 h-full overflow-y-auto custom-scrollbar scroll-smooth"
- style={{
- overflow: releasesStore.isLoading ? "hidden" : "auto",
- }}
- >
+ <div className="relative z-10 h-full overflow-y-auto custom-scrollbar scroll-smooth">
{/* Hero Section (Full Height) - Interactive area */}
<div
role="tab"
@@ -150,13 +85,6 @@ export function HomeView() {
<div className="bg-white/10 backdrop-blur-md border border-white/10 px-3 py-1 rounded-sm text-xs font-bold uppercase tracking-widest text-white shadow-sm">
Java Edition
</div>
- <div className="h-4 w-px bg-white/20"></div>
- <div className="text-sm text-zinc-400">
- Latest Release{" "}
- <span className="text-white font-medium">
- {gameStore.latestRelease?.id || "..."}
- </span>
- </div>
</div>
</div>