Browse Source

优化ai助手相关内容

cq.tianyong 4 hours ago
parent
commit
359b82545e

+ 0 - 1
src/assets/ai.svg

@@ -1 +0,0 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1743221393320" class="icon" viewBox="0 0 1152 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16541" xmlns:xlink="http://www.w3.org/1999/xlink" width="72" height="64"><path d="M640 0l384 1024H0L384 0h256zM512 205.376L329.792 704H576v192H259.648l-46.656 128h597.952L512 205.376z" fill="#3366FF" p-id="16542"></path><path d="M928 384h192v640h-192z" fill="#3366FF" p-id="16543"></path><path d="M1024 128m-128 0a128 128 0 1 0 256 0 128 128 0 1 0-256 0Z" fill="#F5222D" p-id="16544"></path></svg>

BIN
src/assets/img/ai.png


File diff suppressed because it is too large
+ 0 - 0
src/assets/img/ai.svg


+ 30 - 29
src/components/AIChat/index.vue

@@ -12,7 +12,7 @@
     <template #title>
       <div class="ai-chat-title">
         <a-avatar :size="36" class="ai-chat-title__avatar">
-          <img src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" />
+          <img src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" draggable="false" />
         </a-avatar>
         <div class="ai-chat-title__copy">
           <div class="ai-chat-title__name">小妍助理</div>
@@ -80,12 +80,6 @@
             </a-popconfirm>
           </div>
 
-          <div v-if="!conversations.length" class="conversation-empty">
-            <a-avatar :size="42" class="conversation-empty__avatar">
-              <img src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" />
-            </a-avatar>
-            <div>暂无会话</div>
-          </div>
         </div>
       </aside>
 
@@ -104,7 +98,7 @@
 
           <div class="chat-toolbar__identity">
             <a-avatar :size="34" class="chat-toolbar__avatar">
-              <img src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" />
+              <img src="@/assets/img/ai.svg" alt="小妍助理" draggable="false" />
             </a-avatar>
             <div class="chat-toolbar__text">
               <strong>{{ currentConversation?.title || '新对话' }}</strong>
@@ -112,8 +106,8 @@
             </div>
           </div>
 
-          <a-popconfirm content="是否删除该对话?" @ok="deleteCurrentConversation">
-            <a-button :disabled="!currentConversationId" type="text" shape="circle" status="danger">
+          <a-popconfirm v-if="canDeleteCurrentConversation" content="是否删除该对话?" @ok="deleteCurrentConversation">
+            <a-button type="text" shape="circle" status="danger">
               <template #icon><icon-delete /></template>
             </a-button>
           </a-popconfirm>
@@ -122,7 +116,7 @@
         <div ref="messageContainer" class="message-list">
           <div v-if="!currentConversationId" class="empty-state">
             <a-avatar :size="64" class="empty-state__avatar">
-              <img src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" />
+              <img src="@/assets/img/ai.svg" alt="小妍助理" draggable="false" />
             </a-avatar>
             <div class="empty-state__title">开启一段新对话</div>
           </div>
@@ -134,7 +128,7 @@
 
             <div v-if="!messagesLoading && !messages.length" class="welcome-card">
               <a-avatar :size="52" class="welcome-card__avatar">
-                <img src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" />
+                <img src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" draggable="false" />
               </a-avatar>
               <div>
                 <div class="welcome-card__title">我是小妍助理</div>
@@ -161,8 +155,8 @@
               :class="`message-row--${message.role}`"
             >
               <a-avatar :size="36" class="message-avatar">
-                <img v-if="message.role === 'assistant'" src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" />
-                <img v-else-if="message.role === 'user' && avatar" :src="avatar"/>
+                <img v-if="message.role === 'assistant'" src="https://lepao-api.xxoo365.top/uploads/9aca0644-f1f8-4773-b25e-4cd5d268cf0e.png" alt="小妍助理" draggable="false" />
+                <img v-else-if="message.role === 'user' && avatar" :src="avatar" draggable="false" />
                 <icon-user v-else-if="message.role === 'user'" />
                 <icon-info-circle v-else />
               </a-avatar>
@@ -292,6 +286,7 @@ let messageTimer = null
 const visible = computed(() => props.visible)
 const drawerWidth = computed(() => (isMobile.value ? '100%' : '940px'))
 const currentConversation = computed(() => conversations.value.find(item => item.id === currentConversationId.value))
+const canDeleteCurrentConversation = computed(() => canShowConversationActions(currentConversation.value))
 const canSend = computed(() => currentConversationId.value && (input.value.trim() || uploadingImages.value.length > 0))
 const unreadTotal = computed(() => Object.values(unreadMap.value).reduce((sum, value) => sum + Number(value || 0), 0))
 const seenKey = computed(() => `aiChatSeen:${userStore.uuid || 'guest'}`)
@@ -359,8 +354,12 @@ const loadConversations = async () => {
   const localItems = conversations.value.filter(item => item.local)
   conversations.value = [...localItems, ...(res.data || [])]
   updateUnreadByConversations(conversations.value)
-  if (visible.value && !currentConversationId.value && conversations.value.length) {
-    await openConversation(conversations.value[0].id)
+  if (visible.value && !currentConversationId.value) {
+    if (conversations.value.length) {
+      await openConversation(conversations.value[0].id)
+    } else {
+      await createConversationAndOpen()
+    }
   }
 }
 
@@ -654,6 +653,20 @@ onUnmounted(() => {
   }
 }
 
+.ai-chat-title__avatar,
+.chat-toolbar__avatar,
+.empty-state__avatar,
+.welcome-card__avatar,
+.message-avatar {
+  user-select: none;
+
+  :deep(img) {
+    user-select: none;
+    -webkit-user-drag: none;
+    pointer-events: none;
+  }
+}
+
 :global(.ai-chat-drawer .arco-drawer-header) {
   height: 48px;
   padding: 7px 16px;
@@ -857,19 +870,6 @@ onUnmounted(() => {
   }
 }
 
-.conversation-empty {
-  display: grid;
-  place-items: center;
-  gap: 10px;
-  padding: 40px 12px;
-  color: #86909c;
-  font-size: 13px;
-
-  &__avatar {
-    background: #eef4ff;
-  }
-}
-
 .chat-main {
   position: relative;
   display: grid;
@@ -969,6 +969,7 @@ onUnmounted(() => {
 .empty-state__avatar,
 .welcome-card__avatar {
   background: linear-gradient(135deg, #eaf2ff, #f7ecff);
+  user-select: none;
 }
 
 .empty-state__title,

+ 1 - 1
src/layout/default-layout.vue

@@ -46,7 +46,7 @@
 
     <a-badge v-if="aiAvailable" :count="aiUnread" :dot="aiUnread > 0" class="aiButtonBadge">
       <a-avatar class="aiButton" @click="chat = !chat">
-        <img alt="AI助手" src="@/assets/img/ai.png" />
+        <img alt="AI助手" src="@/assets/img/ai.svg" />
       </a-avatar>
     </a-badge>
 

+ 1 - 1
src/pages/admin/aiChat/detail.vue

@@ -18,7 +18,7 @@
       <div v-for="message in data.messages" :key="message.id" class="message">
         <div class="message__head">
           <a-avatar :size="34">
-            <img v-if="message.role === 'assistant'" src="@/assets/img/ai.png" alt="小妍助理" />
+            <img v-if="message.role === 'assistant'" src="@/assets/img/ai.svg" alt="小妍助理" />
             <icon-user v-else-if="message.role === 'user'" />
             <icon-info-circle v-else />
           </a-avatar>

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