diff --git a/opt/options/theme-options.php b/opt/options/theme-options.php index d63e60ce..cb989826 100644 --- a/opt/options/theme-options.php +++ b/opt/options/theme-options.php @@ -2883,6 +2883,25 @@ function iro_validate_optional_url( $value ) { ), 'default' => 'ASC' ), + + array( + 'type' => 'subheading', + 'content' => __('Steam库模板设置','sakurairo_csf'), + ), + + array( + 'id' => 'steam_id', + 'type' => 'text', + 'title' => __('Steam 账号64ID','sakurairo_csf'), + 'desc' => __('填写你的帐号ID,例如:https://steamcommunity.com/profiles/76561199029689067/, 只需填写数字 "76561199029689067" 部分','sakurairo_csf'), + ), + + array( + 'id' => 'steam_key', + 'type' => 'text', + 'title' => __('Steam Api Key','sakurairo_csf'), + 'desc' => __('申请链接 https://steamcommunity.com/dev/apikey','sakurairo_csf'), + ), array( 'type' => 'subheading', diff --git a/user/page-steam.php b/user/page-steam.php new file mode 100644 index 00000000..22f0a1a4 --- /dev/null +++ b/user/page-steam.php @@ -0,0 +1,155 @@ + + + + + + + + + + +
> + +
+ +
+ 10)); + + if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200) { + $data = json_decode(wp_remote_retrieve_body($response), true); + + if (isset($data['response']['games']) && !empty($data['response']['games'])) { + // 按最后游玩时间排序 + usort($data['response']['games'], function($a, $b) { + return $b['rtime_last_played'] - $a['rtime_last_played']; + }); + + foreach ($data['response']['games'] as $game) : ?> +
+ +
+ <?php echo esc_attr($game['name']); ?> +
+
+
+
+ 120) { + $hours = number_format($playtime / 60, 2, '.', ''); + printf('
%s
', esc_html(sprintf('游戏时长: %s 小时', $hours))); + } else { + printf('
%s
', esc_html(sprintf('游戏时长: %d 分钟', $playtime))); + } + $lastPlayed = wp_date('Y-m-d H:i:s', $game['rtime_last_played']); + if ($playtime == 0) { + printf('
%s
', esc_html(sprintf('尚未游玩'))); + } else { + printf('
%s
', esc_html(sprintf('上次启动: %s', $lastPlayed))); + } + ?> +
+
+ ' . esc_html__('无游戏数据', 'sakurairo') . '

'; + } + } else { + echo '

' . esc_html__('无法连接到Steam API, 可能是信息填写错误', 'sakurairo') . '

'; + + } + ?> +
+ +
+

+
+ +
+
+ + + \ No newline at end of file