瀏覽代碼

添加并修改ai聊天

yangg 8 月之前
父節點
當前提交
7210a61636
共有 34 個文件被更改,包括 298 次插入55 次删除
  1. 0 0
      dist/index.html
  2. 0 0
      dist/static/css/app.9ca2e192.css
  3. 0 0
      dist/static/css/chunk-09f78c22.e30e9787.css
  4. 0 0
      dist/static/css/chunk-13ebf84f.360612b2.css
  5. 0 0
      dist/static/css/chunk-277ceec9.6f8877c6.css
  6. 0 0
      dist/static/css/chunk-41d431f5.e30e9787.css
  7. 1 0
      dist/static/css/chunk-59cff762.937bf34d.css
  8. 0 0
      dist/static/css/chunk-9235c1ae.e30e9787.css
  9. 0 0
      dist/static/css/chunk-995a9622.9733ac4d.css
  10. 0 0
      dist/static/css/chunk-d09c27ba.d40db7bc.css
  11. 0 0
      dist/static/css/chunk-d4c547ca.e30e9787.css
  12. 0 0
      dist/static/js/app.bad222d9.js
  13. 0 0
      dist/static/js/app.d88323ba.js
  14. 0 0
      dist/static/js/chunk-09f78c22.28066213.js
  15. 0 0
      dist/static/js/chunk-13ebf84f.d5d5a373.js
  16. 0 0
      dist/static/js/chunk-277ceec9.e1ef13d9.js
  17. 0 0
      dist/static/js/chunk-36bc9124.4d8834ba.js
  18. 0 0
      dist/static/js/chunk-3d9675b3.510a3609.js
  19. 0 0
      dist/static/js/chunk-3da09771.810d31a7.js
  20. 0 0
      dist/static/js/chunk-41d431f5.7c626c01.js
  21. 1 0
      dist/static/js/chunk-59cff762.1daf2cd6.js
  22. 0 0
      dist/static/js/chunk-9235c1ae.c3bfc16e.js
  23. 0 0
      dist/static/js/chunk-995a9622.41227a32.js
  24. 0 0
      dist/static/js/chunk-d09c27ba.b4dc3f9d.js
  25. 0 0
      dist/static/js/chunk-d4c547ca.c5efbcbd.js
  26. 8 0
      src/assets/js/particles.min.js
  27. 86 2
      src/components/webAi/css/ChatBox.css
  28. 91 41
      src/components/webAi/index.vue
  29. 34 0
      src/components/webAi/js/ChatBox.js
  30. 3 1
      src/layout/components/Navbar.vue
  31. 7 7
      src/router/index.js
  32. 52 0
      src/views/chatPage/index.vue
  33. 1 1
      src/views/document/com/menus.vue
  34. 14 3
      src/views/document/create.vue

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.9ca2e192.css


+ 0 - 0
dist/static/css/chunk-3d9675b3.e30e9787.css → dist/static/css/chunk-09f78c22.e30e9787.css


+ 0 - 0
dist/static/css/chunk-36bc9124.360612b2.css → dist/static/css/chunk-13ebf84f.360612b2.css


+ 0 - 0
dist/static/css/chunk-b6791022.6f8877c6.css → dist/static/css/chunk-277ceec9.6f8877c6.css


+ 0 - 0
dist/static/css/chunk-3da09771.e30e9787.css → dist/static/css/chunk-41d431f5.e30e9787.css


+ 1 - 0
dist/static/css/chunk-59cff762.937bf34d.css

@@ -0,0 +1 @@
+[data-v-182bcb9c] .chat-container{height:100vh}[data-v-182bcb9c] .messages{margin-bottom:0;height:calc(100vh - 120px)}[data-v-182bcb9c] .input-container{max-width:1200px}

+ 0 - 0
dist/static/css/chunk-910f7562.e30e9787.css → dist/static/css/chunk-9235c1ae.e30e9787.css


+ 0 - 0
dist/static/css/chunk-d64de3d6.9733ac4d.css → dist/static/css/chunk-995a9622.9733ac4d.css


