diff --git a/.trae/rules/project_rules.md b/.trae/rules/project_rules.md index 3c29089..3ff8560 100644 --- a/.trae/rules/project_rules.md +++ b/.trae/rules/project_rules.md @@ -1,2 +1,3 @@ 将服务端所有需要保存的数据统一保存在server\data 目录下 -前端使用的token存储键是'gsm3_token' \ No newline at end of file +前端使用的token存储键是'gsm3_token' +路由文件的导入语句需要添加.js扩展名。 \ No newline at end of file diff --git a/scripts/package.js b/scripts/package.js index ece6dda..5d7b032 100644 --- a/scripts/package.js +++ b/scripts/package.js @@ -51,6 +51,19 @@ async function createPackage() { await fs.ensureDir(path.join(packageDir, 'server', 'uploads')) console.log('📁 创建uploads目录...') + // 复制server/data/games目录(包含游戏配置文件) + const serverGamesPath = path.join(__dirname, '..', 'server', 'data', 'games') + if (await fs.pathExists(serverGamesPath)) { + await fs.ensureDir(path.join(packageDir, 'server', 'data')) + await fs.copy( + serverGamesPath, + path.join(packageDir, 'server', 'data', 'games') + ) + console.log('📋 复制游戏配置文件...') + } else { + console.log('⚠️ 警告: server/data/games 目录不存在,跳过复制') + } + console.log('📥 安装服务端生产依赖...') // 在打包的服务端目录中安装生产依赖 try { diff --git a/server/src/modules/steamcmd/SteamCMDManager.ts b/server/src/modules/steamcmd/SteamCMDManager.ts index 8986f10..addce46 100644 --- a/server/src/modules/steamcmd/SteamCMDManager.ts +++ b/server/src/modules/steamcmd/SteamCMDManager.ts @@ -7,7 +7,7 @@ import { Extract } from 'unzipper' import tar from 'tar' import winston from 'winston' import os from 'os' -import { ConfigManager } from '../config/ConfigManager' +import { ConfigManager } from '../config/ConfigManager.js' export interface SteamCMDInstallOptions { installPath: string diff --git a/server/src/modules/terminal/TerminalManager.ts b/server/src/modules/terminal/TerminalManager.ts index f4f1ed4..f600f78 100644 --- a/server/src/modules/terminal/TerminalManager.ts +++ b/server/src/modules/terminal/TerminalManager.ts @@ -61,11 +61,11 @@ export class TerminalManager { // 根据操作系统选择PTY程序路径 const platform = os.platform() if (platform === 'win32') { - this.ptyPath = path.resolve(__dirname, '../../../PTY/pty_win32_x64.exe') - // this.ptyPath = path.resolve(__dirname, '../../PTY/pty_win32_x64.exe') + // this.ptyPath = path.resolve(__dirname, '../../../PTY/pty_win32_x64.exe') + this.ptyPath = path.resolve(__dirname, '../../PTY/pty_win32_x64.exe') } else { - this.ptyPath = path.resolve(__dirname, '../../../PTY/pty_linux_x64') - // this.ptyPath = path.resolve(__dirname, '../../PTY/pty_linux_x64') + // this.ptyPath = path.resolve(__dirname, '../../../PTY/pty_linux_x64') + this.ptyPath = path.resolve(__dirname, '../../PTY/pty_linux_x64') } this.logger.info(`终端管理器初始化完成,PTY路径: ${this.ptyPath}`) diff --git a/server/src/routes/gameDeployment.ts b/server/src/routes/gameDeployment.ts index 40b767b..8dc1126 100644 --- a/server/src/routes/gameDeployment.ts +++ b/server/src/routes/gameDeployment.ts @@ -37,7 +37,8 @@ export function setGameDeploymentManagers( // 获取可安装的游戏列表 router.get('/games', authenticateToken, async (req: Request, res: Response) => { try { - const gamesFilePath = path.join(__dirname, '../../data/games/installgame.json') + // const gamesFilePath = path.join(__dirname, '../../data/games/installgame.json') + const gamesFilePath = path.join(__dirname, '../data/games/installgame.json') const gamesData = await fs.readFile(gamesFilePath, 'utf-8') const games = JSON.parse(gamesData) diff --git a/server/src/routes/steamcmd.ts b/server/src/routes/steamcmd.ts index 3c6d443..f98f47c 100644 --- a/server/src/routes/steamcmd.ts +++ b/server/src/routes/steamcmd.ts @@ -1,8 +1,8 @@ import { Router } from 'express' -import { SteamCMDManager } from '../modules/steamcmd/SteamCMDManager' -import { ConfigManager } from '../modules/config/ConfigManager' +import { SteamCMDManager } from '../modules/steamcmd/SteamCMDManager.js' +import { ConfigManager } from '../modules/config/ConfigManager.js' import winston from 'winston' -import { authenticateToken } from '../middleware/auth' +import { authenticateToken } from '../middleware/auth.js' const router = Router() let steamcmdManager: SteamCMDManager