const ModuleLoader={currentModule:null,cache:{},async load(moduleName,menuElement){const container=document.getElementById("active_content_container");if(container){showLoading();try{const modulePath=`./modules/${moduleName}`;if(!this.cache[moduleName]){const response=await fetch(`${modulePath}/index.html`);if(!response.ok)throw new Error(`找不到模块: ${moduleName}`);this.cache[moduleName]=await response.text()}container.innerHTML=this.cache[moduleName],this.cleanupScripts();const script=document.createElement("script");script.className="module-dynamic-script",script.src=`${modulePath}/renderer.js?t=${Date.now()}`,document.body.appendChild(script),this.loadModuleStyle(moduleName,modulePath),menuElement&&(document.querySelectorAll(".main_left_menu_item").forEach(el=>el.classList.remove("active")),menuElement.classList.add("active")),this.currentModule=moduleName}catch(err){container.innerHTML=`<div class="error-info">模块加载失败: ${err.message}</div>`}finally{hideLoading()}}},loadModuleStyle(name,path){let link=document.getElementById(`style-${name}`);link||(link=document.createElement("link"),link.id=`style-${name}`,link.rel="stylesheet",link.href=`${path}/style.css`,fetch(link.href,{method:"HEAD"}).then(res=>{res.ok&&document.head.appendChild(link)}))},cleanupScripts(){document.querySelectorAll(".module-dynamic-script").forEach(s=>s.remove())}};