From version 12.1
edited by Jiahao Lai
on 2026/03/26 15:46
on 2026/03/26 15:46
Change comment:
There is no comment for this version
To version 17.1
edited by Jiahao Lai
on 2026/03/26 16:12
on 2026/03/26 16:12
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -187,53 +187,24 @@ 187 187 {{/velocity}} 188 188 189 189 190 - 191 191 {{html clean="false"}} 192 -< div id="llm-chat-widget"style="position:fixed;right:20px;bottom:20px;z-index:9999;"></div>193 - 191 +<script src="/webjars/wiki%3Awonway/marked/4.0.2/marked.min.js"></script> 192 +<script src="/webjars/wiki%3Awonway/dompurify/2.3.10/purify.min.js"></script> 194 194 <script> 194 +// 初始化 AI 浮窗(主 wiki 专用,直接复用子 wiki 资源) 195 195 document.addEventListener('DOMContentLoaded', function() { 196 - setTimeout(async () => { 197 - try { 198 - // 1. 先加载依赖库 marked.js(子 wiki 用的版本) 199 - await new Promise((resolve, reject) => { 200 - const markedScript = document.createElement('script'); 201 - markedScript.src = 'https://docs.we-con.com.cn/webjars/wiki%3Awonway/marked/4.0.2/marked.min.js'; 202 - markedScript.onload = resolve; 203 - markedScript.onerror = reject; 204 - document.body.appendChild(markedScript); 205 - }); 206 - console.log("✅ marked.js 加载成功"); 196 + // 强制加载浮窗样式 197 + const link = document.createElement('link'); 198 + link.rel = 'stylesheet'; 199 + link.href = '/webjars/wiki%3Awonway/application-ai-llm-chat-webjar/0.7.2/chatWidget.css'; 200 + document.head.appendChild(link); 207 207 208 - // 2. 加载 CSS 209 - await new Promise((resolve) => { 210 - const link = document.createElement('link'); 211 - link.rel = 'stylesheet'; 212 - link.href = 'https://docs.we-con.com.cn/webjars/wiki%3Awonway/application-ai-llm-chat-webjar/0.7.2/chatWidget.css'; 213 - link.onload = resolve; 214 - document.head.appendChild(link); 215 - }); 216 - 217 - // 3. 加载 chatWidget.js 218 - await new Promise((resolve) => { 219 - const script = document.createElement('script'); 220 - script.src = 'https://docs.we-con.com.cn/webjars/wiki%3Awonway/application-ai-llm-chat-webjar/0.7.2/chatWidget.js'; 221 - script.onload = resolve; 222 - document.body.appendChild(script); 223 - }); 224 - 225 - // 4. 启动浮窗 226 - if (window.LLMChatWidget && typeof LLMChatWidget.init === 'function') { 227 - LLMChatWidget.init(); 228 - console.log("✅ 浮窗启动成功!"); 229 - } else { 230 - throw new Error("LLMChatWidget 未初始化"); 231 - } 232 - } catch (e) { 233 - console.error("❌ 加载失败", e); 234 - alert("浮窗加载失败:" + e.message); 235 - } 236 - }, 1000); 202 + // 加载浮窗主脚本 203 + const script = document.createElement('script'); 204 + script.src = '/webjars/wiki%3Awonway/application-ai-llm-chat-webjar/0.7.2/chatWidget.js'; 205 + script.dataset.wikiName = 'wonway'; 206 + script.dataset.baseUrl = '/xwiki/'; 207 + document.body.appendChild(script); 237 237 }); 238 238 </script> 239 239 {{/html}}