✨ Sync 2026-09-11 23:47:18

This commit is contained in:
github-actions[bot] committed 2026-09-11 23:47:18 +08:00
1 parent be72c4a194
commit 8141aa4b54
89 files changed
+3680 -3045

No files matched your search

@@ -101,6 +101,24 @@ act.cfgvalue = function(self, section)
-- 版本选择对话框逻辑
html[#html+1] = 'var _setupTimer=null;'
html[#html+1] = 'var _setupOperation="setup";'
html[#html+1] = 'var _setupPollErrors=0;'
html[#html+1] = 'function ocAcceptedResponse(x){'
html[#html+1] = 'if(!x||typeof x.status!=="number"||x.status<200||x.status>=300)return{ok:false,message:"服务器拒绝请求 (HTTP "+(x&&x.status||0)+")"};'
html[#html+1] = 'try{var r=JSON.parse(x.responseText);return r&&r.status==="ok"?{ok:true,data:r}:{ok:false,message:(r&&r.message)||"服务器未接受请求"};}catch(e){return{ok:false,message:"服务器返回了无效响应"};}'
html[#html+1] = '}'
html[#html+1] = 'function ocSetupRequestRejected(btn,label,message){'
html[#html+1] = 'if(_setupTimer){clearInterval(_setupTimer);_setupTimer=null;}'
html[#html+1] = 'if(btn){btn.disabled=false;btn.textContent=label;}'
html[#html+1] = 'var statusEl=document.getElementById("setup-log-status");var logEl=document.getElementById("setup-log-content");'
html[#html+1] = 'if(statusEl)statusEl.textContent="❌ "+message;if(logEl)logEl.textContent+=message+"\\n";'
html[#html+1] = '}'
html[#html+1] = 'function ocSetupPollingUnknown(){'
html[#html+1] = 'if(_setupTimer){clearInterval(_setupTimer);_setupTimer=null;}'
html[#html+1] = 'var btn=document.getElementById(_setupOperation==="core"?"btn-core-upgrade":"btn-setup");'
html[#html+1] = 'if(btn){btn.disabled=false;btn.textContent=_setupOperation==="core"?"⬆️ 重试核心升级":"📦 安装运行环境";}'
html[#html+1] = 'var statusEl=document.getElementById("setup-log-status");if(statusEl)statusEl.textContent="⚠️ 状态查询连续失败,请手动刷新确认;后台任务可能仍在运行。";'
html[#html+1] = '}'
html[#html+1] = 'function ocShowSetupDialog(){'
html[#html+1] = 'var dlg=document.getElementById("oc-setup-dialog");'
html[#html+1] = 'dlg.style.display="flex";'
@@ -183,6 +201,7 @@ act.cfgvalue = function(self, section)
-- 安装运行环境 (带实时日志,支持自定义路径)
html[#html+1] = 'function ocSetup(version,mem_mb,disk_mb,install_path){'
html[#html+1] = '_setupOperation="setup";'
html[#html+1] = 'var btn=document.getElementById("btn-setup");'
html[#html+1] = 'var logEl=document.getElementById("setup-log-content");'
html[#html+1] = 'btn.disabled=true;btn.textContent="⏳ 安装中...";'
@@ -192,8 +211,8 @@ act.cfgvalue = function(self, section)
html[#html+1] = 'logEl.textContent+="安装路径: "+install_path+"\\n";'
html[#html+1] = 'logEl.textContent+="正在启动安装...\\n";'
html[#html+1] = '(new XHR()).post("' .. ctl_url .. '?action=setup&version="+encodeURIComponent(version)+"&install_path="+encodeURIComponent(install_path),{token:ocCsrfToken},function(x){'
html[#html+1] = 'try{JSON.parse(x.responseText);}catch(e){}'
html[#html+1] = 'ocPollSetupLog();'
html[#html+1] = 'var accepted=ocAcceptedResponse(x);'
html[#html+1] = 'if(accepted.ok){ocPollSetupLog();}else{ocSetupRequestRejected(btn,"📦 安装运行环境",accepted.message);}'
html[#html+1] = '});'
html[#html+1] = '}'
@@ -203,6 +222,7 @@ act.cfgvalue = function(self, section)
html[#html+1] = 'function ocPollSetupLog(){'
html[#html+1] = 'if(_setupTimer)clearInterval(_setupTimer);'
html[#html+1] = '_lastLogLen=0;'
html[#html+1] = '_setupPollErrors=0;'
html[#html+1] = '_autoScrollEnabled=true;' -- 初始状态: 启用自动滚动
html[#html+1] = 'var logEl=document.getElementById("setup-log-content");'
-- 绑定滚动事件监听器 (只绑定一次)
@@ -221,7 +241,9 @@ act.cfgvalue = function(self, section)
html[#html+1] = '_setupTimer=setInterval(function(){'
html[#html+1] = '(new XHR()).get("' .. log_url .. '",null,function(x){'
html[#html+1] = 'try{'
html[#html+1] = 'if(!x||x.status<200||x.status>=300)throw new Error("HTTP "+(x&&x.status||0));'
html[#html+1] = 'var r=JSON.parse(x.responseText);'
html[#html+1] = '_setupPollErrors=0;'
html[#html+1] = 'var logEl=document.getElementById("setup-log-content");'
html[#html+1] = 'var statusEl=document.getElementById("setup-log-status");'
html[#html+1] = 'if(r.log&&r.log.length>_lastLogLen){'
@@ -242,17 +264,17 @@ act.cfgvalue = function(self, section)
html[#html+1] = 'clearInterval(_setupTimer);_setupTimer=null;'
html[#html+1] = 'ocSetupDone(false,logEl.textContent);'
html[#html+1] = '}'
html[#html+1] = '}catch(e){}'
html[#html+1] = '}catch(e){_setupPollErrors++;if(_setupPollErrors>=3)ocSetupPollingUnknown();}'
html[#html+1] = '});'
html[#html+1] = '},1500);'
html[#html+1] = '}'
-- 安装完成处理
html[#html+1] = 'function ocSetupDone(ok,log){'
html[#html+1] = 'var btn=document.getElementById("btn-setup");'
html[#html+1] = 'var btn=document.getElementById(_setupOperation==="core"?"btn-core-upgrade":"btn-setup");'
html[#html+1] = 'var statusEl=document.getElementById("setup-log-status");'
html[#html+1] = 'var resultEl=document.getElementById("setup-log-result");'
html[#html+1] = 'btn.disabled=false;btn.textContent="📦 安装运行环境";'
html[#html+1] = 'if(btn){btn.disabled=false;btn.textContent=_setupOperation==="core"?(ok?"⬆️ 核心升级完成":"⬆️ 重试核心升级"):"📦 安装运行环境";}'
html[#html+1] = 'resultEl.style.display="block";'
html[#html+1] = 'if(ok){'
html[#html+1] = 'statusEl.innerHTML="<span style=\\"color:#1a7f37;\\">✅ 安装完成</span>";'
@@ -408,6 +430,7 @@ act.cfgvalue = function(self, section)
html[#html+1] = '}catch(e){el.innerHTML="<span style=\\"color:red\\">❌ 检测失败</span>";}'
html[#html+1] = '});}'
html[#html+1] = 'function ocOpenclawCoreUpgrade(){'
html[#html+1] = '_setupOperation="core";'
html[#html+1] = 'var ver=window._coreLatestVer||"2026.9.1";'
html[#html+1] = 'if(!confirm("确定要将 OpenClaw 核心升级到 v"+ver+"?\\n\\n升级将执行安全事务:自动全量备份状态、SQLite 数据库预检与配置平滑迁移。"))return;'
html[#html+1] = 'var btn=document.getElementById("btn-core-upgrade");'
@@ -423,7 +446,8 @@ act.cfgvalue = function(self, section)
html[#html+1] = 'statusEl.innerHTML="<span style=\\"color:#7aa2f7;\\">⏳ 核心升级中 (执行状态机事务)...</span>";'
html[#html+1] = 'resultEl.style.display="none";'
html[#html+1] = '(new XHR()).post("' .. service_ctl_url .. '",{action:"upgrade",version:ver,token:ocCsrfToken},function(x){'
html[#html+1] = 'ocPollSetupLog();'
html[#html+1] = 'var accepted=ocAcceptedResponse(x);'
html[#html+1] = 'if(accepted.ok){ocPollSetupLog();}else{ocSetupRequestRejected(btn,"⬆️ 重试核心升级",accepted.message);}'
html[#html+1] = '});'
html[#html+1] = '}'
@@ -447,8 +471,8 @@ act.cfgvalue = function(self, section)
html[#html+1] = 'statusEl.innerHTML="<span style=\\"color:#7aa2f7;\\">⏳ 插件升级中...</span>";'
html[#html+1] = 'resultEl.style.display="none";'
html[#html+1] = '(new XHR()).post("' .. plugin_upgrade_url .. '?version="+encodeURIComponent(ver),{token:ocCsrfToken},function(x){'
html[#html+1] = 'try{JSON.parse(x.responseText);}catch(e){}'
html[#html+1] = 'ocPollPluginUpgradeLog();'
html[#html+1] = 'var accepted=ocAcceptedResponse(x);'
html[#html+1] = 'if(accepted.ok){ocPollPluginUpgradeLog();}else{if(btn){btn.disabled=false;btn.textContent="⬆️ 重试插件升级";}statusEl.textContent="❌ "+accepted.message;logEl.textContent+=accepted.message+"\\n";}'
html[#html+1] = '});'
html[#html+1] = '}'
@@ -482,9 +506,10 @@ act.cfgvalue = function(self, section)
html[#html+1] = '}'
html[#html+1] = '}catch(e){'
html[#html+1] = '_pluginPollErrors++;'
html[#html+1] = 'if(_pluginPollErrors>=8){'
html[#html+1] = 'if(_pluginPollErrors>=3){'
html[#html+1] = 'clearInterval(_pluginUpgradeTimer);_pluginUpgradeTimer=null;'
html[#html+1] = 'ocPluginUpgradeDone(true);'
html[#html+1] = 'var btn=document.getElementById("btn-plugin-upgrade");if(btn){btn.disabled=false;btn.textContent="⬆️ 重试插件升级";}'
html[#html+1] = 'statusEl.textContent="⚠️ 状态查询连续失败,请手动刷新确认;后台任务可能仍在运行。";'
html[#html+1] = '}'
html[#html+1] = '}'
html[#html+1] = '});'