auth update
This commit is contained in:
@@ -86,7 +86,7 @@ export default function AdminDashboard() {
|
||||
{/* Панель добавления сервера */}
|
||||
<div className="lg:col-span-1">
|
||||
<div className="bg-black/40 border border-white/10 rounded-2xl p-6 relative overflow-hidden group">
|
||||
<div className="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-secondary to-primary opacity-50" />
|
||||
<div className="absolute top-0 left-0 w-full h-1 bg-linear-to-r from-secondary to-primary opacity-50" />
|
||||
<h2 className="text-sm font-bold uppercase tracking-widest mb-6 flex items-center gap-2">
|
||||
<Plus className="w-4 h-4 text-secondary" />
|
||||
Deploy New Node
|
||||
|
||||
+17
-52
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Cyberhack, type CyberhackResult } from "cyberhack";
|
||||
import { submitHackResult } from "./api";
|
||||
@@ -8,12 +8,9 @@ export default function HackGame() {
|
||||
const [lang] = useState<"en" | "ru">(
|
||||
() => (localStorage.getItem("lang") as "en" | "ru") || "en",
|
||||
);
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [engineReady, setEngineReady] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// 1. TWA Setup
|
||||
if (typeof window !== "undefined" && (window as any).Telegram?.WebApp) {
|
||||
const tg = (window as any).Telegram.WebApp;
|
||||
tg.expand();
|
||||
@@ -21,30 +18,7 @@ export default function HackGame() {
|
||||
tg.disableVerticalSwipes();
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Resize Observer для вычисления реальных пикселей
|
||||
const resizeObserver = new ResizeObserver((entries) => {
|
||||
for (const entry of entries) {
|
||||
if (canvasRef.current) {
|
||||
const { width, height } = entry.contentRect;
|
||||
canvasRef.current.width = width;
|
||||
canvasRef.current.height = height;
|
||||
// Только после получения первых размеров считаем движок готовым к рендеру
|
||||
if (width > 0 && height > 0 && !engineReady) {
|
||||
setEngineReady(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (containerRef.current) {
|
||||
resizeObserver.observe(containerRef.current);
|
||||
}
|
||||
|
||||
return () => {
|
||||
resizeObserver.disconnect();
|
||||
};
|
||||
}, [engineReady]);
|
||||
}, []);
|
||||
|
||||
const handleComplete = async (result: CyberhackResult) => {
|
||||
try {
|
||||
@@ -65,34 +39,25 @@ export default function HackGame() {
|
||||
>
|
||||
<button
|
||||
onClick={() => navigate("/profile")}
|
||||
className="absolute top-4 right-4 text-muted-foreground hover:text-[#FF003C] z-[60] text-xs uppercase tracking-widest border border-white/10 hover:border-[#FF003C]/50 px-3 py-1 rounded transition-colors bg-black/50 backdrop-blur-sm"
|
||||
className="absolute top-4 right-4 text-muted-foreground hover:text-[#FF003C] z-60 text-xs uppercase tracking-widest border border-white/10 hover:border-[#FF003C]/50 px-3 py-1 rounded transition-colors bg-black/50 backdrop-blur-sm"
|
||||
>
|
||||
[Abort Sequence]
|
||||
</button>
|
||||
|
||||
{!engineReady && (
|
||||
<div className="absolute inset-0 flex items-center justify-center text-secondary z-10 font-mono text-sm animate-pulse">
|
||||
Allocating memory buffer...
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Отрисовываем компонент только когда контейнер готов */}
|
||||
{engineReady && (
|
||||
<div className="absolute inset-0 w-full h-full block">
|
||||
<Cyberhack
|
||||
timeLimit={45}
|
||||
baseValue={50}
|
||||
locale={lang}
|
||||
redirectUrl=""
|
||||
theme={{
|
||||
primary: "#8B3DFF",
|
||||
secondary: "#00E5F2",
|
||||
background: "#05050A",
|
||||
}}
|
||||
onComplete={handleComplete}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute inset-0 w-full h-full block">
|
||||
<Cyberhack
|
||||
timeLimit={45}
|
||||
baseValue={50}
|
||||
locale={lang}
|
||||
redirectUrl=""
|
||||
theme={{
|
||||
primary: "#8B3DFF",
|
||||
secondary: "#00E5F2",
|
||||
background: "#05050A",
|
||||
}}
|
||||
onComplete={handleComplete}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user