jQuery(document).ready(function($) { $('.asl-load-more-btn').on('click', function() { var $button = $(this); var $container = $button.closest('.asl-container'); var $grid = $container.find('.asl-games-grid'); var currentPage = parseInt($container.data('page')); if ($button.hasClass('loading')) { return; } $button.addClass('loading').text('加载中...'); $.ajax({ url: aslAjax.ajaxurl, type: 'POST', data: { action: 'asl_load_more', page: currentPage + 1, nonce: aslAjax.nonce }, success: function(response) { if (response.games && response.games.length > 0) { response.games.forEach(function(game) { var playtime = Math.floor(game.playtime_forever / 60); // 修改为使用 Steam 游戏海报 URL var imageUrl = 'https://steamcdn-a.akamaihd.net/steam/apps/' + game.appid + '/header.jpg'; var gameCard = `
${game.name}

${game.name}

${playtime} 小时
`; $grid.append(gameCard); }); $container.data('page', currentPage + 1); if (!response.has_more) { $button.parent().remove(); } } $button.removeClass('loading').text('加载更多'); }, error: function() { $button.removeClass('loading').text('加载失败,请重试'); } }); }); });