|
| 1 | +<template> |
| 2 | + <el-container> |
| 3 | + <!-- 左侧:会话列表 --> |
| 4 | + <el-aside width="260px" class="conversation-container"> |
| 5 | + <!-- 左顶部:新建对话 --> |
| 6 | + <el-button class="w-1/1" type="primary"> |
| 7 | + <Icon icon="ep:plus" class="mr-5px" /> |
| 8 | + 新建对话 |
| 9 | + </el-button> |
| 10 | + <!-- 左顶部:搜索对话 --> |
| 11 | + <el-input |
| 12 | + v-model="searchName" |
| 13 | + class="mt-10px" |
| 14 | + placeholder="搜索历史记录" |
| 15 | + @keyup="searchConversation" |
| 16 | + > |
| 17 | + <template #prefix> |
| 18 | + <Icon icon="ep:search" /> |
| 19 | + </template> |
| 20 | + </el-input> |
| 21 | + <!-- 左中间:对话列表 --> |
| 22 | + <div class="conversation-list" :style="{ height: leftHeight + 'px' }"> |
| 23 | + <el-row v-for="conversation in conversationList" :key="conversation.id"> |
| 24 | + <div |
| 25 | + :class="conversation.id === conversationId ? 'conversation active' : 'conversation'" |
| 26 | + @click="changeConversation(conversation)" |
| 27 | + > |
| 28 | + <el-image :src="conversation.avatar" class="avatar" /> |
| 29 | + <span class="title">{{ conversation.title }}</span> |
| 30 | + <span class="button"> |
| 31 | + <!-- TODO 芋艿:缺置顶按钮 --> |
| 32 | + <el-icon title="编辑" @click="updateConversationTitle(conversation)"> |
| 33 | + <Icon icon="ep:edit" /> |
| 34 | + </el-icon> |
| 35 | + <el-icon title="删除会话" @click="deleteConversationTitle(conversation)"> |
| 36 | + <Icon icon="ep:delete" /> |
| 37 | + </el-icon> |
| 38 | + </span> |
| 39 | + </div> |
| 40 | + </el-row> |
| 41 | + </div> |
| 42 | + <!-- 左底部:工具栏 TODO 芋艿:50% 不太对 --> |
| 43 | + <div class="tool-box"> |
| 44 | + <sapn class="w-1/2"> <Icon icon="ep:user" /> 角色仓库 </sapn> |
| 45 | + <sapn class="w-1/2"> <Icon icon="ep:delete" />清空未置顶对话</sapn> |
| 46 | + </div> |
| 47 | + </el-aside> |
| 48 | + <!-- 右侧:会话详情 --> |
| 49 | + <el-container class="detail-container"> |
| 50 | + <!-- 右顶部 TODO 芋艿:右对齐 --> |
| 51 | + <el-header class="header"> |
| 52 | + <el-button>3.5-turbo-0125 <Icon icon="ep:setting" /></el-button> |
| 53 | + <el-button> |
| 54 | + <Icon icon="ep:user" /> |
| 55 | + </el-button> |
| 56 | + <el-button> |
| 57 | + <Icon icon="ep:download" /> |
| 58 | + </el-button> |
| 59 | + <el-button> |
| 60 | + <Icon icon="ep:arrow-up" /> |
| 61 | + </el-button> |
| 62 | + </el-header> |
| 63 | + <el-main>对话列表</el-main> |
| 64 | + <el-footer>发送消息框</el-footer> |
| 65 | + </el-container> |
| 66 | + </el-container> |
| 67 | +</template> |
| 68 | +<script setup lang="ts"> |
| 69 | +const conversationList = [ |
| 70 | + { |
| 71 | + id: 1, |
| 72 | + title: '测试标题', |
| 73 | + avatar: |
| 74 | + 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png' |
| 75 | + }, |
| 76 | + { |
| 77 | + id: 2, |
| 78 | + title: '测试对话', |
| 79 | + avatar: |
| 80 | + 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png' |
| 81 | + } |
| 82 | +] |
| 83 | +const conversationId = ref(1) |
| 84 | +const searchName = ref('') |
| 85 | +const leftHeight = window.innerHeight - 240 // TODO 芋艿:这里还不太对 |
| 86 | +
|
| 87 | +const changeConversation = (conversation) => { |
| 88 | + console.log(conversation) |
| 89 | + conversationId.value = conversation.id |
| 90 | + // TODO 芋艿:待实现 |
| 91 | +} |
| 92 | +
|
| 93 | +const updateConversationTitle = (conversation) => { |
| 94 | + console.log(conversation) |
| 95 | + // TODO 芋艿:待实现 |
| 96 | +} |
| 97 | +
|
| 98 | +const deleteConversationTitle = (conversation) => { |
| 99 | + console.log(conversation) |
| 100 | + // TODO 芋艿:待实现 |
| 101 | +} |
| 102 | +
|
| 103 | +const searchConversation = () => { |
| 104 | + // TODO 芋艿:待实现 |
| 105 | +} |
| 106 | +</script> |
| 107 | +<style lang="scss" scoped> |
| 108 | +.conversation-container { |
| 109 | + .conversation-list { |
| 110 | + .conversation { |
| 111 | + display: flex; |
| 112 | + justify-content: flex-start; |
| 113 | + width: 100%; |
| 114 | + padding: 5px 5px 0 0; |
| 115 | + cursor: pointer; |
| 116 | + &.active { |
| 117 | + // TODO 芋艿:这里不太对 |
| 118 | + background-color: #343540; |
| 119 | + .button { |
| 120 | + display: inline; |
| 121 | + } |
| 122 | + } |
| 123 | + .title { |
| 124 | + padding: 5px 10px; |
| 125 | + max-width: 220px; |
| 126 | + font-size: 14px; |
| 127 | + overflow: hidden; |
| 128 | + white-space: nowrap; |
| 129 | + text-overflow: ellipsis; |
| 130 | + } |
| 131 | + .avatar { |
| 132 | + width: 28px; |
| 133 | + height: 28px; |
| 134 | + border-radius: 50%; |
| 135 | + } |
| 136 | + .button { |
| 137 | + position: absolute; |
| 138 | + right: 2px; |
| 139 | + top: 16px; |
| 140 | + .el-icon { |
| 141 | + margin-right: 5px; |
| 142 | + } |
| 143 | + } |
| 144 | + } |
| 145 | +
|
| 146 | + .tool-box { |
| 147 | + display: flex; |
| 148 | + justify-content: flex-start; |
| 149 | + padding: 0 20px 10px 20px; |
| 150 | + border-top: 1px solid black; |
| 151 | + } |
| 152 | + } |
| 153 | +} |
| 154 | +
|
| 155 | +.detail-container { |
| 156 | + .header { |
| 157 | + width: 100%; |
| 158 | + height: 30px; |
| 159 | + display: flex; |
| 160 | + flex-direction: row; |
| 161 | + align-items: center; |
| 162 | + justify-content: center; |
| 163 | + padding-top: 10px; |
| 164 | + } |
| 165 | +} |
| 166 | +</style> |
0 commit comments