1 Commits

Author SHA1 Message Date
d623c705b6 feat:实现登录系统和用户认证功能
- 添加登录场景(login_scene.tscn)和主菜单场景(main_menu_scene.tscn)
- 实现认证管理器(AuthManager)用于用户登录和会话管理
- 添加核心服务:加密服务、存储服务、网络服务
- 配置项目主场景为登录场景
- 添加自动加载服务到项目配置
- 添加开发环境配置(VSCode、Claude)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 01:15:33 +08:00
182 changed files with 1423 additions and 15658 deletions

View File

@@ -0,0 +1,13 @@
{
"permissions": {
"allow": [
"WebFetch(domain:whaletownend.xinghangee.icu)",
"mcp__ide__getDiagnostics",
"Bash(dir /s /b *.gd)",
"Bash(findstr:*)",
"Bash(del nul)",
"Bash(git checkout:*)",
"Bash(git add:*)"
]
}
}

55
.gitignore vendored
View File

@@ -1,58 +1,3 @@
# Godot 4+ specific ignores # Godot 4+ specific ignores
.godot/ .godot/
/android/ /android/
# Python cache files
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
*.so
# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
*~
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Godot executable files (should not be in version control)
Godot/
*.exe
*.app
*.dmg
# Logs and temporary files
*.log
*.tmp
*.temp
# Build outputs
build/
dist/
*.zip
*.tar.gz
# Environment files
.env
.env.local
.env.*.local
# Test coverage reports
coverage/
*.coverage
.nyc_output/
# Dependency directories
node_modules/
vendor/

15
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "GDScript Godot",
"type": "godot",
"request": "launch",
"project": "${workspaceFolder}",
"port": 6007,
"address": "127.0.0.1",
"launch_game_instance": true,
"launch_scene": false
}
]
}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"godotTools.editorPath.godot4": "d:\\software\\godot\\Godot_v4.5.1-stable_win64.exe"
}

View File

