From cf25cfc9d0ada6274c84cc14a0b778f302f2ce76 Mon Sep 17 00:00:00 2001 From: Tiaotiao <65841827@qq.com> Date: Fri, 27 Feb 2026 15:45:50 +0800 Subject: [PATCH 1/6] Update comment fetching mechanism in med.php Fix JavaScript fetch call and update comments section dynamically every 10 seconds. --- med.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/med.php b/med.php index 8c2c404..a846cf4 100644 --- a/med.php +++ b/med.php @@ -472,14 +472,17 @@ function remixExperiment() { alert('改编功能即将开放'); } // 使用JavaScript动态加载评论 -fetch('/comment/?category=&id=') +setInterval(()=>{ + fetch('/comment/?category=&id=') .then(response => response.text()) .then(html => { document.getElementById('comments').innerHTML = html; }) .catch(error => { document.getElementById('comments').innerHTML = '
加载评论失败
'; - }); + }); +}, 10000); +//每10s更新一次 '; + exit; + } +} + +// 检查登录状态 +$isLoggedIn = isset($dt['Data']['User']['Nickname']) && $dt['Data']['User']['Nickname'] !== '点击登录'; + +// 获取API数据 +function getCommunityData() { + $baseUrl = "http://nlm-api-cn.turtlesim.com/"; + + // 准备请求数据 + $requestData = [ + 'Identifier' => 'Workspace', + 'Language' => "Chinese" + ]; + + // 准备请求头 + $headers = [ + 'Content-Type: application/json', + 'Accept: application/json', + 'Accept-Language: zh-CN', + ]; + + // 添加认证头(修复了多余的大括号) + $headers[] = 'x-API-Token: ' . $_SESSION['token']; + $headers[] = 'x-API-AuthCode: ' . $_SESSION['authCode']; + + // 发送POST请求 + $url = $baseUrl . 'Contents/GetLibrary'; + + $ch = curl_init(); + curl_setopt_array($ch, [ + CURLOPT_URL => $url, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => json_encode($requestData, JSON_UNESCAPED_UNICODE), + CURLOPT_HTTPHEADER => $headers, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_TIMEOUT => 30, + ]); + + $response = curl_exec($ch); + curl_close($ch); + $data = json_decode($response, true); + return $data; +} + +// 处理日期格式 +function formatDate($id) { + return (strlen($id) >= 8) ? date('m/d', hexdec(substr($id, 0, 8)) * 1000 / 1000) : '未知日期'; +} + +// 获取数据 +$communityData = getCommunityData(); + +// 模块配置 +$modules = [ + ['title' => '本地实验', 'count' => 4, 'featured' => false, 'type' => 'explore', 'category' => 'Local'], + ['title' => '创建模型', 'count' => 3, 'featured' => true, 'type' => 'featured', 'category' => 'Model'], + ['title' => '我的模型', 'count' => 4, 'featured' => false, 'type' => 'daily', 'category' => 'Model'], + ['title' => '我的实验', 'count' => 4, 'featured' => false, 'type' => 'hot', 'category' => 'Experiment'], + ['title' => '我的讨论', 'count' => 4, 'featured' => false, 'type' => 'new', 'category' => 'Discussion'], + ['title' => '我支持的模型', 'count' => 4, 'featured' => false, 'type' => 'daily', 'category' => 'Model'], + ['title' => '我支持的实验', 'count' => 4, 'featured' => false, 'type' => 'hot', 'category' => 'Experiment'], + ['title' => '我支持的讨论', 'count' => 4, 'featured' => false, 'type' => 'new', 'category' => 'Discussion'], + ['title' => '我收藏的模型', 'count' => 4, 'featured' => false, 'type' => 'daily', 'category' => 'Model'], + ['title' => '我收藏的实验', 'count' => 4, 'featured' => false, 'type' => 'hot', 'category' => 'Experiment'], + ['title' => '我收藏的讨论', 'count' => 4, 'featured' => false, 'type' => 'new', 'category' => 'Discussion'] +]; +?> + + + + + + + Turtle Universe Web - Workspace + + + + +
+

我的实验室

+
+ +
+ + +
+ $module): ?> + + +
+
+
+ + +
+ <?= htmlspecialchars($subject) ?> +
+
+
-
+ +
+ + + +
+ +
+
+ +
+
+ +
+
+ + +
+ +
+

无法加载社区数据,请检查网络连接或稍后重试

+ +
+ +
+ + + + + + From 20d0a1c375178248af254f3c113c74d36f043ca8 Mon Sep 17 00:00:00 2001 From: Tiaotiao <65841827@qq.com> Date: Fri, 27 Feb 2026 15:49:11 +0800 Subject: [PATCH 6/6] Update footer links to use onclick for navigation --- index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 405bed2..b67c865 100644 --- a/index.php +++ b/index.php @@ -52,6 +52,7 @@ function formatDate($id) { + Turtle Universe Web @@ -137,7 +138,7 @@ function formatDate($id) {