diff --git a/AGENTS.md b/AGENTS.md index 1a1b774..9e11af1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,10 +1,7 @@ # AGENTS.md - Build God Project -Guidelines for agentic coding agents working on this repository. - ## Project Overview - -- **Backend**: ASP.NET Core 8.0 Web API (C#) with PostgreSQL and SqlSugar ORM +- **Backend**: ASP.NET Core 8.0 + PostgreSQL + SqlSugar ORM - **Admin Frontend**: Vue 3 + TypeScript + Vite + Element Plus (port 5173) - **Game Frontend**: Vue 3 + TypeScript + Vite + Element Plus + TailwindCSS + Three.js (port 5174) @@ -12,57 +9,31 @@ Guidelines for agentic coding agents working on this repository. ## 1. Build, Lint, and Test Commands -### Backend (.NET API) - +### Backend ```bash -# Build the solution dotnet build Build_God_Api/Build_God_Api/Build_God_Api.csproj - -# Run the API (launches on https://localhost:59447, http://localhost:59448) dotnet run --project Build_God_Api/Build_God_Api/Build_God_Api.csproj - -# Run with specific URL dotnet run --urls "http://localhost:5091" ``` +No test framework or linting configured. -**Note**: No test framework or linting is currently configured for the backend. - -### Admin Frontend (Build_God_Admin_Frontend/Frontend) - +### Admin Frontend ```bash -# Install dependencies npm install - -# Start development server (http://localhost:5173) -npm run dev - -# Build for production -npm run build - -# Type-check only -npm run type-check - -# Preview production build -npm run preview +npm run dev # http://localhost:5173 +npm run build # Production build +npm run type-check # Type-check only +npm run preview # Preview production build ``` -### Game Frontend (Build_God_Game) - +### Game Frontend ```bash -# Install dependencies npm install - -# Start development server (http://localhost:5174) -npm run dev - -# Build for production -npm run build - -# Type-check only -vue-tsc --build +npm run dev # http://localhost:5174 +npm run build # Production build +vue-tsc --build # Type-check only ``` - -**Note**: No test framework or ESLint is configured for either frontend. +No test framework or ESLint configured for frontends. --- @@ -70,208 +41,130 @@ vue-tsc --build ### Backend (.NET/C#) -#### Conventions -- Use **file-scoped namespaces** (`namespace Build_God_Api.Controllers;`) -- Enable **nullable reference types** (`enable`) -- Use **primary constructors** for dependency injection -- Use **async/await** for all I/O operations -- Use **region** sparingly - prefer natural code organization - -#### Naming -- **Classes/Types**: PascalCase (`AccountController`, `AccountService`) -- **Methods/Properties**: PascalCase (`GetAccount`, `UserName`) -- **Local variables/Parameters**: camelCase (`accountId`, `emailAddress`) -- **Interfaces**: Prefix with `I` (`IAccountService`) -- **DTOs**: Postfix with `Cmd` for commands, `Dto` for responses - -#### Project Structure +**Conventions:** +- File-scoped namespaces (`namespace Build_God_Api.Controllers;`) +- Nullable reference types enabled (`enable`) +- Primary constructors for dependency injection +- Use `async/await` for all I/O operations +- Avoid `region` - prefer natural code organization + +**Naming:** +- Classes/Types: PascalCase (`AccountController`) +- Methods/Properties: PascalCase (`GetAccount`) +- Local variables/Parameters: camelCase (`accountId`) +- Interfaces: Prefix with `I` (`IAccountService`) +- DTOs: Postfix with `Cmd` for commands, `Dto` for responses + +**Project Structure:** ``` Build_God_Api/Build_God_Api/ - Controllers/ # API endpoints - Services/ # Business logic interfaces - Services/Game/ # Game-specific services - DB/ # Database entities (extend BaseEntity) - Dto/ # Data transfer objects - Common/ # Utilities and helpers - Hubs/ # SignalR hubs + Controllers/ # API endpoints + Services/ # Business logic interfaces & implementations + Services/Game/ # Game-specific services + DB/ # Database entities (extend BaseEntity) + Dto/ # Data transfer objects + Common/ # Utilities + Hubs/ # SignalR hubs ``` -#### Error Handling -- Return `BadRequest("error message")` for validation errors -- Return `Ok(result)` for successful operations -- Use try-catch with `Console.WriteLine` for error logging -- Validate inputs at controller level using DataAnnotations +**Error Handling:** +- `BadRequest("message")` for validation errors +- `Ok(result)` for success +- Try-catch with `Console.WriteLine` for error logging +- Use DataAnnotations for input validation at controller level -#### Route Conventions -- Use `[Route("api/god/[controller]")]` -- Use `[ApiController]` and HTTP method attributes (`[HttpGet]`, `[HttpPost]`) +**Route Conventions:** +- `[Route("api/god/[controller]")]` +- `[ApiController]` with `[HttpGet]`/`[HttpPost]` attributes -#### Database Entities (SqlSugar) -- All entities extend `BaseEntity` which provides `Id`, `CreatedOn`, `UpdatedOn`, `CreatedBy`, `UpdatedBy` -- Use `[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]` for auto-increment primary keys +**Database (SqlSugar):** +- Entities extend `BaseEntity` (provides `Id`, `CreatedOn`, `UpdatedOn`, `CreatedBy`, `UpdatedBy`) +- Auto-increment PK: `[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]` --- ### Frontend (Vue 3 + TypeScript) -#### Conventions -- Use **Composition API** with ` - - - - -``` - -#### Pinia Store Pattern -```typescript -import { defineStore } from 'pinia' -import { ref, computed } from 'vue' - -export const useAuthStore = defineStore('auth', () => { - const token = ref('') - const isAuthenticated = computed(() => !!token.value) - - const login = async (credentials: LoginRequest): Promise => { - // implementation - } - - return { token, isAuthenticated, login } -}) +{ "strict": false, "strictNullChecks": false, "noUnusedLocals": false, "noUnusedParameters": false } ``` -#### API Module Pattern -All API modules share a centralized axios instance from `api/index.ts`. - -**`src/api/index.ts`** - Shared axios instance (one per frontend): +**API Pattern (shared axios instance):** ```typescript -import axios from 'axios' - +// src/api/index.ts const instance = axios.create({ baseURL: import.meta.env.VITE_API_URL || 'http://localhost:5091/api/god/', timeout: 10000, headers: { 'Content-Type': 'application/json' } }) - instance.interceptors.request.use((config) => { const token = localStorage.getItem('auth_token') // or sessionStorage for Admin if (token) config.headers.Authorization = `Bearer ${token}` return config }) - instance.interceptors.response.use( (response) => response.data, - (error) => { - if (error.response?.status === 401) { - localStorage.removeItem('auth_token') - window.location.href = '/login' - } - return Promise.reject(error.response?.data || error.message) - } + (error) => { /* handle 401, reject with data */ } ) - export default instance -``` -**`src/api/{entity}.ts`** - Individual API modules (import from index): -```typescript +// src/api/{entity}.ts import http from './index' - -export interface CharacterDto { ... } - export const characterApi = { - getList: (): Promise => { - return http.get('/character/list') - } + getList: (): Promise => http.get('/character/list') } ``` +**Pinia Store Pattern:** +```typescript +export const useAuthStore = defineStore('auth', () => { + const token = ref('') + const isAuthenticated = computed(() => !!token.value) + const login = async (credentials: LoginRequest): Promise => { /* ... */ } + return { token, isAuthenticated, login } +}) +``` + --- ## 3. API Integration -### Base URL -- Development: `http://localhost:5091/api/god/` -- Routes: `api/god/{entity}` (e.g., `api/god/account/login`) - -### Authentication -- JWT Bearer tokens -- Store in `localStorage` as `auth_token` (Game) or `sessionStorage` (Admin) -- Header: `Authorization: Bearer {token}` +- **Base URL**: `http://localhost:5091/api/god/` +- **Auth**: JWT Bearer tokens + - Game: `localStorage` as `auth_token` + - Admin: `sessionStorage` as `auth_token` -### Key Endpoints -- POST `/api/god/account/register` - Register account -- POST `/api/god/account/login` - User login -- POST `/api/god/account/login/admin` - Admin login +**Key Endpoints:** +- POST `/api/god/account/register` +- POST `/api/god/account/login` +- POST `/api/god/account/login/admin` --- ## 4. Development Workflow -1. **Start Backend**: `dotnet run --project Build_God_Api/Build_God_Api/Build_God_Api.csproj` -2. **Start Admin Frontend**: `npm run dev` (in `Build_God_Admin_Frontend/Frontend/`) -3. **Start Game Frontend**: `npm run dev` (in `Build_God_Game/`) +1. `dotnet run --project Build_God_Api/Build_God_Api/Build_God_Api.csproj` +2. `npm run dev` in `Build_God_Admin_Frontend/Frontend/` +3. `npm run dev` in `Build_God_Game/` --- @@ -285,7 +178,7 @@ export const characterApi = { 5. Register service in `Program.cs` ### Frontend -1. Add API function in `src/api/{entity}.ts` (import `http` from `./index`) +1. Add API function in `src/api/{entity}.ts` 2. Add Pinia store in `src/stores/` if needed 3. Create view component in `src/views/` 4. Add route in `src/router/index.ts` @@ -296,7 +189,5 @@ export const characterApi = { - **Admin credentials**: `admin` / `love_god.123` - **Test account**: `Tom` / `123456` (email: 976802198@qq.com) -- Backend runs on ports **59447** (HTTPS) and **59448** (HTTP) -- Admin Frontend uses sessionStorage; Game Frontend uses localStorage +- Backend: ports 59447 (HTTPS), 59448 (HTTP) - Always use `await` with async operations -- Run type-check before committing diff --git a/Build_God_Api/Build_God_Api/DB/Scrap.cs b/Build_God_Api/Build_God_Api/DB/Scrap.cs index 81aa0ac..c0ee4b9 100644 --- a/Build_God_Api/Build_God_Api/DB/Scrap.cs +++ b/Build_God_Api/Build_God_Api/DB/Scrap.cs @@ -3,6 +3,9 @@ using System.ComponentModel; namespace Build_God_Api.DB { + /// + /// 垃圾表 + /// public class Scrap : BaseEntity { public string Name { get; set; } = string.Empty; diff --git a/Build_God_Game/package.json b/Build_God_Game/package.json index d8c21ad..5b44bd3 100644 --- a/Build_God_Game/package.json +++ b/Build_God_Game/package.json @@ -13,8 +13,10 @@ "@vueuse/core": "^14.2.1", "axios": "^1.13.6", "element-plus": "^2.13.5", + "gsap": "^3.14.2", "jwt-decode": "^4.0.0", "motion": "^12.35.2", + "motion-v": "^1.10.3", "ogl": "^1.0.11", "pinia": "^3.0.4", "three": "^0.183.2", diff --git a/Build_God_Game/src/components/BlurText/BlurText.vue b/Build_God_Game/src/components/BlurText/BlurText.vue new file mode 100644 index 0000000..420d15c --- /dev/null +++ b/Build_God_Game/src/components/BlurText/BlurText.vue @@ -0,0 +1,131 @@ + + + diff --git a/Build_God_Game/src/components/ElectricBorder/ElectricBorder.vue b/Build_God_Game/src/components/ElectricBorder/ElectricBorder.vue new file mode 100644 index 0000000..792bd05 --- /dev/null +++ b/Build_God_Game/src/components/ElectricBorder/ElectricBorder.vue @@ -0,0 +1,221 @@ + + + diff --git a/Build_God_Game/src/components/Shuffle/Shuffle.vue b/Build_God_Game/src/components/Shuffle/Shuffle.vue new file mode 100644 index 0000000..7d16976 --- /dev/null +++ b/Build_God_Game/src/components/Shuffle/Shuffle.vue @@ -0,0 +1,455 @@ + + + diff --git a/Build_God_Game/src/views/CharacterView.vue b/Build_God_Game/src/views/CharacterView.vue index 8330d82..c294d64 100644 --- a/Build_God_Game/src/views/CharacterView.vue +++ b/Build_God_Game/src/views/CharacterView.vue @@ -6,6 +6,7 @@ import { useAuthStore } from '@/stores/auth' import { ElProgress } from 'element-plus' import Particles from '@/components/Particles/Particles.vue' import GlareHover from '@/components/GlareHover/GlareHover.vue' +import ElectricBorder from '@/components/ElectricBorder/ElectricBorder.vue' const router = useRouter() const characterStore = useCharacterStore() @@ -50,19 +51,19 @@ const getRateBarColor = (rate: number) => { const handleCreateCharacter = async () => { errorMsg.value = '' - + if (!newCharacterName.value || newCharacterName.value.trim().length < 2) { errorMsg.value = '角色名称至少2个字符' return } - + if (!newCharacterProfessionId.value) { errorMsg.value = '请选择职业' return } - + const success = await characterStore.createCharacter(newCharacterName.value.trim(), newCharacterProfessionId.value) - + if (success) { showCreateDialog.value = false newCharacterName.value = '' @@ -107,30 +108,27 @@ const getExpProgress = (currentExp: number, nextLevelMinExp?: number) => {