|
| 1 | +<template> |
| 2 | + <div class="sqlbot-assistant-container"> |
| 3 | + <div class="head"> |
| 4 | + <div class="flex align-center"> |
| 5 | + <div class="head-img-div"> |
| 6 | + <img :src="AssistantGif" /> |
| 7 | + </div> |
| 8 | + <h4>SQLBot 小助手</h4> |
| 9 | + </div> |
| 10 | + </div> |
| 11 | + <chat-component ref="chatRef" class="sqlbot-chat-container" /> |
| 12 | + </div> |
| 13 | + <div class="sqlbot-top-btn"> |
| 14 | + <el-icon style="cursor: pointer" @click="openHistory"> |
| 15 | + <history></history> |
| 16 | + </el-icon> |
| 17 | + </div> |
| 18 | + <div class="sqlbot-history-container"> |
| 19 | + <el-drawer |
| 20 | + v-model="drawer" |
| 21 | + :append-to-body="false" |
| 22 | + class="sqlbot-history-drawer" |
| 23 | + modal-class="sqlbot-history-modal" |
| 24 | + title="" |
| 25 | + direction="ttb" |
| 26 | + :with-header="false" |
| 27 | + > |
| 28 | + <div class="sqlbot-history-title"> |
| 29 | + <span>历史记录</span> |
| 30 | + </div> |
| 31 | + <div class="sqlbot-history-content"> |
| 32 | + <div v-if="!chatList.length" class="history-empty"> |
| 33 | + <span>暂无历史记录</span> |
| 34 | + </div> |
| 35 | + <div v-else class="sqlbot-chat-list-inner"> |
| 36 | + <el-scrollbar max-height="350px" class="sqlbot-chat-scroller"> |
| 37 | + <template v-for="chat in chatList" :key="chat.id"> |
| 38 | + <div |
| 39 | + class="chat-list-item" |
| 40 | + :class="{ 'is-active-chat': currentId === chat.id }" |
| 41 | + @click="onClickHistory(chat)" |
| 42 | + > |
| 43 | + <span class="title">{{ chat.brief ?? 'Untitled' }}</span> |
| 44 | + <div class="history-operate"> |
| 45 | + <el-icon @click="EditPen(chat)"><IconOpeEdit /></el-icon> |
| 46 | + <el-icon @click="Delete(chat)"><IconOpeDelete /></el-icon> |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + </template> |
| 50 | + </el-scrollbar> |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + </el-drawer> |
| 54 | + </div> |
| 55 | +</template> |
| 56 | +<script setup lang="ts"> |
| 57 | +import { ref } from 'vue' |
| 58 | +import ChatComponent from '@/views/chat/index.vue' |
| 59 | +import AssistantGif from '@/assets/img/assistant.gif' |
| 60 | +import history from '@/assets/svg/chart/history.svg' |
| 61 | +import IconOpeEdit from '@/assets/svg/operate/ope-edit.svg' |
| 62 | +import IconOpeDelete from '@/assets/svg/operate/ope-delete.svg' |
| 63 | +
|
| 64 | +const chatRef = ref() |
| 65 | +const chatList = ref<Array<any>>([]) |
| 66 | +const drawer = ref(false) |
| 67 | +const currentId = ref() |
| 68 | +
|
| 69 | +const openHistory = () => { |
| 70 | + chatList.value = chatRef.value?.getHistoryList() |
| 71 | + currentId.value = chatRef.value?.getCurrentChatId() |
| 72 | + drawer.value = true |
| 73 | +} |
| 74 | +const onClickHistory = (chat: any) => { |
| 75 | + chatRef.value?.onClickHistory(chat) |
| 76 | +} |
| 77 | +
|
| 78 | +const EditPen = (chat: any) => { |
| 79 | + chatRef.value?.onChatRenamed(chat) |
| 80 | +} |
| 81 | +const Delete = (chat: any) => { |
| 82 | + chatRef.value?.onChatDeleted(chat.id) |
| 83 | +} |
| 84 | +</script> |
| 85 | + |
| 86 | +<style lang="less" scoped> |
| 87 | +.sqlbot-assistant-container { |
| 88 | + height: 100%; |
| 89 | + width: 100%; |
| 90 | + color: rgb(31, 35, 41); |
| 91 | + .flex { |
| 92 | + display: flex; |
| 93 | + } |
| 94 | + .head { |
| 95 | + background: linear-gradient(90deg, #ebf1ff 24.34%, #e5fbf8 56.18%, #f2ebfe 90.18%); |
| 96 | + position: fixed; |
| 97 | + width: 100%; |
| 98 | + left: 0; |
| 99 | + top: 0; |
| 100 | + z-index: 100; |
| 101 | + height: 56px; |
| 102 | + line-height: 56px; |
| 103 | + box-sizing: border-box; |
| 104 | + border-bottom: 1px solid #dee0e3; |
| 105 | + .align-center { |
| 106 | + align-items: center; |
| 107 | + .head-img-div { |
| 108 | + display: flex; |
| 109 | + margin-left: 24px; |
| 110 | + img { |
| 111 | + width: 32px; |
| 112 | + height: 32px; |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + .sqlbot-chat-container { |
| 118 | + padding-top: 56px; |
| 119 | + :deep(.ed-aside) { |
| 120 | + display: none; |
| 121 | + } |
| 122 | + } |
| 123 | +} |
| 124 | +.sqlbot-top-btn { |
| 125 | + right: 85px; |
| 126 | + z-index: 2009; |
| 127 | + position: absolute; |
| 128 | + top: 16px; |
| 129 | + // right: 16px; |
| 130 | + font-size: 22px; |
| 131 | +} |
| 132 | +.sqlbot-history-container { |
| 133 | + width: 100%; |
| 134 | + :deep(.sqlbot-history-modal) { |
| 135 | + top: 56px !important; |
| 136 | + } |
| 137 | + :deep(.sqlbot-history-title) { |
| 138 | + border-bottom: 1px solid #dee0e3; |
| 139 | + padding: 16px 24px; |
| 140 | + font-size: 14px; |
| 141 | + font-weight: 500; |
| 142 | + color: #1f2329; |
| 143 | + } |
| 144 | + :deep(.ed-drawer__body) { |
| 145 | + padding: 0 !important; |
| 146 | + } |
| 147 | + :deep(.sqlbot-history-drawer) { |
| 148 | + height: fit-content !important; |
| 149 | + .sqlbot-history-content { |
| 150 | + padding: 16px; |
| 151 | + .history-empty { |
| 152 | + height: 60px; |
| 153 | + color: #8f959e !important; |
| 154 | + display: flex; |
| 155 | + align-items: center; |
| 156 | + justify-content: center; |
| 157 | + font-size: 14px; |
| 158 | + } |
| 159 | + .is-active-chat { |
| 160 | + background-color: #ebf1ff; |
| 161 | + color: #3370ff; |
| 162 | + font-weight: 500; |
| 163 | + } |
| 164 | + .chat-list-item { |
| 165 | + display: flex; |
| 166 | + align-items: center; |
| 167 | + padding: 10px 8px; |
| 168 | + font-size: 14px; |
| 169 | + color: #1f2329; |
| 170 | + justify-content: space-between; |
| 171 | + .history-operate { |
| 172 | + display: none; |
| 173 | + } |
| 174 | + &:hover { |
| 175 | + cursor: pointer; |
| 176 | + border-radius: 4px; |
| 177 | + background: rgba(31, 35, 41, 0.1); |
| 178 | + .history-operate { |
| 179 | + padding-right: 16px; |
| 180 | + display: flex; |
| 181 | + column-gap: 16px; |
| 182 | + align-items: center; |
| 183 | + font-size: 18px; |
| 184 | + i { |
| 185 | + color: #8f959e; |
| 186 | + &:hover { |
| 187 | + color: #8f959e99; |
| 188 | + } |
| 189 | + } |
| 190 | + } |
| 191 | + } |
| 192 | + } |
| 193 | + } |
| 194 | + } |
| 195 | +} |
| 196 | +</style> |
0 commit comments