fix: 恢复被误删的 scripts.forEach(function(code){ (3处)

This commit is contained in:
qinglong
2026-06-14 11:12:07 +08:00
parent 66dc4cdfbf
commit f6117cbc5f
2 changed files with 4 additions and 1 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=0710"></script> <script src="./static/js/app.js?v=0711"></script>
</body> </body>
</html> </html>
+3
View File
@@ -124,6 +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){
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); }
}); });
@@ -186,6 +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){
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); }
}); });
@@ -251,6 +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){
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){}
}); });