Xiaoshu-DHzxWqld.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import{u as $,r as l,p as R,o as r,h as m,w as T,d as j,F as q,i as p,k as g,aq as f,T as t,ar as O}from"./index-CRr91q2n.js";import I from"./ContentContainer-CvlOYoec.js";import{u as M}from"./use-logout-B88PQWYa.js";import{u as F}from"./use-current-user-C9DeP88w.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./login-CHypfzTa.js";const z={__name:"Xiaoshu",props:{},setup(h){const _=$(),b=M(),{bus:c}=f,x=h,s=l(!1),u=l([]),y=t("XIAOSHU_URL"),v=t("WEBSOCKET_BASE_URL"),k=t("API_BASE_URL"),w=t("ASSETS_BASE_URL"),S={padding:0};function L(){const e={"system:conversation:board":"/chat/board","system:conversation:hisroty":"/chat/history","system:menu:intelligent":"/intelligent","system:menu:knowledge":"/knowledge","system:menu:model":"/model","system:menu:permission":"/permission","system:menu:conversation":"/chat/qa","system:conversation:qa":"/chat/qa","system:group":"/permission/group","system:dept":"/permission/org","system:role":"/permission/role","system:user":"/permission/account","system:menu":"/permission/resource"};let o="";for(let n in e)if(O(n)){o=e[n];break}return o}return R(()=>{const e=F(),o=e.token,d={userName:e.username,token:o},E=JSON.stringify(d),i=L(),A=`
  2. window.WEBSOCKET_BASE_URL = '${v}';
  3. window.API_BASE_URL = '${k}';
  4. window.ASSETS_BASE_URL = '${w}';
  5. localStorage.setItem('xintongxiaoshu', '${E}');
  6. const observer = new MutationObserver((mutationsList) => {
  7. mutationsList.forEach((mutation) => {
  8. if (mutation.type === "childList") {
  9. // console.log("A child node has been added or removed.");
  10. // console.log(mutation);
  11. if(mutation.addedNodes.length > 0){
  12. // console.log('新节点被添加', mutation.addedNodes);
  13. // console.log(mutation);
  14. const addedNodes = mutation.addedNodes;
  15. addedNodes.forEach((item, index) => {
  16. const klass_name = item.className;
  17. if(klass_name === 'arco-trigger-popup arco-trigger-position-rt arco-popover'){
  18. // popover
  19. // 可能是用户名,账号
  20. const box = item.querySelector('.xiaoshu-aside-left-menus-pop-container');
  21. const div = document.createElement('div');
  22. div.setAttribute('class', 'xiaoshu-aside-left-menus-logout-btn');
  23. const span = document.createElement('span');
  24. span.innerText = '退出登录'
  25. div.appendChild(span);
  26. box.appendChild(div);
  27. div.addEventListener('click', () => {
  28. window.$wujie?.bus.$emit("xiaoshuAsideLogout");
  29. });
  30. }
  31. });
  32. }
  33. if(mutation.removedNodes.length > 0){
  34. // console.log('节点被移除', mutation.removedNodes);
  35. // console.log(mutation);
  36. }
  37. } else if (mutation.type === "attributes") {
  38. // console.log('属性被修改了');
  39. }else{
  40. // console.log('其他');
  41. }
  42. });
  43. });
  44. observer.observe(document.body, {childList: true, subtree: true})
  45. `;let a="";i?a=`
  46. const box = document.querySelector('.xiaoshu-aside-left-menus-container');
  47. if(box){
  48. const btn = document.createElement('div');
  49. box.appendChild(btn);
  50. btn.innerHTML = '<span class="xiaoshu-aside-left-back-btn">返回</span>';
  51. btn.addEventListener('click', () => {
  52. window.$wujie?.bus.$emit("xiaoshuAsideBack");
  53. });
  54. }
  55. `:a="console.log('cant back');";const B=`
  56. .xiaoshu-aside-left-back-btn{
  57. width: 100%;
  58. height: 40px;
  59. line-height: 40px;
  60. text-align: center;
  61. background-color: #165dff;
  62. color: #fff;
  63. display: inline-block;
  64. cursor: pointer;
  65. }
  66. .xiaoshu-aside-left-menus-pop-container {}
  67. .xiaoshu-aside-left-menus-actions-container{
  68. display: none;
  69. }
  70. .user-popover.xiaoshu-aside-left-menus-pop-container>div.item{
  71. display: none;
  72. }
  73. .user-popover.xiaoshu-aside-left-menus-pop-container>header{
  74. padding-bottom: 0;
  75. border-bottom: none;
  76. }
  77. .xiaoshu-aside-left-menus-logout-btn{
  78. cursor: pointer;
  79. text-align: center;
  80. margin-top: 10px;
  81. }
  82. `,C=`
  83. .xiaoshu-loading-container {
  84. position: fixed;
  85. top: 0;
  86. left: 0;
  87. right: 0;
  88. bottom: 0;
  89. background: rgba(205, 230, 248, 0.5);
  90. display: flex;
  91. justify-content: center;
  92. align-items: center;
  93. z-index: 9999;
  94. }
  95. .xiaoshu-loading-spinner {
  96. border: 4px solid #f3f3f3;
  97. border-top: 4px solid #3498db;
  98. border-radius: 50%;
  99. width: 40px;
  100. height: 40px;
  101. animation: spin 2s linear infinite;
  102. }
  103. @keyframes spin {
  104. 0% { transform: rotate(0deg); }
  105. 100% { transform: rotate(360deg); }
  106. }
  107. `,N=`
  108. // 显示 loading 层
  109. document.body.insertAdjacentHTML('afterbegin', '<div class="xiaoshu-loading-container"><div class="xiaoshu-loading-spinner"></div></div>');
  110. `,U=`
  111. // 页面加载完成后,移除 loading 层
  112. window.addEventListener('load', function() {
  113. const loadingContainer = document.querySelector('.xiaoshu-loading-container');
  114. if (loadingContainer) {
  115. loadingContainer.style.display = 'none';
  116. }
  117. });`;c.$on("xiaoshuAsideBack",function(){i&&_.push(i)}),c.$on("xiaoshuAsideLogout",function(){b()}),u.value=[{jsBeforeLoaders:[{content:A},{content:N}]},{jsAfterLoaders:[{content:a},{content:U}]},{cssAfterLoaders:[{content:B},{content:C}]}],s.value=!0}),(e,o)=>(r(),m(I,{containerStyle:S},{default:T(()=>[s.value?p("",!0):(r(),j(q,{key:0},[],64)),s.value?(r(),m(g(f),{key:1,width:"100%",height:"100%",name:"xiaoshu",url:g(y),sync:!1,props:x,plugins:u.value},null,8,["url","props","plugins"])):p("",!0)]),_:1}))}};export{z as default};