From ddde54099441c5c0bda210f471bbe46d4981588b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Apr 2026 10:04:19 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=AC=E5=91=8A=E6=A0=8FGitHub=20API?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0sessionStorage=E7=BC=93=E5=AD=98+=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=A5=E5=BF=97+=E6=88=AA=E6=96=AD=E7=9C=81?= =?UTF-8?q?=E7=95=A5=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/929a30c8-2828-403f-a189-40c9ab2fd0f7 Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- server/sites/portal/index.html | 45 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/server/sites/portal/index.html b/server/sites/portal/index.html index 89fdd98f..bd40a9de 100644 --- a/server/sites/portal/index.html +++ b/server/sites/portal/index.html @@ -602,7 +602,6 @@ setInterval(fetchStatus,60000); // ═══ 公告栏:从GitHub仓库拉取最新动态 ═══ (async function loadBulletin(){ const board=document.getElementById('bulletinBoard'); - // 静态公告 + 尝试从GitHub API获取最新commit const staticBulletins=[ {icon:'🚀',title:'AGE OS v51.0 正式发布',desc:'系统面板重构 · 4个大模型API确认上线 · 硅谷Claude节点接入 · COS存储桶2+1配置完成',time:'2026-04',tag:'deploy',tagText:'版本发布'}, {icon:'🌳',title:'光之树架构上线',desc:'HLDP v3.0 · HNL母语词典v1.0 · 四枝干记忆结构 · 闭包表自动维护',time:'2026-03',tag:'sys',tagText:'架构升级'}, @@ -610,23 +609,39 @@ setInterval(fetchStatus,60000); {icon:'📝',title:'码字工作台内测中',desc:'沉浸式写作环境 · 智能大纲 · 角色管理 · 每日字数目标追踪 · 人格体陪伴',time:'2026-04',tag:'dev',tagText:'功能开发'}, {icon:'🔗',title:'行业接入通道筹备',desc:'网文行业技术主控台 · Awen主导 · 频道化部署架构 · 每人一条专属通道',time:'2026-04',tag:'dev',tagText:'即将开放'}, ]; - // 尝试从GitHub API获取最新提交 + // 尝试从GitHub API获取最新提交(带客户端缓存,避免速率限制) + const cacheKey='hololake-commits-cache'; + const cacheTTL=300000; // 5分钟缓存 try{ - const res=await fetch('https://api.github.com/repos/qinfendebingshuo/guanghulab/commits?per_page=3',{ - headers:{'Accept':'application/vnd.github.v3+json'} - }); - if(res.ok){ - const commits=await res.json(); - const commitBulletins=commits.map(c=>({ - icon:'📦', - title:c.commit.message.split('\n')[0].slice(0,60), - desc:'提交者: '+(c.commit.author?.name||'铸渊')+' · '+c.sha.slice(0,7), - time:c.commit.author?.date?.slice(0,10)||'', - tag:'hot',tagText:'最新提交' - })); + const cached=sessionStorage.getItem(cacheKey); + let commits; + if(cached){ + const {data,ts}=JSON.parse(cached); + if(Date.now()-ts{ + const msg=c.commit.message.split('\n')[0]; + return{ + icon:'📦', + title:msg.length>60?msg.slice(0,57)+'...':msg, + desc:'提交者: '+(c.commit.author?.name||'铸渊')+' · '+c.sha.slice(0,7), + time:c.commit.author?.date?.slice(0,10)||'', + tag:'hot',tagText:'最新提交' + }; + }); staticBulletins.unshift(...commitBulletins); } - }catch(e){/* GitHub API不可达时使用静态公告 */} + }catch(e){console.warn('[公告栏] GitHub API不可达,使用静态公告',e.message)} board.innerHTML=staticBulletins.map(b=>`