71 lines
1.9 KiB
JavaScript
71 lines
1.9 KiB
JavaScript
// 游戏配置文件
|
|
const GameConfig = {
|
|
// WebSocket配置
|
|
websocket: {
|
|
baseUrl: 'ws://localhost:8501',
|
|
reconnectAttempts: 5,
|
|
reconnectDelay: 1000,
|
|
heartbeatInterval: 30000, // 心跳间隔(毫秒)
|
|
connectionTimeout: 10000, // 连接超时(毫秒)
|
|
},
|
|
|
|
// 游戏配置
|
|
game: {
|
|
maxDotsPerSquare: 100, // 每个方块最大圆点数
|
|
dotLifetime: 30000, // 圆点生命周期(毫秒)
|
|
gridSize: {
|
|
width: 400,
|
|
height: 400
|
|
},
|
|
animationDuration: 300, // 动画持续时间(毫秒)
|
|
},
|
|
|
|
// UI配置
|
|
ui: {
|
|
showStatusBar: true,
|
|
showKeyboardHints: true,
|
|
autoHideHints: true,
|
|
hintsHideDelay: 5000, // 提示自动隐藏延迟(毫秒)
|
|
},
|
|
|
|
// 性能配置
|
|
performance: {
|
|
enableAnimations: true,
|
|
enableHoverEffects: true,
|
|
enableBackdropFilter: true,
|
|
maxFPS: 60,
|
|
},
|
|
|
|
// 调试配置
|
|
debug: {
|
|
enableLogging: true,
|
|
logLevel: 'info', // 'debug', 'info', 'warn', 'error'
|
|
showConnectionDetails: false,
|
|
}
|
|
};
|
|
|
|
// 环境检测
|
|
const isDevelopment = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
|
|
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
|
|
// 根据环境调整配置
|
|
if (isDevelopment) {
|
|
GameConfig.debug.enableLogging = true;
|
|
GameConfig.debug.logLevel = 'debug';
|
|
} else {
|
|
GameConfig.debug.enableLogging = false;
|
|
GameConfig.performance.enableAnimations = true;
|
|
}
|
|
|
|
if (isMobile) {
|
|
GameConfig.ui.showKeyboardHints = false;
|
|
GameConfig.performance.enableHoverEffects = false;
|
|
GameConfig.game.maxDotsPerSquare = 50; // 移动端减少圆点数量
|
|
}
|
|
|
|
// 导出配置
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
module.exports = GameConfig;
|
|
} else {
|
|
window.GameConfig = GameConfig;
|
|
}
|