From 9cf1d0ef315f8f58ff19769dd6c064bb720e0f23 Mon Sep 17 00:00:00 2001 From: JGZYES Date: Wed, 2 Sep 2026 21:58:05 +0800 Subject: [PATCH] git.php: add Releases view (GitHub API: tag/name/date/body/assets), Code|Releases toggle in header --- web/assets/style.css | 13 ++++++++++ web/git.php | 62 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/web/assets/style.css b/web/assets/style.css index 10c2ce3..3f7345b 100644 --- a/web/assets/style.css +++ b/web/assets/style.css @@ -214,3 +214,16 @@ code{font-family:"JetBrains Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,"Co /* download copy-command card */ .dl-cmd{margin-top:8px;border:1px solid var(--line);border-radius:8px;padding:10px 12px;background:#0a0e15} .dl-cmd code{font-size:12.5px;white-space:pre-wrap;word-break:break-all;color:#d0d0d0} + +/* ---------- git.php releases ---------- */ +.gh-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap} +.rel-list{display:grid;gap:18px} +.rel-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:22px} +.rel-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:10px} +.rel-version{font-weight:800;font-size:17px;color:#fff} +.rel-tag{font-family:ui-monospace,monospace;font-size:12.5px;color:var(--muted);margin-left:8px} +.rel-date{font-size:12.5px;color:var(--dim);font-family:ui-monospace,monospace} +.rel-assets{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px} +.rel-asset{border:1px solid var(--line);border-radius:8px;padding:6px 10px;font-size:12.5px;font-family:ui-monospace,monospace;color:var(--text);text-decoration:none} +.rel-asset:hover{border-color:#fff;color:#fff} +.rel-size{color:var(--dim);margin-left:6px} diff --git a/web/git.php b/web/git.php index 5744a79..891fec2 100644 --- a/web/git.php +++ b/web/git.php @@ -57,7 +57,57 @@ function md(string $t): string { $t = preg_replace('/`([^`]+)`/', '$1', $t); return $t; } +function gh_api(string $url): array { + $json = null; + if (function_exists('curl_init')) { + $ch = curl_init($url); + curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, + CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_SSL_VERIFYHOST => false, CURLOPT_USERAGENT => 'pmm-site']); + $r = curl_exec($ch); curl_close($ch); + if (is_string($r) && $r !== '') $json = $r; + } + if ($json === null) $json = (string)@shell_exec('curl -s --max-time 15 ' . escapeshellarg($url)); + $d = json_decode((string)$json, true); + return is_array($d) ? $d : []; +} +function render_releases(): void { + $rels = gh_api('https://api.github.com/repos/JGZYES/ParlzPackageManger/releases?per_page=30'); + if (!$rels) { echo '
无法获取 Releases(网络或 API 受限)。
'; return; } + echo '
'; + foreach ($rels as $r): + $tag = $r['tag_name'] ?? '?'; $name = $r['name'] ?? $tag; + $date = $r['published_at'] ?? ($r['created_at'] ?? ''); + $date = substr(str_replace('T', ' ', (string)$date), 0, 10); + $prere = !empty($r['prerelease']); + $assets = $r['assets'] ?? []; +?> +
+
+
+ + 预发布 + +
+ +
+ +
+ + +
+ + + + + +
+ +
+'; +} +$view = $_GET['view'] ?? ''; $branch = $repo_ok ? sh("git -C " . escapeshellarg($REPO_DIR) . " rev-parse --abbrev-ref HEAD 2>/dev/null") : ''; $last = $repo_ok ? sh('git -C ' . escapeshellarg($REPO_DIR) . " log -1 --format=\"%H|%s|%an|%ad\" --date=short 2>/dev/null") : ''; [$lhash, $lsubj, $luser, $ldate] = array_pad(explode('|', $last, 4), 4, ''); @@ -102,7 +152,11 @@ pmm_header('source', '源码浏览');
@@ -111,6 +165,10 @@ pmm_header('source', '源码浏览');
+ +

Releases

+ +
source
README
- +