(async function(){console.log("[Color] 模块脚本启动 (JS 重构版)...");const container=document.getElementById("color_container");const contentArea=document.getElementById("color_content");if(!container||!contentArea){console.error("[Color] 找不到容器元素，请检查 index.html 结构");return}container.style.display="block";try{const config=window.pluginConfig||{};const userToken=await window.configAPI.getUserToken();const baseUrl=(config.api_base_url||"https://www.bgxiong.com").trim();const endpoint=config.color_list_endpoint||"/client/v1/color/list";let url=`${baseUrl}${endpoint}`;console.log(`[Color] 请求调色列表 HTML: ${url}`);const response=await fetch(url,{method:"GET",headers:{Accept:"text/html",Authorization:userToken?`Bearer ${userToken}`:"","Content-Type":"application/json"}});if(!response.ok){throw new Error(`HTTP ${response.status}: ${response.statusText}`)}const htmlContent=await response.text();if(htmlContent&&htmlContent.trim().length>0){contentArea.innerHTML=htmlContent;console.log("[Color] 内容已注入 ✓")}else{contentArea.innerHTML=`\n                <div class="building">\n                    <p>🚧 调色模块努力建設中啊...</p>\n                    <p>敬请期待！</p>\n                </div>\n            `}}catch(error){console.error("[Color] 加载失败:",error);const errorMsg=typeof decodeUnicodeString==="function"?decodeUnicodeString(error.message):error.message;const finalMsg="网络服务器维护中，请稍后再试！"+errorMsg;if(typeof showErrorInContent==="function"){showErrorInContent(finalMsg,[{text:"重试",callback:async()=>{const colorBtn=document.querySelector(".main_left_menu_item:nth-child(2)");if(colorBtn&&window.ModuleLoader){await window.ModuleLoader.load("color",colorBtn)}}}])}else{contentArea.innerHTML=`\n                <div class="error-notice-card">\n                    <p>${finalMsg}</p>\n                    <button id="btn_retry_color" class="btn-retry">🔄 重试</button>\n                </div>\n            `;document.getElementById("btn_retry_color")?.addEventListener("click",()=>{const colorBtn=document.querySelector(".main_left_menu_item:nth-child(2)");if(colorBtn&&window.ModuleLoader){window.ModuleLoader.load("color",colorBtn)}})}}finally{}})();