请选择 进入手机版 | 继续访问电脑版
问答 查看内容
返回列表

【产品AI问答助手】内置到BI产品操作指南

97 1
发表于 2025-4-9 16:29:01 | 查看全部 阅读模式
需要管理员权限来操作
1、进入管理中心,点击右上角【新建插件】
image.png

                               
登录/注册后可看大图
2、填写相关信息后点击【确定】
image (1).png

                               
登录/注册后可看大图
3、找到刚刚创建的插件,点击【编辑代码】按钮来添加代码
image (2).png

4、将以下代码复制到文本框中,点击【确定】。
image (3).png

                               
登录/注册后可看大图
如果要限制只有编辑者才能看到的话需要把代码中第8行const editorOnly = false; 修改为 const editorOnly = true;
  1. GD.on('gd-ready', () => {
  2.     const isMobileUrl = window.location.pathname.startsWith('/m');
  3.     if (isMobileUrl) {
  4.         return;        
  5.     }
  6.   
  7.     // 如果要限制只有编辑者才可以看到的话需要把下面这行的false改成true
  8.     const editorOnly = false;
  9.     const userInfo = GD.getUser();
  10.     if (userInfo.role[0] === 'participant' && editorOnly) {
  11.       return;
  12.     }
  13.     const innerWidth = window.innerWidth;
  14.     const userAgent = navigator.userAgent || navigator.vendor || window.opera;
  15.     const isMobile = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent.toLowerCase()) || innerWidth < 480;
  16.     const isPrintPage = window.location.pathname.includes('/print');
  17.     if (window.self === window.top && !isMobile && !isPrintPage) {
  18.       // Create a button and append it to the document body
  19.       const button = document.createElement('div');
  20.       button.style.position = 'fixed';
  21.       button.style.bottom = '20px';
  22.       button.style.right = '10px';
  23.       button.style.backgroundColor = '#fff';
  24.       button.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.1)';
  25.       button.style.cursor = 'pointer';
  26.       button.style.padding = '8px 8px';
  27.       button.style.borderRadius = '30px';
  28.       button.style.display = 'flex';
  29.       button.style.flexDirection = 'column';
  30.       button.style.alignItems = 'center';
  31.       button.style.zIndex = 1000;
  32.       document.body.appendChild(button);
  33.   
  34.       // Modify the button to include an image and text in a vertical layout
  35.       button.innerHTML = '';
  36.       
  37.       const dragSvg = '<svg t="1743060843660" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3628" width="14"><path fill="#00bebe" d="M219.428571 585.142857c-36.571429 0-73.142857 36.571429-73.142857 73.142857s36.571429 73.142857 73.142857 73.142857 73.142857-36.571429 73.142858-73.142857-36.571429-73.142857-73.142858-73.142857z m585.142858-146.285714c36.571429 0 73.142857-36.571429 73.142857-73.142857s-36.571429-73.142857-73.142857-73.142857-73.142857 36.571429-73.142858 73.142857 36.571429 73.142857 73.142858 73.142857zM219.428571 292.571429c-36.571429 0-73.142857 36.571429-73.142857 73.142857s36.571429 73.142857 73.142857 73.142857 73.142857-36.571429 73.142858-73.142857-36.571429-73.142857-73.142858-73.142857z m585.142858 292.571428c-36.571429 0-73.142857 36.571429-73.142858 73.142857s36.571429 73.142857 73.142858 73.142857 73.142857-36.571429 73.142857-73.142857-36.571429-73.142857-73.142857-73.142857zM512 292.571429c-36.571429 0-73.142857 36.571429-73.142857 73.142857s36.571429 73.142857 73.142857 73.142857 73.142857-36.571429 73.142857-73.142857-36.571429-73.142857-73.142857-73.142857z m0 292.571428c-36.571429 0-73.142857 36.571429-73.142857 73.142857s36.571429 73.142857 73.142857 73.142857 73.142857-36.571429 73.142857-73.142857-36.571429-73.142857-73.142857-73.142857z" p-id="3629"></path></svg>'
  38.    
  39.       const dragContainer = document.createElement('div');
  40.       dragContainer.innerHTML = dragSvg;
  41.       dragContainer.style.display = 'block';
  42.       dragContainer.style.margin = '0 auto';
  43.    
  44.       const text = document.createElement('div');
  45.       text.innerText = 'AI助手';
  46.       text.style.color = '#00bebe';
  47.       text.style.width = '16px';
  48.       text.style.display = 'block';
  49.       text.style.textAlign = 'center';
  50.    
  51.       button.appendChild(dragContainer);
  52.       button.appendChild(text);

  53.        // 添加拖拽功能
  54.       let isDragging = false;
  55.       let currentX;
  56.       let currentY;
  57.       let initialX;
  58.       let initialY;
  59.       let xOffset = 0;
  60.       let yOffset = 0;
  61.       let hasMoved = false;

  62.       button.addEventListener('mousedown', dragStart, { passive: false, capture: true });
  63.       document.addEventListener('mousemove', drag, { passive: false, capture: true });
  64.       document.addEventListener('mouseup', dragEnd);

  65.       function dragStart(e) {
  66.         e.preventDefault();
  67.         e.stopPropagation();
  68.         initialX = e.clientX - xOffset;
  69.         initialY = e.clientY - yOffset;
  70.         hasMoved = false;

  71.         if (e.target === button || button.contains(e.target)) {
  72.           isDragging = true;
  73.           button.style.backgroundColor = 'rgba(255, 255, 255, 0.9)';
  74.           button.style.boxShadow = '0 0 15px rgba(0, 190, 190, 0.3)';
  75.           button.style.border = '1px solid #00bebe';
  76.         }
  77.       }

  78.       function drag(e) {
  79.         if (isDragging) {
  80.           e.preventDefault();
  81.           e.stopPropagation();
  82.           currentX = e.clientX - initialX;
  83.           currentY = e.clientY - initialY;
  84.           if (Math.abs(currentX) > 5 || Math.abs(currentY) > 5) {
  85.             hasMoved = true;
  86.           }
  87.           xOffset = currentX;
  88.           yOffset = currentY;

  89.           setTranslate(currentX, currentY, button);
  90.         }
  91.       }

  92.       function setTranslate(xPos, yPos, el) {
  93.         el.style.transform = `translate3d(${xPos}px, ${yPos}px, 0)`;
  94.       }

  95.       function dragEnd(e) {
  96.         if (e) {
  97.           e.preventDefault();
  98.         }
  99.         initialX = currentX;
  100.         initialY = currentY;
  101.         isDragging = false;
  102.         button.style.backgroundColor = '#fff';
  103.         button.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.1)';
  104.         button.style.border = 'none';
  105.       }
  106.    
  107.       // Add event listener to the button to show the modal
  108.       button.addEventListener('click', () => {
  109.         if (!hasMoved) {
  110.           modal.style.display = 'block';
  111.         }
  112.       });
  113.     }
  114.   
  115.   // Create a modal container
  116.   const modal = document.createElement('div');
  117.   modal.style.position = 'fixed';
  118.   modal.style.bottom = '0px';
  119.   modal.style.right = '0px';
  120.   modal.style.width = '480px';
  121.   modal.style.height = '100vh';
  122.   modal.style.backgroundColor = 'white';
  123.   modal.style.border = '1px solid #e7e9e8';
  124.   modal.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.1)';
  125.   modal.style.zIndex = '1000';
  126.   modal.style.display = 'none'; // Initially hidden
  127.   
  128.   // Create a head container
  129.   const head = document.createElement('div');
  130.   head.style.display = 'flex';
  131.   head.style.justifyContent = 'space-between';
  132.   head.style.alignItems = 'center';
  133.   head.style.height = '48px';
  134.   head.style.padding = '0 12px';
  135.   head.style.borderBottom = '1px solid #e7e9e8';
  136.   head.style.backgroundColor = '#fafafa';
  137.   
  138.   // Create a title for the modal
  139.   const title = document.createElement('span');
  140.   title.innerText = 'AI助手';
  141.   title.style.color = '#00bebe';
  142.   title.style.fontSize = '16px';
  143.   title.style.fontWeight = '500';
  144.   head.appendChild(title);
  145.   
  146.   // Create a close button and append it to the head
  147.   const closeButton = document.createElement('span');
  148.   closeButton.innerText = '关闭';
  149.   closeButton.style.color = '#00bebe';
  150.   closeButton.style.cursor = 'pointer';
  151.   head.appendChild(closeButton);
  152.   
  153.   // Append the head to the modal
  154.   modal.appendChild(head);
  155.   
  156.   // Create an iframe and append it to the modal
  157.   const iframe = document.createElement('iframe');  
  158.   iframe.src = 'https://robot.guandata.com/galaxy' + '?cid=' + window.location.host + '&uid=' + userInfo.uId;
  159.   iframe.style.width = '100%';
  160.   iframe.style.height = 'calc(100vh - 48px)'; // Adjust height to account for head
  161.   modal.appendChild(iframe);
  162.   
  163.   // Append the modal to the document body
  164.   document.body.appendChild(modal);
  165.   
  166.   // Add event listener to the close button to hide the modal
  167.   closeButton.addEventListener('click', () => {
  168.     modal.style.display = 'none';
  169.   });
  170. })
复制代码



5、通过点击【本地调试】进行本地浏览器测试,测试通过后切换【应用状态】到开启(绿色)即可发布
image (4).png

                               
登录/注册后可看大图
6、效果如图所示,如果页面上没有出现,可以强制刷新、清理缓存或者重启浏览器

                               
登录/注册后可看大图
image (5).png

7、有任何问题或者建议都可以通过点击此处进行反馈
image (6).png

                               
登录/注册后可看大图


评论1

赖兴荣楼主Lv.9 发表于 2025-4-9 16:29:46 | 查看全部
有什么问题可以联系我或者直接评论

回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

微信服务号
联系我们
电话:400-880-0750
邮箱:hello@guandata.com
Copyright © 2001-2025 观远社区 版权所有 All Rights Reserved. 浙 ICP 备15006424号-3
去回复 去发帖 返回顶部
快速回复 返回顶部 返回列表