+ 0 - 0
dist/static/css/chunk-fa2fe916.58b6579a.css → dist/static/css/chunk-d09c27ba.d40db7bc.css


+ 0 - 0
dist/static/css/chunk-d649fd9a.e30e9787.css → dist/static/css/chunk-d4c547ca.e30e9787.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.bad222d9.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.d88323ba.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-09f78c22.28066213.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-13ebf84f.d5d5a373.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-277ceec9.e1ef13d9.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-36bc9124.4d8834ba.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-3d9675b3.510a3609.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-3da09771.810d31a7.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-41d431f5.7c626c01.js


+ 1 - 0
dist/static/js/chunk-59cff762.1daf2cd6.js

@@ -0,0 +1 @@
+(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-59cff762"],{3369:function(o,n,t){"use strict";t("b89d")},b89d:function(o,n,t){},c8cf:function(o,n,t){"use strict";t.r(n);var c=function(){var o=this,n=o.$createElement,t=o._self._c||n;return t("div",[t("ChatBox"),t("LoginModal",{attrs:{visible:o.showLoginModal},on:{"update:visible":function(n){o.showLoginModal=n},close:function(n){o.showLoginModal=!1},"login-success":o.handleLoginSuccess}})],1)},a=[],e=t("c3b3"),i=t("ecd9"),s={components:{ChatBox:e["default"],LoginModal:i["default"]},data:function(){return{showLoginModal:!1}},mounted:function(){this.checkAIData()},methods:{checkAIData:function(){var o=localStorage.getItem("AIData");this.showLoginModal=!o},handleLoginSuccess:function(){this.showLoginModal=!1}}},u=s,l=(t("3369"),t("2877")),d=Object(l["a"])(u,c,a,!1,null,"182bcb9c",null);n["default"]=d.exports}}]);

File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-9235c1ae.c3bfc16e.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-995a9622.41227a32.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-d09c27ba.b4dc3f9d.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-d4c547ca.c5efbcbd.js


File diff suppressed because it is too large
+ 8 - 0
src/assets/js/particles.min.js


+ 86 - 2
src/components/webAi/css/ChatBox.css

@@ -5,10 +5,94 @@
     flex-direction: column;
      /* 或者按照实际需要调整高度 */
 }