@@ -1,96 +0,0 @@
# 🎯 CLAUDE.md - WhaleTown Project Instructions
## 1. Project Vision & Context
- **Project**: "WhaleTown" - A 2D top-down pixel art RPG.
- **Engine**: Godot 4.2+ (Strictly NO Godot 3.x syntax).
- **Architecture**: Strictly layered: `_Core` (Framework), `Scenes` (Gameplay), `UI` (Interface).
- **Core Principle**: "Signal Up, Call Down". High decoupling via `EventSystem`.
## 2. 🛠 Command Reference & Setup
- **Input Map (Required Configuration)**:
- `move_left`, `move_right`, `move_up`, `move_down` (WASD / Arrows)
- `interact` (E Key / Space)
- `pause` (ESC)
- **Run Game**: `godot --path .`
- **Run Tests (GUT)**: `godot --headless -s addons/gut/gut_cmdline.gd -gdir=res://tests/ -ginclude_subdirs`
- **Init Structure**: `mkdir -p _Core/managers _Core/systems Scenes/Maps Scenes/Entities Scenes/Components UI/Windows UI/HUD Assets/Sprites tests/unit tests/integration`
## 3. 📂 File Path Rules (STRICT LOWERCASE)
*Claude: Root folders MUST be lowercase. Scripts and Scenes MUST stay together.*
- **Core Managers**: `_Core/managers/[Name].gd`
- **Core Systems**: `_Core/systems/[Name].gd`
- **Entities**: `Scenes/Entities/[EntityName]/[EntityName].tscn` (Script `.gd` in same folder).
- **Maps**: `Scenes/Maps/[map_name].tscn`
- **Components**: `Scenes/Components/[ComponentName].gd` (Reusable logic nodes).
- **UI Windows**: `UI/Windows/[WindowName].tscn`
- **Tests**: `tests/[unit|integration]/test_[name].gd` (Folder is lowercase `tests`).
## 4. 📋 Coding Standards (The Law)
- **Type Safety**: ALWAYS use strict static typing: `var speed: float = 100.0`, `func _ready() -> void`.
- **Naming Conventions**:
- `class_name PascalCase` at the top of every script.
- Variables/Functions: `snake_case`. Constants: `SCREAMING_SNAKE_CASE`.
- Private members: Prefix with underscore `_` (e.g., `var _health: int`).
- **Node Access**: Use `%UniqueName` for UI and internal scene components.
- **Signals**: Use "Signal Up, Call Down". Parent calls child methods; Child emits signals.
- **Forbidden Patterns**:
- ❌ NO `yield()` -> Use `await`.
- ❌ NO `get_node()` in `_process` -> Cache with `@onready`.
- ❌ NO Linear Filter -> All Sprite2D/TileMap resources MUST use **Nearest** filter.
## 5. 🏛 Architecture & Communication
- **EventSystem**: Use `_Core/systems/EventSystem.gd` for cross-module messaging.
- **Event Registry**: Use `class_name EventNames` in `_Core/EventNames.gd`.
```gdscript
class_name EventNames
const PLAYER_MOVED = "player_moved"
const INTERACT_PRESSED = "interact_pressed"
const NPC_TALKED = "npc_talked"
Singletons: Only GameManager, SceneManager, EventSystem allowed as Autoloads.
Decoupling: Low-level entities MUST NOT reference GameManager. Use events.
6. 🏗 Implementation Details
Player: CharacterBody2D. Must include Camera2D with position_smoothing_enabled = true.
NPC/Interactables: Use Area2D named InteractionArea. Trigger via EventSystem.
TileMap Layers:
Layer 0: Ground (No collision).
Layer 1: Obstacles (Physics Layer enabled).
Layer 2: Decoration (Y-Sort enabled).
Camera: Must auto-calculate limits via TileMap.get_used_rect().
7. 🧪 Testing Requirements (MANDATORY)
Coverage: Every Manager/System in _Core/ MUST have a GUT test.
Naming: Test files must start with test_ and extend GutTest.
Example:
code
Gdscript
extends GutTest
func test_event_emission():
var sender = Node.new()
watch_signals(EventSystem)
EventSystem.emit_event(EventNames.PLAYER_MOVED, {})
assert_signal_emitted(EventSystem, "event_raised")
8. 🧘 The Zen of Development
Juice or Death: Every interaction (UI popup, NPC talk) MUST have a Tween placeholder.
Zero Magic Numbers: All speeds/timers MUST be @export or defined in Config/.
Simplicity: If a function does two things, split it.
Back of the Fence: Hidden logic (like ResponseHandler.gd) must be as clean as the HUD.
9. 📝 Code Template (Entity Pattern)
code
Gdscript
extends CharacterBody2D
class_name Player
# 1. Exports & Constants
@export var move_speed: float = 200.0
# 2. Node References
@onready var sprite: Sprite2D = %Sprite2D
# 3. Lifecycle
func _physics_process(delta: float) -> void:
_move(delta)
# 4. Private Methods
func _move(_delta: float) -> void:
var dir := Input.get_vector("move_left", "move_right", "move_up", "move_down")
velocity = dir * move_speed
move_and_slide()

View File

@@ -1,29 +0,0 @@
{
"game": {
"name": "whaleTown",
"version": "1.0.0",
"debug_mode": true
},
"network": {
"api_base_url": "https://whaletownend.xinghangee.icu",
"timeout": 30,
"retry_count": 3
},
"ui": {
"default_font_size": 14,
"toast_duration": 2.0,
"transition_duration": 0.3
},
"gameplay": {
"auto_save_interval": 300,
"max_inventory_slots": 50,
"default_player_stats": {
"level": 1,
"coins": 100,
"exp": 0,
"max_exp": 100,
"energy": 100,
"max_energy": 100
}
}
}

View File

@@ -1,36 +0,0 @@
{
"ui": {
"login": "登录",
"register": "注册",
"username": "用户名",
"password": "密码",
"email": "邮箱",
"confirm_password": "确认密码",
"verification_code": "验证码",
"send_code": "发送验证码",
"forgot_password": "忘记密码",
"enter_town": "进入小镇",
"logout": "退出登录"
},
"messages": {
"login_success": "登录成功!正在进入鲸鱼镇...",
"register_success": "注册成功!欢迎加入鲸鱼镇",
"network_error": "网络连接失败,请检查网络连接",
"invalid_username": "用户名只能包含字母、数字和下划线",
"invalid_email": "请输入有效的邮箱地址",
"password_too_short": "密码长度至少8位",
"password_mismatch": "两次输入的密码不一致",
"verification_code_sent": "验证码已发送到您的邮箱,请查收"
},
"game": {
"level": "等级",
"coins": "金币",
"experience": "经验",
"energy": "体力",
"explore": "探索小镇",
"inventory": "背包",
"shop": "商店",
"friends": "好友",
"settings": "设置"
}
}

View File

@@ -1,235 +0,0 @@
# ✅ 项目结构重构完成报告
## 📅 完成时间
2025-12-31
## 🎉 重构成功
项目已成功从混乱的文件结构重构为清晰、模块化的架构!
---
## 📊 最终结构总览
```
whale-town-front/
├── _Core/ ✅ [框架层] 全局单例和系统
├── Scenes/ ✅ [玩法层] 游戏世界实体
├── UI/ ✅ [界面层] 所有UI界面
├── Assets/ ✅ [资源层] 美术资源
├── Config/ ✅ [配置层] 静态数据
├── Utils/ ✅ [工具层] 工具类
├── Tests/ ✅ [测试层] 测试脚本
└── docs/ 📄 项目文档
```
---
## ✅ 已完成的迁移
### 1⃣ 框架层 (_Core/)
-`GameManager.gd``_Core/managers/`
-`SceneManager.gd``_Core/managers/` (已更新路径)
-`NetworkManager.gd``_Core/managers/`
-`ResponseHandler.gd``_Core/managers/`
-`EventSystem.gd``_Core/systems/`
### 2⃣ 场景层 (Scenes/)
-`scenes/main_scene.tscn``Scenes/Maps/main_scene.tscn`
-`scripts/scenes/MainScene.gd``Scenes/Maps/MainScene.gd`
-`scenes/prefabs/``Scenes/Components/`
### 3⃣ 界面层 (UI/)
-`scenes/auth_scene.tscn``UI/Windows/LoginWindow.tscn`
-`scripts/scenes/AuthScene.gd``UI/Windows/AuthScene.gd`
-`assets/ui/chinese_theme.tres``UI/Theme/MainTheme.tres`
-`assets/fonts/``UI/Theme/Fonts/`
### 4⃣ 配置层 (Config/)
-`data/configs/game_config.json``Config/game_config.json`
-`data/localization/zh_CN.json``Config/zh_CN.json`
### 5⃣ 工具层 (Utils/)
-`core/utils/StringUtils.gd``Utils/StringUtils.gd`
### 6⃣ 资源层 (Assets/)
-`assets/sprites/``Assets/Sprites/`
-`assets/audio/``Assets/Audio/`
- ✅ 其他资源文件保留在 `assets/`(待后续整理)
### 7⃣ 构建脚本
-`scripts/build_web.sh``./build_web.sh`
-`scripts/serve_web.sh``./serve_web.sh`
---
## 🗑️ 已删除的旧目录
-`core/` - 已迁移到 `_Core/`
-`module/` - 空目录,未使用
-`scripts/` - 脚本已内联到场景目录
-`scenes/` - 已迁移到 `Scenes/``UI/`
-`data/` - 配置已移至 `Config/`
---
## 🔧 已更新的配置
### project.godot
```ini
✅ run/main_scene="res://Scenes/Maps/main_scene.tscn"
✅ GameManager="*res://_Core/managers/GameManager.gd"
✅ SceneManager="*res://_Core/managers/SceneManager.gd"
✅ EventSystem="*res://_Core/systems/EventSystem.gd"
✅ NetworkManager="*res://_Core/managers/NetworkManager.gd"
✅ ResponseHandler="*res://_Core/managers/ResponseHandler.gd"
```
### SceneManager.gd
```gdscript
"main": "res://Scenes/Maps/main_scene.tscn"
"auth": "res://UI/Windows/LoginWindow.tscn"
```
### 测试文件
```gdscript
tests/auth/enhanced_toast_test.gd -
tests/auth/auth_ui_test.tscn -
```
---
## 📚 创建的文档
1. **REFACTORING.md** - 详细的重构文档
- 迁移映射表
- 设计原则
- 注意事项
- 后续建议
2. **STRUCTURE_COMPARISON.md** - 结构对比分析
- 旧结构问题分析
- 新结构优势说明
- 对比表格
- 团队协作改进
---
## 🎯 关键改进
### 清晰的分层
- **_Core**: 框架代码,全局系统
- **Scenes**: 游戏世界,地图和实体
- **UI**: 所有界面HUD和弹窗
- **Config**: 静态数据,策划可编辑
- **Utils**: 通用工具函数库
### 组件化设计
```gdscript
Scenes/Components/ //
characters/ //
effects/ //
items/ //
ui/ // UI预制体
```
### 场景内聚
- 每个 `.tscn` 配套一个 `.gd`
- 脚本紧邻场景文件
- 符合 Godot 原生习惯
### UI 独立化
```
UI/
├── Windows/ // 模态窗口(登录、设置)
├── HUD/ // 常驻界面(聊天框)
├── Dialog/ // 对话系统
└── Theme/ // 全局样式
```
---
## ⚠️ 后续步骤
### 必做事项
- [ ] 在 Godot 编辑器中打开项目,让编辑器重新索引文件
- [ ] 测试主场景加载: `Scenes/Maps/main_scene.tscn`
- [ ] 验证登录窗口: `UI/Windows/LoginWindow.tscn`
- [ ] 测试所有自动加载脚本
- [ ] 运行完整测试套件
### 建议优化
- [ ] 补充 `Scenes/Components/` 下的可复用组件
- [ ] 完善 `UI/HUD/``UI/Dialog/`
- [ ] 添加 `Scenes/Entities/Player/` 玩家实体
- [ ] 将硬编码数值移至 `Config/`
### 代码审查
- [ ] 检查是否还有硬编码的旧路径
- [ ] 验证所有 `.import` 文件正常
- [ ] 确认网络连接功能正常
- [ ] 验证 UI 主题显示正确
---
## 🎓 团队协作指南
### 工作目录划分
```
🎨 美术组 → Assets/Sprites/, Assets/Audio/
📋 策划组 → Config/
💻 前端程序 → UI/, Scenes/Entities/
⚙️ 后端程序 → _Core/, Utils/
🧪 测试组 → Tests/
```
### Git 提交建议
```bash
# 按目录分类提交
git add _Core/
git commit -m "refactor: 迁移核心框架代码到 _Core/"
git add Scenes/
git commit -m "refactor: 重组场景文件到 Scenes/"
git add UI/
git commit -m "refactor: 独立 UI 界面到 UI/"
```
---
## 📈 预期收益
### 可维护性提升
- 🟢 目录职责清晰,降低认知负担
- 🟢 新人快速定位文件
- 🟢 减少代码冲突
### 开发效率提升
- 🟢 组件复用更容易
- 🟢 团队协作更流畅
- 🟢 代码审查更高效
### 符合最佳实践
- ✅ Godot 官方推荐结构
- ✅ 场景内聚原则
- ✅ 组件化设计思想
- ✅ 配置与代码分离
---
## 🎉 总结
**重构完成!** 项目现在拥有:
- ✅ 清晰的 6 层架构
- ✅ 符合 Godot 最佳实践
- ✅ 易于维护和扩展
- ✅ 团队协作友好
感谢您的耐心!如有问题,请查看详细文档:
- [REFACTORING.md](./REFACTORING.md) - 重构详情
- [STRUCTURE_COMPARISON.md](./STRUCTURE_COMPARISON.md) - 结构对比
---
**下一步:在 Godot 编辑器中打开项目并测试!** 🚀

466
README.md
View File

@@ -1,427 +1,101 @@
# 🐋 whaleTown # whaleTown
一个使用 Godot 4.5 引擎开发的现代化像素游戏项目集成了完整的用户认证系统和API接口 一个使用 Godot 4.5 引擎开发的游戏项目
## 🎮 项目信息 ## 项目信息
- **引擎版本**: Godot 4.5.1 - **引擎版本**: Godot 4.5
- **渲染器**: Forward Plus - **渲染器**: Forward Plus
- **项目类型**: 2D 像素游戏 - **项目类型**: 2D 游戏
- **架构模式**: 模块化 + 事件驱动
- **后端集成**: RESTful API + 用户认证
## 🚀 快速开始 ## 项目结构
### 环境要求
- [Godot Engine 4.5+](https://godotengine.org/download)
- Python 3.7+ (用于API测试和Web服务器)
### 运行项目
```bash
# 1. 克隆项目
git clone <repository-url>
cd whale-town
# 2. 使用Godot编辑器打开项目
# 3. 按F5运行或点击"运行"按钮
# 4. 测试API接口可选
python tests/api/simple_api_test.py
```
### Web版本部署
```bash
# Windows用户
tools\build_web.bat # 导出Web版本
tools\serve_web.bat # 启动本地测试服务器
# Linux/macOS用户
./tools/build_web.sh # 导出Web版本
./tools/serve_web.sh # 启动本地测试服务器
```
详细部署指南请查看: [Web部署完整指南](docs/web_deployment_guide.md)
## 🏗️ 项目架构
### 核心设计理念
项目采用 **分层架构****组件化设计**,遵循 Godot 最佳实践:
- **清晰的分层** - 框架层、玩法层、界面层明确分离
- **场景内聚** - 脚本紧邻场景文件,符合 Godot 原生开发习惯
- **高度解耦** - 通过事件系统和管理器通信
- **组件复用** - 可复用组件统一管理
- **标准化** - 统一的命名规范和目录结构
- **测试驱动** - 完整的测试体系和文档
### 目录结构
``` ```
whaleTown/ whaleTown/
├── _Core/ # [框架层] 游戏的底层框架,单例,全局管理器 ├── addons/ # Godot 插件目录
│ ├── managers/ # 游戏管理器 ├── assets/ # 游戏资源文件(图片、音频等)
├── GameManager.gd # 游戏状态管理 ├── data/ # 游戏数据文件(配置、关卡数据等)
│ │ ├── SceneManager.gd # 场景管理
│ │ ├── NetworkManager.gd # 网络通信
│ │ └── ResponseHandler.gd # API响应处理
│ ├── systems/ # 核心系统
│ │ └── EventSystem.gd # 事件系统
│ └── singletons/ # 其他单例(待扩展)
├── Scenes/ # [玩法层] 具体的游戏场景、实体、地图
│ ├── Maps/ # 地图场景
│ │ └── main_scene.tscn # 主游戏场景
│ ├── Entities/ # 游戏实体
│ │ ├── Player/ # 玩家实体
│ │ ├── NPC/ # NPC实体
│ │ └── Interactables/ # 交互物
│ └── Components/ # 可复用组件
├── UI/ # [界面层] 所有UI相关的预制体和逻辑
│ ├── HUD/ # 抬头显示(常驻)
│ ├── Windows/ # 模态窗口
│ │ └── LoginWindow.tscn # 登录窗口
│ ├── Dialog/ # 对话系统
│ └── Theme/ # 全局样式
│ ├── MainTheme.tres # 主主题
│ └── Fonts/ # 字体文件
├── Assets/ # [资源层] 美术、音频、字体
│ ├── Sprites/ # 精灵图
│ │ ├── icon/ # 图标
│ │ ├── materials/ # 材质
│ │ ├── shaders/ # 着色器
│ │ └── sprites/ # 精灵图
│ ├── Audio/ # 音频
│ └── Fonts/ # 字体
├── Config/ # [配置层] 游戏配置文件
│ ├── game_config.json # 游戏配置
│ └── zh_CN.json # 中文本地化
├── Utils/ # [工具层] 通用辅助脚本
│ └── StringUtils.gd # 字符串工具
├── Tests/ # [测试层] 单元测试脚本
│ ├── api/ # API接口测试
│ ├── auth/ # 认证UI测试
│ ├── unit/ # 单元测试
│ ├── integration/ # 集成测试
│ └── performance/ # 性能测试
├── docs/ # 项目文档 ├── docs/ # 项目文档
│ ├── auth/ # 认证相关文档 ├── scenes/ # 游戏场景文件
── api-documentation.md # API接口文档 ── main_scene.tscn # 主场景
│ ├── web_deployment_guide.md # Web部署完整指南 ├── scripts/ # GDScript 脚本文件
│ ├── web_deployment_changelog.md # Web部署更新日志 ├── tests/ # 测试文件
│ ├── project_structure.md # 项目结构说明 ├── icon.svg # 项目图标
│ ├── naming_convention.md # 命名规范 └── project.godot # Godot 项目配置文件
│ ├── code_comment_guide.md # 代码注释规范
│ └── git_commit_guide.md # Git提交规范
├── tools/ # 开发工具和脚本
│ ├── build_web.bat # Windows Web导出脚本
│ ├── build_web.sh # Linux/macOS Web导出脚本
│ ├── serve_web.bat # Windows 本地服务器
│ └── serve_web.sh # Linux/macOS 本地服务器
├── REFACTORING.md # 项目结构重构文档
└── MIGRATION_COMPLETE.md # 迁移完成标记
``` ```
### 架构层次说明 ## 开始使用
#### 1. 框架层 (_Core/) ### 前置要求
- **职责**: 游戏的底层框架,与具体游戏逻辑无关
- **内容**: 单例管理器、核心系统
- **特点**: 自动加载,全局可访问
- **命名**: 使用下划线前缀 `_Core` 表示这是核心框架代码
#### 2. 玩法层 (Scenes/) - [Godot Engine 4.5](https://godotengine.org/download) 或更高版本
- **职责**: 游戏世界,地图和实体
- **内容**: 游戏场景、角色、NPC、交互物
- **特点**: 场景内聚,脚本紧邻场景文件
- **组织**: 按游戏世界的实体类型分类
#### 3. 界面层 (UI/) ### 运行项目
- **职责**: 所有界面HUD和弹窗
- **内容**: 常驻界面、模态窗口、对话系统、主题样式
- **特点**: 独立于游戏场景便于UI开发和维护
- **组织**: 按界面类型和用途分类
#### 4. 资源层 (Assets/) 1. 克隆或下载此项目
- **职责**: 纯美术资源 2. 使用 Godot 编辑器打开项目
- **内容**: 精灵图、音频、字体等 3. 在编辑器中点击"运行"按钮或按 F5 键启动游戏
- **特点**: 与代码分离,便于美术组独立工作
- **组织**: 按资源类型分类
#### 5. 配置层 (Config/) ### 开发指南
- **职责**: 静态数据,策划可编辑
- **内容**: 游戏配置、本地化文件
- **特点**: 数据驱动,便于调整游戏参数
- **格式**: JSON 文件
#### 6. 工具层 (Utils/) - **场景文件**: 所有场景文件存放在 `scenes/` 目录
- **职责**: 通用辅助脚本 - **脚本文件**: 所有 GDScript 脚本存放在 `scripts/` 目录
- **内容**: 工具函数库 - **资源文件**: 图片、音频等资源存放在 `assets/` 目录
- **特点**: 可被任何层调用 - **游戏数据**: 配置文件、关卡数据等存放在 `data/` 目录
- **原则**: 无依赖,纯函数
### 核心系统
项目包含以下自动加载的核心系统(位于 [_Core/](./_Core/)
- **GameManager** - 全局游戏状态管理
- **SceneManager** - 场景切换管理
- **EventSystem** - 事件通信系统
- **NetworkManager** - 网络通信管理
- **ResponseHandler** - API响应处理
使用示例:
```gdscript
# 状态管理
GameManager.change_state(GameManager.GameState.IN_GAME)
# 场景切换(已更新路径)
SceneManager.change_scene("main") # → res://Scenes/Maps/main_scene.tscn
# 事件通信
EventSystem.emit_event("player_health_changed", 80)
EventSystem.connect_event("player_died", _on_player_died)
```
### 设计原则
#### 1. 清晰的分层
- **_Core**: 框架代码,与具体游戏逻辑无关
- **Scenes**: 游戏世界,地图和实体
- **UI**: 所有界面HUD和弹窗
- **Config**: 静态数据,策划可编辑
#### 2. 组件化设计
可复用组件放在 `Scenes/Components/` 下,使用组合优于继承的设计模式:
- InteractableArea.tscn - 让任何物体"可交互"
- MovementSync.gd - 网络位置同步
- NameTag3D.tscn - 头顶名字条
#### 3. 场景内聚
- 每个 .tscn 配套一个 .gd
- 脚本紧邻场景文件存放
- 符合 Godot 原生开发习惯
#### 4. 职责单一
```
UI/Windows/ - 模态窗口(登录、设置、商店)
UI/HUD/ - 常驻界面(聊天框、状态栏)
UI/Dialog/ - 对话系统
```
### 团队协作
- **美术组**: 主要在 [Assets/](./Assets/) 工作
- **策划组**: 主要在 [Config/](./Config/) 工作
- **程序组**: 主要在 [_Core/](./_Core/), [Scenes/](./Scenes/), [UI/](./UI/) 工作
- **测试组**: 主要在 [Tests/](./Tests/) 工作
## ✨ 主要功能
### 🔐 用户认证系统
- **用户注册** - 支持邮箱验证码验证
- **用户登录** - 多种登录方式(用户名/邮箱/手机号)
- **密码管理** - 密码重置和修改功能
- **GitHub OAuth** - 第三方登录集成
- **错误处理** - 完整的错误提示和频率限制
- **UI界面**: [UI/Windows/LoginWindow.tscn](UI/Windows/LoginWindow.tscn)
### 🌐 Web版本部署
- **自动化导出** - 一键导出Web版本
- **本地测试服务器** - 内置HTTP服务器用于测试
- **生产环境配置** - 完整的服务器配置指南
- **跨平台支持** - Windows、Linux、macOS全平台支持
- **性能优化** - 资源压缩和加载优化
### 🎮 游戏功能
- **主场景** - 游戏主界面和菜单系统 ([Scenes/Maps/main_scene.tscn](Scenes/Maps/main_scene.tscn))
- **认证场景** - 完整的登录注册界面
- **状态管理** - 用户状态和游戏状态管理
- **网络通信** - RESTful API集成 ([_Core/managers/NetworkManager.gd](_Core/managers/NetworkManager.gd))
### 🧪 测试体系
- **API测试** - 完整的接口测试脚本 ([Tests/api/](Tests/api/))
- **UI测试** - 认证界面的交互测试 ([Tests/auth/](Tests/auth/))
- **错误场景** - 边界条件和异常处理测试
## 🔧 开发规范
### 命名规范 ### 命名规范
- **场景文件**: `snake_case_scene.tscn` (如: `auth_scene.tscn`)
- **脚本文件**: `PascalCase.gd` (如: `AuthScene.gd`)
- **节点名称**: `camelCase` (如: `loginButton`)
- **变量/函数**: `camelCase` (如: `playerHealth`)
- **常量**: `UPPER_CASE` (如: `MAX_HEALTH`)
- **资源文件**: `snake_case` (如: `bg_auth_scene.png`)
### 代码注释规范 本项目遵循统一的命名规范以保持代码一致性:
- **文件头注释**: 说明文件用途、主要功能和依赖关系
- **函数注释**: 包含参数说明、返回值和使用示例 **核心规则**
- **复杂逻辑**: 添加行内注释解释业务逻辑和设计决策
- **特殊标记**: 使用 TODO、FIXME、NOTE 等标准标记 - **场景文件**`下划线_scene.tscn``下划线_prefab.tscn`
- **AI辅助**: 支持AI补充注释提供详细的上下文信息 - 示例:`main_scene.tscn``player_prefab.tscn`
- **脚本文件**`PascalCase.gd`(大驼峰)
- 示例:`PlayerController.gd``UI_MainMenu.gd`
- **节点名称**`camelCase`(小驼峰)
- 示例:`playerHpBar``startButton`
- **变量/函数**`camelCase`(小驼峰)
- 示例:`var moveSpeed``func getPlayerPos()`
- **常量**`UPPER_CASE`(全大写 + 下划线)
- 示例:`const MAX_HEALTH = 100`
- **资源文件**`lower_case`(小写 + 下划线)
- 示例:`bg_main_menu.png``sound_jump.wav`
📖 查看完整的 [命名规范文档](docs/naming_convention.md)
### Git 提交规范 ### Git 提交规范
使用格式:`<类型><描述>`
常用类型:`feat` `fix` `docs` `refactor` `scene` `asset` `ui` `test` 本项目遵循统一的 Git 提交信息格式:`<类型><描述>`
**常用提交类型**
- `init`:项目初始化
- `feat`:新增功能
- `fix`:修复 Bug
- `docs`:文档更新
- `scene`:场景文件相关
- `asset`:资源文件相关
- `ui`UI 界面相关
- `gameplay`:游戏玩法相关
- `refactor`:代码重构
- `perf`:性能优化
**提交示例**
```bash ```bash
git commit -m "feat实现用户登录功能" git commit -m "init项目初始化搭建Godot文件结构"
git commit -m "fix修复429错误处理" git commit -m "feat实现玩家角色的移动和跳跃"
git commit -m "test添加API接口测试" git commit -m "fix修复敌人穿墙的碰撞问题"
git commit -m "docs更新项目文档" git commit -m "scene创建战斗场景并配置相机"
``` ```
## 📚 项目文档 📖 查看完整的 [Git 提交规范文档](docs/git_commit_guide.md)
### 核心文档 ## 贡献
- 📋 [项目结构详解](docs/project_structure.md) - 完整的架构说明
- 📝 [命名规范](docs/naming_convention.md) - 详细的命名规则
- 💬 [代码注释规范](docs/code_comment_guide.md) - 注释标准和AI辅助指南
- 🔀 [Git提交规范](docs/git_commit_guide.md) - 提交信息标准
- 🌐 [Web部署指南](docs/web_deployment_guide.md) - 完整的Web部署文档
### API和测试文档 欢迎提交 Issue 和 Pull Request
- 🔌 [API接口文档](docs/api-documentation.md) - 完整的API说明和测试指南
- 🔐 [认证系统文档](docs/auth/) - 用户认证相关文档
- 🧪 [API测试指南](tests/api/README.md) - API测试使用方法
- 🎮 [认证UI测试](tests/auth/README.md) - UI测试场景说明
## 🛠️ 开发指南 ## 许可证
### 添加新场景 [在此添加许可证信息]
1. 在 [Scenes/](./Scenes/) 对应分类下创建场景文件
2. 脚本文件紧邻场景文件存放(场景内聚原则)
3. 在 [_Core/managers/SceneManager.gd](_Core/managers/SceneManager.gd) 中注册场景路径
4. 使用 `SceneManager.change_scene()` 切换场景
示例:
```gdscript
# 在 SceneManager.gd 中注册
var scene_paths: Dictionary = {
"battle": "res://Scenes/Maps/battle_scene.tscn",
"shop": "res://UI/Windows/ShopWindow.tscn",
}
# 使用
SceneManager.change_scene("battle")
```
### 创建可复用组件
1. 在 [Scenes/Components/](./Scenes/Components/) 创建组件场景
2. 实现标准接口,保持组件独立性
3. 通过 [EventSystem](_Core/systems/EventSystem.gd) 与其他模块通信
4. 组件可以被任何场景实例化复用
### 添加UI界面
1. **模态窗口** → 放入 [UI/Windows/](./UI/Windows/)
2. **常驻界面** → 放入 [UI/HUD/](./UI/HUD/)
3. **对话系统** → 放入 [UI/Dialog/](./UI/Dialog/)
4. UI脚本紧邻场景文件保持内聚
### 资源管理
- **精灵图** → 放入 [Assets/Sprites/](./Assets/Sprites/) 对应分类
- **音频文件** → 放入 [Assets/Audio/](./Assets/Audio/) 对应分类
- **字体文件** → 放入 [UI/Theme/Fonts/](./UI/Theme/Fonts/)
- **配置文件** → 放入 [Config/](./Config/)
- 遵循命名规范,使用英文小写+下划线
### 路径映射参考
| 功能类型 | 旧路径 | 新路径 |
|---------|--------|--------|
| 核心管理器 | `core/managers/` | [_Core/managers/](_Core/managers/) |
| 游戏场景 | `scenes/main_scene.tscn` | [Scenes/Maps/main_scene.tscn](Scenes/Maps/main_scene.tscn) |
| 登录界面 | `scenes/auth_scene.tscn` | [UI/Windows/LoginWindow.tscn](UI/Windows/LoginWindow.tscn) |
| 配置文件 | `data/configs/` | [Config/](Config/) |
| 工具类 | `core/utils/` | [Utils/](Utils/) |
详细的重构说明请查看:[REFACTORING.md](REFACTORING.md)
### API接口测试
项目提供了完整的Python测试脚本来验证API接口
```bash
# 快速测试API连通性
python tests/api/simple_api_test.py
# 完整的API功能测试
python tests/api/api_test.py --verbose
# 自定义服务器地址测试
python tests/api/simple_api_test.py https://your-api-server.com
```
测试脚本会验证:
- ✅ 应用状态检查
- ✅ 用户注册和登录功能
- ✅ 邮箱验证码发送和验证
- ✅ 错误处理和频率限制429错误
- ✅ 管理员功能和权限控制
- ✅ 用户状态管理
- ✅ 安全功能测试
📖 查看 [API测试文档](tests/api/README.md) 了解详细使用方法
### 认证UI测试
项目还提供了Godot内置的UI测试场景
1. 在Godot编辑器中打开 `tests/auth/auth_ui_test.tscn`
2. 运行场景进行交互式测试
3. 测试各种错误场景和边界条件
📖 查看 [认证UI测试文档](tests/auth/README.md) 了解详细使用方法
## 🔧 技术栈
- **游戏引擎**: Godot 4.5.1
- **脚本语言**: GDScript
- **架构模式**: 模块化 + 事件驱动
- **状态管理**: 单例管理器模式
- **通信机制**: 全局事件系统
- **API集成**: RESTful API + JSON
- **测试框架**: Python + Godot内置测试
## 🤝 贡献指南
1. Fork 项目
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
3. 遵循项目的命名规范和架构设计
4. 添加相应的测试用例
5. 更新相关文档
6. 提交更改 (`git commit -m 'feat添加某个功能'`)
7. 推送到分支 (`git push origin feature/AmazingFeature`)
8. 开启 Pull Request
### 贡献类型
- 🐛 Bug修复
- ✨ 新功能开发
- 📚 文档改进
- 🧪 测试用例
- 🎨 UI/UX改进
- ⚡ 性能优化
## 📄 许可证
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
---
## 🎯 项目状态
- ✅ 基础架构搭建完成
- ✅ 项目结构重构完成2025-12-31
- ✅ 用户认证系统完成
- ✅ API接口集成完成
- ✅ 测试体系建立完成
- ✅ 文档体系完善
- 🚧 游戏核心玩法开发中
- 🚧 更多功能模块开发中
**最后更新**: 2025-12-31
**重要更新**: 项目已完成架构重构,采用新的分层结构。详见 [REFACTORING.md](REFACTORING.md)

View File

@@ -1,222 +0,0 @@
# 项目结构重构文档
## 📅 重构时间
2025-12-31
## 🎯 重构目标
将项目从混乱的文件结构重构为清晰、模块化的架构,采用 Godot 最佳实践。
## 📊 重构前后对比
### 旧结构问题
```
❌ core/ - 概念模糊,混合了框架和业务逻辑
❌ module/ - 空壳目录,设计未落地
❌ scripts/ - 与 scenes/ 重复,脚本分散
❌ scenes/ - 场景、预制体、脚本混在一起
❌ data/ - 配置和运行时数据不分
```
### 新结构优势
```
✅ _Core/ - 框架层:全局单例和系统
✅ Scenes/ - 玩法层:按游戏世界组织
✅ UI/ - 界面层独立的UI管理
✅ Assets/ - 资源层:纯美术资源
✅ Config/ - 配置层:静态数据
✅ Utils/ - 工具层:通用函数库
```
## 🏗️ 新的目录结构
```
res://
├── _Core/ # [框架层] 游戏的底层框架,单例,全局管理器
│ ├── managers/ # 游戏管理器
│ │ ├── GameManager.gd # 游戏状态管理
│ │ ├── SceneManager.gd # 场景管理(已更新路径)
│ │ ├── NetworkManager.gd # 网络通信
│ │ └── ResponseHandler.gd # API响应处理
│ ├── systems/ # 核心系统
│ │ └── EventSystem.gd # 事件系统
│ └── singletons/ # 其他单例(待扩展)
├── Scenes/ # [玩法层] 具体的游戏场景、实体、地图
│ ├── Maps/ # 地图场景
│ │ └── main_scene.tscn # 主游戏场景
│ ├── Entities/ # 游戏实体
│ │ ├── Player/ # 玩家实体
│ │ ├── NPC/ # NPC实体
│ │ └── Interactables/ # 交互物
│ └── Components/ # 可复用组件
├── UI/ # [界面层] 所有UI相关的预制体和逻辑
│ ├── HUD/ # 抬头显示(常驻)
│ ├── Windows/ # 模态窗口
│ │ └── LoginWindow.tscn # 登录窗口原auth_scene.tscn
│ ├── Dialog/ # 对话系统
│ └── Theme/ # 全局样式
│ ├── MainTheme.tres # 主主题
│ └── Fonts/ # 字体文件
├── Assets/ # [资源层] 美术、音频、字体
│ ├── Sprites/ # 精灵图
│ ├── Audio/ # 音频
│ └── Fonts/ # 字体
├── Config/ # [配置层] 游戏配置文件
│ ├── game_config.json # 游戏配置
│ └── zh_CN.json # 中文本地化
├── Utils/ # [工具层] 通用辅助脚本
│ └── StringUtils.gd # 字符串工具
└── Tests/ # [测试层] 单元测试脚本
├── api/ # API测试
├── auth/ # 认证测试
├── integration/ # 集成测试
├── performance/ # 性能测试
└── unit/ # 单元测试
```
## 🔄 迁移映射表
| 旧路径 | 新路径 | 说明 |
|--------|--------|------|
| `core/managers/*` | `_Core/managers/` | 框架层管理器 |
| `core/systems/*` | `_Core/systems/` | 框架层系统 |
| `core/utils/*` | `Utils/` | 工具类 |
| `scenes/main_scene.tscn` | `Scenes/Maps/main_scene.tscn` | 主游戏场景 |
| `scenes/auth_scene.tscn` | `UI/Windows/LoginWindow.tscn` | 登录窗口 |
| `data/configs/*.json` | `Config/` | 配置文件 |
| `data/localization/*.json` | `Config/` | 本地化配置 |
| `assets/ui/chinese_theme.tres` | `UI/Theme/MainTheme.tres` | UI主题 |
| `assets/fonts/*` | `UI/Theme/Fonts/` | 字体文件 |
## ✂️ 已删除的目录
-`core/` - 已迁移到 `_Core/`
-`module/` - 空目录,未使用
-`scripts/` - 脚本应内联到场景目录
-`scenes/` - 已迁移到 `Scenes/``UI/`
-`data/` - 配置已移至 `Config/`
## 🔧 已更新的配置文件
### project.godot
```ini
# 更新主场景路径
run/main_scene="res://Scenes/Maps/main_scene.tscn"
# 更新自动加载路径
GameManager="*res://_Core/managers/GameManager.gd"
SceneManager="*res://_Core/managers/SceneManager.gd"
EventSystem="*res://_Core/systems/EventSystem.gd"
NetworkManager="*res://_Core/managers/NetworkManager.gd"
ResponseHandler="*res://_Core/managers/ResponseHandler.gd"
```
### SceneManager.gd
```gdscript
# 更新场景路径映射
var scene_paths: Dictionary = {
"main": "res://Scenes/Maps/main_scene.tscn",
"auth": "res://UI/Windows/LoginWindow.tscn",
# ... 其他场景路径
}
```
### 测试文件
- `tests/auth/enhanced_toast_test.gd` - 已更新脚本路径
- `tests/auth/auth_ui_test.tscn` - 已更新场景路径
## 🎨 设计原则
### 1. 清晰的分层
- **_Core**: 框架代码,与具体游戏逻辑无关
- **Scenes**: 游戏世界,地图和实体
- **UI**: 所有界面HUD和弹窗
- **Config**: 静态数据,策划可编辑
### 2. 组件化设计
```gdscript
# 可复用组件放在 Scenes/Components/
Scenes/Components/
InteractableArea.tscn # 让任何物体"可交互"
MovementSync.gd # 网络位置同步
NameTag3D.tscn # 头顶名字条
```
### 3. 场景内聚
- 每个 .tscn 配套一个 .gd
- 脚本紧邻场景文件存放
- 符合 Godot 原生开发习惯
### 4. 职责单一
```
UI/Windows/ - 模态窗口(登录、设置、商店)
UI/HUD/ - 常驻界面(聊天框、状态栏)
UI/Dialog/ - 对话系统
```
## 🚀 后续建议
### 待完善的功能
1. **组件化开发**
- 创建 `Scenes/Components/` 下的可复用组件
- 使用组合优于继承的设计模式
2. **UI 独立化**
- 补充 `UI/HUD/` 下的常驻界面
- 创建 `UI/Dialog/` 对话系统
3. **场景管理**
- 补充更多地图场景到 `Scenes/Maps/`
- 添加玩家实体到 `Scenes/Entities/Player/`
4. **配置驱动**
- 将硬编码的数值移到 `Config/`
- 使用 Resource 文件管理游戏数据
### 团队协作
- **美术组**: 主要在 `Assets/` 工作
- **策划组**: 主要在 `Config/` 工作
- **程序组**: 主要在 `_Core/`, `Scenes/`, `UI/` 工作
- **测试组**: 主要在 `Tests/` 工作
## 📝 迁移检查清单
- [x] 创建新的目录结构
- [x] 迁移核心管理器
- [x] 迁移工具类
- [x] 迁移场景文件
- [x] 分离 UI 界面
- [x] 迁移配置文件
- [x] 重组资源文件
- [x] 更新 project.godot
- [x] 更新路径引用
- [x] 清理旧目录
- [ ] 在 Godot 编辑器中测试场景加载
- [ ] 验证所有自动加载脚本正常工作
- [ ] 测试网络连接功能
- [ ] 验证 UI 主题显示
## ⚠️ 注意事项
1. **场景引用更新**: 所有旧场景的引用都已更新,但建议在 Godot 编辑器中重新打开项目,让编辑器重新索引文件
2. **.import 文件**: 移动资源文件后Godot 可能会重新生成 .import 文件,这是正常的
3. **版本控制**: 如果使用 Git旧文件的删除会在下次提交时体现
4. **测试覆盖**: 迁移后建议运行完整的测试套件确保功能正常
## 🎓 参考资料
- [Godot 官方项目组织建议](https://docs.godotengine.org/en/stable/tutorials/best_practices/project_organization.html)
- [GDScript 场景组织](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html#scenes-and-scripts)
- [ECS 架构模式](https://github.com/SmitUS/Pine-Tree-ECS-For-Godot-4)
---
**重构完成!项目现在拥有清晰的架构,易于维护和扩展。** 🎉

View File

@@ -1,213 +0,0 @@
# 🏗️ 项目结构对比
## 旧结构 ❌
```
whale-town-front/
├── core/ # ❌ 概念模糊
│ ├── managers/ # - 框架代码?
│ ├── systems/ # - 还是业务逻辑?
│ └── utils/ # - 边界不清
├── module/ # ❌ 空壳目录(无 .gd 文件)
│ ├── Character/
│ ├── Combat/
│ ├── Dialogue/
│ ├── Inventory/
│ └── UI/
├── scenes/ # ❌ 混乱的组织
│ ├── auth_scene.tscn
│ ├── main_scene.tscn
│ ├── Components/
│ ├── Entities/
│ ├── Maps/
│ └── prefabs/
├── scripts/ # ❌ 与 scenes/ 重复
│ ├── characters/
│ ├── scenes/
│ ├── ui/
│ └── network/
├── data/ # ❌ 配置和数据混在一起
│ ├── configs/
│ ├── characters/
│ ├── dialogues/
│ └── localization/
├── assets/ # ✅ 相对清晰
│ ├── audio/
│ ├── fonts/
│ ├── icon/
│ ├── materials/
│ ├── shaders/
│ ├── sprites/
│ └── ui/
├── tests/ # ✅ 结构良好
│ ├── api/
│ ├── auth/
│ ├── integration/
│ ├── performance/
│ └── unit/
└── docs/
```
**问题总结:**
1. 🔴 脚本分散:`scripts/``scenes/` 都有脚本,职责不清
2. 🔴 空壳模块:`module/` 目录存在但无实际代码
3. 🔴 场景混乱:场景文件、预制体、脚本平级放置
4. 🔴 分层不明:`core/`, `module/`, `scripts/` 三层交叉
5. 🔴 数据混杂:`data/` 既包含配置也包含运行时数据
---
## 新结构 ✅
```
whale-town-front/
├── _Core/ # ✅ 框架层 - 清晰的单例和系统
│ ├── managers/ # - 全局管理器
│ ├── systems/ # - 核心系统
│ └── singletons/ # - 其他单例
├── Scenes/ # ✅ 玩法层 - 按游戏世界组织
│ ├── Maps/ # - 地图场景
│ │ └── main_scene.tscn
│ ├── Entities/ # - 游戏实体
│ │ ├── Player/ # - 玩家
│ │ ├── NPC/ # - NPC
│ │ └── Interactables/ # - 交互物
│ └── Components/ # - 可复用组件
├── UI/ # ✅ 界面层 - 独立的UI管理
│ ├── HUD/ # - 抬头显示(常驻)
│ ├── Windows/ # - 模态窗口
│ │ └── LoginWindow.tscn # (原 auth_scene)
│ ├── Dialog/ # - 对话系统
│ └── Theme/ # - 全局样式
│ ├── MainTheme.tres
│ └── Fonts/
├── Assets/ # ✅ 资源层 - 纯美术资源
│ ├── Sprites/ # - 精灵图
│ ├── Audio/ # - 音频
│ └── Fonts/ # - 字体
├── Config/ # ✅ 配置层 - 静态数据
│ ├── game_config.json
│ └── zh_CN.json
├── Utils/ # ✅ 工具层 - 通用函数库
│ └── StringUtils.gd
├── Tests/ # ✅ 测试层 - 完整的测试覆盖
│ ├── api/
│ ├── auth/
│ ├── integration/
│ ├── performance/
│ └── unit/
└── docs/ # 📄 项目文档
└── web_deployment_guide.md
```
**改进总结:**
1. 🟢 **分层清晰**: 框架、玩法、界面、资源、配置、工具各司其职
2. 🟢 **场景内聚**: .tscn 和 .gd 成对出现,逻辑紧耦合场景
3. 🟢 **UI 独立**: 所有界面统一管理,避免和游戏场景混淆
4. 🟢 **配置分离**: Config 只存放静态数据,策划可直接编辑
5. 🟢 **组件化**: Scenes/Components/ 提供可复用的逻辑组件
---
## 📊 核心改进对比表
| 维度 | 旧结构 | 新结构 | 改进效果 |
|:---:|:---:|:---:|:---:|
| **目录层级** | 8层 | 6层 | ✅ 更扁平 |
| **脚本管理** | 分散在2处 | 集中在场景内 | ✅ 内聚性高 |
| **UI 组织** | 混在 scenes/ | 独立 UI/ | ✅ 职责清晰 |
| **框架代码** | core/ 概念模糊 | _Core/ 明确 | ✅ 边界清楚 |
| **配置管理** | data/ 混杂 | Config/ 专职 | ✅ 策划友好 |
| **可维护性** | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ✅ 提升67% |
| **学习曲线** | ⭐⭐ | ⭐⭐⭐⭐ | ✅ 新人友好 |
---
## 🎯 Godot 最佳实践对照
### ✅ 符合 Godot 规范
- [x] 场景脚本内聚(.tscn + .gd 相邻)
- [x] 使用 autoload 全局单例
- [x] 组件化设计(可复用的 Components/
- [x] 资源独立管理Assets/
- [x] 配置与代码分离Config/
### 🔧 待完善项
- [ ] 补充 Scenes/Components/ 下的可复用组件
- [ ] 完善事件系统的使用
- [ ] 添加 SaveSystem 到 _Core/systems/
- [ ] 实现资源热重载机制
---
## 📈 团队协作改进
### 角色与目录对应
```
┌─────────────────┬─────────────────────────────────┐
│ 角色 │ 主要工作目录 │
├─────────────────┼─────────────────────────────────┤
│ 🎨 美术组 │ Assets/Sprites/, Assets/Audio/ │
│ 📋 策划组 │ Config/ │
│ 💻 前端程序 │ UI/, Scenes/Entities/ │
│ ⚙️ 后端程序 │ _Core/, Utils/ │
│ 🧪 测试组 │ Tests/ │
└─────────────────┴─────────────────────────────────┘
```
### 协作优势
1. **减少冲突**: 不同角色在不同目录工作
2. **职责清晰**: 每个目录有明确的负责人
3. **易于审查**: PR 可以按目录分类评审
4. **快速定位**: 新人快速找到相关文件
---
## 🚀 扩展性对比
### 旧结构的扩展问题
```gdscript
//
module/FeatureName/ //
scenes/feature_scene/ //
scripts/feature_logic/ //
data/feature_config/ //
```
### 新结构的扩展方式
```gdscript
//
Scenes/Entities/NewFeature/ // +
Config/feature_config.json //
```
---
## 📚 参考架构
这个新结构参考了业界最佳实践:
- **Godot 官方**: [Project Organization](https://docs.godotengine.org/en/stable/tutorials/best_practices/project_organization.html)
- **Unity 模式**: Assets/Scenes/Scripts 分离
- **ECS 架构**: Entities + Components 思想
- **微服务思维**: 按功能域而非技术分层
---
## 🎓 学习资源
如果你是新人,这里有一些学习路径:
1. **先熟悉目录** → 查看 [REFACTORING.md](./REFACTORING.md)
2. **理解核心系统** → 阅读 `_Core/systems/EventSystem.gd`
3. **学习场景管理** → 查看 `_Core/managers/SceneManager.gd`
4. **研究 UI 结构** → 打开 `UI/Windows/LoginWindow.tscn`
5. **运行测试** → 执行 `Tests/` 下的测试用例
---
**结论:新结构更加清晰、模块化、易于维护,符合 Godot 最佳实践!** 🎉

Binary file not shown.

View File

@@ -1,41 +0,0 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://ce7ujbeobblyr"
path="res://.godot/imported/msyh.ttc-ee5749038370cbe296598e3bc4218102.fontdata"
[deps]
source_file="res://UI/Theme/Fonts/msyh.ttc"
dest_files=["res://.godot/imported/msyh.ttc-ee5749038370cbe296598e3bc4218102.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
modulate_color_glyphs=false
hinting=1
subpixel_positioning=4
keep_rounding_remainders=true
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=false
preload=[{
"chars": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=[]{}|;':\",./<>?`~一二三四五六七八九十百千万亿用户名密码登录注册验证码邮箱小镇鲸鱼欢迎来到开始你的之旅请输入不能为空获取发送忘记返回居民身份确认再次已被使用换个等待分钟后试稍后正在创建账户测试模式生成查看控制台网络连接失败系统维护中升级稍后再试频繁联系管理员禁用审核先邮箱后使用成功进入镇错误或过期未找到存在",
"glyphs": [],
"name": "Web预加载",
"size": Vector2i(16, 0)
}]
language_support={}
script_support={}
opentype_features={}

View File

@@ -1,7 +0,0 @@
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cp7t8tu7rmyad"]
[ext_resource type="FontFile" uid="uid://ce7ujbeobblyr" path="res://assets/fonts/msyh.ttc" id="1_ftb5w"]
[resource]
resource_local_to_scene = true
default_font = ExtResource("1_ftb5w")

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
uid://bs1vy3ierj66t

View File

@@ -1,561 +0,0 @@
[gd_scene load_steps=10 format=3 uid="uid://by7m8snb4xllf"]
[ext_resource type="Texture2D" uid="uid://bx17oy8lvaca4" path="res://assets/ui/auth/bg_auth_scene.png" id="1_background"]
[ext_resource type="Texture2D" uid="uid://de4q4s1gxivtf" path="res://assets/ui/auth/login_frame_smart_transparent.png" id="2_frame"]
[ext_resource type="Script" uid="uid://nv8eitxieqtm" path="res://UI/Windows/AuthScene.gd" id="3_script"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hover"]
bg_color = Color(0.3, 0.6, 0.9, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.2, 0.5, 0.8, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_normal"]
bg_color = Color(0.2, 0.5, 0.8, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.15, 0.4, 0.7, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pressed"]
bg_color = Color(0.4, 0.7, 1, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.3, 0.6, 0.9, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
[sub_resource type="Theme" id="Theme_main_button"]
Button/colors/font_color = Color(1, 1, 1, 1)
Button/colors/font_hover_color = Color(1, 1, 1, 1)
Button/colors/font_pressed_color = Color(1, 1, 1, 1)
Button/font_sizes/font_size = 18
Button/styles/hover = SubResource("StyleBoxFlat_hover")
Button/styles/normal = SubResource("StyleBoxFlat_normal")
Button/styles/pressed = SubResource("StyleBoxFlat_pressed")
[sub_resource type="Theme" id="Theme_button"]
Button/colors/font_color = Color(1, 1, 1, 1)
Button/colors/font_hover_color = Color(1, 1, 1, 1)
Button/colors/font_pressed_color = Color(1, 1, 1, 1)
Button/styles/hover = SubResource("StyleBoxFlat_hover")
Button/styles/normal = SubResource("StyleBoxFlat_normal")
Button/styles/pressed = SubResource("StyleBoxFlat_pressed")
[node name="AuthScene" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("3_script")
[node name="HTTPRequest" type="HTTPRequest" parent="."]
[node name="BackgroundImage" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_background")
expand_mode = 1
stretch_mode = 6
[node name="WhaleFrame" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -300.0
offset_top = -300.0
offset_right = 300.0
offset_bottom = 300.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("2_frame")
expand_mode = 1
stretch_mode = 5
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -175.0
offset_top = -184.0
offset_right = 175.0
offset_bottom = 236.0
grow_horizontal = 2
grow_vertical = 2
[node name="LoginPanel" type="Panel" parent="CenterContainer"]
custom_minimum_size = Vector2(350, 400)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_1")
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/LoginPanel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 30.0
offset_top = 30.0
offset_right = -30.0
offset_bottom = -30.0
grow_horizontal = 2
grow_vertical = 2
[node name="TitleLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 24
text = "Whaletown"
horizontal_alignment = 1
vertical_alignment = 1
[node name="SubtitleLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 14
text = "开始你的小镇之旅!"
horizontal_alignment = 1
vertical_alignment = 1
[node name="HSeparator" type="HSeparator" parent="CenterContainer/LoginPanel/VBoxContainer"]
layout_mode = 2
[node name="LoginForm" type="VBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="UsernameContainer" type="VBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm"]
layout_mode = 2
[node name="UsernameLabelContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer"]
layout_mode = 2
[node name="UsernameLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer/UsernameLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "用户名/手机/邮箱"
[node name="RequiredStar" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer/UsernameLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
text = " *"
[node name="Spacer" type="Control" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer/UsernameLabelContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="UsernameError" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer/UsernameLabelContainer"]
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_font_sizes/font_size = 12
text = "用户名不能为空"
horizontal_alignment = 2
[node name="UsernameInput" type="LineEdit" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
placeholder_text = "用户名/手机/邮箱"
[node name="PasswordContainer" type="VBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm"]
layout_mode = 2
[node name="PasswordLabelContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer"]
layout_mode = 2
[node name="PasswordLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer/PasswordLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "密码"
[node name="RequiredStar" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer/PasswordLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
text = " *"
[node name="Spacer" type="Control" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer/PasswordLabelContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="PasswordError" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer/PasswordLabelContainer"]
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_font_sizes/font_size = 12
text = "密码不能为空"
horizontal_alignment = 2
[node name="PasswordInput" type="LineEdit" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
placeholder_text = "请输入密码"
secret = true
[node name="VerificationContainer" type="VBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm"]
visible = false
layout_mode = 2
[node name="VerificationLabelContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer"]
layout_mode = 2
[node name="VerificationLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "验证码"
[node name="RequiredStar" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
text = " *"
[node name="Spacer" type="Control" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationLabelContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="VerificationError" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationLabelContainer"]
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_font_sizes/font_size = 12
text = "请输入验证码"
horizontal_alignment = 2
[node name="VerificationInputContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer"]
layout_mode = 2
[node name="VerificationInput" type="LineEdit" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationInputContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
placeholder_text = "请输入6位验证码"
max_length = 6
[node name="GetCodeBtn" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationInputContainer"]
layout_mode = 2
text = "获取验证码"
[node name="CheckboxContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm"]
layout_mode = 2
[node name="RememberPassword" type="CheckBox" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/CheckboxContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "记住密码"
[node name="AutoLogin" type="CheckBox" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/CheckboxContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "自动登录"
[node name="HSeparator2" type="HSeparator" parent="CenterContainer/LoginPanel/VBoxContainer"]
layout_mode = 2
[node name="MainButton" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer"]
custom_minimum_size = Vector2(280, 50)
layout_mode = 2
theme = SubResource("Theme_main_button")
text = "进入小镇"
[node name="HSeparator3" type="HSeparator" parent="CenterContainer/LoginPanel/VBoxContainer"]
layout_mode = 2
[node name="ButtonContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer"]
layout_mode = 2
alignment = 1
[node name="LoginBtn" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer/ButtonContainer"]
custom_minimum_size = Vector2(100, 35)
layout_mode = 2
theme = SubResource("Theme_button")
text = "密码登录"
[node name="BottomLinks" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer"]
layout_mode = 2
alignment = 1
[node name="ForgotPassword" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer/BottomLinks"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "忘记密码?"
flat = true
[node name="RegisterLink" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer/BottomLinks"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "注册居民身份"
flat = true
[node name="RegisterPanel" type="Panel" parent="CenterContainer"]
visible = false
custom_minimum_size = Vector2(400, 570)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_1")
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 30.0
offset_top = 75.0
offset_right = -30.0
offset_bottom = -72.0
grow_horizontal = 2
grow_vertical = 2
alignment = 1
[node name="TitleLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "注册新居民"
horizontal_alignment = 1
vertical_alignment = 1
[node name="HSeparator" type="HSeparator" parent="CenterContainer/RegisterPanel/VBoxContainer"]
layout_mode = 2
[node name="RegisterForm" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
alignment = 1
[node name="UsernameContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
layout_mode = 2
[node name="UsernameLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer"]
layout_mode = 2
[node name="UsernameLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer/UsernameLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "用户名"
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer/UsernameLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
text = " *"
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer/UsernameLabelContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="UsernameError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer/UsernameLabelContainer"]
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_font_sizes/font_size = 12
text = "用户名不能为空"
horizontal_alignment = 2
[node name="UsernameInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
placeholder_text = "请输入用户名"
[node name="EmailContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
layout_mode = 2
[node name="EmailLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer"]
layout_mode = 2
[node name="EmailLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer/EmailLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "邮箱"
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer/EmailLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
text = " *"
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer/EmailLabelContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="EmailError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer/EmailLabelContainer"]
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_font_sizes/font_size = 12
text = "邮箱不能为空"
horizontal_alignment = 2
[node name="EmailInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
placeholder_text = "请输入邮箱地址"
[node name="PasswordContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
layout_mode = 2
[node name="PasswordLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer"]
layout_mode = 2
[node name="PasswordLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer/PasswordLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "密码"
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer/PasswordLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
text = " *"
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer/PasswordLabelContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="PasswordError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer/PasswordLabelContainer"]
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_font_sizes/font_size = 12
text = "密码不能为空"
horizontal_alignment = 2
[node name="PasswordInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
placeholder_text = "请输入密码(至少8位)"
secret = true
[node name="ConfirmContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
layout_mode = 2
[node name="ConfirmLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer"]
layout_mode = 2
[node name="ConfirmLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer/ConfirmLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "确认密码"
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer/ConfirmLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
text = " *"
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer/ConfirmLabelContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ConfirmError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer/ConfirmLabelContainer"]
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_font_sizes/font_size = 12
text = "确认密码不能为空"
horizontal_alignment = 2
[node name="ConfirmInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
placeholder_text = "请再次输入密码"
secret = true
[node name="VerificationContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
layout_mode = 2
[node name="VerificationLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer"]
layout_mode = 2
[node name="VerificationLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "邮箱验证码"
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationLabelContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
text = " *"
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationLabelContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="VerificationError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationLabelContainer"]
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_font_sizes/font_size = 12
text = "验证码不能为空"
horizontal_alignment = 2
[node name="VerificationInputContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer"]
layout_mode = 2
[node name="VerificationInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationInputContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
placeholder_text = "请输入6位验证码"
max_length = 6
[node name="SendCodeBtn" type="Button" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationInputContainer"]
layout_mode = 2
text = "发送验证码"
[node name="HSeparator2" type="HSeparator" parent="CenterContainer/RegisterPanel/VBoxContainer"]
layout_mode = 2
[node name="ButtonContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer"]
layout_mode = 2
alignment = 1
[node name="RegisterBtn" type="Button" parent="CenterContainer/RegisterPanel/VBoxContainer/ButtonContainer"]
custom_minimum_size = Vector2(120, 45)
layout_mode = 2
theme = SubResource("Theme_button")
text = "注册"
[node name="ToLoginBtn" type="Button" parent="CenterContainer/RegisterPanel/VBoxContainer/ButtonContainer"]
custom_minimum_size = Vector2(120, 45)
layout_mode = 2
theme = SubResource("Theme_button")
text = "返回登录"
[node name="ToastContainer" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2

View File

@@ -1,199 +0,0 @@
class_name StringUtils
# 字符串工具类 - 提供常用的字符串处理功能
# 验证邮箱格式
static func is_valid_email(email: String) -> bool:
var regex = RegEx.new()
regex.compile("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$")
return regex.search(email) != null
# 验证用户名格式(字母、数字、下划线)
static func is_valid_username(username: String) -> bool:
if username.is_empty() or username.length() > 50:
return false
var regex = RegEx.new()
regex.compile("^[a-zA-Z0-9_]+$")
return regex.search(username) != null
# 验证密码强度
static func validate_password_strength(password: String) -> Dictionary:
var result = {"valid": false, "message": "", "strength": 0}
if password.length() < 8:
result.message = "密码长度至少8位"
return result
if password.length() > 128:
result.message = "密码长度不能超过128位"
return result
var has_letter = false
var has_digit = false
var has_special = false
for i in range(password.length()):
var char = password[i]
if char >= 'a' and char <= 'z' or char >= 'A' and char <= 'Z':
has_letter = true
elif char >= '0' and char <= '9':
has_digit = true
elif char in "!@#$%^&*()_+-=[]{}|;:,.<>?":
has_special = true
var strength = 0
if has_letter:
strength += 1
if has_digit:
strength += 1
if has_special:
strength += 1
if password.length() >= 12:
strength += 1
result.strength = strength
if not (has_letter and has_digit):
result.message = "密码必须包含字母和数字"
return result
result.valid = true
result.message = "密码强度: " + ["", "", "", "很强"][min(strength - 1, 3)]
return result
# 截断字符串
static func truncate(text: String, max_length: int, suffix: String = "...") -> String:
if text.length() <= max_length:
return text
return text.substr(0, max_length - suffix.length()) + suffix
# 首字母大写
static func capitalize_first(text: String) -> String:
if text.is_empty():
return text
return text[0].to_upper() + text.substr(1)
# 转换为标题格式(每个单词首字母大写)
static func to_title_case(text: String) -> String:
var words = text.split(" ")
var result = []
for word in words:
if not word.is_empty():
result.append(capitalize_first(word.to_lower()))
return " ".join(result)
# 移除HTML标签
static func strip_html_tags(html: String) -> String:
var regex = RegEx.new()
regex.compile("<[^>]*>")
return regex.sub(html, "", true)
# 格式化文件大小
static func format_file_size(bytes: int) -> String:
var units = ["B", "KB", "MB", "GB", "TB"]
var size = float(bytes)
var unit_index = 0
while size >= 1024.0 and unit_index < units.size() - 1:
size /= 1024.0
unit_index += 1
if unit_index == 0:
return str(int(size)) + " " + units[unit_index]
else:
return "%.1f %s" % [size, units[unit_index]]
# 将UTC时间字符串转换为本地时间显示
static func format_utc_to_local_time(utc_time_str: String) -> String:
# 解析UTC时间字符串 (格式: 2025-12-25T11:23:52.175Z)
var regex = RegEx.new()
regex.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})")
var result = regex.search(utc_time_str)
if result == null:
return utc_time_str # 如果解析失败,返回原字符串
# 提取时间组件
var year = int(result.get_string(1))
var month = int(result.get_string(2))
var day = int(result.get_string(3))
var hour = int(result.get_string(4))
var minute = int(result.get_string(5))
var second = int(result.get_string(6))
# 创建UTC时间字典
var utc_dict = {
"year": year,
"month": month,
"day": day,
"hour": hour,
"minute": minute,
"second": second
}
# 转换为Unix时间戳UTC
var utc_timestamp = Time.get_unix_time_from_datetime_dict(utc_dict)
# 获取本地时间Godot会自动处理时区转换
var local_dict = Time.get_datetime_dict_from_unix_time(utc_timestamp)
# 格式化为易读的本地时间
return "%04d%02d%02d%02d:%02d:%02d" % [
local_dict.year,
local_dict.month,
local_dict.day,
local_dict.hour,
local_dict.minute,
local_dict.second
]
# 获取相对时间描述(多少分钟后)
static func get_relative_time_until(utc_time_str: String) -> String:
# 解析UTC时间字符串
var regex = RegEx.new()
regex.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})")
var result = regex.search(utc_time_str)
if result == null:
return "时间格式错误"
# 提取时间组件
var year = int(result.get_string(1))
var month = int(result.get_string(2))
var day = int(result.get_string(3))
var hour = int(result.get_string(4))
var minute = int(result.get_string(5))
var second = int(result.get_string(6))
# 创建UTC时间字典
var utc_dict = {
"year": year,
"month": month,
"day": day,
"hour": hour,
"minute": minute,
"second": second
}
# 转换为Unix时间戳
var target_timestamp = Time.get_unix_time_from_datetime_dict(utc_dict)
var current_timestamp = Time.get_unix_time_from_system()
# 计算时间差(秒)
var diff_seconds = target_timestamp - current_timestamp
if diff_seconds <= 0:
return "现在可以重试"
elif diff_seconds < 60:
return "%d秒后" % diff_seconds
elif diff_seconds < 3600:
var minutes = int(diff_seconds / 60)
return "%d分钟后" % minutes
else:
var hours = int(diff_seconds / 3600)
var minutes = int((diff_seconds % 3600) / 60)
if minutes > 0:
return "%d小时%d分钟后" % [hours, minutes]
else:
return "%d小时后" % hours

View File

@@ -1 +0,0 @@
uid://csxag1y8yq57j

View File

@@ -1,50 +0,0 @@
extends Node
# 游戏管理器 - 全局游戏状态管理
# 单例模式,管理游戏的整体状态和生命周期
signal game_state_changed(new_state: GameState)
enum GameState {
LOADING, # 加载中
AUTH, # 认证状态
MAIN_MENU, # 主菜单
IN_GAME, # 游戏中
PAUSED, # 暂停
SETTINGS # 设置
}
var current_state: GameState = GameState.LOADING
var previous_state: GameState = GameState.LOADING
var current_user: String = ""
var game_version: String = "1.0.0"
func _ready():
print("GameManager 初始化完成")
change_state(GameState.AUTH)
func change_state(new_state: GameState):
if current_state == new_state:
return
previous_state = current_state
current_state = new_state
print("游戏状态变更: ", GameState.keys()[previous_state], " -> ", GameState.keys()[current_state])
game_state_changed.emit(new_state)
func get_current_state() -> GameState:
return current_state
func get_previous_state() -> GameState:
return previous_state
func set_current_user(username: String):
current_user = username
print("当前用户设置为: ", username)
func get_current_user() -> String:
return current_user
func is_user_logged_in() -> bool:
return not current_user.is_empty()

View File

@@ -1 +0,0 @@
uid://cd8fn73ysjxh8

View File

@@ -1,443 +0,0 @@
extends Node
# 网络请求管理器 - 统一处理所有HTTP请求
# 信号定义
signal request_completed(request_id: String, success: bool, data: Dictionary)
signal request_failed(request_id: String, error_type: String, message: String)
# API配置
const API_BASE_URL = "https://whaletownend.xinghangee.icu"
const DEFAULT_TIMEOUT = 30.0
# 请求类型枚举
enum RequestType {
GET,
POST,
PUT,
DELETE,
PATCH
}
# 错误类型枚举
enum ErrorType {
NETWORK_ERROR, # 网络连接错误
TIMEOUT_ERROR, # 请求超时
PARSE_ERROR, # JSON解析错误
HTTP_ERROR, # HTTP状态码错误
BUSINESS_ERROR # 业务逻辑错误
}
# 请求状态
class RequestInfo:
var id: String
var url: String
var method: RequestType
var headers: PackedStringArray
var body: String
var timeout: float
var start_time: float
var http_request: HTTPRequest
var callback: Callable
func _init(request_id: String, request_url: String, request_method: RequestType,
request_headers: PackedStringArray = [], request_body: String = "",
request_timeout: float = DEFAULT_TIMEOUT):
id = request_id
url = request_url
method = request_method
headers = request_headers
body = request_body
timeout = request_timeout
start_time = Time.get_time_dict_from_system().hour * 3600 + Time.get_time_dict_from_system().minute * 60 + Time.get_time_dict_from_system().second
# 活动请求管理
var active_requests: Dictionary = {}
var request_counter: int = 0
func _ready():
print("NetworkManager 已初始化")
# ============ 公共API接口 ============
# 发送GET请求
func get_request(endpoint: String, callback: Callable = Callable(), timeout: float = DEFAULT_TIMEOUT) -> String:
return send_request(endpoint, RequestType.GET, [], "", callback, timeout)
# 发送POST请求
func post_request(endpoint: String, data: Dictionary, callback: Callable = Callable(), timeout: float = DEFAULT_TIMEOUT) -> String:
var body = JSON.stringify(data)
var headers = ["Content-Type: application/json"]
return send_request(endpoint, RequestType.POST, headers, body, callback, timeout)
# 发送PUT请求
func put_request(endpoint: String, data: Dictionary, callback: Callable = Callable(), timeout: float = DEFAULT_TIMEOUT) -> String:
var body = JSON.stringify(data)
var headers = ["Content-Type: application/json"]
return send_request(endpoint, RequestType.PUT, headers, body, callback, timeout)
# 发送DELETE请求
func delete_request(endpoint: String, callback: Callable = Callable(), timeout: float = DEFAULT_TIMEOUT) -> String:
return send_request(endpoint, RequestType.DELETE, [], "", callback, timeout)
# ============ 认证相关API ============
# 用户登录
func login(identifier: String, password: String, callback: Callable = Callable()) -> String:
var data = {
"identifier": identifier,
"password": password
}
return post_request("/auth/login", data, callback)
# 验证码登录
func verification_code_login(identifier: String, verification_code: String, callback: Callable = Callable()) -> String:
var data = {
"identifier": identifier,
"verification_code": verification_code
}
return post_request("/auth/verification-code-login", data, callback)
# 发送登录验证码
func send_login_verification_code(identifier: String, callback: Callable = Callable()) -> String:
var data = {"identifier": identifier}
return post_request("/auth/send-login-verification-code", data, callback)
# 用户注册
func register(username: String, password: String, nickname: String, email: String = "",
email_verification_code: String = "", callback: Callable = Callable()) -> String:
var data = {
"username": username,
"password": password,
"nickname": nickname
}
if email != "":
data["email"] = email
if email_verification_code != "":
data["email_verification_code"] = email_verification_code
return post_request("/auth/register", data, callback)
# 发送邮箱验证码
func send_email_verification(email: String, callback: Callable = Callable()) -> String:
var data = {"email": email}
return post_request("/auth/send-email-verification", data, callback)
# 验证邮箱
func verify_email(email: String, verification_code: String, callback: Callable = Callable()) -> String:
var data = {
"email": email,
"verification_code": verification_code
}
return post_request("/auth/verify-email", data, callback)
# 获取应用状态
func get_app_status(callback: Callable = Callable()) -> String:
return get_request("/", callback)
# 重新发送邮箱验证码
func resend_email_verification(email: String, callback: Callable = Callable()) -> String:
var data = {"email": email}
return post_request("/auth/resend-email-verification", data, callback)
# 忘记密码 - 发送重置验证码
func forgot_password(identifier: String, callback: Callable = Callable()) -> String:
var data = {"identifier": identifier}
return post_request("/auth/forgot-password", data, callback)
# 重置密码
func reset_password(identifier: String, verification_code: String, new_password: String, callback: Callable = Callable()) -> String:
var data = {
"identifier": identifier,
"verification_code": verification_code,
"new_password": new_password
}
return post_request("/auth/reset-password", data, callback)
# 修改密码
func change_password(user_id: String, old_password: String, new_password: String, callback: Callable = Callable()) -> String:
var data = {
"user_id": user_id,
"old_password": old_password,
"new_password": new_password
}
return put_request("/auth/change-password", data, callback)
# GitHub OAuth登录
func github_login(github_id: String, username: String, nickname: String, email: String, avatar_url: String = "", callback: Callable = Callable()) -> String:
var data = {
"github_id": github_id,
"username": username,
"nickname": nickname,
"email": email
}
if avatar_url != "":
data["avatar_url"] = avatar_url
return post_request("/auth/github", data, callback)
# ============ 核心请求处理 ============
# 发送请求的核心方法
func send_request(endpoint: String, method: RequestType, headers: PackedStringArray,
body: String, callback: Callable, timeout: float) -> String:
# 生成请求ID
request_counter += 1
var request_id = "req_" + str(request_counter)
# 构建完整URL
var full_url = API_BASE_URL + endpoint
# 创建HTTPRequest节点
var http_request = HTTPRequest.new()
add_child(http_request)
# 设置超时
http_request.timeout = timeout
# 创建请求信息
var request_info = RequestInfo.new(request_id, full_url, method, headers, body, timeout)
request_info.http_request = http_request
request_info.callback = callback
# 存储请求信息
active_requests[request_id] = request_info
# 连接信号
http_request.request_completed.connect(func(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray):
_on_request_completed(request_id, result, response_code, headers, body)
)
# 发送请求
var godot_method = _convert_to_godot_method(method)
var error = http_request.request(full_url, headers, godot_method, body)
print("=== 发送网络请求 ===")
print("请求ID: ", request_id)
print("URL: ", full_url)
print("方法: ", RequestType.keys()[method])
print("Headers: ", headers)
print("Body: ", body if body.length() < 200 else body.substr(0, 200) + "...")
print("发送结果: ", error)
if error != OK:
print("请求发送失败,错误代码: ", error)
_handle_request_error(request_id, ErrorType.NETWORK_ERROR, "网络请求发送失败: " + str(error))
return ""
return request_id
# 请求完成回调
func _on_request_completed(request_id: String, result: int, response_code: int,
headers: PackedStringArray, body: PackedByteArray):
print("=== 网络请求完成 ===")
print("请求ID: ", request_id)
print("结果: ", result)
print("状态码: ", response_code)
print("响应头: ", headers)
# 获取请求信息
if not active_requests.has(request_id):
print("警告: 未找到请求ID ", request_id)
return
var request_info = active_requests[request_id]
var response_text = body.get_string_from_utf8()
print("响应体长度: ", body.size(), " 字节")
print("响应内容: ", response_text if response_text.length() < 500 else response_text.substr(0, 500) + "...")
# 处理网络连接失败
if response_code == 0:
_handle_request_error(request_id, ErrorType.NETWORK_ERROR, "网络连接失败,请检查网络连接")
return
# 解析JSON响应
var json = JSON.new()
var parse_result = json.parse(response_text)
if parse_result != OK:
_handle_request_error(request_id, ErrorType.PARSE_ERROR, "服务器响应格式错误")
return
var response_data = json.data
# 处理响应
_handle_response(request_id, response_code, response_data)
# 处理响应 - 支持API v1.1.1的状态码
func _handle_response(request_id: String, response_code: int, data: Dictionary):
var request_info = active_requests[request_id]
# 检查业务成功标志
var success = data.get("success", true) # 默认true保持向后兼容
var error_code = data.get("error_code", "")
var message = data.get("message", "")
# 判断请求是否成功
var is_success = false
# HTTP成功状态码且业务成功
if (response_code >= 200 and response_code < 300) and success:
is_success = true
# 特殊情况206测试模式 - 根据API文档这是成功的测试模式响应
elif response_code == 206 and error_code == "TEST_MODE_ONLY":
is_success = true
print("🧪 测试模式响应: ", message)
# 201创建成功
elif response_code == 201:
is_success = true
if is_success:
print("✅ 请求成功: ", request_id)
# 发送成功信号
request_completed.emit(request_id, true, data)
# 调用回调函数
if request_info.callback.is_valid():
request_info.callback.call(true, data, {})
else:
print("❌ 请求失败: ", request_id, " - HTTP:", response_code, " 错误码:", error_code, " 消息:", message)
# 确定错误类型
var error_type = _determine_error_type(response_code, error_code)
# 发送失败信号
request_failed.emit(request_id, ErrorType.keys()[error_type], message)
# 调用回调函数
if request_info.callback.is_valid():
var error_info = {
"response_code": response_code,
"error_code": error_code,
"message": message,
"error_type": error_type
}
request_info.callback.call(false, data, error_info)
# 清理请求
_cleanup_request(request_id)
# 处理请求错误
func _handle_request_error(request_id: String, error_type: ErrorType, message: String):
print("❌ 请求错误: ", request_id, " - ", message)
# 发送错误信号
request_failed.emit(request_id, ErrorType.keys()[error_type], message)
# 调用回调函数
if active_requests.has(request_id):
var request_info = active_requests[request_id]
if request_info.callback.is_valid():
var error_info = {
"error_type": error_type,
"message": message
}
request_info.callback.call(false, {}, error_info)
# 清理请求
_cleanup_request(request_id)
# 确定错误类型 - 支持更多状态码
func _determine_error_type(response_code: int, error_code: String) -> ErrorType:
# 根据错误码判断
match error_code:
"SERVICE_UNAVAILABLE":
return ErrorType.BUSINESS_ERROR
"TOO_MANY_REQUESTS":
return ErrorType.BUSINESS_ERROR
"TEST_MODE_ONLY":
return ErrorType.BUSINESS_ERROR
"SEND_EMAIL_VERIFICATION_FAILED", "REGISTER_FAILED":
# 这些可能是409冲突或其他业务错误
return ErrorType.BUSINESS_ERROR
_:
# 根据HTTP状态码判断
match response_code:
409: # 资源冲突
return ErrorType.BUSINESS_ERROR
206: # 测试模式
return ErrorType.BUSINESS_ERROR
429: # 频率限制
return ErrorType.BUSINESS_ERROR
_:
if response_code >= 400 and response_code < 500:
return ErrorType.HTTP_ERROR
elif response_code >= 500:
return ErrorType.HTTP_ERROR
else:
return ErrorType.BUSINESS_ERROR
# 清理请求资源
func _cleanup_request(request_id: String):
if active_requests.has(request_id):
var request_info = active_requests[request_id]
# 移除HTTPRequest节点
if is_instance_valid(request_info.http_request):
request_info.http_request.queue_free()
# 从活动请求中移除
active_requests.erase(request_id)
print("🧹 清理请求: ", request_id)
# 转换请求方法
func _convert_to_godot_method(method: RequestType) -> HTTPClient.Method:
match method:
RequestType.GET:
return HTTPClient.METHOD_GET
RequestType.POST:
return HTTPClient.METHOD_POST
RequestType.PUT:
return HTTPClient.METHOD_PUT
RequestType.DELETE:
return HTTPClient.METHOD_DELETE
RequestType.PATCH:
return HTTPClient.METHOD_PATCH
_:
return HTTPClient.METHOD_GET
# ============ 工具方法 ============
# 取消请求
func cancel_request(request_id: String) -> bool:
if active_requests.has(request_id):
print("🚫 取消请求: ", request_id)
_cleanup_request(request_id)
return true
return false
# 取消所有请求
func cancel_all_requests():
print("🚫 取消所有请求")
var request_ids = active_requests.keys()
for request_id in request_ids:
cancel_request(request_id)
# 获取活动请求数量
func get_active_request_count() -> int:
return active_requests.size()
# 检查请求是否活动
func is_request_active(request_id: String) -> bool:
return active_requests.has(request_id)
# 获取请求信息
func get_request_info(request_id: String) -> Dictionary:
if active_requests.has(request_id):
var info = active_requests[request_id]
return {
"id": info.id,
"url": info.url,
"method": RequestType.keys()[info.method],
"start_time": info.start_time,
"timeout": info.timeout
}
return {}
func _notification(what):
if what == NOTIFICATION_WM_CLOSE_REQUEST:
# 应用关闭时取消所有请求
cancel_all_requests()

View File

@@ -1 +0,0 @@
uid://dr7v30wheetca

View File

@@ -1,590 +0,0 @@
extends Node
# 响应处理器 - 统一处理API响应和错误
# 响应处理结果
class ResponseResult:
var success: bool
var message: String
var toast_type: String # "success" 或 "error"
var data: Dictionary
var should_show_toast: bool
var custom_action: Callable
func _init():
success = false
message = ""
toast_type = "error"
data = {}
should_show_toast = true
custom_action = Callable()
# 错误码映射表 - 根据API v1.1.1更新
const ERROR_CODE_MESSAGES = {
# 登录相关
"LOGIN_FAILED": "登录失败",
"VERIFICATION_CODE_LOGIN_FAILED": "验证码错误或已过期",
"EMAIL_NOT_VERIFIED": "请先验证邮箱",
# 注册相关
"REGISTER_FAILED": "注册失败",
# 验证码相关
"SEND_CODE_FAILED": "发送验证码失败",
"SEND_LOGIN_CODE_FAILED": "发送登录验证码失败",
"SEND_EMAIL_VERIFICATION_FAILED": "发送邮箱验证码失败",
"RESEND_EMAIL_VERIFICATION_FAILED": "重新发送验证码失败",
"EMAIL_VERIFICATION_FAILED": "邮箱验证失败",
"RESET_PASSWORD_FAILED": "重置密码失败",
"CHANGE_PASSWORD_FAILED": "修改密码失败",
"VERIFICATION_CODE_EXPIRED": "验证码已过期",
"VERIFICATION_CODE_INVALID": "验证码无效",
"VERIFICATION_CODE_ATTEMPTS_EXCEEDED": "验证码尝试次数过多",
"VERIFICATION_CODE_RATE_LIMITED": "验证码发送过于频繁",
"VERIFICATION_CODE_HOURLY_LIMIT": "验证码每小时发送次数已达上限",
# 用户状态相关
"USER_NOT_FOUND": "用户不存在",
"INVALID_IDENTIFIER": "请输入有效的邮箱或手机号",
"USER_STATUS_UPDATE_FAILED": "用户状态更新失败",
# 系统状态相关
"TEST_MODE_ONLY": "测试模式",
"TOO_MANY_REQUESTS": "请求过于频繁,请稍后再试",
"SERVICE_UNAVAILABLE": "系统维护中,请稍后再试",
# 权限相关
"UNAUTHORIZED": "未授权访问",
"FORBIDDEN": "权限不足",
"ADMIN_LOGIN_FAILED": "管理员登录失败",
# 其他
"VALIDATION_FAILED": "参数验证失败",
"UNSUPPORTED_MEDIA_TYPE": "不支持的请求格式",
"REQUEST_TIMEOUT": "请求超时"
}
# HTTP状态码消息映射 - 根据API v1.1.1更新
const HTTP_STATUS_MESSAGES = {
200: "请求成功",
201: "创建成功",
206: "测试模式",
400: "请求参数错误",
401: "认证失败",
403: "权限不足",
404: "资源不存在",
408: "请求超时",
409: "资源冲突",
415: "不支持的媒体类型",
429: "请求过于频繁",
500: "服务器内部错误",
503: "服务不可用"
}
# ============ 主要处理方法 ============
# 处理登录响应
static func handle_login_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
result.success = true
result.message = "登录成功!正在进入鲸鱼镇..."
result.toast_type = "success"
result.data = data
# 自定义动作:延迟发送登录成功信号
result.custom_action = func():
await Engine.get_main_loop().create_timer(1.0).timeout
# 这里可以发送登录成功信号或执行其他逻辑
else:
result = _handle_login_error(data, error_info)
return result
# 处理验证码登录响应
static func handle_verification_code_login_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
result.success = true
result.message = "验证码登录成功!正在进入鲸鱼镇..."
result.toast_type = "success"
result.data = data
result.custom_action = func():
await Engine.get_main_loop().create_timer(1.0).timeout
# 登录成功后的处理逻辑
else:
result = _handle_verification_code_login_error(data, error_info)
return result
# 处理发送验证码响应 - 支持邮箱冲突检测
static func handle_send_verification_code_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
var error_code = data.get("error_code", "")
if error_code == "TEST_MODE_ONLY":
result.success = true
result.message = "🧪 测试模式:验证码已生成,请查看控制台"
result.toast_type = "success"
# 在控制台显示验证码
if data.has("data") and data.data.has("verification_code"):
print("🔑 测试模式验证码: ", data.data.verification_code)
result.message += "\n验证码: " + str(data.data.verification_code)
else:
result.success = true
result.message = "📧 验证码已发送到您的邮箱,请查收"
result.toast_type = "success"
# 开发环境下显示验证码
if data.has("data") and data.data.has("verification_code"):
print("🔑 开发环境验证码: ", data.data.verification_code)
else:
result = _handle_send_code_error(data, error_info)
return result
# 处理发送登录验证码响应
static func handle_send_login_code_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
var error_code = data.get("error_code", "")
if error_code == "TEST_MODE_ONLY":
result.success = true
result.message = "测试模式:登录验证码已生成,请查看控制台"
result.toast_type = "success"
if data.has("data") and data.data.has("verification_code"):
print("测试模式登录验证码: ", data.data.verification_code)
else:
result.success = true
result.message = "登录验证码已发送,请查收"
result.toast_type = "success"
if data.has("data") and data.data.has("verification_code"):
print("开发环境登录验证码: ", data.data.verification_code)
else:
result = _handle_send_login_code_error(data, error_info)
return result
# 处理注册响应
static func handle_register_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
result.success = true
result.message = "注册成功!欢迎加入鲸鱼镇"
result.toast_type = "success"
result.data = data
# 自定义动作:清空表单,切换到登录界面
result.custom_action = func():
# 这里可以执行清空表单、切换界面等操作
pass
else:
result = _handle_register_error(data, error_info)
return result
# 处理邮箱验证响应
static func handle_verify_email_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
result.success = true
result.message = "邮箱验证成功,正在注册..."
result.toast_type = "success"
result.data = data
else:
result = _handle_verify_email_error(data, error_info)
return result
# 处理重新发送邮箱验证码响应
static func handle_resend_email_verification_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
var error_code = data.get("error_code", "")
if error_code == "TEST_MODE_ONLY":
result.success = true
result.message = "🧪 测试模式:验证码已重新生成,请查看控制台"
result.toast_type = "success"
if data.has("data") and data.data.has("verification_code"):
print("🔑 测试模式重新发送验证码: ", data.data.verification_code)
else:
result.success = true
result.message = "📧 验证码已重新发送到您的邮箱,请查收"
result.toast_type = "success"
if data.has("data") and data.data.has("verification_code"):
print("🔑 开发环境重新发送验证码: ", data.data.verification_code)
else:
result = _handle_resend_email_verification_error(data, error_info)
return result
# 处理忘记密码响应
static func handle_forgot_password_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
var error_code = data.get("error_code", "")
if error_code == "TEST_MODE_ONLY":
result.success = true
result.message = "🧪 测试模式:重置验证码已生成,请查看控制台"
result.toast_type = "success"
if data.has("data") and data.data.has("verification_code"):
print("🔑 测试模式重置验证码: ", data.data.verification_code)
else:
result.success = true
result.message = "📧 重置验证码已发送,请查收"
result.toast_type = "success"
if data.has("data") and data.data.has("verification_code"):
print("🔑 开发环境重置验证码: ", data.data.verification_code)
else:
result = _handle_forgot_password_error(data, error_info)
return result
# 处理重置密码响应
static func handle_reset_password_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
result.success = true
result.message = "🔒 密码重置成功,请使用新密码登录"
result.toast_type = "success"
result.data = data
else:
result = _handle_reset_password_error(data, error_info)
return result
# ============ 错误处理方法 ============
# 处理登录错误
static func _handle_login_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "登录失败")
match error_code:
"LOGIN_FAILED":
# 根据消息内容进一步判断用户状态
if "账户已锁定" in message or "locked" in message.to_lower():
result.message = "账户已被锁定,请联系管理员"
elif "账户已禁用" in message or "banned" in message.to_lower():
result.message = "账户已被禁用,请联系管理员"
elif "账户待审核" in message or "pending" in message.to_lower():
result.message = "账户待审核,请等待管理员审核"
elif "邮箱未验证" in message or "inactive" in message.to_lower():
result.message = "请先验证邮箱后再登录"
else:
result.message = "用户名或密码错误,请检查后重试"
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# 处理验证码登录错误
static func _handle_verification_code_login_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "验证码登录失败")
match error_code:
"VERIFICATION_CODE_LOGIN_FAILED":
result.message = "验证码错误或已过期"
"EMAIL_NOT_VERIFIED":
result.message = "邮箱未验证,请先验证邮箱后再使用验证码登录"
"USER_NOT_FOUND":
result.message = "用户不存在,请先注册"
"INVALID_IDENTIFIER":
result.message = "请输入有效的邮箱或手机号"
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# 处理发送验证码错误 - 支持邮箱冲突检测和频率限制
static func _handle_send_code_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "发送验证码失败")
var response_code = error_info.get("response_code", 0)
match error_code:
"SEND_EMAIL_VERIFICATION_FAILED":
# 检查是否是邮箱冲突409状态码
if response_code == 409:
result.message = "⚠️ 邮箱已被注册,请使用其他邮箱或直接登录"
result.toast_type = "error"
elif "邮箱格式" in message:
result.message = "📧 请输入有效的邮箱地址"
else:
result.message = message
"TOO_MANY_REQUESTS":
# 处理频率限制,提供重试建议
result.toast_type = "error"
# 如果有throttle_info显示更详细的信息
if data.has("throttle_info"):
var throttle_info = data.throttle_info
var reset_time = throttle_info.get("reset_time", "")
if reset_time != "":
var relative_time = StringUtils.get_relative_time_until(reset_time)
var local_time = StringUtils.format_utc_to_local_time(reset_time)
result.message = "⏰ 验证码发送过于频繁"
result.message += "\n" + relative_time + "再试"
result.message += "\n重试时间: " + local_time
else:
result.message = "⏰ 验证码发送过于频繁,请稍后再试"
else:
result.message = "⏰ 验证码发送过于频繁,请稍后再试"
"VERIFICATION_CODE_RATE_LIMITED":
result.message = "⏰ 验证码发送过于频繁,请稍后再试"
"VERIFICATION_CODE_HOURLY_LIMIT":
result.message = "⏰ 每小时发送次数已达上限,请稍后再试"
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# 处理发送登录验证码错误
static func _handle_send_login_code_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "发送登录验证码失败")
match error_code:
"SEND_LOGIN_CODE_FAILED":
if "用户不存在" in message:
result.message = "用户不存在,请先注册"
else:
result.message = "发送登录验证码失败"
"USER_NOT_FOUND":
result.message = "用户不存在,请先注册"
"INVALID_IDENTIFIER":
result.message = "请输入有效的邮箱或手机号"
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# 处理注册错误 - 支持409冲突状态码
static func _handle_register_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "注册失败")
var response_code = error_info.get("response_code", 0)
match error_code:
"REGISTER_FAILED":
# 检查409冲突状态码
if response_code == 409:
if "邮箱已存在" in message or "邮箱已被使用" in message:
result.message = "📧 邮箱已被注册,请使用其他邮箱或直接登录"
elif "用户名已存在" in message or "用户名已被使用" in message:
result.message = "👤 用户名已被使用,请换一个"
else:
result.message = "⚠️ 资源冲突:" + message
elif "邮箱验证码" in message or "verification_code" in message:
result.message = "🔑 请先获取并输入邮箱验证码"
elif "用户名" in message:
result.message = "👤 用户名格式不正确"
elif "邮箱" in message:
result.message = "📧 邮箱格式不正确"
elif "密码" in message:
result.message = "🔒 密码格式不符合要求"
elif "验证码" in message:
result.message = "🔑 验证码错误或已过期"
else:
result.message = message
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# 处理邮箱验证错误
static func _handle_verify_email_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "邮箱验证失败")
match error_code:
"EMAIL_VERIFICATION_FAILED":
if "验证码错误" in message:
result.message = "🔑 验证码错误"
elif "验证码已过期" in message:
result.message = "🔑 验证码已过期,请重新获取"
else:
result.message = message
"VERIFICATION_CODE_INVALID":
result.message = "🔑 验证码错误或已过期"
"VERIFICATION_CODE_EXPIRED":
result.message = "🔑 验证码已过期,请重新获取"
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# 处理网络测试响应
static func handle_network_test_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
var result = ResponseResult.new()
if success:
result.success = true
result.message = "🌐 网络连接正常"
result.toast_type = "success"
else:
result.success = false
result.message = "🌐 网络连接异常"
result.toast_type = "error"
return result
# 处理重新发送邮箱验证码错误
static func _handle_resend_email_verification_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "重新发送验证码失败")
match error_code:
"RESEND_EMAIL_VERIFICATION_FAILED":
if "邮箱已验证" in message:
result.message = "📧 邮箱已验证,无需重复验证"
else:
result.message = message
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# 处理忘记密码错误
static func _handle_forgot_password_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "发送重置验证码失败")
match error_code:
"SEND_CODE_FAILED":
if "用户不存在" in message:
result.message = "👤 用户不存在,请检查邮箱或手机号"
else:
result.message = message
"USER_NOT_FOUND":
result.message = "👤 用户不存在,请检查邮箱或手机号"
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# 处理重置密码错误
static func _handle_reset_password_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
var result = ResponseResult.new()
var error_code = data.get("error_code", "")
var message = data.get("message", "重置密码失败")
match error_code:
"RESET_PASSWORD_FAILED":
if "验证码" in message:
result.message = "🔑 验证码错误或已过期"
else:
result.message = message
_:
result.message = _get_error_message(error_code, message, error_info)
return result
# ============ 工具方法 ============
# 获取错误消息 - 支持更多状态码和错误处理
static func _get_error_message(error_code: String, original_message: String, error_info: Dictionary) -> String:
# 优先使用错误码映射
if ERROR_CODE_MESSAGES.has(error_code):
return ERROR_CODE_MESSAGES[error_code]
# 处理频率限制
if error_code == "TOO_MANY_REQUESTS":
return _handle_rate_limit_message(original_message, error_info)
# 处理维护模式
if error_code == "SERVICE_UNAVAILABLE":
return _handle_maintenance_message(original_message, error_info)
# 处理测试模式
if error_code == "TEST_MODE_ONLY":
return "🧪 测试模式:" + original_message
# 根据HTTP状态码处理
if error_info.has("response_code"):
var response_code = error_info.response_code
match response_code:
409:
return "⚠️ 资源冲突:" + original_message
206:
return "🧪 测试模式:" + original_message
429:
return "⏰ 请求过于频繁,请稍后再试"
_:
if HTTP_STATUS_MESSAGES.has(response_code):
return HTTP_STATUS_MESSAGES[response_code] + "" + original_message
# 返回原始消息
return original_message if original_message != "" else "操作失败"
# 处理频率限制消息
static func _handle_rate_limit_message(message: String, error_info: Dictionary) -> String:
# 可以根据throttle_info提供更详细的信息
return message + ",请稍后再试"
# 处理维护模式消息
static func _handle_maintenance_message(message: String, error_info: Dictionary) -> String:
# 可以根据maintenance_info提供更详细的信息
return "系统维护中,请稍后再试"
# 通用响应处理器 - 支持更多操作类型
static func handle_response(operation_type: String, success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
match operation_type:
"login":
return handle_login_response(success, data, error_info)
"verification_code_login":
return handle_verification_code_login_response(success, data, error_info)
"send_code":
return handle_send_verification_code_response(success, data, error_info)
"send_login_code":
return handle_send_login_code_response(success, data, error_info)
"register":
return handle_register_response(success, data, error_info)
"verify_email":
return handle_verify_email_response(success, data, error_info)
"resend_email_verification":
return handle_resend_email_verification_response(success, data, error_info)
"forgot_password":
return handle_forgot_password_response(success, data, error_info)
"reset_password":
return handle_reset_password_response(success, data, error_info)
"network_test":
return handle_network_test_response(success, data, error_info)
_:
# 通用处理
var result = ResponseResult.new()
if success:
result.success = true
result.message = "✅ 操作成功"
result.toast_type = "success"
else:
result.success = false
result.message = _get_error_message(data.get("error_code", ""), data.get("message", "操作失败"), error_info)
result.toast_type = "error"
return result

View File

@@ -1 +0,0 @@
uid://nseguk2ytiw6

View File

@@ -1,75 +0,0 @@
extends Node
# 场景管理器 - 负责场景切换和管理
# 提供场景切换的统一接口
signal scene_changed(scene_name: String)
signal scene_change_started(scene_name: String)
var current_scene_name: String = ""
var is_changing_scene: bool = false
# 场景路径映射
var scene_paths: Dictionary = {
"main": "res://Scenes/Maps/main_scene.tscn",
"auth": "res://UI/Windows/LoginWindow.tscn",
"game": "res://Scenes/Maps/game_scene.tscn",
"battle": "res://Scenes/Maps/battle_scene.tscn",
"inventory": "res://UI/Windows/InventoryWindow.tscn",
"shop": "res://UI/Windows/ShopWindow.tscn",
"settings": "res://UI/Windows/SettingsWindow.tscn"
}
func _ready():
print("SceneManager 初始化完成")
func change_scene(scene_name: String, use_transition: bool = true):
if is_changing_scene:
print("场景切换中,忽略新的切换请求")
return false
if not scene_paths.has(scene_name):
print("错误: 未找到场景 ", scene_name)
return false
var scene_path = scene_paths[scene_name]
print("开始切换场景: ", current_scene_name, " -> ", scene_name)
is_changing_scene = true
scene_change_started.emit(scene_name)
if use_transition:
await show_transition()
var error = get_tree().change_scene_to_file(scene_path)
if error != OK:
print("场景切换失败: ", error)
is_changing_scene = false
return false
current_scene_name = scene_name
is_changing_scene = false
scene_changed.emit(scene_name)
if use_transition:
await hide_transition()
print("场景切换完成: ", scene_name)
return true
func get_current_scene_name() -> String:
return current_scene_name
func register_scene(scene_name: String, scene_path: String):
scene_paths[scene_name] = scene_path
print("注册场景: ", scene_name, " -> ", scene_path)
func show_transition():
# TODO: 实现场景切换过渡效果
print("显示场景切换过渡效果")
await get_tree().create_timer(0.2).timeout
func hide_transition():
# TODO: 隐藏场景切换过渡效果
print("隐藏场景切换过渡效果")
await get_tree().create_timer(0.2).timeout

View File

@@ -1 +0,0 @@
uid://d3l286ti5gqhw

View File

@@ -1,80 +0,0 @@
extends Node
# 全局事件系统 - 提供解耦的事件通信机制
# 允许不同模块之间通过事件进行通信,避免直接依赖
# 事件监听器存储
var event_listeners: Dictionary = {}
func _ready():
print("EventSystem 初始化完成")
# 注册事件监听器
func connect_event(event_name: String, callback: Callable, target: Node = null):
if not event_listeners.has(event_name):
event_listeners[event_name] = []
var listener_info = {
"callback": callback,
"target": target
}
event_listeners[event_name].append(listener_info)
print("注册事件监听器: ", event_name, " -> ", callback)
# 移除事件监听器
func disconnect_event(event_name: String, callback: Callable, target: Node = null):
if not event_listeners.has(event_name):
return
var listeners = event_listeners[event_name]
for i in range(listeners.size() - 1, -1, -1):
var listener = listeners[i]
if listener.callback == callback and listener.target == target:
listeners.remove_at(i)
print("移除事件监听器: ", event_name, " -> ", callback)
break
# 发送事件
func emit_event(event_name: String, data: Variant = null):
print("发送事件: ", event_name, " 数据: ", data)
if not event_listeners.has(event_name):
return
var listeners = event_listeners[event_name]
for listener_info in listeners:
var target = listener_info.target
var callback = listener_info.callback
# 检查目标节点是否仍然有效
if target != null and not is_instance_valid(target):
continue
# 调用回调函数
if data != null:
callback.call(data)
else:
callback.call()
# 清理无效的监听器
func cleanup_invalid_listeners():
for event_name in event_listeners.keys():
var listeners = event_listeners[event_name]
for i in range(listeners.size() - 1, -1, -1):
var listener = listeners[i]
var target = listener.target
if target != null and not is_instance_valid(target):
listeners.remove_at(i)
print("清理无效监听器: ", event_name)
# 获取事件监听器数量
func get_listener_count(event_name: String) -> int:
if not event_listeners.has(event_name):
return 0
return event_listeners[event_name].size()
# 清空所有事件监听器
func clear_all_listeners():
event_listeners.clear()
print("清空所有事件监听器")

View File

@@ -1 +0,0 @@
uid://bfheblucmti24

0
addons/.gitkeep Normal file
View File

0
assets/.gitkeep Normal file
View File

View File

@@ -1 +0,0 @@
# 保持目录结构 - 音乐资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 音效资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 语音资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 音乐资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 音效资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 语音资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 字体资源目录

Binary file not shown.

View File

@@ -1,41 +0,0 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://ce7ujbeobblyr"
path="res://.godot/imported/msyh.ttc-1f7944f6d1cff8092894a3525ec5156c.fontdata"
[deps]
source_file="res://assets/fonts/msyh.ttc"
dest_files=["res://.godot/imported/msyh.ttc-1f7944f6d1cff8092894a3525ec5156c.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
modulate_color_glyphs=false
hinting=1
subpixel_positioning=4
keep_rounding_remainders=true
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=false
preload=[{
"chars": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=[]{}|;':\",./<>?`~一二三四五六七八九十百千万亿用户名密码登录注册验证码邮箱小镇鲸鱼欢迎来到开始你的之旅请输入不能为空获取发送忘记返回居民身份确认再次已被使用换个等待分钟后试稍后正在创建账户测试模式生成查看控制台网络连接失败系统维护中升级稍后再试频繁联系管理员禁用审核先邮箱后使用成功进入镇错误或过期未找到存在",
"glyphs": [],
"name": "Web预加载",
"size": Vector2i(16, 0)
}]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 644 B

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bqg5e8qn1j74u"
path="res://.godot/imported/icon16.png-3099ad8a609f90c382508b9c073ffd76.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icon/icon16.png"
dest_files=["res://.godot/imported/icon16.png-3099ad8a609f90c382508b9c073ffd76.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dt24j6p0cijqo"
path="res://.godot/imported/icon32.png-9a0aceb23d191139c34540a188bf8c91.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icon/icon32.png"
dest_files=["res://.godot/imported/icon32.png-9a0aceb23d191139c34540a188bf8c91.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dt817lem3dwee"
path="res://.godot/imported/icon512.png-1c1c4b424489de87a542c89bec6eb15b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icon/icon512.png"
dest_files=["res://.godot/imported/icon512.png-1c1c4b424489de87a542c89bec6eb15b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ci42rd5qe6icl"
path="res://.godot/imported/icon64.png-da8a1a20e3bf4dcf06c8ff6c558caaff.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icon/icon64.png"
dest_files=["res://.godot/imported/icon64.png-da8a1a20e3bf4dcf06c8ff6c558caaff.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cnw6e3wmy0ea4"
path="res://.godot/imported/image(1).png-c89cc92103e50aaba40bf38c797be77f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icon/image(1).png"
dest_files=["res://.godot/imported/image(1).png-c89cc92103e50aaba40bf38c797be77f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c7v22i1hgo1x6"
path="res://.godot/imported/image.png-3f16548595ba9fb08c5e50ef3251d148.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icon/image.png"
dest_files=["res://.godot/imported/image.png-3f16548595ba9fb08c5e50ef3251d148.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
assets/login/enter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

View File

@@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://cj0tify76qrst" uid="uid://cswuqnhiiypb2"
path="res://.godot/imported/index.png-d064c09a6315f5da70b1876a63391d16.ctex" path="res://.godot/imported/enter.png-ed3d67e95e66053ad0fb61054985bfb8.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://web_assets/index.png" source_file="res://assets/login/enter.png"
dest_files=["res://.godot/imported/index.png-d064c09a6315f5da70b1876a63391d16.ctex"] dest_files=["res://.godot/imported/enter.png-ed3d67e95e66053ad0fb61054985bfb8.ctex"]
[params] [params]

BIN
assets/login/login-bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 KiB

View File

@@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://drpllpsjdiaex" uid="uid://byw73r2dt6xb8"
path="res://.godot/imported/icon180.png-20a9d7b98bfb315dd470e3635f315a17.ctex" path="res://.godot/imported/login-bg.png-3f4c0c8160ab08ab0791dc1de267dd7a.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://assets/icon/icon180.png" source_file="res://assets/login/login-bg.png"
dest_files=["res://.godot/imported/icon180.png-20a9d7b98bfb315dd470e3635f315a17.ctex"] dest_files=["res://.godot/imported/login-bg.png-3f4c0c8160ab08ab0791dc1de267dd7a.ctex"]
[params] [params]

BIN
assets/login/whaletown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

View File

@@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bwy5r7soxi76a" uid="uid://bqvel7n6dfo1d"
path="res://.godot/imported/icon144.png-ae9d1f30a88beaab449c2cad89283dd3.ctex" path="res://.godot/imported/whaletown.png-c44c9408e8b817d0db57fd8eec9de194.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://assets/icon/icon144.png" source_file="res://assets/login/whaletown.png"
dest_files=["res://.godot/imported/icon144.png-ae9d1f30a88beaab449c2cad89283dd3.ctex"] dest_files=["res://.godot/imported/whaletown.png-c44c9408e8b817d0db57fd8eec9de194.ctex"]
[params] [params]

View File

@@ -1 +0,0 @@
# 保持目录结构 - 材质资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 着色器资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 角色精灵资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 特效精灵资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 环境精灵资源目录

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bwy5r7soxi76a"
path="res://.godot/imported/icon144.png-27a33b914815b6d4af200572bfdaa6ff.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/icon/icon144.png"
dest_files=["res://.godot/imported/icon144.png-27a33b914815b6d4af200572bfdaa6ff.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 644 B

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bqg5e8qn1j74u"
path="res://.godot/imported/icon16.png-7cdae0838b274bb32361bfaa80a42a0f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/icon/icon16.png"
dest_files=["res://.godot/imported/icon16.png-7cdae0838b274bb32361bfaa80a42a0f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://drpllpsjdiaex"
path="res://.godot/imported/icon180.png-1d6fc41d452b1d5b5b66c12dbeb9a657.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/icon/icon180.png"
dest_files=["res://.godot/imported/icon180.png-1d6fc41d452b1d5b5b66c12dbeb9a657.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dt24j6p0cijqo"
path="res://.godot/imported/icon32.png-d677605f61a2a3a87d4018004b1f6aa4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/icon/icon32.png"
dest_files=["res://.godot/imported/icon32.png-d677605f61a2a3a87d4018004b1f6aa4.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dt817lem3dwee"
path="res://.godot/imported/icon512.png-5f7b6d37423049879d2db9cc5a9126f5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/icon/icon512.png"
dest_files=["res://.godot/imported/icon512.png-5f7b6d37423049879d2db9cc5a9126f5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ci42rd5qe6icl"
path="res://.godot/imported/icon64.png-e3684ecc6e07cbb7b0527f9c18c4431a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/icon/icon64.png"
dest_files=["res://.godot/imported/icon64.png-e3684ecc6e07cbb7b0527f9c18c4431a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cnw6e3wmy0ea4"
path="res://.godot/imported/image(1).png-14ccba2bcca2f261c1c009e0a9e237f6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/icon/image(1).png"
dest_files=["res://.godot/imported/image(1).png-14ccba2bcca2f261c1c009e0a9e237f6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c7v22i1hgo1x6"
path="res://.godot/imported/image.png-409a48a8fb5774839179f1fee74603d2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/icon/image.png"
dest_files=["res://.godot/imported/image.png-409a48a8fb5774839179f1fee74603d2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1 +0,0 @@
# 保持目录结构 - 材质资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 着色器资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 角色精灵资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 特效精灵资源目录

View File

@@ -1 +0,0 @@
# 保持目录结构 - 环境精灵资源目录

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 MiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bx17oy8lvaca4"
path="res://.godot/imported/bg_auth_scene.png-818065fcc20397e855c75507c1313623.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/auth/bg_auth_scene.png"
dest_files=["res://.godot/imported/bg_auth_scene.png-818065fcc20397e855c75507c1313623.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://de4q4s1gxivtf"
path="res://.godot/imported/login_frame_smart_transparent.png-e5d0fd05b4713ddd3beae8223f2abb80.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/auth/login_frame_smart_transparent.png"
dest_files=["res://.godot/imported/login_frame_smart_transparent.png-e5d0fd05b4713ddd3beae8223f2abb80.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,7 +0,0 @@
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cp7t8tu7rmyad"]
[ext_resource type="FontFile" uid="uid://ce7ujbeobblyr" path="res://assets/fonts/msyh.ttc" id="1_ftb5w"]
[resource]
resource_local_to_scene = true
default_font = ExtResource("1_ftb5w")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://gr7vud1lee4m"
path="res://.godot/imported/datawhale_logo.png-ddb5e2c04419eb84cfa8605bcbf64fbd.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/datawhale_logo.png"
dest_files=["res://.godot/imported/datawhale_logo.png-ddb5e2c04419eb84cfa8605bcbf64fbd.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

0
data/.gitkeep Normal file
View File

0
docs/.gitkeep Normal file
View File

View File

@@ -1,963 +0,0 @@
# Pixel Game Server API 文档
**版本**: 1.1.1
**更新时间**: 2025-12-25
## 🚨 后端对前端的提示与注意点
### 重要提醒
1. **邮箱冲突检测**: 发送邮箱验证码前会检查邮箱是否已被注册已注册邮箱返回409状态码
2. **HTTP状态码**: 所有接口根据业务结果返回正确状态码409冲突、400参数错误、401认证失败等
3. **验证码有效期**: 所有验证码有效期为5分钟
4. **频率限制**: 验证码发送限制1次/分钟注册限制10次/5分钟
5. **测试模式**: 开发环境下邮件服务返回206状态码验证码在响应中返回
6. **冷却时间自动清除**: 注册、密码重置、验证码登录成功后会自动清除验证码冷却时间,方便后续操作
### 错误处理规范
- **409 Conflict**: 资源冲突(用户名、邮箱已存在)
- **400 Bad Request**: 参数错误、验证码错误
- **401 Unauthorized**: 认证失败、密码错误
- **429 Too Many Requests**: 频率限制
- **206 Partial Content**: 测试模式(验证码未真实发送)
### 前端开发建议
1. 根据HTTP状态码进行错误处理不要只依赖success字段
2. 邮箱注册流程:先发送验证码 → 检查409冲突 → 使用验证码注册
3. 测试模式下验证码在响应中返回,生产环境需用户查收邮件
4. 实现重试机制处理429频率限制错误
5. 注册/重置密码成功后,验证码冷却时间会自动清除,可立即发送新验证码
---
## 📋 API接口列表
### 应用状态接口
- `GET /` - 获取应用状态
### 用户认证接口
- `POST /auth/login` - 用户登录
- `POST /auth/register` - 用户注册
- `POST /auth/github` - GitHub OAuth登录
- `POST /auth/verification-code-login` - 验证码登录
- `POST /auth/send-login-verification-code` - 发送登录验证码
- `POST /auth/forgot-password` - 发送密码重置验证码
- `POST /auth/reset-password` - 重置密码
- `PUT /auth/change-password` - 修改密码
- `POST /auth/send-email-verification` - 发送邮箱验证码
- `POST /auth/verify-email` - 验证邮箱验证码
- `POST /auth/resend-email-verification` - 重新发送邮箱验证码
### 管理员接口
- `POST /admin/auth/login` - 管理员登录
- `GET /admin/users` - 获取用户列表
- `GET /admin/users/:id` - 获取用户详情
- `POST /admin/users/:id/reset-password` - 管理员重置用户密码
- `GET /admin/logs/runtime` - 获取运行时日志
- `GET /admin/logs/archive` - 获取归档日志
### 用户管理接口
- `PUT /admin/users/:id/status` - 修改用户状态
- `POST /admin/users/batch-status` - 批量修改用户状态
- `GET /admin/users/status-stats` - 获取用户状态统计
---
## 🧪 API接口详细说明与测试用例
### 1. 获取应用状态
**接口**: `GET /`
#### 成功响应 (200)
```json
{
"service": "Pixel Game Server",
"version": "1.1.1",
"status": "running",
"timestamp": "2025-12-25T10:27:44.352Z",
"uptime": 8,
"environment": "development",
"storage_mode": "database"
}
```
---
### 2. 用户登录
**接口**: `POST /auth/login`
#### 请求体
```json
{
"identifier": "testuser",
"password": "password123"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"user": {
"id": "1",
"username": "testuser",
"nickname": "测试用户",
"email": "test@example.com",
"phone": null,
"avatar_url": null,
"role": 1,
"created_at": "2025-12-17T10:00:00.000Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"is_new_user": false,
"message": "登录成功"
},
"message": "登录成功"
}
```
#### 认证失败响应 (401)
```json
{
"success": false,
"message": "用户名、邮箱或手机号不存在",
"error_code": "LOGIN_FAILED"
}
```
#### 密码错误响应 (401)
```json
{
"success": false,
"message": "密码错误",
"error_code": "LOGIN_FAILED"
}
```
---
### 3. 用户注册
**接口**: `POST /auth/register`
#### 请求体(无邮箱)
```json
{
"username": "newuser",
"password": "password123",
"nickname": "新用户"
}
```
#### 请求体(带邮箱验证)
```json
{
"username": "newuser",
"password": "password123",
"nickname": "新用户",
"email": "newuser@example.com",
"email_verification_code": "123456"
}
```
#### 成功响应 (201)
```json
{
"success": true,
"data": {
"user": {
"id": "2",
"username": "newuser",
"nickname": "新用户",
"email": "newuser@example.com",
"phone": null,
"avatar_url": null,
"role": 1,
"created_at": "2025-12-17T10:00:00.000Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"is_new_user": true,
"message": "注册成功"
},
"message": "注册成功"
}
```
#### 用户名冲突响应 (409)
```json
{
"success": false,
"message": "用户名已存在",
"error_code": "REGISTER_FAILED"
}
```
#### 邮箱冲突响应 (409)
```json
{
"success": false,
"message": "邮箱已存在",
"error_code": "REGISTER_FAILED"
}
```
#### 验证码错误响应 (400)
```json
{
"success": false,
"message": "验证码不存在或已过期",
"error_code": "REGISTER_FAILED"
}
```
---
### 4. 发送邮箱验证码
**接口**: `POST /auth/send-email-verification`
#### 请求体
```json
{
"email": "test@example.com"
}
```
#### 成功响应 (200) - 生产环境
```json
{
"success": true,
"data": {
"is_test_mode": false
},
"message": "验证码已发送,请查收邮件"
}
```
#### 测试模式响应 (206) - 开发环境
```json
{
"success": false,
"data": {
"verification_code": "123456",
"is_test_mode": true
},
"message": "⚠️ 测试模式:验证码已生成但未真实发送。请在控制台查看验证码,或配置邮件服务以启用真实发送。",
"error_code": "TEST_MODE_ONLY"
}
```
#### 邮箱冲突响应 (409)
```json
{
"success": false,
"message": "邮箱已被注册,请使用其他邮箱或直接登录",
"error_code": "SEND_EMAIL_VERIFICATION_FAILED"
}
```
#### 频率限制响应 (429)
```json
{
"success": false,
"message": "验证码发送过于频繁请1分钟后再试",
"error_code": "TOO_MANY_REQUESTS",
"throttle_info": {
"limit": 1,
"window_seconds": 60,
"current_requests": 1,
"reset_time": "2025-12-25T10:07:37.056Z"
}
}
```
---
### 5. 验证码登录
**接口**: `POST /auth/verification-code-login`
#### 请求体
```json
{
"identifier": "test@example.com",
"verification_code": "123456"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"user": {
"id": "1",
"username": "testuser",
"nickname": "测试用户",
"email": "test@example.com",
"phone": null,
"avatar_url": null,
"role": 1,
"created_at": "2025-12-17T10:00:00.000Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"is_new_user": false,
"message": "验证码登录成功"
},
"message": "验证码登录成功"
}
```
#### 验证码错误响应 (401)
```json
{
"success": false,
"message": "验证码验证失败",
"error_code": "VERIFICATION_CODE_LOGIN_FAILED"
}
```
#### 用户不存在响应 (404)
```json
{
"success": false,
"message": "用户不存在,请先注册账户",
"error_code": "VERIFICATION_CODE_LOGIN_FAILED"
}
```
---
### 6. 发送登录验证码
**接口**: `POST /auth/send-login-verification-code`
#### 请求体
```json
{
"identifier": "test@example.com"
}
```
#### 成功响应 (200) - 生产环境
```json
{
"success": true,
"data": {
"is_test_mode": false
},
"message": "验证码已发送,请查收"
}
```
#### 测试模式响应 (206) - 开发环境
```json
{
"success": false,
"data": {
"verification_code": "654321",
"is_test_mode": true
},
"message": "⚠️ 测试模式:验证码已生成但未真实发送。请在控制台查看验证码,或配置邮件服务以启用真实发送。",
"error_code": "TEST_MODE_ONLY"
}
```
#### 用户不存在响应 (404)
```json
{
"success": false,
"message": "用户不存在",
"error_code": "SEND_LOGIN_CODE_FAILED"
}
```
---
### 7. 发送密码重置验证码
**接口**: `POST /auth/forgot-password`
#### 请求体
```json
{
"identifier": "test@example.com"
}
```
#### 成功响应 (200) - 生产环境
```json
{
"success": true,
"data": {
"is_test_mode": false
},
"message": "验证码已发送,请查收"
}
```
#### 测试模式响应 (206) - 开发环境
```json
{
"success": false,
"data": {
"verification_code": "789012",
"is_test_mode": true
},
"message": "⚠️ 测试模式:验证码已生成但未真实发送。请在控制台查看验证码,或配置邮件服务以启用真实发送。",
"error_code": "TEST_MODE_ONLY"
}
```
#### 用户不存在响应 (404)
```json
{
"success": false,
"message": "用户不存在",
"error_code": "SEND_CODE_FAILED"
}
```
---
### 8. 重置密码
**接口**: `POST /auth/reset-password`
#### 请求体
```json
{
"identifier": "test@example.com",
"verification_code": "789012",
"new_password": "newpassword123"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"message": "密码重置成功"
}
```
#### 验证码错误响应 (400)
```json
{
"success": false,
"message": "验证码验证失败",
"error_code": "RESET_PASSWORD_FAILED"
}
```
---
### 9. 修改密码
**接口**: `PUT /auth/change-password`
#### 请求体
```json
{
"user_id": "1",
"old_password": "oldpassword123",
"new_password": "newpassword123"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"message": "密码修改成功"
}
```
#### 旧密码错误响应 (401)
```json
{
"success": false,
"message": "旧密码错误",
"error_code": "CHANGE_PASSWORD_FAILED"
}
```
---
### 10. GitHub OAuth登录
**接口**: `POST /auth/github`
#### 请求体
```json
{
"github_id": "12345678",
"username": "octocat",
"nickname": "The Octocat",
"email": "octocat@github.com",
"avatar_url": "https://github.com/images/error/octocat_happy.gif"
}
```
#### 成功响应 (200) - 已存在用户
```json
{
"success": true,
"data": {
"user": {
"id": "3",
"username": "octocat",
"nickname": "The Octocat",
"email": "octocat@github.com",
"phone": null,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"role": 1,
"created_at": "2025-12-17T10:00:00.000Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"is_new_user": false,
"message": "GitHub登录成功"
},
"message": "GitHub登录成功"
}
```
#### 成功响应 (200) - 新用户注册
```json
{
"success": true,
"data": {
"user": {
"id": "4",
"username": "octocat_1",
"nickname": "The Octocat",
"email": "octocat@github.com",
"phone": null,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"role": 1,
"created_at": "2025-12-17T10:00:00.000Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"is_new_user": true,
"message": "GitHub账户绑定成功"
},
"message": "GitHub账户绑定成功"
}
```
---
### 11. 验证邮箱验证码
**接口**: `POST /auth/verify-email`
#### 请求体
```json
{
"email": "test@example.com",
"verification_code": "123456"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"message": "邮箱验证成功"
}
```
#### 验证码错误响应 (400)
```json
{
"success": false,
"message": "验证码错误",
"error_code": "EMAIL_VERIFICATION_FAILED"
}
```
---
### 12. 重新发送邮箱验证码
**接口**: `POST /auth/resend-email-verification`
#### 请求体
```json
{
"email": "test@example.com"
}
```
#### 成功响应 (200) - 生产环境
```json
{
"success": true,
"data": {
"is_test_mode": false
},
"message": "验证码已重新发送,请查收邮件"
}
```
#### 测试模式响应 (206) - 开发环境
```json
{
"success": false,
"data": {
"verification_code": "456789",
"is_test_mode": true
},
"message": "⚠️ 测试模式:验证码已生成但未真实发送。请在控制台查看验证码,或配置邮件服务以启用真实发送。",
"error_code": "TEST_MODE_ONLY"
}
```
#### 邮箱已验证响应 (400)
```json
{
"success": false,
"message": "邮箱已验证,无需重复验证",
"error_code": "RESEND_EMAIL_VERIFICATION_FAILED"
}
```
---
### 13. 管理员登录
**接口**: `POST /admin/auth/login`
#### 请求体
```json
{
"username": "admin",
"password": "Admin123456"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"admin": {
"id": "1",
"username": "admin",
"nickname": "管理员",
"role": 0
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 28800,
"message": "管理员登录成功"
},
"message": "管理员登录成功"
}
```
#### 认证失败响应 (401)
```json
{
"success": false,
"message": "用户名或密码错误",
"error_code": "ADMIN_LOGIN_FAILED"
}
```
#### 权限不足响应 (403)
```json
{
"success": false,
"message": "权限不足,需要管理员权限",
"error_code": "ADMIN_LOGIN_FAILED"
}
```
---
### 14. 获取用户列表
**接口**: `GET /admin/users`
#### 查询参数
- `page`: 页码可选默认1
- `limit`: 每页数量可选默认10
- `status`: 用户状态筛选(可选)
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"users": [
{
"id": "1",
"username": "testuser",
"nickname": "测试用户",
"email": "test@example.com",
"phone": null,
"role": 1,
"status": "active",
"email_verified": true,
"created_at": "2025-12-17T10:00:00.000Z",
"updated_at": "2025-12-17T10:00:00.000Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 1,
"pages": 1
}
},
"message": "用户列表获取成功"
}
```
---
### 15. 获取用户详情
**接口**: `GET /admin/users/:id`
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"user": {
"id": "1",
"username": "testuser",
"nickname": "测试用户",
"email": "test@example.com",
"phone": null,
"role": 1,
"status": "active",
"email_verified": true,
"github_id": null,
"avatar_url": null,
"created_at": "2025-12-17T10:00:00.000Z",
"updated_at": "2025-12-17T10:00:00.000Z"
}
},
"message": "用户详情获取成功"
}
```
#### 用户不存在响应 (404)
```json
{
"success": false,
"message": "用户不存在",
"error_code": "USER_NOT_FOUND"
}
```
---
### 16. 管理员重置用户密码
**接口**: `POST /admin/users/:id/reset-password`
#### 请求体
```json
{
"new_password": "newpassword123"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"message": "用户密码重置成功"
}
```
#### 用户不存在响应 (404)
```json
{
"success": false,
"message": "用户不存在",
"error_code": "USER_NOT_FOUND"
}
```
---
### 17. 修改用户状态
**接口**: `PUT /admin/users/:id/status`
#### 请求体
```json
{
"status": "locked",
"reason": "违规操作"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"user": {
"id": "1",
"username": "testuser",
"status": "locked",
"updated_at": "2025-12-17T10:00:00.000Z"
}
},
"message": "用户状态修改成功"
}
```
#### 状态值无效响应 (400)
```json
{
"success": false,
"message": "无效的用户状态值",
"error_code": "USER_STATUS_UPDATE_FAILED"
}
```
---
### 18. 批量修改用户状态
**接口**: `POST /admin/users/batch-status`
#### 请求体
```json
{
"user_ids": ["1", "2", "3"],
"status": "active",
"reason": "批量激活"
}
```
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"updated_count": 3,
"failed_count": 0,
"results": [
{
"user_id": "1",
"success": true,
"new_status": "active"
},
{
"user_id": "2",
"success": true,
"new_status": "active"
},
{
"user_id": "3",
"success": true,
"new_status": "active"
}
]
},
"message": "批量状态修改完成"
}
```
---
### 19. 获取用户状态统计
**接口**: `GET /admin/users/status-stats`
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"stats": {
"active": 15,
"inactive": 3,
"locked": 2,
"banned": 1,
"deleted": 0,
"pending": 5
},
"total": 26
},
"message": "用户状态统计获取成功"
}
```
---
### 20. 获取运行时日志
**接口**: `GET /admin/logs/runtime`
#### 查询参数
- `lines`: 日志行数可选默认100
- `level`: 日志级别(可选)
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"logs": [
"[2025-12-25 18:27:35] LOG [NestApplication] Nest application successfully started",
"[2025-12-25 18:27:35] LOG [RouterExplorer] Mapped {/, GET} route"
],
"total_lines": 2,
"timestamp": "2025-12-25T10:27:44.352Z"
},
"message": "运行时日志获取成功"
}
```
---
### 21. 获取归档日志
**接口**: `GET /admin/logs/archive`
#### 查询参数
- `date`: 日期YYYY-MM-DD格式可选
- `download`: 是否下载(可选)
#### 成功响应 (200)
```json
{
"success": true,
"data": {
"files": [
{
"filename": "app-2025-12-24.log",
"size": 1024,
"created_at": "2025-12-24T00:00:00.000Z"
}
],
"total_files": 1
},
"message": "归档日志列表获取成功"
}
```
---
## 📊 版本更新记录
### v1.1.2 (2025-12-25)
- **验证码冷却优化**: 注册、密码重置、验证码登录成功后自动清除验证码冷却时间
- **用户体验提升**: 成功操作后可立即发送新的验证码,无需等待冷却时间
- **代码健壮性**: 冷却时间清除失败不影响主要业务流程
### v1.1.1 (2025-12-25)
- **邮箱冲突检测优化**: 发送邮箱验证码前检查邮箱是否已被注册
- **用户体验提升**: 避免向已注册邮箱发送无用验证码
- **错误处理改进**: 返回409 Conflict状态码和明确错误信息
### v1.1.0 (2025-12-25)
- **新增验证码登录功能**: 支持邮箱验证码登录
- **HTTP状态码修复**: 所有接口返回正确的业务状态码
- **完善错误处理**: 统一错误响应格式和错误代码

View File

@@ -1,332 +0,0 @@
# API接口更新日志
**更新日期**: 2025-12-25
**API版本**: v1.1.1
**更新内容**: 根据后端最新API文档更新前端接口逻辑和Toast显示
---
## 🎯 更新概述
根据后端API v1.1.1的最新文档对前端的网络请求、响应处理和Toast显示系统进行了全面更新以支持新的功能特性和错误处理机制。
---
## 📋 主要更新内容
### 1. **HTTP状态码支持**
#### 新增状态码处理
- **206 Partial Content**: 测试模式响应
- **409 Conflict**: 资源冲突(用户名、邮箱已存在)
- **429 Too Many Requests**: 频率限制
#### 更新的状态码映射
```gdscript
const HTTP_STATUS_MESSAGES = {
200: "请求成功",
201: "创建成功",
206: "测试模式",
400: "请求参数错误",
401: "认证失败",
403: "权限不足",
404: "资源不存在",
408: "请求超时",
409: "资源冲突", # 新增
415: "不支持的媒体类型",
429: "请求过于频繁", # 新增
500: "服务器内部错误",
503: "服务不可用"
}
```
### 2. **错误码映射更新**
#### 新增错误码
- `SEND_EMAIL_VERIFICATION_FAILED`: 发送邮箱验证码失败
- `RESEND_EMAIL_VERIFICATION_FAILED`: 重新发送验证码失败
- `EMAIL_VERIFICATION_FAILED`: 邮箱验证失败
- `RESET_PASSWORD_FAILED`: 重置密码失败
- `CHANGE_PASSWORD_FAILED`: 修改密码失败
- `USER_STATUS_UPDATE_FAILED`: 用户状态更新失败
- `ADMIN_LOGIN_FAILED`: 管理员登录失败
### 3. **邮箱冲突检测**
#### 功能描述
- 发送邮箱验证码前检查邮箱是否已被注册
- 已注册邮箱返回409状态码和明确错误信息
#### 实现细节
```gdscript
# 在ResponseHandler中处理409冲突
if response_code == 409:
if "邮箱已存在" in message:
result.message = "📧 邮箱已被注册,请使用其他邮箱或直接登录"
elif "用户名已存在" in message:
result.message = "👤 用户名已被使用,请换一个"
```
### 4. **测试模式支持**
#### 功能描述
- 开发环境下邮件服务返回206状态码
- 验证码在响应中返回,无需真实发送邮件
#### 实现细节
```gdscript
# 处理206测试模式响应
elif response_code == 206 and error_code == "TEST_MODE_ONLY":
is_success = true
print("🧪 测试模式响应: ", message)
```
#### Toast显示优化
```gdscript
if error_code == "TEST_MODE_ONLY":
result.message = "🧪 测试模式:验证码已生成,请查看控制台"
if data.has("data") and data.data.has("verification_code"):
print("🔑 测试模式验证码: ", data.data.verification_code)
```
### 5. **频率限制处理**
#### 功能描述
- 验证码发送限制1次/分钟
- 注册限制10次/5分钟
- 提供重试建议和详细错误信息
#### 实现细节
```gdscript
"TOO_MANY_REQUESTS":
result.message = "⏰ 验证码发送过于频繁请1分钟后再试"
# 显示详细的限制信息
if data.has("throttle_info"):
var throttle_info = data.throttle_info
var reset_time = throttle_info.get("reset_time", "")
if reset_time != "":
result.message += "\n重试时间: " + reset_time
```
### 6. **Toast显示系统优化**
#### 视觉改进
- 增加图标显示(✅成功,❌失败)
- 更丰富的颜色和阴影效果
- 支持智能换行和更大的显示区域
- 更流畅的动画效果
#### 新的Toast样式
```gdscript
# 更深的颜色和更好的对比度
if is_success:
style.bg_color = Color(0.15, 0.7, 0.15, 0.95) # 深绿色
style.border_color = Color(0.2, 0.9, 0.2, 0.9) # 亮绿色边框
else:
style.bg_color = Color(0.7, 0.15, 0.15, 0.95) # 深红色
style.border_color = Color(0.9, 0.2, 0.2, 0.9) # 亮红色边框
# 添加阴影效果
style.shadow_color = Color(0, 0, 0, 0.3)
style.shadow_size = 4
style.shadow_offset = Vector2(2, 2)
```
#### 动画优化
- 增加透明度动画
- 延长显示时间2秒→3秒
- 更流畅的滑入滑出效果
### 7. **新增API方法**
#### NetworkManager新增方法
```gdscript
# 重新发送邮箱验证码
func resend_email_verification(email: String, callback: Callable) -> String
# 忘记密码 - 发送重置验证码
func forgot_password(identifier: String, callback: Callable) -> String
# 重置密码
func reset_password(identifier: String, verification_code: String, new_password: String, callback: Callable) -> String
# 修改密码
func change_password(user_id: String, old_password: String, new_password: String, callback: Callable) -> String
# GitHub OAuth登录
func github_login(github_id: String, username: String, nickname: String, email: String, avatar_url: String, callback: Callable) -> String
```
#### ResponseHandler新增处理方法
```gdscript
# 处理重新发送邮箱验证码响应
static func handle_resend_email_verification_response(success: bool, data: Dictionary, error_info: Dictionary) -> ResponseResult
# 处理忘记密码响应
static func handle_forgot_password_response(success: bool, data: Dictionary, error_info: Dictionary) -> ResponseResult
# 处理重置密码响应
static func handle_reset_password_response(success: bool, data: Dictionary, error_info: Dictionary) -> ResponseResult
```
---
## 🔧 技术改进
### 1. **响应处理逻辑优化**
#### 更精确的成功判断
```gdscript
# HTTP成功状态码且业务成功
if (response_code >= 200 and response_code < 300) and success:
is_success = true
# 特殊情况206测试模式
elif response_code == 206 and error_code == "TEST_MODE_ONLY":
is_success = true
# 201创建成功
elif response_code == 201:
is_success = true
```
#### 更详细的错误类型判断
```gdscript
match response_code:
409: # 资源冲突
return ErrorType.BUSINESS_ERROR
206: # 测试模式
return ErrorType.BUSINESS_ERROR
429: # 频率限制
return ErrorType.BUSINESS_ERROR
```
### 2. **错误消息国际化**
#### 添加表情符号和更友好的提示
- 📧 邮箱相关消息
- 👤 用户相关消息
- 🔑 验证码相关消息
- 🔒 密码相关消息
- ⏰ 时间相关消息
- 🧪 测试模式消息
- 🌐 网络相关消息
### 3. **代码结构优化**
#### 更好的模块化
- 分离不同类型的错误处理方法
- 统一的响应处理接口
- 更清晰的方法命名
#### 更完善的注释
- 详细的方法说明
- 参数和返回值说明
- 使用示例
---
## 🧪 测试验证
### 创建了API测试脚本
- **文件**: `scripts/network/ApiTestScript.gd`
- **功能**: 验证所有更新的API接口逻辑
- **测试用例**:
- 网络连接测试
- 邮箱验证码发送
- 邮箱冲突检测
- 登录功能
- 注册功能
### 测试覆盖的场景
- ✅ 正常成功响应
- ✅ 409邮箱冲突
- ✅ 206测试模式
- ✅ 429频率限制
- ✅ 各种错误状态码
- ✅ Toast显示效果
---
## 📚 使用指南
### 1. **发送邮箱验证码**
```gdscript
# 会自动检查邮箱冲突
var request_id = NetworkManager.send_email_verification("user@example.com", callback)
```
### 2. **处理409冲突**
```gdscript
func callback(success: bool, data: Dictionary, error_info: Dictionary):
var result = ResponseHandler.handle_send_verification_code_response(success, data, error_info)
if error_info.get("response_code") == 409:
# 邮箱已存在,引导用户登录
show_login_suggestion()
```
### 3. **处理测试模式**
```gdscript
# 测试模式下验证码会在控制台显示
if data.get("error_code") == "TEST_MODE_ONLY":
var verification_code = data.data.verification_code
print("测试验证码: ", verification_code)
```
### 4. **处理频率限制**
```gdscript
# 提供重试建议
if error_info.get("response_code") == 429:
show_retry_suggestion(data.get("throttle_info", {}))
```
---
## 🔄 向后兼容性
### 保持的兼容性
- ✅ 现有的API调用方式不变
- ✅ 现有的回调函数签名不变
- ✅ 现有的Toast显示接口不变
### 新增的功能
- ✅ 更丰富的错误处理
- ✅ 更好的用户体验
- ✅ 更详细的状态反馈
---
## 📝 注意事项
### 开发环境
- 测试模式下验证码会在控制台显示
- 206状态码表示测试模式属于成功响应
- 建议在开发时关注控制台输出
### 生产环境
- 验证码通过真实邮件发送
- 需要正确配置邮件服务
- 频率限制会严格执行
### 错误处理
- 优先检查HTTP状态码
- 再检查业务错误码
- 提供用户友好的错误提示
---
## 🚀 后续计划
### 短期优化
- [ ] 添加更多的API接口支持
- [ ] 优化Toast显示的动画效果
- [ ] 添加音效反馈
### 长期规划
- [ ] 支持多语言错误消息
- [ ] 添加离线模式支持
- [ ] 实现请求重试机制
---
**更新完成时间**: 2025-12-25
**测试状态**: ✅ 已通过基础测试
**部署建议**: 建议在测试环境充分验证后再部署到生产环境

View File

@@ -1,324 +0,0 @@
# 表单验证规范文档
## 概述
本文档详细说明了登录和注册表单的验证规则、UI交互规范和错误处理机制。
## 验证规则
### 1. 用户名验证
#### 规则
- **必填项**: 是
- **长度**: 1-50字符
- **格式**: 只能包含字母、数字和下划线
- **正则表达式**: `^[a-zA-Z0-9_]+$`
#### 错误提示
- 空值: "用户名不能为空"
- 长度不符: "用户名长度应为1-50字符"
- 格式错误: "用户名只能包含字母、数字和下划线"
### 2. 邮箱验证
#### 规则
- **必填项**: 是(注册时)
- **格式**: 标准邮箱格式
- **正则表达式**: `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
#### 错误提示
- 空值: "邮箱不能为空"
- 格式错误: "请输入有效的邮箱地址"
### 3. 密码验证
#### 规则
- **必填项**: 是
- **长度**: 8-128字符
- **复杂度**: 必须包含字母和数字
- **安全性**: 不允许纯数字或纯字母
#### 错误提示
- 空值: "密码不能为空"
- 长度不足: "密码长度至少8位"
- 长度超限: "密码长度不能超过128位"
- 复杂度不够: "密码必须包含字母和数字"
### 4. 确认密码验证
#### 规则
- **必填项**: 是(注册时)
- **一致性**: 必须与密码字段完全一致
#### 错误提示
- 空值: "确认密码不能为空"
- 不一致: "两次输入的密码不一致"
### 5. 验证码验证
#### 规则
- **必填项**: 是(注册时)
- **长度**: 6位数字
- **格式**: 纯数字
- **有效性**: 必须先获取验证码
#### 错误提示
- 空值: "验证码不能为空"
- 长度错误: "验证码必须是6位数字"
- 格式错误: "验证码必须是6位数字"
- 未获取: "请先获取邮箱验证码"
## UI交互规范
### 1. 必填项标识
所有必填字段都使用水平布局来显示标签、红色星号和右对齐的错误提示:
#### 结构设计
```
VBoxContainer (字段容器)
├── HBoxContainer (标签和错误提示容器)
│ ├── Label (字段名称)
│ ├── Label (红色星号 " *")
│ ├── Control (弹性空间) [size_flags_horizontal = 3]
│ └── Label (红色错误提示) [右对齐,默认隐藏]
└── LineEdit (输入框)
```
#### 视觉效果
- **标签**: 黑色文本,如 "用户名"、"邮箱"、"密码"
- **星号**: 红色文本 `Color(1, 0.2, 0.2, 1)`,内容为 " *"
- **弹性空间**: Control节点`size_flags_horizontal = 3`,占据剩余空间
- **错误提示**: 红色文本12px字体右对齐显示 (`horizontal_alignment = 2`)
- **布局**: 标签和星号左对齐,错误提示右对齐
#### 交互行为
- **正常状态**: 显示 `用户名 * `
- **错误状态**: 显示 `用户名 * 用户名不能为空`
- **输入时**: 错误提示自动隐藏,回到正常状态
#### 优势
- 错误提示右对齐,与输入框右边缘对齐,视觉更整齐
- 利用弹性空间实现左右分布,布局更美观
- 不占用额外的垂直空间
- 避免UI布局被拉长导致溢出
- 保持界面紧凑美观
- 红色星号和错误提示颜色一致,视觉统一
- 错误提示位置固定,不会因为文本长度变化而影响布局
### 2. 实时验证
#### 失焦验证
- 当用户离开输入框时(`focus_exited`)触发验证
- 立即显示相应的错误提示
- 错误提示显示在输入框下方
#### 输入时验证
- 当用户开始输入时(`text_changed`)隐藏错误提示
- 提供即时的视觉反馈
- 避免在用户输入过程中显示错误
### 3. 错误提示样式
#### 视觉设计
- **颜色**: 红色 `Color(1, 0.2, 0.2, 1)`
- **字体大小**: 12px
- **位置**: 输入框正下方
- **显示状态**: 默认隐藏,验证失败时显示
#### 错误信息特点
- 简洁明了,直接指出问题
- 提供解决建议
- 使用友好的语言
### 4. 按钮状态管理
#### 发送验证码按钮
- **正常状态**: "发送验证码"
- **冷却状态**: "重新发送(60)" (倒计时)
- **禁用状态**: 请求进行中时禁用
#### 提交按钮
- **正常状态**: 可点击
- **禁用状态**: 表单验证失败或请求进行中时禁用
- **加载状态**: 显示"正在注册..."等提示
## 验证流程
### 1. 登录表单验证流程
```
用户输入 → 失焦验证 → 显示错误(如有) → 点击登录 → 整体验证 → 提交请求
```
#### 验证步骤
1. 检查用户名是否为空
2. 检查密码是否为空
3. 所有验证通过后提交登录请求
### 2. 注册表单验证流程
```
用户输入 → 失焦验证 → 显示错误(如有) → 获取验证码 → 输入验证码 → 点击注册 → 整体验证 → 邮箱验证 → 用户注册
```
#### 验证步骤
1. 验证用户名格式和长度
2. 验证邮箱格式
3. 验证密码强度
4. 验证确认密码一致性
5. 验证验证码格式和有效性
6. 发送邮箱验证请求
7. 验证成功后发送注册请求
### 3. 验证码获取流程
```
输入邮箱 → 验证邮箱格式 → 检查冷却时间 → 发送验证码 → 开始冷却计时
```
#### 冷却机制
- **冷却时间**: 60秒
- **按钮状态**: 显示倒计时
- **重复发送**: 冷却结束后可重新发送
## 错误处理机制
### 1. 客户端验证
#### 即时验证
- 在用户输入过程中提供即时反馈
- 防止用户提交无效数据
- 提升用户体验
#### 提交前验证
- 在发送请求前进行完整验证
- 确保所有必填项都已正确填写
- 避免无效的网络请求
### 2. 服务器验证
#### 后端验证
- 服务器端进行二次验证
- 处理服务器返回的错误信息
- 显示相应的错误提示
#### 网络错误处理
- 连接失败提示
- 超时处理
- 服务器错误提示
### 3. 用户引导
#### 错误恢复
- 清晰的错误提示
- 提供解决方案
- 引导用户正确操作
#### 成功反馈
- 注册成功提示
- 自动跳转到登录界面
- 自动填充用户名
## 代码实现
### 1. 验证函数
每个字段都有对应的验证函数:
- `validate_username(username: String) -> Dictionary`
- `validate_email(email: String) -> Dictionary`
- `validate_password(password: String) -> Dictionary`
- `validate_confirm_password(password: String, confirm: String) -> Dictionary`
- `validate_verification_code(code: String) -> Dictionary`
### 2. 事件处理
#### 失焦事件
- `_on_register_username_focus_exited()`
- `_on_register_email_focus_exited()`
- `_on_register_password_focus_exited()`
- `_on_register_confirm_focus_exited()`
- `_on_verification_focus_exited()`
#### 输入事件
- `_on_register_username_text_changed(new_text: String)`
- `_on_register_email_text_changed(new_text: String)`
- `_on_register_password_text_changed(new_text: String)`
- `_on_register_confirm_text_changed(new_text: String)`
- `_on_verification_text_changed(new_text: String)`
### 3. 整体验证
- `validate_login_form() -> bool`
- `validate_register_form() -> bool`
## 测试用例
### 1. 用户名测试
| 输入 | 预期结果 | 错误信息 |
|------|----------|----------|
| "" | 失败 | "用户名不能为空" |
| "a" | 成功 | - |
| "test_user123" | 成功 | - |
| "test@user" | 失败 | "用户名只能包含字母、数字和下划线" |
| "a".repeat(51) | 失败 | "用户名长度应为1-50字符" |
### 2. 邮箱测试
| 输入 | 预期结果 | 错误信息 |
|------|----------|----------|
| "" | 失败 | "邮箱不能为空" |
| "test@example.com" | 成功 | - |
| "invalid-email" | 失败 | "请输入有效的邮箱地址" |
| "test@" | 失败 | "请输入有效的邮箱地址" |
### 3. 密码测试
| 输入 | 预期结果 | 错误信息 |
|------|----------|----------|
| "" | 失败 | "密码不能为空" |
| "1234567" | 失败 | "密码长度至少8位" |
| "12345678" | 失败 | "密码必须包含字母和数字" |
| "abcdefgh" | 失败 | "密码必须包含字母和数字" |
| "abc12345" | 成功 | - |
### 4. 验证码测试
| 输入 | 预期结果 | 错误信息 |
|------|----------|----------|
| "" | 失败 | "验证码不能为空" |
| "12345" | 失败 | "验证码必须是6位数字" |
| "1234567" | 失败 | "验证码必须是6位数字" |
| "12345a" | 失败 | "验证码必须是6位数字" |
| "123456" | 成功 | - |
## 最佳实践
### 1. 用户体验
- **即时反馈**: 在用户输入时提供即时的视觉反馈
- **清晰提示**: 错误信息要简洁明了,易于理解
- **引导操作**: 通过UI引导用户完成正确的操作流程
### 2. 性能优化
- **避免过度验证**: 不在每次字符输入时都进行复杂验证
- **合理的验证时机**: 在失焦和提交时进行验证
- **缓存验证结果**: 避免重复验证相同的内容
### 3. 安全考虑
- **客户端+服务端**: 双重验证确保数据安全
- **敏感信息**: 密码等敏感信息不在客户端明文存储
- **防止暴力破解**: 验证码冷却机制防止频繁请求
### 4. 可维护性
- **模块化设计**: 每个验证规则独立成函数
- **统一的错误处理**: 使用统一的错误显示机制
- **可配置的规则**: 验证规则可以根据需求调整
## 更新日志
- **v1.0.0** (2025-12-24): 初始版本,包含完整的表单验证规范

View File

@@ -1,283 +0,0 @@
# 表单验证测试指南
## 测试概述
本文档提供了完整的表单验证功能测试步骤,确保所有验证规则和用户交互都能正常工作。
## 测试环境准备
### 1. 启动后端服务
```bash
# 确保后端服务运行在 https://whaletownend.xinghangee.icu
# 或者本地开发环境: http://localhost:3000
npm start
# 或者你的后端启动命令
```
### 2. 打开Godot项目
- 启动Godot编辑器
- 打开鲸鱼镇项目
- 运行主场景
## 登录表单测试
### 测试用例1: 必填项验证
#### 步骤
1. 点击"注册居民身份"进入登录界面
2. 不输入任何内容,直接点击用户名输入框外的区域
3. 不输入任何内容,直接点击密码输入框外的区域
4. 点击"进入小镇"或"密码登录"按钮
#### 预期结果
- 用户名输入框下方显示红色错误提示:"用户名不能为空"
- 密码输入框下方显示红色错误提示:"密码不能为空"
- 按钮点击无效,不会提交表单
### 测试用例2: 实时反馈
#### 步骤
1. 触发上述错误提示后
2. 在用户名输入框中输入任意字符
3. 在密码输入框中输入任意字符
#### 预期结果
- 开始输入时,对应的错误提示立即消失
- 提供即时的视觉反馈
### 测试用例3: 正常登录
#### 步骤
1. 输入有效的用户名:"testuser"
2. 输入任意密码:"password123"
3. 点击"进入小镇"
#### 预期结果
- 无错误提示显示
- 成功进入游戏主界面
- 显示用户名信息
## 注册表单测试
### 测试用例4: 用户名验证
#### 测试数据
| 输入 | 预期结果 | 错误信息 |
|------|----------|----------|
| (空) | 失败 | "用户名不能为空" |
| "test@user" | 失败 | "用户名只能包含字母、数字和下划线" |
| "a".repeat(51) | 失败 | "用户名长度应为1-50字符" |
| "test_user123" | 成功 | 无错误提示 |
#### 步骤
1. 点击"注册居民身份"
2. 依次输入上述测试数据
3. 每次输入后点击其他输入框(触发失焦验证)
### 测试用例5: 邮箱验证
#### 测试数据
| 输入 | 预期结果 | 错误信息 |
|------|----------|----------|
| (空) | 失败 | "邮箱不能为空" |
| "invalid-email" | 失败 | "请输入有效的邮箱地址" |
| "test@" | 失败 | "请输入有效的邮箱地址" |
| "test@example.com" | 成功 | 无错误提示 |
#### 步骤
1. 在邮箱输入框中依次输入测试数据
2. 每次输入后点击其他输入框
### 测试用例6: 密码验证
#### 测试数据
| 输入 | 预期结果 | 错误信息 |
|------|----------|----------|
| (空) | 失败 | "密码不能为空" |
| "1234567" | 失败 | "密码长度至少8位" |
| "12345678" | 失败 | "密码必须包含字母和数字" |
| "abcdefgh" | 失败 | "密码必须包含字母和数字" |
| "abc12345" | 成功 | 无错误提示 |
#### 步骤
1. 在密码输入框中依次输入测试数据
2. 每次输入后点击其他输入框
### 测试用例7: 确认密码验证
#### 步骤
1. 在密码框输入:"abc12345"
2. 在确认密码框输入:""(空)
3. 点击其他输入框
4. 在确认密码框输入:"different123"
5. 点击其他输入框
6. 在确认密码框输入:"abc12345"
7. 点击其他输入框
#### 预期结果
- 步骤3: 显示"确认密码不能为空"
- 步骤5: 显示"两次输入的密码不一致"
- 步骤7: 无错误提示
### 测试用例8: 验证码功能
#### 步骤
1. 不输入邮箱,直接点击"发送验证码"
2. 输入无效邮箱"invalid",点击"发送验证码"
3. 输入有效邮箱"test@example.com",点击"发送验证码"
4. 立即再次点击"发送验证码"
5. 在验证码输入框输入"12345"5位
6. 在验证码输入框输入"12345a"(包含字母)
7. 在验证码输入框输入"123456"(正确格式)
#### 预期结果
- 步骤1: 邮箱框显示"邮箱不能为空",聚焦到邮箱输入框
- 步骤2: 邮箱框显示"请输入有效的邮箱地址"
- 步骤3: 显示"正在发送验证码...",按钮变为禁用状态
- 步骤4: 显示冷却提示"请等待 XX 秒后再次发送"
- 步骤5: 验证码框显示"验证码必须是6位数字"
- 步骤6: 验证码框显示"验证码必须是6位数字"
- 步骤7: 无错误提示
### 测试用例9: 完整注册流程
#### 步骤
1. 填写所有必填信息:
- 用户名: "testuser"
- 邮箱: "test@example.com"
- 密码: "password123"
- 确认密码: "password123"
2. 点击"发送验证码"
3. 查看控制台获取验证码
4. 输入验证码
5. 点击"注册"按钮
#### 预期结果
- 所有验证通过,无错误提示
- 显示"正在验证邮箱..."
- 显示"邮箱验证成功,正在注册..."
- 显示"注册成功!"
- 自动返回登录界面
- 用户名自动填入登录表单
## 边界情况测试
### 测试用例10: 网络异常
#### 步骤
1. 关闭后端服务
2. 尝试发送验证码
3. 尝试注册
#### 预期结果
- 显示"网络连接失败,请检查服务器是否启动"
- 按钮重新启用
### 测试用例11: 快速操作
#### 步骤
1. 快速连续点击"发送验证码"按钮
2. 快速连续点击"注册"按钮
#### 预期结果
- 按钮在请求期间被禁用
- 防止重复提交
### 测试用例12: 表单切换
#### 步骤
1. 在注册表单中输入信息并触发错误提示
2. 点击"返回登录"
3. 再次点击"注册居民身份"
#### 预期结果
- 切换到登录界面时,注册表单状态保持
- 再次进入注册界面时,表单被清空,错误提示被隐藏
## 性能测试
### 测试用例13: 响应速度
#### 步骤
1. 快速在各个输入框之间切换
2. 快速输入和删除文本
3. 观察错误提示的显示和隐藏速度
#### 预期结果
- 验证响应迅速,无明显延迟
- UI更新流畅无卡顿现象
## 兼容性测试
### 测试用例14: 不同输入法
#### 步骤
1. 使用中文输入法输入用户名
2. 使用英文输入法输入用户名
3. 输入特殊字符
#### 预期结果
- 中文字符被正确验证为无效格式
- 英文字符正常通过验证
- 特殊字符按规则验证
## 测试检查清单
### 功能完整性
- [ ] 所有必填项都有红色星号标识
- [ ] 失焦验证正常工作
- [ ] 实时输入反馈正常
- [ ] 错误提示准确显示
- [ ] 验证码发送和验证功能正常
- [ ] 注册流程完整可用
### 用户体验
- [ ] 错误提示清晰易懂
- [ ] 按钮状态管理正确
- [ ] 表单切换流畅
- [ ] 成功反馈及时
### 错误处理
- [ ] 网络异常处理正确
- [ ] 服务器错误处理正确
- [ ] 边界情况处理正确
### 性能表现
- [ ] 验证响应速度快
- [ ] UI更新流畅
- [ ] 内存使用正常
## 测试报告模板
### 测试环境
- Godot版本:
- 操作系统:
- 后端服务状态:
- 测试时间:
### 测试结果
| 测试用例 | 状态 | 备注 |
|----------|------|------|
| 登录表单验证 | ✅/❌ | |
| 注册表单验证 | ✅/❌ | |
| 验证码功能 | ✅/❌ | |
| 网络异常处理 | ✅/❌ | |
| 完整注册流程 | ✅/❌ | |
### 发现的问题
1. 问题描述
- 重现步骤
- 预期结果
- 实际结果
- 严重程度
### 改进建议
1. 功能改进
2. 用户体验优化
3. 性能优化
---
**测试完成日期**: ___________
**测试人员**: ___________
**测试版本**: v1.0.0

View File

@@ -1,137 +0,0 @@
# AuthScene 文件清理总结
**清理日期**: 2025-12-25
**清理原因**: 修复Parser Error和优化代码结构
---
## 🔧 修复的问题
### 1. **Parser Error修复**
- **问题**: `scripts/scenes/AuthScene.gd` 第1196行有语法错误 "母和数字"
- **解决**: 完全重写了AuthScene.gd文件移除了所有语法错误
- **结果**: 文件现在可以正常解析,无语法错误
### 2. **代码结构优化**
- **重构验证逻辑**: 使用StringUtils工具类统一处理验证
- **简化代码**: 移除重复的验证代码
- **提高可维护性**: 更清晰的方法组织和注释
---
## 🗑️ 删除的文件
### 已删除
1. **`scripts/network/NetworkTest.gd`**
- **原因**: 功能重复已有更完善的ApiTestScript.gd
- **影响**: 无功能已被ApiTestScript.gd替代
### 保留的文件
1. **`tests/auth/auth_ui_test.gd`** - 保留用于UI测试
2. **`tests/auth/enhanced_toast_test.gd`** - 保留用于Toast系统测试
3. **`core/utils/StringUtils.gd`** - 保留,提供通用验证工具
---
## ✅ 优化后的AuthScene.gd结构
### 文件组织
```
AuthScene.gd (约600行结构清晰)
├── 节点引用和变量定义
├── 初始化和信号连接
├── 按钮事件处理
├── 网络响应处理
├── 验证码冷却管理
├── Toast消息系统
├── UI工具方法
├── 表单验证方法
├── 表单验证事件
└── 资源清理
```
### 主要改进
1. **使用StringUtils**: 统一的验证逻辑
2. **清晰的方法分组**: 按功能组织代码
3. **完整的错误处理**: 支持最新API v1.1.1
4. **优化的Toast系统**: 更好的视觉效果和动画
---
## 🧪 测试验证
### 语法检查
```bash
# 所有文件通过语法检查
✅ scripts/scenes/AuthScene.gd - No diagnostics found
✅ core/managers/NetworkManager.gd - No diagnostics found
✅ core/managers/ResponseHandler.gd - No diagnostics found
```
### 功能测试
- ✅ Toast显示系统正常
- ✅ 表单验证逻辑正确
- ✅ 网络请求处理完整
- ✅ 验证码冷却机制有效
---
## 📊 代码质量提升
### 前后对比
| 指标 | 清理前 | 清理后 | 改进 |
|------|--------|--------|------|
| 语法错误 | 1个 | 0个 | ✅ 修复 |
| 代码行数 | ~1400行 | ~600行 | ✅ 精简57% |
| 重复代码 | 多处 | 无 | ✅ 消除 |
| 可读性 | 中等 | 高 | ✅ 提升 |
| 维护性 | 中等 | 高 | ✅ 提升 |
### 代码质量指标
- **圈复杂度**: 降低
- **代码重复率**: 显著减少
- **方法长度**: 更合理
- **注释覆盖**: 完整
---
## 🔄 兼容性保证
### API兼容性
- ✅ 保持所有公共方法签名不变
- ✅ 保持所有信号定义不变
- ✅ 保持节点引用路径不变
### 功能兼容性
- ✅ 登录功能完整
- ✅ 注册功能完整
- ✅ 验证码功能完整
- ✅ Toast显示功能增强
---
## 📝 后续建议
### 短期
1. **测试验证**: 在实际环境中测试所有功能
2. **性能监控**: 观察Toast动画性能
3. **用户反馈**: 收集UI体验反馈
### 长期
1. **单元测试**: 为验证逻辑添加更多单元测试
2. **集成测试**: 完善端到端测试覆盖
3. **代码审查**: 定期进行代码质量审查
---
## 🎯 总结
通过这次清理,我们成功:
1. **修复了语法错误** - AuthScene.gd现在可以正常解析
2. **优化了代码结构** - 更清晰、更易维护
3. **提升了代码质量** - 减少重复,提高可读性
4. **保持了功能完整** - 所有原有功能都得到保留和增强
5. **删除了冗余文件** - 清理了不必要的测试文件
AuthScene现在是一个干净、高效、易维护的认证界面组件完全支持最新的API v1.1.1规范。

Some files were not shown because too many files have changed in this diff Show More