diff --git a/client/src/pages/GameDeploymentPage.tsx b/client/src/pages/GameDeploymentPage.tsx index 1ce955e..7a029ec 100644 --- a/client/src/pages/GameDeploymentPage.tsx +++ b/client/src/pages/GameDeploymentPage.tsx @@ -29,6 +29,7 @@ interface GameInfo { system?: string[] supportedOnCurrentPlatform?: boolean currentPlatform?: string + panelCompatibleOnCurrentPlatform?: boolean } interface Games { @@ -134,6 +135,11 @@ const GameDeploymentPage: React.FC = () => { const [onlineGameTypeFilter, setOnlineGameTypeFilter] = useState('all') const [onlineGameSearchQuery, setOnlineGameSearchQuery] = useState('') + // 面板兼容性确认对话框状态 + const [showCompatibilityModal, setShowCompatibilityModal] = useState(false) + const [compatibilityModalAnimating, setCompatibilityModalAnimating] = useState(false) + const [pendingGameInstall, setPendingGameInstall] = useState<{ key: string; info: GameInfo } | null>(null) + const socketRef = useRef(null) const currentDownloadId = useRef(null) const currentMoreGameDeploymentId = useRef(null) @@ -1039,6 +1045,21 @@ const GameDeploymentPage: React.FC = () => { return } + // 检查面板是否兼容当前平台 + if (gameInfo.panelCompatibleOnCurrentPlatform === false) { + // 显示兼容性确认对话框 + setPendingGameInstall({ key: gameKey, info: gameInfo }) + setShowCompatibilityModal(true) + setTimeout(() => setCompatibilityModalAnimating(true), 10) + return + } + + // 直接打开安装对话框 + openInstallModal(gameKey, gameInfo) + } + + // 打开安装对话框的通用函数 + const openInstallModal = (gameKey: string, gameInfo: GameInfo) => { setSelectedGame({ key: gameKey, info: gameInfo }) setInstanceName(gameInfo.game_nameCN) setInstallPath('') @@ -1054,6 +1075,26 @@ const GameDeploymentPage: React.FC = () => { }, 300) } + // 关闭兼容性确认对话框 + const handleCloseCompatibilityModal = () => { + setCompatibilityModalAnimating(false) + setTimeout(() => { + setShowCompatibilityModal(false) + setPendingGameInstall(null) + }, 300) + } + + // 确认继续安装不兼容的游戏 + const handleConfirmIncompatibleInstall = () => { + if (pendingGameInstall) { + handleCloseCompatibilityModal() + // 延迟一点时间等待对话框关闭动画完成 + setTimeout(() => { + openInstallModal(pendingGameInstall.key, pendingGameInstall.info) + }, 350) + } + } + // 关闭创建实例对话框 const handleCloseCreateInstanceModal = () => { setCreateInstanceModalAnimating(false) @@ -1679,12 +1720,18 @@ const GameDeploymentPage: React.FC = () => { className={`w-full py-2 px-4 rounded-lg transition-colors flex items-center justify-center space-x-2 ${ gameInfo.supportedOnCurrentPlatform === false ? 'bg-gray-400 cursor-not-allowed text-gray-200' + : gameInfo.panelCompatibleOnCurrentPlatform === false + ? 'bg-orange-600 hover:bg-orange-700 text-white' : 'bg-blue-600 hover:bg-blue-700 text-white' }`} > - {gameInfo.supportedOnCurrentPlatform === false ? '平台不兼容' : '安装游戏'} + {gameInfo.supportedOnCurrentPlatform === false + ? '平台不兼容' + : gameInfo.panelCompatibleOnCurrentPlatform === false + ? '面板不兼容' + : '安装游戏'} @@ -3429,6 +3476,71 @@ const GameDeploymentPage: React.FC = () => { )} + + {/* 面板兼容性确认对话框 */} + {showCompatibilityModal && pendingGameInstall && ( +
+
+
+

+ + 面板兼容性提示 +

+ +
+ +
+
+
+ +
+

+ 面板兼容性警告 +

+

+ 此游戏在您当前平台上,面板尚未适配,您将无法进行管理。但是您可以继续安装。 +

+
+
+
+ +
+

+ 游戏: {pendingGameInstall.info.game_nameCN} +

+

+ 当前平台: {pendingGameInstall.info.currentPlatform} +

+
+
+ +
+ + +
+
+
+ )} ) } diff --git a/server/data/games/installgame.json b/server/data/games/installgame.json index a4f2d09..bcb627f 100644 --- a/server/data/games/installgame.json +++ b/server/data/games/installgame.json @@ -21,7 +21,8 @@ "tip": "游戏端口:7777 UDP,配置文件位置:Config/Game.ini,存档位置:位于映射的通用游戏存档路径目录中,温馨提示:请将保存位置映射到容器外部,防止存档丢失", "image":"https://shared.cdn.queniuqe.com/store_item_assets/steam/apps/526870/header.jpg", "url":"https://store.steampowered.com/app/526870/_/", - "system":["Windows","Linux"] + "system":["Windows","Linux"], + "system_info":["Linux"] }, "L4D2": { "game_nameCN": "求生之路2", diff --git a/server/src/routes/gameDeployment.ts b/server/src/routes/gameDeployment.ts index 2b6cf65..f65d77f 100644 --- a/server/src/routes/gameDeployment.ts +++ b/server/src/routes/gameDeployment.ts @@ -25,6 +25,7 @@ interface SteamGameInfo { image: string url: string system?: Platform[] + system_info?: Platform[] // 面板兼容的系统列表 } // 获取当前平台 @@ -53,6 +54,17 @@ function isGameSupportedOnCurrentPlatform(game: SteamGameInfo): boolean { return game.system.includes(currentPlatform) } +// 检查面板是否兼容当前平台 +function isPanelCompatibleOnCurrentPlatform(game: SteamGameInfo): boolean { + // 如果游戏没有定义system_info字段,默认面板兼容 + if (!game.system_info || game.system_info.length === 0) { + return true + } + + const currentPlatform = getCurrentPlatform() + return game.system_info.includes(currentPlatform) +} + const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) @@ -86,17 +98,23 @@ router.get('/games', authenticateToken, async (req: Request, res: Response) => { const allGames: { [key: string]: SteamGameInfo } = JSON.parse(gamesData) const currentPlatform = getCurrentPlatform() - const filteredGames: { [key: string]: SteamGameInfo & { supportedOnCurrentPlatform: boolean, currentPlatform: Platform } } = {} + const filteredGames: { [key: string]: SteamGameInfo & { + supportedOnCurrentPlatform: boolean, + currentPlatform: Platform, + panelCompatibleOnCurrentPlatform: boolean + } } = {} // 添加平台信息到所有游戏(不再过滤不兼容的游戏) for (const [gameKey, gameInfo] of Object.entries(allGames)) { const isSupported = isGameSupportedOnCurrentPlatform(gameInfo) + const isPanelCompatible = isPanelCompatibleOnCurrentPlatform(gameInfo) // 返回所有游戏,包括不支持当前平台的游戏 filteredGames[gameKey] = { ...gameInfo, supportedOnCurrentPlatform: isSupported, - currentPlatform + currentPlatform, + panelCompatibleOnCurrentPlatform: isPanelCompatible } }