+.chat-container .header{
+    display: flex;
+    justify-content: flex-end;
+}
+.chat-container .header ::v-deep .el-select .el-input--medium .el-input__inner{
+    border: none;
+}
+.chat-container .header ::v-deep .el-select .el-input--medium .el-input__suffix .el-input__suffix-inner{
+    display: none;
+}
+.chat-container .content {
+    display: flex;
+    justify-content: flex-start;
+}
+
+.chat-container .content .left{
+    margin-left: 10px;
+    width: 330px;
+    height: 87vh;
+}
+.chat-item {
+    border-radius: 10px;
+    padding: 10px;
+    border-bottom: 1px solid #e8edf2;
+    background-color: #f5f5fa;
+    margin-bottom: 10px;
+  }
+  
+  .chat-header {
+    display: flex;
+    align-items: center;
+    margin-bottom: 5px;
+  }
+  
+  .avatar {
+    width: 40px;
+    height: 40px;
+    border-radius: 50%;
+    margin-right: 10px;
+  }
+  
+  .user-info {
+    flex-grow: 1;
+  }
+  .user-info .info_header{
+    display: flex;
+    align-items: flex-end;
+  }
+  
+  .username {
+    font-weight: bold;
+  }
+  
+  .timestamp {
+    margin-left:13px;
+    font-size: 0.8em;
+    color: #888;
+  }
+  
+  .more-options {
+    cursor: pointer;
+  }
+  
+  .chat-message {
+    font-weight: bold;
+    margin-top: 8px;
+    margin-bottom: 10px;
+  }
+  
+  .chat-preview {
+    font-size: 0.9em;
+    color: #666;
+  }
+  
+  /* Adjust existing styles */
+  .left {
+    width: 300px; /* Increased width to accommodate the new layout */
+  }
+  
+  .chat-history {
+    width: 330px;
+    height: 100%;
+    overflow-y: auto;
+  }
 
 .messages {
-    width: 1200px; /* 设置消息列表宽度为屏幕宽度的 80% */
-    max-width: 80%; /* 限制最大宽度,避免超出视口 */
+    width: 1180px; /* 设置消息列表宽度为屏幕宽度的 80% */
+    max-width: 90%; /* 限制最大宽度,避免超出视口 */
     margin: 0 auto; /* 上下保持原有的 margin,左右自动调整以居中 */
     overflow-y: auto; /* 如果消息太多,允许滚动 */
     height: calc(100vh - 230px); /* 高度需要根据输入框和其他元素的高度调整 */

+ 91 - 41
src/components/webAi/index.vue

@@ -1,48 +1,98 @@
 <template>
-  <div class="chat-container">
-    <div class="messages">
-      <ul>
-        <li
-          v-for="message in messages"
-          :key="message.id"
-          :class="[message.user, message.user === 'user' ? 'user-message' : '']"
-        >
-          <!-- 添加判断,如果是机器人的消息也显示头像 -->
-          <div class="message_name">
-            <div
-              class="avatar"
-              :class="{
-                'user-avatar': message.user === 'user',
-                'bot-avatar': message.user === 'bot',
-              }"
-            ></div>
-            <div class="name">
-              <span class="sender-name" style="color: #666666;" v-if="message.user === 'user'">你</span>
-              <span class="sender-name" v-if="message.user === 'bot'"
-                >轻良AI助理</span
-              >
+  <div class="chat-container" >
+    <div class="header" style="margin-top: 15px;">
+      <el-select v-model="AImodel" placeholder="请选择模型">
+        <el-option label="请选择模型" value="1"> </el-option>
+      </el-select>
+      <el-select v-model="AIknowledgeBase" placeholder="请选择知识库">
+        <el-option label="请选择知识库" value="1"> </el-option>
+      </el-select>
+      <el-select v-model="AIFile" placeholder="请选择文件">
+        <el-option label="请选择文件" value="1"> </el-option>
+      </el-select>
+    </div>
+    <div class="content">
+      <div class="left">
+        <div class="chat-history">
+          <div
+            v-for="(chat, index) in chatHistory"
+            :key="index"
+            class="chat-item"
+          >
+            <div class="chat-header">
+              <img
+                src="../../assets/images/logo.png"
+                alt="User avatar"
+                class="avatar"
+              />
+              <div class="user-info">
+                <div class="info_header">
+                  <div class="username">{{ chat.username }}</div>
+                  <div class="timestamp">{{ chat.timestamp }}</div>
+                </div>
+                <div class="chat-message">{{ chat.message }}</div>
+                <div class="chat-preview">{{ chat.preview }}</div>
+              </div>
+              <!-- <div class="more-options">...</div> -->
             </div>
           </div>
