Migrate storage to DogeCloud and expand admin dashboard
This commit is contained in:
71
front/src/pages/GamePlayer.tsx
Normal file
71
front/src/pages/GamePlayer.tsx
Normal file
@@ -0,0 +1,71 @@
|
||||
import React from 'react';
|
||||
import { Navigate, useNavigate, useParams } from 'react-router-dom';
|
||||
import { ArrowLeft, ExternalLink } from 'lucide-react';
|
||||
|
||||
import { Button } from '@/src/components/ui/button';
|
||||
|
||||
import { GAME_EXIT_PATH, isGameId, resolveGameHref } from './games-links';
|
||||
|
||||
export default function GamePlayer() {
|
||||
const navigate = useNavigate();
|
||||
const { gameId } = useParams<{ gameId: string }>();
|
||||
|
||||
if (!gameId || !isGameId(gameId)) {
|
||||
return <Navigate to={GAME_EXIT_PATH} replace />;
|
||||
}
|
||||
|
||||
const gameHref = resolveGameHref(gameId);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="glass-panel relative overflow-hidden rounded-3xl p-4 shadow-xl md:p-6">
|
||||
<div className="pointer-events-none absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-white/10 to-transparent" />
|
||||
<div className="relative z-10 flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-xs uppercase tracking-[0.32em] text-slate-400">Game Session</div>
|
||||
<h1 className="mt-2 text-2xl font-bold text-white">{gameId.toUpperCase()}</h1>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant="glass"
|
||||
className="gap-2"
|
||||
onClick={() => navigate(GAME_EXIT_PATH)}
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
退出游戏
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="glass"
|
||||
className="gap-2"
|
||||
onClick={() => window.open(gameHref, '_blank', 'noopener,noreferrer')}
|
||||
>
|
||||
<ExternalLink className="h-4 w-4" />
|
||||
新窗口打开
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="glass-panel relative mt-5 overflow-hidden rounded-2xl p-1 shadow-[0_24px_80px_rgba(0,0,0,0.5)]">
|
||||
<div className="relative overflow-hidden rounded-xl bg-black">
|
||||
<Button
|
||||
type="button"
|
||||
variant="glass"
|
||||
className="absolute left-4 top-4 z-10 gap-2 shadow-lg"
|
||||
onClick={() => navigate(GAME_EXIT_PATH)}
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
退出
|
||||
</Button>
|
||||
<iframe
|
||||
title={`${gameId} game`}
|
||||
src={gameHref}
|
||||
className="h-[70vh] min-h-[560px] w-full border-0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,21 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { motion } from 'motion/react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/src/components/ui/card';
|
||||
import { Button } from '@/src/components/ui/button';
|
||||
import { Gamepad2, Cat, Car, Play } from 'lucide-react';
|
||||
import { Gamepad2, Cat, Car, ExternalLink, Play } from 'lucide-react';
|
||||
import { cn } from '@/src/lib/utils';
|
||||
import { calculateCardTilt } from './games-card-tilt';
|
||||
import { MORE_GAMES_LABEL, MORE_GAMES_URL, resolveGamePlayerPath, type GameId } from './games-links';
|
||||
|
||||
const GAMES = [
|
||||
const GAMES: Array<{
|
||||
id: GameId;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: typeof Cat;
|
||||
color: string;
|
||||
category: 'featured';
|
||||
}> = [
|
||||
{
|
||||
id: 'cat',
|
||||
name: 'CAT',
|
||||
@@ -34,6 +43,7 @@ function applyCardTilt(card: HTMLDivElement, rotateX: number, rotateY: number, g
|
||||
}
|
||||
|
||||
function GameCard({ game, index }: { game: (typeof GAMES)[number]; index: number }) {
|
||||
const navigate = useNavigate();
|
||||
const cardRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
const handleMouseMove = (event: React.MouseEvent<HTMLDivElement>) => {
|
||||
@@ -110,7 +120,11 @@ function GameCard({ game, index }: { game: (typeof GAMES)[number]; index: number
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="relative z-10 mt-auto pt-4">
|
||||
<Button className="w-full gap-2 transition-all group-hover:bg-white group-hover:text-black">
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => navigate(resolveGamePlayerPath(game.id))}
|
||||
className="w-full gap-2 transition-all group-hover:bg-white group-hover:text-black"
|
||||
>
|
||||
<Play className="h-4 w-4" fill="currentColor" /> Launch
|
||||
</Button>
|
||||
</CardContent>
|
||||
@@ -140,6 +154,15 @@ export default function Games() {
|
||||
<p className="text-sm text-slate-400 leading-relaxed">
|
||||
保留轻量试玩与静态资源检查入口,维持与整站一致的毛玻璃语言。在这里您可以快速启动站内集成的小游戏。
|
||||
</p>
|
||||
<a
|
||||
href={MORE_GAMES_URL}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-2 text-sm text-slate-300 transition-colors hover:text-white"
|
||||
>
|
||||
<ExternalLink className="h-4 w-4" />
|
||||
{MORE_GAMES_LABEL}
|
||||
</a>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
|
||||
@@ -331,12 +331,12 @@ export default function Login() {
|
||||
value={registerPassword}
|
||||
onChange={(event) => setRegisterPassword(event.target.value)}
|
||||
required
|
||||
minLength={10}
|
||||
minLength={8}
|
||||
maxLength={64}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-xs text-slate-500 ml-1">
|
||||
至少 10 位,并包含大写字母、小写字母、数字和特殊字符。
|
||||
至少 8 位,并包含大写字母。
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
@@ -350,7 +350,7 @@ export default function Login() {
|
||||
value={registerConfirmPassword}
|
||||
onChange={(event) => setRegisterConfirmPassword(event.target.value)}
|
||||
required
|
||||
minLength={10}
|
||||
minLength={8}
|
||||
maxLength={64}
|
||||
/>
|
||||
</div>
|
||||
|
||||
45
front/src/pages/games-links.test.ts
Normal file
45
front/src/pages/games-links.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
GAME_EXIT_PATH,
|
||||
MORE_GAMES_LABEL,
|
||||
MORE_GAMES_URL,
|
||||
isGameId,
|
||||
resolveGameHref,
|
||||
resolveGamePlayerPath,
|
||||
} from './games-links';
|
||||
|
||||
test('resolveGameHref maps the cat game to the t_race OSS page', () => {
|
||||
assert.equal(resolveGameHref('cat'), '/t_race/');
|
||||
});
|
||||
|
||||
test('resolveGameHref maps the race game to the race OSS page', () => {
|
||||
assert.equal(resolveGameHref('race'), '/race/');
|
||||
});
|
||||
|
||||
test('resolveGamePlayerPath maps the cat game to the in-app player route', () => {
|
||||
assert.equal(resolveGamePlayerPath('cat'), '/games/cat');
|
||||
});
|
||||
|
||||
test('resolveGamePlayerPath maps the race game to the in-app player route', () => {
|
||||
assert.equal(resolveGamePlayerPath('race'), '/games/race');
|
||||
});
|
||||
|
||||
test('isGameId only accepts supported game ids', () => {
|
||||
assert.equal(isGameId('cat'), true);
|
||||
assert.equal(isGameId('race'), true);
|
||||
assert.equal(isGameId('t_race'), false);
|
||||
});
|
||||
|
||||
test('GAME_EXIT_PATH points back to the games lobby', () => {
|
||||
assert.equal(GAME_EXIT_PATH, '/games');
|
||||
});
|
||||
|
||||
test('MORE_GAMES_URL points to the requested external games site', () => {
|
||||
assert.equal(MORE_GAMES_URL, 'https://quruifps.xyz');
|
||||
});
|
||||
|
||||
test('MORE_GAMES_LABEL keeps the friendly-link copy', () => {
|
||||
assert.equal(MORE_GAMES_LABEL, '更多游戏请访问quruifps.xyz');
|
||||
});
|
||||
21
front/src/pages/games-links.ts
Normal file
21
front/src/pages/games-links.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
const GAME_HREFS = {
|
||||
cat: '/t_race/',
|
||||
race: '/race/',
|
||||
} as const;
|
||||
|
||||
export type GameId = keyof typeof GAME_HREFS;
|
||||
export const GAME_EXIT_PATH = '/games';
|
||||
export const MORE_GAMES_URL = 'https://quruifps.xyz';
|
||||
export const MORE_GAMES_LABEL = '更多游戏请访问quruifps.xyz';
|
||||
|
||||
export function resolveGameHref(gameId: GameId) {
|
||||
return GAME_HREFS[gameId];
|
||||
}
|
||||
|
||||
export function resolveGamePlayerPath(gameId: GameId) {
|
||||
return `${GAME_EXIT_PATH}/${gameId}`;
|
||||
}
|
||||
|
||||
export function isGameId(value: string): value is GameId {
|
||||
return value in GAME_HREFS;
|
||||
}
|
||||
Reference in New Issue
Block a user