feat(docs): 文档站自带热更新——源码变更自动重建后端+刷新元数据

- docs 后端从 go run 改为 build+spawn(编译成功才切换,与 fun run 同语义)
- watchLoop 复用:.go/go.mod/go.sum 变更→重采元数据+重启后端
- 新增 /fun-version 端点;文档页轮询版本变化自动刷新(编辑中推迟)
- snapshot 跳过 fun_gen_helper_test.go,避免采集辅助文件自触发
- -from 静态模式不启用;-no-run 仍刷新元数据(后端由外部管理)

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
2026-09-19 15:46:07 +08:00
co-authored by Devin
parent 96d8a4074f
commit dabf8c2953
4 changed files with 86 additions and 12 deletions
+15
View File
@@ -243,6 +243,21 @@ Promise.all([
selectFromHash();
}).catch(e=>{const h=$('#hmeta');h.textContent='元数据加载失败: '+e.message;h.style.color='var(--err)';$('#live').style.background='var(--err)'});
/* 热更新:源码变更触发后端重建+元数据刷新后,文档页自动重载;
正在输入时推迟一轮,避免打断编辑(防抖保存会先把备注落盘) */
let DOC_V=null;
setInterval(async()=>{
try{
const r=await fetch('/fun-version').then(r=>r.json());
if(DOC_V===null){DOC_V=r.v;return}
if(r.v!==DOC_V){
const ae=document.activeElement;
if(ae&&/INPUT|TEXTAREA/.test(ae.tagName))return;
location.reload();
}
}catch{}
},1500);
window.addEventListener('hashchange',selectFromHash);
/* 深链:#Svc.Method 或 #Svc.Method?req=<base64url 请求体> */
function selectFromHash(){