

一个基于AI图片生成的多人在线派对游戏,玩家通过文字描述传递AI生成的图片,最后投票猜测原始图片。
在启动游戏前,请先配置环境变量:
编辑 server\.env 文件,配置以下参数:
AI_MODE=real
AI_DEVELOPER_TOKEN=你的开发者令牌
AI_GAME_ID=你的游戏ID
Windows用户:
双击运行 start-dev.bat
Linux/Mac用户:
chmod +x start-dev.sh
./start-dev.sh
# 服务器依赖
cd server
npm install
# 客户端依赖
cd ../client
npm install
cd server
copy env.example .env
# 编辑 .env 文件,设置 AI_MODE=mock
# 终端1:启动服务器
cd server
npm run dev
# 终端2:启动客户端
cd client
npm run dev
让同一WiFi下的其他设备(手机、平板等)连接游戏:
Windows系统:
ipconfig
# 找到 "无线局域网适配器 WLAN" 下的 IPv4 地址
# 例如:192.168.1.100
Mac/Linux系统:
ifconfig
# 或
ip addr show
# 找到 WiFi 网卡的 IP 地址
打开浏览器访问:http://localhost:3000
多人游戏:其他设备访问 http://[你的IP]:3000
例如:http://192.168.1.100:3000
Windows:
# 允许 3000 端口(客户端)
netsh advfirewall firewall add rule name="pAIant&guess Client" dir=in action=allow protocol=TCP localport=3000
# 允许 3001 端口(服务器)
netsh advfirewall firewall add rule name="pAIant&guess Server" dir=in action=allow protocol=TCP localport=3001
或者临时关闭防火墙测试:
Mac:
让不在同一网络的朋友也能一起玩!
确保游戏服务器正在运行:
# 在项目根目录运行
start-dev.bat # Windows
# 或
./start-dev.sh # Linux/Mac
服务器会在3001端口启动,客户端在3000端口启动。
方法1:使用项目提供的脚本(推荐)
# 双击运行项目根目录下的文件
ngrok-start.bat
方法2:手动启动
打开新的命令行窗口:
ngrok http 3000
注意:需要暴露3000端口(客户端),因为Vite会自动代理socket.io和API请求到3001。
Ngrok启动后,会看到类似界面:
ngrok
Session Status online
Account 你的账户名
Version 3.x.x
Region United States (us)
Forwarding https://xxxx-xx-xx-xx-xx.ngrok-free.app -> http://localhost:3000
重要信息:
Forwarding 那一行的 https://xxxx-xx-xx-xx-xx.ngrok-free.app 就是你的公网地址玩家只需在浏览器中打开:
https://xxxx-xx-xx-xx-xx.ngrok-free.app
访问 http://127.0.0.1:4040 可以看到Ngrok的Web界面,查看:
&& 语法错误,请使用 CMD 或 Git Bash&& 语法错误,请使用 CMD 或 Git Bash