35 changed files with 4219 additions and 865 deletions
@ -0,0 +1,138 @@
@@ -0,0 +1,138 @@
|
||||
# 🚀 GoFaster 快速启动指南 |
||||
|
||||
## 📋 启动方式总览 |
||||
|
||||
### **🎯 多种启动方式** |
||||
|
||||
#### **方式 1: PowerShell 脚本(推荐)** |
||||
```powershell |
||||
# 右键选择"使用 PowerShell 运行" |
||||
.\start.ps1 |
||||
|
||||
# 或者在 PowerShell 中运行 |
||||
.\start.ps1 |
||||
``` |
||||
|
||||
#### **方式 2: 批处理文件** |
||||
```bash |
||||
# 双击运行(如果仍有编码问题,使用方式1) |
||||
start-dev.bat |
||||
|
||||
# 或者使用英文版本 |
||||
start-simple.bat |
||||
``` |
||||
|
||||
#### **方式 3: 直接启动** |
||||
```powershell |
||||
# 全栈启动(标准模式) |
||||
.\dev-full.ps1 |
||||
|
||||
# 全栈启动(调试模式) |
||||
.\dev-full.ps1 -Debug |
||||
|
||||
# 全栈启动(监听模式) |
||||
.\dev-full.ps1 -Watch |
||||
``` |
||||
|
||||
### **⚡ 直接启动** |
||||
```powershell |
||||
# 全栈启动(标准模式) |
||||
.\dev-full.ps1 |
||||
|
||||
# 全栈启动(调试模式) |
||||
.\dev-full.ps1 -Debug |
||||
|
||||
# 全栈启动(监听模式) |
||||
.\dev-full.ps1 -Watch |
||||
``` |
||||
|
||||
### **🔧 灵活启动** |
||||
```powershell |
||||
# 仅启动后端 |
||||
.\dev-full.ps1 -BackendOnly |
||||
|
||||
# 仅启动前端 |
||||
.\dev-full.ps1 -FrontendOnly |
||||
``` |
||||
|
||||
## 🚀 推荐启动流程 |
||||
|
||||
### **1. 首次使用** |
||||
```bash |
||||
# 双击运行 |
||||
start-dev.bat |
||||
|
||||
# 选择选项 1: 全栈启动 |
||||
``` |
||||
|
||||
### **2. 日常开发** |
||||
```bash |
||||
# 选择选项 3: 监听模式(自动重载) |
||||
start-dev.bat |
||||
``` |
||||
|
||||
### **3. 调试问题** |
||||
```bash |
||||
# 选择选项 2: 调试模式(详细日志) |
||||
start-dev.bat |
||||
``` |
||||
|
||||
## 📁 文件说明 |
||||
|
||||
| 文件 | 说明 | 用途 | |
||||
|------|------|------| |
||||
| `start-dev.bat` | 快速启动菜单 | 一键选择启动模式 | |
||||
| `dev-full.ps1` | 增强版全栈脚本 | 智能启动前后端 | |
||||
| `app/dev-enhanced.ps1` | 前端增强脚本 | 仅启动前端 | |
||||
| `backend/dev.ps1` | 后端启动脚本 | 仅启动后端 | |
||||
|
||||
## 🔧 功能特性 |
||||
|
||||
### **✅ 已解决的问题** |
||||
- 🎯 中文乱码问题 |
||||
- 📊 日志信息少的问题 |
||||
- 🔄 热重载不工作的问题 |
||||
- 📦 依赖管理问题 |
||||
|
||||
### **🚀 新增功能** |
||||
- 🧠 智能依赖检查 |
||||
- 📱 进程管理和监控 |
||||
- 🎨 友好的用户界面 |
||||
- ⚡ 多种启动模式 |
||||
|
||||
## 💡 使用技巧 |
||||
|
||||
### **开发阶段** |
||||
1. **开始开发**:使用监听模式,自动重载 |
||||
2. **调试问题**:使用调试模式,查看详细日志 |
||||
3. **测试功能**:使用标准模式,稳定运行 |
||||
|
||||
### **维护阶段** |
||||
1. **仅修改前端**:使用 `-FrontendOnly` 模式 |
||||
2. **仅修改后端**:使用 `-BackendOnly` 模式 |
||||
3. **全栈开发**:使用标准模式 |
||||
|
||||
## 🚨 常见问题 |
||||
|
||||
### **Q: 启动失败怎么办?** |
||||
A: 使用调试模式 `.\dev-full.ps1 -Debug` 查看详细错误信息 |
||||
|
||||
### **Q: 中文显示乱码?** |
||||
A: 脚本已自动设置 UTF-8 编码,确保使用 PowerShell 或 CMD |
||||
|
||||
### **Q: 端口被占用?** |
||||
A: 脚本会自动检查端口状态,如有冲突会提示解决方案 |
||||
|
||||
### **Q: 依赖安装失败?** |
||||
A: 脚本会自动检查和安装依赖,如失败会提供手动安装指导 |
||||
|
||||
## 🎯 下一步 |
||||
|
||||
1. **立即体验**:双击 `start-dev.bat` |
||||
2. **查看文档**:阅读 `FULL_STACK_ENHANCED.md` |
||||
3. **自定义配置**:修改 `app/vue.config.js` |
||||
4. **反馈问题**:记录遇到的问题和解决方案 |
||||
|
||||
--- |
||||
|
||||
**🎉 现在你可以享受无乱码、详细日志、智能管理的开发环境了!** |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
# npm 配置文件 |
||||
# 设置编码 |
||||
registry=https://registry.npmjs.org/ |
||||
loglevel=info |
||||
color=true |
||||
unicode=true |
||||
|
||||
# 设置环境变量 |
||||
node-options=--max-old-space-size=4096 |
||||
|
||||
# 设置日志格式 |
||||
progress=true |
||||
timing=true |
||||
|
||||
# 设置缓存 |
||||
cache-min=3600 |
||||
prefer-offline=true |
||||
|
||||
# 设置安全选项 |
||||
audit=false |
||||
fund=false |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
# 前端启动脚本 - 解决中文编码问题 |
||||
param( |
||||
[switch]$Debug, |
||||
[switch]$Watch |
||||
) |
||||
|
||||
# 强制设置控制台编码 |
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
||||
[Console]::InputEncoding = [System.Text.Encoding]::UTF8 |
||||
$OutputEncoding = [System.Text.Encoding]::UTF8 |
||||
|
||||
# 设置环境变量 |
||||
$env:VUE_CLI_BABEL_TRANSPILE_MODULES = "false" |
||||
$env:VUE_CLI_MODERN_BUILD = "false" |
||||
$env:VUE_CLI_LOG_LEVEL = "info" |
||||
$env:VUE_CLI_DEBUG = "true" |
||||
$env:LANG = "zh_CN.UTF-8" |
||||
$env:LC_ALL = "zh_CN.UTF-8" |
||||
$env:NODE_OPTIONS = "--max-old-space-size=4096" |
||||
$env:CHROME_BIN = "C:\Program Files\Google\Chrome\Application\chrome.exe" |
||||
|
||||
# Windows 特定编码设置 |
||||
$env:PYTHONIOENCODING = "utf-8" |
||||
$env:PYTHONLEGACYWINDOWSSTDIO = "utf-8" |
||||
|
||||
Write-Host "Starting Frontend Development Environment (UTF-8 Optimized)..." -ForegroundColor Cyan |
||||
Write-Host "Encoding: UTF-8" -ForegroundColor Green |
||||
Write-Host "Log Level: INFO" -ForegroundColor Green |
||||
Write-Host "Hot Reload: Enabled" -ForegroundColor Green |
||||
Write-Host "" |
||||
|
||||
# Select startup mode |
||||
$script = if ($Debug) { "npm run dev:debug" } elseif ($Watch) { "npm run dev:watch" } else { "npm run dev" } |
||||
|
||||
Write-Host "Startup Command: $script" -ForegroundColor Yellow |
||||
Write-Host "" |
||||
|
||||
# Start frontend |
||||
try { |
||||
Invoke-Expression $script |
||||
} catch { |
||||
Write-Host "Startup failed: $($_.Exception.Message)" -ForegroundColor Red |
||||
Write-Host "Trying fallback startup method..." -ForegroundColor Yellow |
||||
|
||||
# Fallback startup method |
||||
if ($Debug) { |
||||
npm run dev:debug |
||||
} elseif ($Watch) { |
||||
npm run dev:watch |
||||
} else { |
||||
npm run dev |
||||
} |
||||
} |
||||
|
||||
Write-Host "" |
||||
Write-Host "Press any key to exit..." |
||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,99 @@
@@ -0,0 +1,99 @@
|
||||
/** |
||||
* IP地址获取工具 |
||||
* 使用Electron API获取本地IP地址 |
||||
*/ |
||||
|
||||
/** |
||||
* 获取客户端IP地址 |
||||
* @returns {Promise<string>} IP地址字符串 |
||||
*/ |
||||
export async function getClientIP() { |
||||
try { |
||||
// 使用 Electron API 获取本地IP
|
||||
if (window.electronAPI && window.electronAPI.getLocalIP) { |
||||
try { |
||||
const result = await window.electronAPI.getLocalIP() |
||||
if (result.success) { |
||||
console.log('通过Electron API获取到本地IP:', result.ip, '接口:', result.interface) |
||||
return result.ip |
||||
} else { |
||||
console.warn('Electron API获取本地IP失败:', result.message) |
||||
// 如果API调用失败,使用备用IP
|
||||
if (result.fallback) { |
||||
console.log('使用备用IP:', result.fallback) |
||||
return result.fallback |
||||
} |
||||
} |
||||
} catch (error) { |
||||
console.warn('调用Electron API获取本地IP失败:', error.message) |
||||
} |
||||
} else { |
||||
console.warn('Electron API不可用,无法获取本地IP') |
||||
} |
||||
|
||||
// 如果所有方法都失败,使用默认值
|
||||
console.log('使用默认IP: 127.0.0.1') |
||||
return '127.0.0.1' |
||||
} catch (error) { |
||||
console.error('获取客户端IP失败:', error) |
||||
return '127.0.0.1' |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取本地网络接口信息 |
||||
* @returns {Promise<Object|null>} 网络接口信息或null |
||||
*/ |
||||
export async function getLocalNetworkInfo() { |
||||
try { |
||||
if (window.electronAPI && window.electronAPI.getLocalIP) { |
||||
const result = await window.electronAPI.getLocalIP() |
||||
if (result.success) { |
||||
return { |
||||
ip: result.ip, |
||||
interface: result.interface, |
||||
netmask: result.netmask, |
||||
type: 'local' |
||||
} |
||||
} |
||||
} |
||||
return null |
||||
} catch (error) { |
||||
console.error('获取本地网络信息失败:', error) |
||||
return null |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 检查是否为本地IP地址 |
||||
* @param {string} ip IP地址字符串 |
||||
* @returns {boolean} 是否为本地IP |
||||
*/ |
||||
export function isLocalIP(ip) { |
||||
if (!ip) return false |
||||
|
||||
// 检查是否为本地回环地址
|
||||
if (ip === '127.0.0.1' || ip === 'localhost') return true |
||||
|
||||
// 检查是否为私有IP地址范围
|
||||
const privateRanges = [ |
||||
/^10\./, // 10.0.0.0 - 10.255.255.255
|
||||
/^172\.(1[6-9]|2[0-9]|3[0-1])\./, // 172.16.0.0 - 172.31.255.255
|
||||
/^192\.168\./ // 192.168.0.0 - 192.168.255.255
|
||||
] |
||||
|
||||
return privateRanges.some(range => range.test(ip)) |
||||
} |
||||
|
||||
/** |
||||
* 获取IP地址类型描述 |
||||
* @param {string} ip IP地址字符串 |
||||
* @returns {string} IP地址类型描述 |
||||
*/ |
||||
export function getIPTypeDescription(ip) { |
||||
if (!ip) return '未知' |
||||
|
||||
if (ip === '127.0.0.1') return '本地回环' |
||||
if (isLocalIP(ip)) return '本地网络' |
||||
return '公网地址' |
||||
} |
Binary file not shown.
Binary file not shown.
@ -1,28 +1,157 @@
@@ -1,28 +1,157 @@
|
||||
Write-Host "🚀 Starting GoFaster Full Stack Development Environment..." -ForegroundColor Cyan |
||||
# GoFaster Full Stack Development Environment |
||||
param( |
||||
[switch]$Debug, |
||||
[switch]$Watch, |
||||
[switch]$BackendOnly, |
||||
[switch]$FrontendOnly |
||||
) |
||||
|
||||
# Set console encoding |
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
||||
$OutputEncoding = [System.Text.Encoding]::UTF8 |
||||
|
||||
# Set environment variables |
||||
$env:VUE_CLI_BABEL_TRANSPILE_MODULES = "false" |
||||
$env:VUE_CLI_MODERN_BUILD = "false" |
||||
$env:VUE_CLI_LOG_LEVEL = "info" |
||||
$env:VUE_CLI_DEBUG = "true" |
||||
$env:LANG = "zh_CN.UTF-8" |
||||
$env:LC_ALL = "zh_CN.UTF-8" |
||||
$env:NODE_OPTIONS = "--max-old-space-size=4096" |
||||
|
||||
# Display startup information |
||||
Write-Host "Starting GoFaster Full Stack Development Environment..." -ForegroundColor Cyan |
||||
Write-Host "Encoding: UTF-8" -ForegroundColor Green |
||||
Write-Host "Log Level: INFO" -ForegroundColor Green |
||||
Write-Host "Hot Reload: Enabled" -ForegroundColor Green |
||||
Write-Host "" |
||||
Write-Host "Frontend: Electron + Vue.js with Hot Reload" -ForegroundColor Green |
||||
Write-Host "Backend: Go + Gin with Hot Reload" -ForegroundColor Green |
||||
Write-Host "Frontend: Electron + Vue.js with Enhanced Hot Reload" -ForegroundColor Green |
||||
Write-Host "Backend: Go + Gin with Air Hot Reload" -ForegroundColor Green |
||||
Write-Host "" |
||||
Write-Host "Press Ctrl+C to stop all services" -ForegroundColor Yellow |
||||
|
||||
# Check run mode |
||||
if ($Debug) { |
||||
Write-Host "Debug mode starting..." -ForegroundColor Magenta |
||||
$env:DEBUG = "*" |
||||
} elseif ($Watch) { |
||||
Write-Host "Watch mode starting..." -ForegroundColor Blue |
||||
} else { |
||||
Write-Host "Standard mode starting..." -ForegroundColor Green |
||||
} |
||||
|
||||
Write-Host "" |
||||
|
||||
# 启动后端热加载(后台运行) |
||||
Write-Host "Starting Backend with Hot Reload..." -ForegroundColor Green |
||||
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd backend; air" -WindowStyle Normal |
||||
# Check dependencies |
||||
Write-Host "Checking frontend dependencies..." -ForegroundColor Yellow |
||||
if (-not (Test-Path "app/node_modules")) { |
||||
Write-Host "Frontend dependencies not installed, installing..." -ForegroundColor Yellow |
||||
Set-Location "app" |
||||
npm install |
||||
if ($LASTEXITCODE -ne 0) { |
||||
Write-Host "Frontend dependency installation failed" -ForegroundColor Red |
||||
exit 1 |
||||
} |
||||
Set-Location ".." |
||||
} |
||||
|
||||
# 等待2秒让后端启动 |
||||
Start-Sleep -Seconds 2 |
||||
# Install cross-env if not exists |
||||
$crossEnvInstalled = npm list cross-env 2>$null -Path "app" |
||||
if (-not $crossEnvInstalled) { |
||||
Write-Host "Installing cross-env..." -ForegroundColor Yellow |
||||
Set-Location "app" |
||||
npm install --save-dev cross-env |
||||
Set-Location ".." |
||||
} |
||||
|
||||
# 启动前端热加载(后台运行) |
||||
Write-Host "Starting Frontend with Hot Reload..." -ForegroundColor Green |
||||
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd app; npm run dev" -WindowStyle Normal |
||||
Write-Host "Frontend dependency check completed" -ForegroundColor Green |
||||
Write-Host "" |
||||
|
||||
# Check backend dependencies |
||||
Write-Host "Checking backend dependencies..." -ForegroundColor Yellow |
||||
if (-not (Test-Path "backend/go.mod")) { |
||||
Write-Host "Backend Go module not found" -ForegroundColor Red |
||||
exit 1 |
||||
} |
||||
|
||||
# Check if air is installed |
||||
try { |
||||
$airVersion = air -v 2>$null |
||||
if (-not $airVersion) { |
||||
Write-Host "Air not installed, installing..." -ForegroundColor Yellow |
||||
go install github.com/air-verse/air@latest |
||||
} |
||||
} catch { |
||||
Write-Host "Air not installed, installing..." -ForegroundColor Yellow |
||||
go install github.com/air-verse/air@latest |
||||
} |
||||
|
||||
Write-Host "Backend dependency check completed" -ForegroundColor Green |
||||
Write-Host "" |
||||
Write-Host "✅ Both services started successfully!" -ForegroundColor Green |
||||
Write-Host "Frontend: http://localhost:3000 (Electron app)" -ForegroundColor Cyan |
||||
Write-Host "Backend: http://localhost:8080" -ForegroundColor Cyan |
||||
Write-Host "Swagger: http://localhost:8080/swagger/index.html" -ForegroundColor Cyan |
||||
|
||||
# Select startup mode |
||||
$frontendScript = if ($Debug) { "npm run dev:debug" } elseif ($Watch) { "npm run dev:watch" } else { "npm run dev" } |
||||
$backendScript = "air" |
||||
|
||||
# Start services |
||||
if (-not $FrontendOnly) { |
||||
Write-Host "Starting backend hot reload..." -ForegroundColor Green |
||||
$backendProcess = Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd backend; $backendScript" -WindowStyle Normal -PassThru |
||||
Write-Host "Backend started (PID: $($backendProcess.Id))" -ForegroundColor Green |
||||
|
||||
# Wait for backend to start |
||||
Write-Host "Waiting for backend to start..." -ForegroundColor Yellow |
||||
Start-Sleep -Seconds 3 |
||||
|
||||
# Check if backend started successfully |
||||
try { |
||||
$response = Invoke-WebRequest -Uri "http://localhost:8080/health" -Method GET -TimeoutSec 5 -ErrorAction Stop |
||||
if ($response.StatusCode -eq 200) { |
||||
Write-Host "Backend started successfully" -ForegroundColor Green |
||||
} |
||||
} catch { |
||||
Write-Host "Backend might still be starting, continuing with frontend..." -ForegroundColor Yellow |
||||
} |
||||
} |
||||
|
||||
if (-not $BackendOnly) { |
||||
Write-Host "Starting frontend hot reload..." -ForegroundColor Green |
||||
$frontendProcess = Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd app; $frontendScript" -WindowStyle Normal -PassThru |
||||
Write-Host "Frontend started (PID: $($frontendProcess.Id))" -ForegroundColor Green |
||||
} |
||||
|
||||
Write-Host "" |
||||
Write-Host "💡 Code changes will automatically trigger rebuilds and reloads!" -ForegroundColor Yellow |
||||
Write-Host "Press any key to exit this launcher..." |
||||
Write-Host "Service startup completed!" -ForegroundColor Green |
||||
|
||||
if (-not $BackendOnly) { |
||||
Write-Host "Backend: http://localhost:8080" -ForegroundColor Cyan |
||||
Write-Host "Swagger: http://localhost:8080/swagger/index.html" -ForegroundColor Cyan |
||||
} |
||||
|
||||
if (-not $FrontendOnly) { |
||||
Write-Host "Frontend: Electron app (auto-reload)" -ForegroundColor Cyan |
||||
} |
||||
|
||||
Write-Host "" |
||||
Write-Host "Usage:" -ForegroundColor Yellow |
||||
Write-Host " - Use -Debug parameter to enable detailed debug info" -ForegroundColor White |
||||
Write-Host " - Use -Watch parameter to enable file watching" -ForegroundColor White |
||||
Write-Host " - Use -BackendOnly to start only backend" -ForegroundColor White |
||||
Write-Host " - Use -FrontendOnly to start only frontend" -ForegroundColor White |
||||
Write-Host " - Press Ctrl+C to stop services" -ForegroundColor White |
||||
Write-Host "" |
||||
|
||||
# Display process information |
||||
if (-not $BackendOnly -and -not $FrontendOnly) { |
||||
Write-Host "Process Information:" -ForegroundColor Yellow |
||||
Write-Host " Backend PID: $($backendProcess.Id)" -ForegroundColor White |
||||
Write-Host " Frontend PID: $($frontendProcess.Id)" -ForegroundColor White |
||||
Write-Host "" |
||||
Write-Host "Management Commands:" -ForegroundColor Yellow |
||||
Write-Host " Stop Backend: Stop-Process -Id $($backendProcess.Id)" -ForegroundColor White |
||||
Write-Host " Stop Frontend: Stop-Process -Id $($frontendProcess.Id)" -ForegroundColor White |
||||
Write-Host " Stop All: Get-Process | Where-Object {$_.ProcessName -eq 'powershell'} | Stop-Process" -ForegroundColor White |
||||
} |
||||
|
||||
Write-Host "Code changes will automatically trigger rebuilds and reloads!" -ForegroundColor Yellow |
||||
Write-Host "Press any key to exit..." |
||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") |
||||
|
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
@echo off |
||||
chcp 65001 >nul |
||||
setlocal enabledelayedexpansion |
||||
|
||||
echo ======================================== |
||||
echo GoFaster 开发环境快速启动 |
||||
echo ======================================== |
||||
echo. |
||||
|
||||
REM 检查 PowerShell 执行策略 |
||||
powershell -Command "Get-ExecutionPolicy" >nul 2>&1 |
||||
if errorlevel 1 ( |
||||
echo [INFO] 正在设置 PowerShell 执行策略... |
||||
powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force" |
||||
) |
||||
|
||||
echo. |
||||
echo 启动选项: |
||||
echo 1. 全栈启动 (前后端) |
||||
echo 2. 全栈启动 (调试模式) |
||||
echo 3. 全栈启动 (监听模式) |
||||
echo 4. 仅启动后端 |
||||
echo 5. 仅启动前端 |
||||
echo 6. 退出 |
||||
echo. |
||||
|
||||
set /p choice="请选择 (1-6): " |
||||
|
||||
if "%choice%"=="1" ( |
||||
echo [INFO] 启动全栈开发环境... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 |
||||
if errorlevel 1 ( |
||||
echo [ERROR] 启动失败,请检查错误信息 |
||||
pause |
||||
) |
||||
) else if "%choice%"=="2" ( |
||||
echo [INFO] 启动全栈开发环境 (调试模式)... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 -Debug |
||||
if errorlevel 1 ( |
||||
echo [ERROR] 启动失败,请检查错误信息 |
||||
pause |
||||
) |
||||
) else if "%choice%"=="3" ( |
||||
echo [INFO] 启动全栈开发环境 (监听模式)... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 -Watch |
||||
if errorlevel 1 ( |
||||
echo [ERROR] 启动失败,请检查错误信息 |
||||
pause |
||||
) |
||||
) else if "%choice%"=="4" ( |
||||
echo [INFO] 仅启动后端... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 -BackendOnly |
||||
if errorlevel 1 ( |
||||
echo [ERROR] 启动失败,请检查错误信息 |
||||
pause |
||||
) |
||||
) else if "%choice%"=="5" ( |
||||
echo [INFO] 仅启动前端... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 -FrontendOnly |
||||
if errorlevel 1 ( |
||||
echo [ERROR] 启动失败,请检查错误信息 |
||||
pause |
||||
) |
||||
) else if "%choice%"=="6" ( |
||||
echo [INFO] 再见! |
||||
pause |
||||
exit /b 0 |
||||
) else ( |
||||
echo [ERROR] 无效选择,请重新运行脚本 |
||||
pause |
||||
exit /b 1 |
||||
) |
||||
|
||||
echo. |
||||
echo 按任意键退出... |
||||
pause >nul |
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
# GoFaster 开发环境启动脚本 |
||||
param( |
||||
[switch]$Help |
||||
) |
||||
|
||||
# 设置控制台编码 |
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
||||
$OutputEncoding = [System.Text.Encoding]::UTF8 |
||||
|
||||
# 显示帮助信息 |
||||
if ($Help) { |
||||
Write-Host "使用方法:" -ForegroundColor Cyan |
||||
Write-Host " .\start-dev.ps1 # 显示菜单" -ForegroundColor White |
||||
Write-Host " .\start-dev.ps1 -Help # 显示此帮助" -ForegroundColor White |
||||
Write-Host " .\dev-full.ps1 # 直接启动全栈" -ForegroundColor White |
||||
Write-Host " .\dev-full.ps1 -Debug # 调试模式启动" -ForegroundColor White |
||||
Write-Host " .\dev-full.ps1 -Watch # 监听模式启动" -ForegroundColor White |
||||
exit 0 |
||||
} |
||||
|
||||
# 显示启动菜单 |
||||
function Show-Menu { |
||||
Clear-Host |
||||
Write-Host "========================================" -ForegroundColor Cyan |
||||
Write-Host " GoFaster 开发环境启动菜单" -ForegroundColor Cyan |
||||
Write-Host "========================================" -ForegroundColor Cyan |
||||
Write-Host "" |
||||
Write-Host "启动选项:" -ForegroundColor Yellow |
||||
Write-Host " 1. 全栈启动 (前后端)" -ForegroundColor White |
||||
Write-Host " 2. 全栈启动 (调试模式)" -ForegroundColor White |
||||
Write-Host " 3. 全栈启动 (监听模式)" -ForegroundColor White |
||||
Write-Host " 4. 仅启动后端" -ForegroundColor White |
||||
Write-Host " 5. 仅启动前端" -ForegroundColor White |
||||
Write-Host " 6. 退出" -ForegroundColor White |
||||
Write-Host "" |
||||
} |
||||
|
||||
# 主菜单循环 |
||||
do { |
||||
Show-Menu |
||||
$choice = Read-Host "请选择 (1-6)" |
||||
|
||||
switch ($choice) { |
||||
"1" { |
||||
Write-Host "[INFO] 启动全栈开发环境..." -ForegroundColor Green |
||||
try { |
||||
& ".\dev-full.ps1" |
||||
} catch { |
||||
Write-Host "[ERROR] 启动失败: $($_.Exception.Message)" -ForegroundColor Red |
||||
Read-Host "按回车键继续..." |
||||
} |
||||
} |
||||
"2" { |
||||
Write-Host "[INFO] 启动全栈开发环境 (调试模式)..." -ForegroundColor Green |
||||
try { |
||||
& ".\dev-full.ps1" -Debug |
||||
} catch { |
||||
Write-Host "[ERROR] 启动失败: $($_.Exception.Message)" -ForegroundColor Red |
||||
Read-Host "按回车键继续..." |
||||
} |
||||
} |
||||
"3" { |
||||
Write-Host "[INFO] 启动全栈开发环境 (监听模式)..." -ForegroundColor Green |
||||
try { |
||||
& ".\dev-full.ps1" -Watch |
||||
} catch { |
||||
Write-Host "[ERROR] 启动失败: $($_.Exception.Message)" -ForegroundColor Red |
||||
Read-Host "按回车键继续..." |
||||
} |
||||
} |
||||
"4" { |
||||
Write-Host "[INFO] 仅启动后端..." -ForegroundColor Green |
||||
try { |
||||
& ".\dev-full.ps1" -BackendOnly |
||||
} catch { |
||||
Write-Host "[ERROR] 启动失败: $($_.Exception.Message)" -ForegroundColor Red |
||||
Read-Host "按回车键继续..." |
||||
} |
||||
} |
||||
"5" { |
||||
Write-Host "[INFO] 仅启动前端..." -ForegroundColor Green |
||||
try { |
||||
& ".\dev-full.ps1" -FrontendOnly |
||||
} catch { |
||||
Write-Host "[ERROR] 启动失败: $($_.Exception.Message)" -ForegroundColor Red |
||||
Read-Host "按回车键继续..." |
||||
} |
||||
} |
||||
"6" { |
||||
Write-Host "[INFO] 再见!" -ForegroundColor Green |
||||
exit 0 |
||||
} |
||||
default { |
||||
Write-Host "[ERROR] 无效选择,请重新选择" -ForegroundColor Red |
||||
Start-Sleep -Seconds 2 |
||||
} |
||||
} |
||||
|
||||
if ($choice -match "^[1-5]$") { |
||||
$continue = Read-Host "是否返回主菜单? (y/n)" |
||||
if ($continue -eq "n" -or $continue -eq "N") { |
||||
break |
||||
} |
||||
} |
||||
} while ($true) |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
@echo off |
||||
title GoFaster Development Environment |
||||
|
||||
echo ======================================== |
||||
echo GoFaster Development Environment |
||||
echo ======================================== |
||||
echo. |
||||
|
||||
echo Starting options: |
||||
echo 1. Full Stack (Frontend + Backend) |
||||
echo 2. Full Stack (Debug Mode) |
||||
echo 3. Full Stack (Watch Mode) |
||||
echo 4. Backend Only |
||||
echo 5. Frontend Only |
||||
echo 6. Exit |
||||
echo. |
||||
|
||||
set /p choice="Please select (1-6): " |
||||
|
||||
if "%choice%"=="1" ( |
||||
echo [INFO] Starting full stack development environment... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 |
||||
) else if "%choice%"=="2" ( |
||||
echo [INFO] Starting full stack development environment (Debug Mode)... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 -Debug |
||||
) else if "%choice%"=="3" ( |
||||
echo [INFO] Starting full stack development environment (Watch Mode)... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 -Watch |
||||
) else if "%choice%"=="4" ( |
||||
echo [INFO] Starting backend only... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 -BackendOnly |
||||
) else if "%choice%"=="5" ( |
||||
echo [INFO] Starting frontend only... |
||||
powershell -ExecutionPolicy Bypass -File dev-full.ps1 -FrontendOnly |
||||
) else if "%choice%"=="6" ( |
||||
echo [INFO] Goodbye! |
||||
pause |
||||
exit /b 0 |
||||
) else ( |
||||
echo [ERROR] Invalid choice, please run the script again |
||||
pause |
||||
exit /b 1 |
||||
) |
||||
|
||||
echo. |
||||
echo Press any key to exit... |
||||
pause >nul |
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
# GoFaster 开发环境启动脚本 |
||||
Write-Host "========================================" -ForegroundColor Cyan |
||||
Write-Host " GoFaster Development Environment" -ForegroundColor Cyan |
||||
Write-Host "========================================" -ForegroundColor Cyan |
||||
Write-Host "" |
||||
|
||||
Write-Host "选择启动模式:" -ForegroundColor Yellow |
||||
Write-Host "1. 全栈启动 (前后端)" -ForegroundColor White |
||||
Write-Host "2. 全栈启动 (调试模式)" -ForegroundColor White |
||||
Write-Host "3. 全栈启动 (监听模式)" -ForegroundColor White |
||||
Write-Host "4. 仅启动后端" -ForegroundColor White |
||||
Write-Host "5. 仅启动前端" -ForegroundColor White |
||||
Write-Host "" |
||||
|
||||
$choice = Read-Host "请输入选择 (1-5)" |
||||
|
||||
switch ($choice) { |
||||
"1" { |
||||
Write-Host "启动全栈开发环境..." -ForegroundColor Green |
||||
& ".\dev-full.ps1" |
||||
} |
||||
"2" { |
||||
Write-Host "启动全栈开发环境 (调试模式)..." -ForegroundColor Green |
||||
& ".\dev-full.ps1" -Debug |
||||
} |
||||
"3" { |
||||
Write-Host "启动全栈开发环境 (监听模式)..." -ForegroundColor Green |
||||
& ".\dev-full.ps1" -Watch |
||||
} |
||||
"4" { |
||||
Write-Host "仅启动后端..." -ForegroundColor Green |
||||
& ".\dev-full.ps1" -BackendOnly |
||||
} |
||||
"5" { |
||||
Write-Host "仅启动前端..." -ForegroundColor Green |
||||
& ".\dev-full.ps1" -FrontendOnly |
||||
} |
||||
default { |
||||
Write-Host "无效选择!" -ForegroundColor Red |
||||
} |
||||
} |
||||
|
||||
Write-Host "" |
||||
Write-Host "按任意键退出..." -ForegroundColor Gray |
||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") |
@ -0,0 +1,122 @@
@@ -0,0 +1,122 @@
|
||||
# 登录功能完整测试脚本 |
||||
|
||||
## 🚨 重要提醒 |
||||
**在测试之前,请确保:** |
||||
1. 后端已经重新编译并启动 |
||||
2. 前端已经重新编译并启动 |
||||
3. 所有修改都已保存 |
||||
|
||||
## 🔧 问题诊断 |
||||
|
||||
### 检查 1: 后端验证码是否增强 |
||||
1. 访问 `http://localhost:8080/api/auth/captcha` |
||||
2. **预期结果**: 返回的 `captcha_image` 应该包含复杂的 SVG 内容 |
||||
3. **如果还是简单文本**: 说明后端没有重新编译 |
||||
|
||||
### 检查 2: 前端模态窗是否修复 |
||||
1. 打开前端应用 |
||||
2. 点击"登录"按钮 |
||||
3. 尝试点击登录弹窗外部区域 |
||||
4. **预期结果**: 弹窗不应该关闭 |
||||
|
||||
### 检查 3: 登录状态切换是否正常 |
||||
1. 完成登录流程 |
||||
2. 检查欢迎页面是否显示用户信息 |
||||
3. **预期结果**: 应该显示"欢迎回来,sysadmin!" |
||||
|
||||
## 🧪 完整测试流程 |
||||
|
||||
### 步骤 1: 重启服务 |
||||
```bash |
||||
# 停止当前服务 |
||||
# 重新启动后端 |
||||
cd backend |
||||
air |
||||
|
||||
# 重新启动前端 |
||||
cd app |
||||
npm run dev |
||||
``` |
||||
|
||||
### 步骤 2: 测试验证码增强 |
||||
1. 打开浏览器开发者工具 |
||||
2. 访问 `http://localhost:8080/api/auth/captcha` |
||||
3. 检查响应中的 `captcha_image` 字段 |
||||
4. **应该看到**: 复杂的 SVG 内容,包含干扰元素 |
||||
|
||||
### 步骤 3: 测试前端模态窗 |
||||
1. 打开前端应用 |
||||
2. 点击右上角"登录"按钮 |
||||
3. 尝试点击弹窗外部区域 |
||||
4. **预期**: 弹窗保持打开状态 |
||||
5. 点击弹窗右上角 × 按钮 |
||||
6. **预期**: 弹窗正常关闭 |
||||
|
||||
### 步骤 4: 测试登录流程 |
||||
1. 在登录弹窗中输入: |
||||
- 用户名: `sysadmin` |
||||
- 密码: `sysadmin@123` |
||||
- 验证码: 从图片中识别 |
||||
2. 点击"登录"按钮 |
||||
3. **预期**: 登录成功,弹窗关闭 |
||||
|
||||
### 步骤 5: 测试状态切换 |
||||
1. 登录成功后,检查欢迎页面 |
||||
2. **预期看到**: |
||||
- "欢迎回来,sysadmin!" |
||||
- 功能卡片(速度测试、历史记录等) |
||||
- 待办事项列表 |
||||
- 最近活动 |
||||
3. **不应该看到**: "登录"按钮 |
||||
|
||||
### 步骤 6: 测试登出功能 |
||||
1. 点击右上角用户头像 |
||||
2. 选择"退出登录" |
||||
3. **预期**: 页面回到未登录状态 |
||||
|
||||
## 🐛 常见问题排查 |
||||
|
||||
### 问题 1: 验证码还是简单文本 |
||||
**原因**: 后端没有重新编译 |
||||
**解决**: |
||||
```bash |
||||
cd backend |
||||
go build -o main.exe . |
||||
./main.exe |
||||
``` |
||||
|
||||
### 问题 2: 模态窗还是可以点击外部关闭 |
||||
**原因**: 前端没有重新编译 |
||||
**解决**: |
||||
```bash |
||||
cd app |
||||
npm run dev |
||||
``` |
||||
|
||||
### 问题 3: 登录后状态没有切换 |
||||
**原因**: Vue 响应式问题 |
||||
**解决**: 检查浏览器控制台是否有错误 |
||||
|
||||
## 📊 测试结果记录 |
||||
|
||||
| 测试项目 | 预期结果 | 实际结果 | 状态 | |
||||
|---------|---------|---------|------| |
||||
| 验证码增强 | 复杂SVG | | | |
||||
| 模态窗修复 | 外部点击不关闭 | | | |
||||
| 登录状态切换 | 显示用户信息 | | | |
||||
| 登出功能 | 回到未登录状态 | | | |
||||
|
||||
## 🎯 下一步行动 |
||||
|
||||
如果测试失败,请: |
||||
1. 检查控制台错误信息 |
||||
2. 确认服务是否重新启动 |
||||
3. 检查网络请求是否正常 |
||||
4. 提供具体的错误信息 |
||||
|
||||
## 📞 技术支持 |
||||
|
||||
如果问题仍然存在,请提供: |
||||
1. 浏览器控制台错误信息 |
||||
2. 网络请求的响应内容 |
||||
3. 具体的操作步骤和结果 |
@ -0,0 +1,94 @@
@@ -0,0 +1,94 @@
|
||||
# 登录状态切换修复验证 |
||||
|
||||
## 🔧 已修复的问题 |
||||
|
||||
### 1. MainLayout.vue 架构问题 ✅ |
||||
- **问题**: provide 在 export default 中引用了 setup 中的响应式数据 |
||||
- **修复**: 将 provide 移到 setup 函数中,使用正确的 Vue 3 Composition API 语法 |
||||
- **效果**: 子组件现在可以正确接收到响应式的登录状态 |
||||
|
||||
### 2. 响应式数据传递 ✅ |
||||
- **问题**: isLoggedIn 和 currentUser 没有正确传递给子组件 |
||||
- **修复**: 使用 provide() 函数在 setup 中提供响应式数据 |
||||
- **效果**: 子组件可以实时响应登录状态变化 |
||||
|
||||
## 🧪 测试步骤 |
||||
|
||||
### 步骤 1: 重启前端服务 |
||||
```bash |
||||
# 停止当前前端服务 (Ctrl+C) |
||||
cd app |
||||
npm run dev |
||||
``` |
||||
|
||||
### 步骤 2: 测试登录流程 |
||||
1. 打开前端应用 |
||||
2. 点击右上角"登录"按钮 |
||||
3. 输入凭据: |
||||
- 用户名: `sysadmin` |
||||
- 密码: `sysadmin@123` |
||||
- 验证码: 从图片中识别 |
||||
4. 点击"登录"按钮 |
||||
|
||||
### 步骤 3: 验证状态切换 |
||||
**预期结果**: |
||||
- 登录成功后弹窗关闭 |
||||
- 欢迎页面显示"欢迎回来,sysadmin!" |
||||
- 不显示"登录"按钮 |
||||
- 显示功能卡片(速度测试、历史记录等) |
||||
- 显示待办事项列表 |
||||
- 显示最近活动 |
||||
|
||||
### 步骤 4: 验证用户信息 |
||||
**预期结果**: |
||||
- 用户信息应该显示为 `admin` 而不是 `用户` |
||||
- 邮箱应该显示为 `admin@gofaster.com` 而不是 `user@example.com` |
||||
|
||||
## 🐛 如果仍有问题 |
||||
|
||||
### 检查控制台日志 |
||||
应该看到以下日志: |
||||
``` |
||||
Home.vue - 登录状态变化: true |
||||
Home.vue - 当前用户信息: {name: "admin", email: "admin@gofaster.com", ...} |
||||
Home.vue - 更新后的用户信息: {name: "admin", email: "admin@gofaster.com", ...} |
||||
``` |
||||
|
||||
### 检查网络请求 |
||||
1. 验证码获取是否成功 |
||||
2. 登录请求是否成功 |
||||
3. 响应数据格式是否正确 |
||||
|
||||
### 检查本地存储 |
||||
```javascript |
||||
// 在浏览器控制台中执行 |
||||
localStorage.getItem('isLoggedIn') // 应该是 "true" |
||||
localStorage.getItem('user') // 应该包含用户信息 |
||||
localStorage.getItem('token') // 应该包含 JWT token |
||||
``` |
||||
|
||||
## 📝 技术细节 |
||||
|
||||
### 修复的核心问题 |
||||
1. **Vue 3 Composition API 架构**: 将 provide 移到 setup 函数中 |
||||
2. **响应式数据传递**: 使用 provide() 函数提供响应式引用 |
||||
3. **数据绑定**: 确保子组件能正确接收和响应数据变化 |
||||
|
||||
### 数据流 |
||||
``` |
||||
MainLayout (setup) → provide() → Home.vue (inject) → 模板渲染 |
||||
↓ |
||||
响应式数据变化 → 自动更新 → UI 状态切换 |
||||
``` |
||||
|
||||
## 🎯 下一步 |
||||
|
||||
如果测试成功: |
||||
1. 验证登出功能是否正常工作 |
||||
2. 检查其他页面的登录状态是否正确 |
||||
3. 测试页面刷新后的状态保持 |
||||
|
||||
如果测试失败: |
||||
1. 提供具体的错误信息 |
||||
2. 检查控制台日志 |
||||
3. 确认前端服务是否重新启动 |
@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
|
||||
# 登录功能修复测试指南 |
||||
|
||||
## 🔧 已修复的问题 |
||||
|
||||
### 1. 登录弹窗模态窗问题 ✅ |
||||
- **问题**:点击登录窗外部区域,登录窗会消失 |
||||
- **修复**:将 `@click="handleOverlayClick"` 改为 `@click.self="closeModal"` |
||||
- **效果**:现在只有点击遮罩层(非弹窗区域)才会关闭弹窗 |
||||
|
||||
### 2. 验证码安全性增强 ✅ |
||||
- **问题**:验证码只是简单字符,安全性不足 |
||||
- **修复**:添加了干扰线、干扰点、干扰圆、字符旋转、随机颜色等 |
||||
- **效果**:验证码现在包含多种干扰元素,提高安全性 |
||||
|
||||
### 3. 登录后欢迎页面状态切换 ✅ |
||||
- **问题**:登录后欢迎页面没有切换到登录状态 |
||||
- **修复**:修复了 `$watch` 语法,确保正确监听登录状态变化 |
||||
- **效果**:登录后应该正确显示用户信息和功能卡片 |
||||
|
||||
## 🧪 测试步骤 |
||||
|
||||
### 测试 1: 模态窗功能 |
||||
1. 点击右上角"登录"按钮 |
||||
2. 尝试点击登录弹窗外部区域 |
||||
3. **预期结果**:弹窗不会关闭 |
||||
4. 点击弹窗右上角的 × 按钮 |
||||
5. **预期结果**:弹窗正常关闭 |
||||
|
||||
### 测试 2: 验证码安全性 |
||||
1. 打开登录弹窗 |
||||
2. 点击"点击获取验证码" |
||||
3. **预期结果**:显示包含干扰元素的验证码图片 |
||||
4. 刷新验证码几次 |
||||
5. **预期结果**:每次生成的验证码都有不同的干扰元素 |
||||
|
||||
### 测试 3: 登录状态切换 |
||||
1. 使用正确凭据登录(sysadmin / sysadmin@123) |
||||
2. **预期结果**:登录成功后弹窗关闭 |
||||
3. 检查欢迎页面 |
||||
4. **预期结果**: |
||||
- 显示"欢迎回来,sysadmin!" |
||||
- 不显示"登录"按钮 |
||||
- 显示功能卡片(速度测试、历史记录等) |
||||
- 显示待办事项列表 |
||||
- 显示最近活动 |
||||
|
||||
### 测试 4: 登出功能 |
||||
1. 点击右上角用户头像 |
||||
2. 选择"退出登录" |
||||
3. **预期结果**: |
||||
- 欢迎页面切换回未登录状态 |
||||
- 显示"欢迎光临,请登录!" |
||||
- 显示"登录"按钮 |
||||
- 隐藏功能卡片和待办事项 |
||||
|
||||
## 🐛 如果仍有问题 |
||||
|
||||
### 检查控制台日志 |
||||
- 查看是否有 JavaScript 错误 |
||||
- 检查登录状态变化日志 |
||||
- 检查用户信息更新日志 |
||||
|
||||
### 检查网络请求 |
||||
- 验证码获取是否成功 |
||||
- 登录请求是否成功 |
||||
- 响应数据格式是否正确 |
||||
|
||||
### 检查本地存储 |
||||
- `localStorage.getItem('isLoggedIn')` |
||||
- `localStorage.getItem('user')` |
||||
- `localStorage.getItem('token')` |
||||
|
||||
## 📝 技术细节 |
||||
|
||||
### 验证码增强特性 |
||||
- 随机干扰线(3条) |
||||
- 随机干扰点(20个) |
||||
- 随机干扰圆(5个) |
||||
- 字符随机旋转(±10度) |
||||
- 字符随机颜色 |
||||
- 字符随机字体大小 |
||||
- 噪声滤镜效果 |
||||
|
||||
### 状态管理 |
||||
- 使用 Vue 3 Composition API |
||||
- 响应式数据绑定 |
||||
- 全局事件通信 |
||||
- 本地存储持久化 |
||||
|
||||
## 🎯 下一步优化建议 |
||||
|
||||
1. **添加验证码刷新按钮**:在验证码图片旁边添加刷新图标 |
||||
2. **增强错误处理**:显示更友好的错误提示 |
||||
3. **添加记住密码功能**:可选的密码记忆功能 |
||||
4. **添加自动登录**:检查本地存储的登录状态 |
||||
5. **优化移动端体验**:响应式设计优化 |
Loading…
Reference in new issue