-          <!-- 使用 v-html 来渲染 Markdown 文本 -->
-          <div class="message-content">
-            <div
-              class="message-text"
-              v-html="renderMarkdown(message.message)"
-               @click="handleLinkClick"
-            ></div>
-          </div>
-        </li>
-      </ul>
-    </div>
-    <div class="input-container">
-      <textarea
-        v-model="userInput"
-        rows="4"
-        @keydown="handleKeydown"
-        placeholder="发送消息..."
-      ></textarea>
-      <button @click="sendMessage" class="btn">发送</button>
+        </div>
+      </div>
+      <div class="right" style="position: relative">
+        <div class="messages">
+          <ul>
+            <li
+              v-for="message in messages"
+              :key="message.id"
+              :class="[
+                message.user,
+                message.user === 'user' ? 'user-message' : '',
+              ]"
+            >
+              <!-- 添加判断,如果是机器人的消息也显示头像 -->
+              <div class="message_name">
+                <div
+                  class="avatar"
+                  :class="{
+                    'user-avatar': message.user === 'user',
+                    'bot-avatar': message.user === 'bot',
+                  }"
+                ></div>
+                <div class="name">
+                  <span
+                    class="sender-name"
+                    style="color: #666666"
+                    v-if="message.user === 'user'"
+                    >你</span
+                  >
+                  <span class="sender-name" v-if="message.user === 'bot'"
+                    >轻良AI助理</span
+                  >
+                </div>
+              </div>
+              <!-- 使用 v-html 来渲染 Markdown 文本 -->
+              <div class="message-content">
+                <div
+                  class="message-text"
+                  v-html="renderMarkdown(message.message)"
+                  @click="handleLinkClick"
+                ></div>
+              </div>
+            </li>
+          </ul>
+        </div>
+        <div class="input-container">
+          <textarea
+            v-model="userInput"
+            rows="4"
+            @keydown="handleKeydown"
+            placeholder="发送消息..."
+          ></textarea>
+          <button @click="sendMessage" class="btn">发送</button>
+        </div>
+      </div>
     </div>
+
     <!-- 添加 LoginModal 组件 -->
     <LoginModal
       :visible.sync="showLoginModal"

+ 34 - 0
src/components/webAi/js/ChatBox.js

