1
QYF-GitLab1
2025-04-11 768eb63fc69d413055821c7963168f2e2677412c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<script lang="ts" setup>
interface ChatMessage {
  question: string
  answer: string
  timestamp?: string
}
 
defineProps<{
  msg: ChatMessage
}>()
</script>
 
<template>
  <div class="chat">
    <!-- 时间显示 -->
    <div v-if="msg.timestamp" class="timestamp">
      {{ msg.timestamp }}
    </div>
 
    <!-- 问题 -->
    <div class="message-right">
      <div class="chat-bubble chat-right">
        {{ msg.question }}
      </div>
      <!-- <div class="avatar">
        <img src="../assets/images/user-avatar.png" alt="user" />
      </div> -->
    </div>
 
    <!-- AI回答 -->
    <div class="message-left">
      <div class="avatar">
        <img src="../assets/images/image3.png" alt="AI" />
      </div>
      <div class="chat-bubble chat-left">
        <template v-if="msg.answer.includes('《')">
          <div class="book-info">
            <div class="book-header">
              <h3>AI智能图书检索助手为您检索到以下关于月亮的书,供您浏览如下:</h3>
            </div>
            <div class="book-content">
              <div class="book-image">
                <img src="../assets/book-cover.png" alt="book cover" />
              </div>
              <div class="book-details">
                <h4>《月亮与六便士》</h4>
                <p>责任者:毛姆, 张云飞著</p>
                <p>出版社:中国人民大学出版社</p>
                <p>ISBN号:978-7-300-25494-4</p>
                <p>入藏时间:20220226</p>
                <p>索书号:V1-18/12.3354(ENG)</p>
                <p>馆藏地:外文图书馆2楼-1.8954</p>
              </div>
            </div>
            <div class="book-description">
              <h4>图书简介:</h4>
              <p>
                本书以生动流畅笔触描写了卡尔·马克思的一生,展现了他作为思想家革命家的非凡历程,全书阐述马克思的学术思想实践与个人生活原升,深入剖析其对资本主义的批判及对人类解放的追求。作者将马克思比作"人间的苦罗米修斯",凸显其为无产阶级和全人类福祉不懈奋斗的精神。语言通俗易懂,适合对马克思主义思想及其发展历程感兴趣的读者阅读。
              </p>
            </div>
            <div class="book-actions">
              <button class="action-btn">浏览更多</button>
              <button class="action-btn">继续对话</button>
            </div>
          </div>
        </template>
        <template v-else>
          {{ msg.answer }}
        </template>
      </div>
    </div>
  </div>
</template>
 
<style scoped>
.chat {
  max-width: 1200px;
  margin: 0 auto;
}
 
.timestamp {
  text-align: center;
  color: #999;
  font-size: 12px;
  margin: 10px 0;
}
 
.message-left,
.message-right {
  display: flex;
  align-items: flex-start;
  margin: 20px 0;
}
 
.message-right {
  flex-direction: row-reverse;
}
 
.avatar {
  width: 60px;
  height: 60px;
  margin-right: 10px;
}
 
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
 
.chat-bubble {
  max-width: 70%;
  padding: 15px 30px;
  border-radius: 50px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
  word-break: break-all;
}
 
.chat-left {
  background-color: #fff;
  margin-left: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
 
.chat-right {
  background-color: #af8b56;
  margin-right: 10px;
  color: #fff;
}
 
.book-info {
  width: 100%;
}
 
.book-header {
  margin-bottom: 15px;
}
 
.book-content {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}
 
.book-image {
  width: 120px;
  height: 160px;
}
 
.book-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
 
.book-details {
  flex: 1;
}
 
.book-details h4 {
  margin: 0 0 10px 0;
  color: #333;
}
 
.book-details p {
  margin: 5px 0;
  color: #666;
  font-size: 13px;
}
 
.book-description {
  margin: 20px 0;
}
 
.book-description h4 {
  margin-bottom: 10px;
  color: #333;
}
 
.book-description p {
  color: #666;
  line-height: 1.6;
  font-size: 14px;
}
 
.book-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
 
.action-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background-color: #b4946e;
  color: white;
  cursor: pointer;
  font-size: 14px;
}
 
.action-btn:hover {
  background-color: #a38461;
}
</style>