debug: loadPluginPage 加日志追踪错误来源

This commit is contained in:
qinglong
2026-06-14 11:07:29 +08:00
parent 29e7b2be41
commit 3e632252ab
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -79,6 +79,6 @@
<script src="./static/js/chart.js?v=0603"></script> <script src="./static/js/chart.js?v=0603"></script>
<!-- 🟢 2. 再加载主逻辑 --> <!-- 🟢 2. 再加载主逻辑 -->
<script src="./static/js/app.js?v=0706"></script> <script src="./static/js/app.js?v=0707"></script>
</body> </body>
</html> </html>
+3 -3
View File
@@ -124,7 +124,7 @@ async function loadPage(pageName) {
var cleanHtml = html.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi, function(m,code){ scripts.push(code.trim()); return ''; }); var cleanHtml = html.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi, function(m,code){ scripts.push(code.trim()); return ''; });
content.innerHTML = cleanHtml; content.innerHTML = cleanHtml;
scripts.forEach(function(code){ scripts.forEach(function(code){ console.log("loadPluginPage executing script from:", pluginName, "length:", code.length);
try { var s=document.createElement('script'); s.textContent=code; document.head.appendChild(s); document.head.removeChild(s); } try { var s=document.createElement('script'); s.textContent=code; document.head.appendChild(s); document.head.removeChild(s); }
catch(ex){ console.error('Inline script error:', ex); } catch(ex){ console.error('Inline script error:', ex); }
}); });
@@ -187,7 +187,7 @@ async function loadPluginPage(pluginName) {
content.style.padding = '0'; content.style.padding = '0';
content.innerHTML = '<div class="plugin-page-root"><style>'+styles+'</style>'+clean+'</div>'; content.innerHTML = '<div class="plugin-page-root"><style>'+styles+'</style>'+clean+'</div>';
scripts.forEach(function(code){ scripts.forEach(function(code){ console.log("loadPluginPage executing script from:", pluginName, "length:", code.length);
try { var s=document.createElement('script'); s.textContent=code; document.head.appendChild(s); document.head.removeChild(s); } try { var s=document.createElement('script'); s.textContent=code; document.head.appendChild(s); document.head.removeChild(s); }
catch(ex){ console.error('Plugin script error:', ex); } catch(ex){ console.error('Plugin script error:', ex); }
}); });
@@ -253,7 +253,7 @@ window.pickPath = function(mode, callback) {
var clean = html.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi, function(m,code){ scripts.push(code.trim()); return ''; }); var clean = html.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi, function(m,code){ scripts.push(code.trim()); return ''; });
contentArea.innerHTML = clean; contentArea.innerHTML = clean;
// Execute scripts // Execute scripts
scripts.forEach(function(code){ scripts.forEach(function(code){ console.log("loadPluginPage executing script from:", pluginName, "length:", code.length);
try { var s=document.createElement('script'); s.textContent=code; document.head.appendChild(s); document.head.removeChild(s); } try { var s=document.createElement('script'); s.textContent=code; document.head.appendChild(s); document.head.removeChild(s); }
catch(ex){} catch(ex){}
}); });