@@ -31,6 +31,27 @@ export default {
       isLoggedIn: false, // 添加登录状态标志
       idArray: [],
       minioUrls: [], // 新增:用于存储 Minio URL
+      AImodel:'1',//模型
+      AIknowledgeBase:"1",//知识库
+      AIFile:'1',//文件
+      chatHistory: [
+        {
+          username: "Theresa Rose",
+          avatar: "/path/to/avatar1.jpg",
+          timestamp: "08:33AM",
+          message: "I hope I can finish Frox soon",
+          preview: "Hi, what's new with Frox? Please upload the latest code, and I will check today"
+        },
+        {
+          username: "Theresa Rose",
+          avatar: "/path/to/avatar2.jpg",
+          timestamp: "08:33AM",
+          message: "I hope I can finish Frox soon",
+          preview: "Hi, what's new with Frox? Please upload the latest code, and I will check today"
+        },
+        // Add more chat history items as needed
+      ],
+      currentChatIndex: 0,
     };
   },
   created() {
@@ -54,6 +75,19 @@ export default {
     }
   },
   methods: {
+/* 聊天记录 */
+selectChat(index) {
+  this.currentChatIndex = index;
+  // Load the selected chat messages
+  // This is where you would typically load the messages for the selected chat
+},
+newChat() {
+  this.chatHistory.push({ title: `聊天 ${this.chatHistory.length + 1}`, preview: "新的聊天..." });
+  this.currentChatIndex = this.chatHistory.length - 1;
+  // Clear the current messages and start a new chat
+  this.messages = [];
+},
+
     handleLinkClick(event) {
       if (event.target.tagName === 'A') {
         sessionStorage.setItem('href',event.target.href)

+ 3 - 1
src/layout/components/Navbar.vue

@@ -44,7 +44,7 @@
         </el-dropdown-menu>
       </el-dropdown>
     </div>
-    <el-dialog  :close-on-click-modal="false" top="20px" :visible.sync="chatDialogVisible" append-to-body v-el-drag-dialog>
+    <el-dialog  :close-on-click-modal="false" top="20px" width="80%" :visible.sync="chatDialogVisible" append-to-body v-el-drag-dialog>
       <ChatBox />
     </el-dialog>
   </div>
@@ -59,6 +59,7 @@ import Screenfull from "@/components/Screenfull";
 import SizeSelect from "@/components/SizeSelect";
 import Search from "@/components/HeaderSearch";
 import ChatBox from "@/components/webAi/index.vue";
+import elDragDialog from "@/directive/el-drag-dialog";
 
 export default {
   components: {
@@ -70,6 +71,7 @@ export default {
     Search,
     ChatBox,
   },
+  directives: { elDragDialog },
   data() {
     return {
       chatDialogVisible: false, // 控制聊天对话框的显示

+ 7 - 7
src/router/index.js

@@ -340,13 +340,13 @@ export const asyncRoutes = [
         hidden:true,
         meta: { title: '知识库配置',  noCache: true ,roles: ['admin']}
       },
-      /* {
-        path: 'category/infoList',
-        component: () => import('@/views/knowledgeMenu/category/infoList'),
-        name: 'KBM_info',
-        hidden:true,
-        meta: { title: '解析块',  noCache: true ,roles: ['admin']}
-      } */
+      {
+        path: 'chatPage/index',
+        component: () => import('@/views/chatPage/index.vue'),
+        name: 'chatbot',
+      
+        meta: { title: '聊天应用',  noCache: true ,roles: ['admin']}
+      }
     ]
   },
     {

+ 52 - 0
src/views/chatPage/index.vue

@@ -0,0 +1,52 @@
+<template>
+    <div>
+      <ChatBox />
+      <LoginModal
+        :visible.sync="showLoginModal"
+        @close="showLoginModal = false"
+        @login-success="handleLoginSuccess"
+      />
+    </div>
+  </template>
+  
+  <script>
+  import ChatBox from "@/components/webAi/index.vue";
+  import LoginModal from "@/components/LoginModal";
+  
+  export default {
+    components: {
+      ChatBox,
+      LoginModal,
+    },
+    data() {
+      return {
+        showLoginModal: false,
+      };
+    },
+    mounted() {
+      this.checkAIData();
+    },
+    methods: {
+      checkAIData() {
+        const aiData = localStorage.getItem('AIData');
+        this.showLoginModal = !aiData;
+      },
+      handleLoginSuccess() {
+        this.showLoginModal = false;
+        // 处理登录成功后的逻辑,例如刷新数据或更新状态
+      },
+    },
+  };
+  </script>
+  <style scoped>
+  ::v-deep .chat-container {
+    height: 100vh;
+  }
+  ::v-deep .messages {
+    margin-bottom: 0;
+    height: calc(100vh - 120px);
+  }
+  ::v-deep .input-container {
+    max-width: 1200px;
+  }
+  </style>

+ 1 - 1
src/views/document/com/menus.vue

@@ -82,7 +82,7 @@
       :visible.sync="showSourceAi"
       append-to-body
       v-el-drag-dialog
-      width="300"
+      width="80%"
       :close-on-click-modal="false"
       top="20px"
       custom-class="prod-verify"

+ 14 - 3
src/views/document/create.vue

@@ -1404,7 +1404,7 @@ export default {
           templateData.map(async (el) => {
             if (!el || !el.id) {
               console.warn("Invalid template item:", el);
-              return null; // 跳过无效的项
+              return null;
             }
 
             const templateInfo = await getTemplateInfo({ id: el.id });
@@ -1417,6 +1417,18 @@ export default {
                 : [];
 
             attrs = attrs.map((item) => {
+              // 如果是目录类型,保留原始数据,但要确保正确更新
+              if (item.type === "Directory") {
+                const matchingAttr = el.attrs.find(
+                  (e) => e.type === "Directory" && e.id === item.id
+                );
+                console.log(el.attrs);
+                if (matchingAttr) {
+                  return { ...item, number: matchingAttr.number };
+                }
+                
+                return item;
+              }
               if (!item || !item.data || !item.data.id) {
                 console.warn("Invalid attribute item:", item);
                 return item; // 保留原始项,即使它可能是无效的
@@ -1822,8 +1834,7 @@ export default {
 
     generateNumberedContent(moduleIndex, level) {
       let number = this.generateLevelPrefix(moduleIndex, level);
-      let content =
-        this.coms[moduleIndex].type === "TextArea" ? "" : "";
+      let content = this.coms[moduleIndex].type === "TextArea" ? "" : "";
 
       return { number, content };
     },

Some files were not shown because too many files changed in this diff