Home

Version 13.1 by Jiahao Lai on 2026/03/26 15:47
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Help.Code.VelocityMacros]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Home.WebHome]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Home.WebHome]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Home.WebHome]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Home.WebHome]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Home.WebHome]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Home.WebHome]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

document.addEventListener('DOMContentLoaded', function() {
  // 延长等待时间,确保配置和依赖完全加载
  setTimeout(async () => {
    try {
      // 1. 加载 marked.js 依赖
      await new Promise((resolve) => {
        const s = document.createElement('script');
        s.src = 'https://docs.we-con.com.cn/webjars/wiki%3Awonway/marked/4.0.2/marked.min.js';
        s.onload = resolve;
        document.body.appendChild(s);
      });

      // 2. 加载 CSS
      await new Promise((resolve) => {
        const l = document.createElement('link');
        l.rel = 'stylesheet';
        l.href = 'https://docs.we-con.com.cn/webjars/wiki%3Awonway/application-ai-llm-chat-webjar/0.7.2/chatWidget.css';
        l.onload = resolve;
        document.head.appendChild(l);
      });

      // 3. 加载 chatWidget.js
      await new Promise((resolve) => {
        const s = document.createElement('script');
        s.src = 'https://docs.we-con.com.cn/webjars/wiki%3Awonway/application-ai-llm-chat-webjar/0.7.2/chatWidget.js';
        s.onload = resolve;
        document.body.appendChild(s);
      });

      // 4. 循环等待,直到 LLM 配置就绪
      let retries = 0;
      const maxRetries = 20; // 最多等 20*200ms = 4秒
      const waitForLLM = () => {
        if (window.LLMChatWidget && typeof LLMChatWidget.init === 'function') {
          LLMChatWidget.init();
          console.log("✅ 浮窗启动成功!");
        } else if (retries < maxRetries) {
          retries++;
          setTimeout(waitForLLM, 200);
        } else {
          throw new Error("LLM 配置超时未就绪");
        }
      };
      waitForLLM();
    } catch (e) {
      console.error("❌ 最终失败", e);
      alert("浮窗加载失败:" + (e.message || "未知错误"));
    }
  }, 1500); // 延长初始等待时间
});