agilebuilder-ui 1.1.45-ai2 → 1.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{401-beb8c7d3.js → 401-1bde8dc9.js} +1 -1
- package/lib/{404-453588b3.js → 404-48d76996.js} +1 -1
- package/lib/{iframe-page-11560b58.js → iframe-page-77e184a0.js} +1 -1
- package/lib/index-465b0d69.js +73558 -0
- package/lib/super-ui.css +1 -1
- package/lib/super-ui.js +32 -33
- package/lib/super-ui.umd.cjs +136 -168
- package/lib/{tab-content-iframe-index-2cadaa46.js → tab-content-iframe-index-39745d49.js} +1 -1
- package/lib/{tab-content-index-3455e8d6.js → tab-content-index-65696e56.js} +1 -1
- package/lib/{tache-subprocess-history-cfb4e2eb.js → tache-subprocess-history-ef943f95.js} +1 -1
- package/package.json +2 -7
- package/packages/index.js +13 -16
- package/packages/super-grid/src/super-grid.vue +1 -14
- package/src/i18n/langs/cn.js +2 -14
- package/src/i18n/langs/en.js +1 -13
- package/src/store/modules/tab-content.js +3 -9
- package/src/styles/element-ui.scss +8 -7
- package/lib/index-bc79f11f.js +0 -93084
- package/packages/chat-embed/index.ts +0 -6
- package/packages/chat-embed/src/chat-embed-message.ts +0 -79
- package/packages/chat-embed/src/chat-embed.css +0 -117
- package/packages/chat-embed/src/chat-sender.vue +0 -240
- package/packages/chat-embed/src/header.vue +0 -50
- package/packages/chat-embed/src/index.vue +0 -420
- package/packages/chat-embed/src/recommendation-message.vue +0 -37
- package/packages/chat-embed/src/util.ts +0 -33
- package/packages/json-view/index.ts +0 -3
- package/packages/json-view/json-view-dialog.vue +0 -53
- package/packages/json-view/json-view.vue +0 -126
- package/src/assets/chat-embed/avatar.png +0 -0
- package/src/store/modules/chat-ai-store.ts +0 -78
- package/src/utils/chat-ai-util.ts +0 -31
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- <div v-permission="'mc.ragFlow.converseWithChat'"> -->111111111111
|
|
3
|
-
<div>
|
|
4
|
-
<div ref="chatIcon" :style="style" style="position: fixed; cursor: pointer; z-index: 1">
|
|
5
|
-
<img src="https://maxkb.fit2cloud.com/ui/MaxKB.gif" @click="showChatDialog" />
|
|
6
|
-
</div>
|
|
7
|
-
<transition name="slide-up">
|
|
8
|
-
<div v-show="showChatVisable" ref="chatContainerRef" class="chat-container">
|
|
9
|
-
<!-- 头部 -->
|
|
10
|
-
<Header
|
|
11
|
-
:aiAvatar="aiAvatar"
|
|
12
|
-
:dialogFullScreen="dialogFullScreen"
|
|
13
|
-
@expandDialog="expandDialog"
|
|
14
|
-
@showChatDialog="showChatDialog"
|
|
15
|
-
/>
|
|
16
|
-
<!-- 聊天内容展示 -->
|
|
17
|
-
<!-- <div ref="talkMainRef" :key="talkMainRefKey" class="chat-embed__main"> -->
|
|
18
|
-
<div ref="talkMainRef" class="chat-embed__main" :key="talkMainRefKey">
|
|
19
|
-
<div class="chat-embed__main_content">
|
|
20
|
-
<BubbleList :list="messageList" :max-height="bubbleMaxHeight" :is-fog="true">
|
|
21
|
-
<template #content="{ item }">
|
|
22
|
-
<template v-if="!item.isRecommend && item.thinkingContent !== null">
|
|
23
|
-
<!-- ai消息正在回复中 -->
|
|
24
|
-
<Thinking
|
|
25
|
-
style="margin-bottom: 5px"
|
|
26
|
-
v-model="item.showThinkingContent"
|
|
27
|
-
:status="item.thinkingStatus"
|
|
28
|
-
auto-collapse
|
|
29
|
-
:content="item.thinkingContent"
|
|
30
|
-
max-width="100%"
|
|
31
|
-
:typing="{ interval: 20 }"
|
|
32
|
-
duration=".3s"
|
|
33
|
-
class="thinking-chain-warp"
|
|
34
|
-
>
|
|
35
|
-
</Thinking>
|
|
36
|
-
</template>
|
|
37
|
-
<template v-if="item.content">
|
|
38
|
-
<!-- ai消息和用户消息 -->
|
|
39
|
-
<div
|
|
40
|
-
:class="item.role === 'ai' ? 'content-container' : 'content-borderless-container'"
|
|
41
|
-
:style="{ maxWidth: bubbleMaxWidth }"
|
|
42
|
-
>
|
|
43
|
-
<Typewriter
|
|
44
|
-
v-if="item.role === 'ai' && !item.isRecommend"
|
|
45
|
-
:content="item.content"
|
|
46
|
-
:typing="{ interval: 10 }"
|
|
47
|
-
:is-markdown="true"
|
|
48
|
-
/>
|
|
49
|
-
<template v-else-if="item.role === 'user'">
|
|
50
|
-
{{ item.content }}
|
|
51
|
-
<template v-if="item.additionalData?.length > 0">
|
|
52
|
-
<el-divider border-style="dashed" />
|
|
53
|
-
<el-tag type="primary">
|
|
54
|
-
<template #default>
|
|
55
|
-
<div
|
|
56
|
-
style="
|
|
57
|
-
display: flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
flex-shrink: 0;
|
|
60
|
-
min-width: max-content;
|
|
61
|
-
margin-left: auto;
|
|
62
|
-
gap: 10px;
|
|
63
|
-
"
|
|
64
|
-
>
|
|
65
|
-
<el-icon><Paperclip /></el-icon>
|
|
66
|
-
{{ item.additionalDataLabel }}
|
|
67
|
-
</div>
|
|
68
|
-
</template>
|
|
69
|
-
</el-tag>
|
|
70
|
-
<div
|
|
71
|
-
style="
|
|
72
|
-
display: flex;
|
|
73
|
-
align-items: center;
|
|
74
|
-
justify-content: center;
|
|
75
|
-
margin-top: 10px;
|
|
76
|
-
gap: 10px;
|
|
77
|
-
"
|
|
78
|
-
>
|
|
79
|
-
<el-button plain round size="small" @click="viewJson(item.additionalData)">
|
|
80
|
-
<el-icon><View /></el-icon> <span>预览数据</span>
|
|
81
|
-
</el-button>
|
|
82
|
-
<el-button
|
|
83
|
-
plain
|
|
84
|
-
round
|
|
85
|
-
size="small"
|
|
86
|
-
@click="downloadJsonData(item.additionalData, item.menuName)"
|
|
87
|
-
>
|
|
88
|
-
<el-icon><Download /></el-icon> 下载数据
|
|
89
|
-
</el-button>
|
|
90
|
-
</div>
|
|
91
|
-
</template>
|
|
92
|
-
</template>
|
|
93
|
-
<template v-else> {{ item.content }} </template>
|
|
94
|
-
</div>
|
|
95
|
-
<template v-if="item.recommendations && item.recommendations.length > 0">
|
|
96
|
-
<!-- 推荐内容的消息 -->
|
|
97
|
-
<RecommendationMessage :item="item" @clickRecommendation="clickRecommendation" />
|
|
98
|
-
</template>
|
|
99
|
-
</template>
|
|
100
|
-
</template>
|
|
101
|
-
<template #footer="{ item }">
|
|
102
|
-
<div
|
|
103
|
-
v-if="item.role === 'ai' && !item.isRecommend && item.thinkingStatus !== 'thinking'"
|
|
104
|
-
class="footer-container"
|
|
105
|
-
>
|
|
106
|
-
<el-tooltip class="box-item" effect="dark" :content="$t('chatEmbed.regenerate')">
|
|
107
|
-
<el-button type="info" :icon="Refresh" size="small" circle @click="regenerateQuestion(item)" />
|
|
108
|
-
</el-tooltip>
|
|
109
|
-
<el-tooltip class="box-item" effect="dark" :content="$t('chatEmbed.copy')">
|
|
110
|
-
<el-button
|
|
111
|
-
type="info"
|
|
112
|
-
color="#626aef"
|
|
113
|
-
:icon="DocumentCopy"
|
|
114
|
-
size="small"
|
|
115
|
-
circle
|
|
116
|
-
@click="cpoyContent(item)"
|
|
117
|
-
/>
|
|
118
|
-
</el-tooltip>
|
|
119
|
-
</div>
|
|
120
|
-
</template>
|
|
121
|
-
</BubbleList>
|
|
122
|
-
</div>
|
|
123
|
-
<!-- 对话输入框 -->
|
|
124
|
-
<div ref="talkInputRef" class="chat-embed__input_container">
|
|
125
|
-
<ChatSender
|
|
126
|
-
:loading="loading"
|
|
127
|
-
@submit-question="sendQuestion"
|
|
128
|
-
@new-chat-session="newChatSession"
|
|
129
|
-
@handle-cancel="handleCancel"
|
|
130
|
-
@view-json="viewJson"
|
|
131
|
-
/>
|
|
132
|
-
</div>
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
135
|
-
</transition>
|
|
136
|
-
<json-view-dialog v-model="jsonDialogVisible" :json-object="jsonObject" :append-to-body="true" title="预览数据" />
|
|
137
|
-
</div>
|
|
138
|
-
</template>
|
|
139
|
-
<script setup lang="ts">
|
|
140
|
-
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
|
141
|
-
import { Refresh, DocumentCopy } from '@element-plus/icons-vue'
|
|
142
|
-
import { BubbleList, Thinking, useXStream, Typewriter } from 'vue-element-plus-x'
|
|
143
|
-
import { useDraggable } from '@vueuse/core'
|
|
144
|
-
import { ElMessage } from 'element-plus'
|
|
145
|
-
import { getMessageTemplate, defaultMessage } from './chat-embed-message'
|
|
146
|
-
import RecommendationMessage from './recommendation-message.vue'
|
|
147
|
-
import { BubbleProps } from 'vue-element-plus-x/types/Bubble'
|
|
148
|
-
import { useI18n } from 'vue-i18n'
|
|
149
|
-
import Header from './header.vue'
|
|
150
|
-
import ChatSender from './chat-sender.vue'
|
|
151
|
-
import { JsonViewDialog } from '../../json-view'
|
|
152
|
-
import { generateFileName, downloadJsonFile } from './util.ts'
|
|
153
|
-
|
|
154
|
-
const { t } = useI18n()
|
|
155
|
-
const chatIcon = ref()
|
|
156
|
-
let isActualClick = ref(true)
|
|
157
|
-
const isActualClickTimer = ref(null)
|
|
158
|
-
|
|
159
|
-
const jsonDialogVisible = ref(false)
|
|
160
|
-
const jsonObject = ref({})
|
|
161
|
-
|
|
162
|
-
const initialX = document.documentElement.clientWidth - 100
|
|
163
|
-
const initialY = document.documentElement.clientHeight - 100
|
|
164
|
-
const { x, y, style } = useDraggable(chatIcon, {
|
|
165
|
-
// 聊天图标的初始位置
|
|
166
|
-
initialValue: { x: initialX, y: initialY },
|
|
167
|
-
preventDefault: true,
|
|
168
|
-
onStart() {
|
|
169
|
-
// 拖拽开始时重置状态
|
|
170
|
-
isActualClick.value = true
|
|
171
|
-
},
|
|
172
|
-
onMove(position) {
|
|
173
|
-
isActualClick.value = false
|
|
174
|
-
// 限制拖拽范围 防止拖出屏幕外
|
|
175
|
-
const maxX = window.innerWidth - chatIcon.value.offsetWidth
|
|
176
|
-
const maxY = window.innerHeight - chatIcon.value.offsetHeight
|
|
177
|
-
position.x = Math.max(0, Math.min(position.x, maxX))
|
|
178
|
-
position.y = Math.max(0, Math.min(position.y, maxY))
|
|
179
|
-
},
|
|
180
|
-
onEnd() {
|
|
181
|
-
adjustChatIconPosition()
|
|
182
|
-
// 延迟重置确保 click 事件先处理
|
|
183
|
-
setTimeout(() => (isActualClick.value = true), 50)
|
|
184
|
-
}
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
function adjustChatIconPosition() {
|
|
188
|
-
if (!chatIcon.value) return
|
|
189
|
-
const maxX = window.innerWidth - chatIcon.value.offsetWidth
|
|
190
|
-
const maxY = window.innerHeight - chatIcon.value.offsetHeight
|
|
191
|
-
if (x.value > maxX) x.value = maxX
|
|
192
|
-
if (y.value > maxY) y.value = maxY
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const talkInputRef = ref()
|
|
196
|
-
// 显示聊天窗口的状态
|
|
197
|
-
const showChatVisable = ref(false)
|
|
198
|
-
// 聊天窗口的引用
|
|
199
|
-
const chatContainerRef = ref()
|
|
200
|
-
// 聊天窗口主区域的引用
|
|
201
|
-
const talkMainRef = ref()
|
|
202
|
-
// 聊天输入框状态
|
|
203
|
-
const loading = ref(false)
|
|
204
|
-
// 聊天窗口是否全屏
|
|
205
|
-
const dialogFullScreen = ref(false)
|
|
206
|
-
|
|
207
|
-
const talkMainRefKey = ref(0)
|
|
208
|
-
|
|
209
|
-
const bubbleMaxWidth = ref('')
|
|
210
|
-
const bubbleMaxHeight = ref('500px')
|
|
211
|
-
|
|
212
|
-
const aiAvatar = ref('https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png')
|
|
213
|
-
|
|
214
|
-
// 聊天内容
|
|
215
|
-
const messageList: any = ref([])
|
|
216
|
-
// 默认ai提示消息
|
|
217
|
-
messageList.value.push(defaultMessage)
|
|
218
|
-
// messageList.value.push(getMessageTemplate('user', '11111111111', true))
|
|
219
|
-
// 正在生成的ai消息
|
|
220
|
-
const answerContent: any = ref({})
|
|
221
|
-
// 后端会话session_id
|
|
222
|
-
const session_id = ref(null)
|
|
223
|
-
|
|
224
|
-
onMounted(() => {
|
|
225
|
-
window.addEventListener('resize', adjustChatIconPosition)
|
|
226
|
-
})
|
|
227
|
-
|
|
228
|
-
onUnmounted(() => {
|
|
229
|
-
window.removeEventListener('resize', adjustChatIconPosition)
|
|
230
|
-
// 清除定时器
|
|
231
|
-
if (isActualClickTimer.value) {
|
|
232
|
-
clearTimeout(isActualClickTimer.value)
|
|
233
|
-
}
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
// 处理聊天窗口的显示和隐藏
|
|
237
|
-
function showChatDialog() {
|
|
238
|
-
if (isActualClick.value) {
|
|
239
|
-
showChatVisable.value = !showChatVisable.value
|
|
240
|
-
talkMainRefKey.value++
|
|
241
|
-
nextTick(() => {
|
|
242
|
-
setHeightAndWidth()
|
|
243
|
-
})
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const { cancel, data } = useXStream()
|
|
248
|
-
|
|
249
|
-
// 发送聊天内容
|
|
250
|
-
function sendQuestion(submitData: any) {
|
|
251
|
-
const question = submitData.question
|
|
252
|
-
if (!question) {
|
|
253
|
-
return
|
|
254
|
-
}
|
|
255
|
-
data.value = []
|
|
256
|
-
const message = getMessageTemplate('user', question, true)
|
|
257
|
-
if (submitData.additionalData && submitData.additionalData.length > 0) {
|
|
258
|
-
message.additionalData = submitData.additionalData
|
|
259
|
-
message.additionalDataLabel = submitData.additionalDataLabel
|
|
260
|
-
message.menuName = submitData.menuName
|
|
261
|
-
message.menuCode = submitData.menuCode
|
|
262
|
-
}
|
|
263
|
-
messageList.value.push(message)
|
|
264
|
-
// console.log('submit', question)
|
|
265
|
-
loading.value = true
|
|
266
|
-
if (!session_id.value) {
|
|
267
|
-
session_id.value = new Date().getTime().toString()
|
|
268
|
-
}
|
|
269
|
-
// 创建一个新的消息对象
|
|
270
|
-
answerContent.value = getMessageTemplate('ai', '', false)
|
|
271
|
-
// 设置消息的状态为正在思考 并存下历史的 question信息
|
|
272
|
-
answerContent.value.thinkingStatus = 'thinking'
|
|
273
|
-
answerContent.value.question = question
|
|
274
|
-
answerContent.value.menuName = submitData.menuName
|
|
275
|
-
answerContent.value.menuCode = submitData.menuCode
|
|
276
|
-
answerContent.value.askAdditionalData = submitData.additionalData
|
|
277
|
-
messageList.value.push(answerContent.value)
|
|
278
|
-
try {
|
|
279
|
-
window.$vueApp.config.globalProperties.$http
|
|
280
|
-
.post(window.$vueApp.config.globalProperties.baseAPI + '/component/ai/multiple-fuck', {
|
|
281
|
-
question: question,
|
|
282
|
-
messageId: session_id.value,
|
|
283
|
-
data: JSON.stringify(submitData.additionalData)
|
|
284
|
-
})
|
|
285
|
-
.then((res) => {
|
|
286
|
-
// 创建一个新的消息对象
|
|
287
|
-
answerContent.value.thinkingStatus = 'end'
|
|
288
|
-
answerContent.value.content = res
|
|
289
|
-
answerContent.value = {}
|
|
290
|
-
loading.value = false
|
|
291
|
-
})
|
|
292
|
-
} catch (err) {
|
|
293
|
-
console.error('Fetch error:', err)
|
|
294
|
-
messageList.push(getMessageTemplate('ai', t('chatEmbed.requestFailed'), false))
|
|
295
|
-
loading.value = false
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// 处理聊天内容的取消
|
|
300
|
-
function handleCancel() {
|
|
301
|
-
loading.value = false
|
|
302
|
-
messageList.value[messageList.value.length - 1].thinkingStatus = 'end'
|
|
303
|
-
cancel()
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// 处理聊天窗口的全屏和缩小
|
|
307
|
-
function expandDialog() {
|
|
308
|
-
dialogFullScreen.value = !dialogFullScreen.value
|
|
309
|
-
setHeightAndWidth()
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function setHeightAndWidth() {
|
|
313
|
-
let heightVh = 100
|
|
314
|
-
let widthVw = 40
|
|
315
|
-
if (dialogFullScreen.value) {
|
|
316
|
-
heightVh = 100
|
|
317
|
-
widthVw = 100
|
|
318
|
-
}
|
|
319
|
-
chatContainerRef.value.style.height = `calc(${heightVh}vh - var(--chat-padding) * 2)`
|
|
320
|
-
chatContainerRef.value.style.width = `calc(${widthVw}vw - var(--chat-padding) * 2)`
|
|
321
|
-
// talkMainRef.value.style.height = `calc(${heightVh}vh - var(--header-height) - var(--chat-padding) * 2)`
|
|
322
|
-
const talkHeight = talkInputRef.value.offsetHeight
|
|
323
|
-
// alert(`talkHeight: ${talkHeight}`)
|
|
324
|
-
// bubbleMaxHeight.value = `calc(${heightVh}vh - var(--header-height) - var(--chat-padding) * 5 - 144px)`
|
|
325
|
-
nextTick(() => {
|
|
326
|
-
const talkHeight = talkInputRef.value?.offsetHeight || 80
|
|
327
|
-
// 定义具体的像素值
|
|
328
|
-
const headerHeight = 56
|
|
329
|
-
const chatPadding = 12
|
|
330
|
-
// 更清晰的计算:总高度 - 头部 - 输入框 - 各种padding和间距
|
|
331
|
-
bubbleMaxHeight.value = `calc(${heightVh}vh - ${headerHeight}px - ${talkHeight}px - ${chatPadding * 4}px)`
|
|
332
|
-
talkMainRefKey.value++
|
|
333
|
-
})
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// 点击推荐内容的处理函数
|
|
337
|
-
// 这里可以根据需要进行处理,比如发送请求、更新状态等
|
|
338
|
-
function clickRecommendation(item: BubbleProps) {
|
|
339
|
-
console.log('clickRecommendation', item)
|
|
340
|
-
sendQuestion(item.content)
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function regenerateQuestion(answerData) {
|
|
344
|
-
sendQuestion({
|
|
345
|
-
question: answerData.question,
|
|
346
|
-
additionalData: answerData.additionalData,
|
|
347
|
-
additionalDataLabel: answerData.additionalDataLabel,
|
|
348
|
-
menuName: answerData.menuName,
|
|
349
|
-
menuCode: answerData.menuCode
|
|
350
|
-
})
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
function cpoyContent(item: BubbleProps) {
|
|
354
|
-
// 复制内容到剪贴板
|
|
355
|
-
if (!item.content) {
|
|
356
|
-
return
|
|
357
|
-
}
|
|
358
|
-
navigator.clipboard.writeText(item.content).then(() => {
|
|
359
|
-
ElMessage({
|
|
360
|
-
message: t('chatEmbed.copySuccess'),
|
|
361
|
-
type: 'success'
|
|
362
|
-
})
|
|
363
|
-
})
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
function newChatSession() {
|
|
367
|
-
// 清空聊天记录
|
|
368
|
-
messageList.value = []
|
|
369
|
-
if (session_id.value) {
|
|
370
|
-
try {
|
|
371
|
-
window.$vueApp.config.globalProperties.$http
|
|
372
|
-
.post(window.$vueApp.config.globalProperties.baseAPI + '/component/ai/multiple-fuck/clear/' + session_id.value)
|
|
373
|
-
.then((res) => {
|
|
374
|
-
//
|
|
375
|
-
})
|
|
376
|
-
} catch (err) {
|
|
377
|
-
console.error('Fetch error:', err)
|
|
378
|
-
messageList.push(getMessageTemplate('ai', t('chatEmbed.requestFailed'), false))
|
|
379
|
-
loading.value = false
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
session_id.value = null
|
|
383
|
-
// 重置加载状态
|
|
384
|
-
loading.value = false
|
|
385
|
-
messageList.value.push(defaultMessage)
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function viewJson(viewData: any) {
|
|
389
|
-
jsonObject.value = viewData
|
|
390
|
-
jsonDialogVisible.value = true
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// 下载 JSON 数据功能
|
|
394
|
-
function downloadJsonData(data: any, fileName: string) {
|
|
395
|
-
try {
|
|
396
|
-
downloadJsonFile(data, generateFileName(fileName || 'data'))
|
|
397
|
-
} catch (error) {
|
|
398
|
-
console.error('下载失败:', error)
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
</script>
|
|
402
|
-
<style lang="scss" rel="stylesheet/scss" scoped>
|
|
403
|
-
@import url('./chat-embed.css');
|
|
404
|
-
:root {
|
|
405
|
-
--header-height: 56px;
|
|
406
|
-
--chat-padding: 12px;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
h4 {
|
|
410
|
-
font-size: 16px;
|
|
411
|
-
margin-top: 0px;
|
|
412
|
-
margin-bottom: 0px;
|
|
413
|
-
}
|
|
414
|
-
:deep(.el-bubble-content-wrapper .el-bubble-content) {
|
|
415
|
-
padding: 0 !important;
|
|
416
|
-
}
|
|
417
|
-
:deep(.el-divider--horizontal) {
|
|
418
|
-
margin: 5px 0;
|
|
419
|
-
}
|
|
420
|
-
</style>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Bubble
|
|
3
|
-
v-for="(recommendation, index) in item.recommendations"
|
|
4
|
-
class="chat-embed__recommendation"
|
|
5
|
-
:no-style="true"
|
|
6
|
-
variant="borderless"
|
|
7
|
-
>
|
|
8
|
-
<template v-if="index === 0" #header>
|
|
9
|
-
<div class="content-container-header">推荐内容</div>
|
|
10
|
-
</template>
|
|
11
|
-
<template #content>
|
|
12
|
-
<div class="content-borderless-container" @click="clickRecommendation(recommendation)">
|
|
13
|
-
{{ recommendation.content }}
|
|
14
|
-
</div>
|
|
15
|
-
</template>
|
|
16
|
-
</Bubble>
|
|
17
|
-
</template>
|
|
18
|
-
<script lang="ts" setup>
|
|
19
|
-
import { Bubble } from 'vue-element-plus-x'
|
|
20
|
-
import { defineProps, defineEmits } from 'vue'
|
|
21
|
-
const props = defineProps({
|
|
22
|
-
item: {
|
|
23
|
-
type: Object,
|
|
24
|
-
required: true
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const emit = defineEmits(['clickRecommendation'])
|
|
29
|
-
|
|
30
|
-
const clickRecommendation = (recommendation: any) => {
|
|
31
|
-
emit('clickRecommendation', recommendation)
|
|
32
|
-
}
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<style scoped>
|
|
36
|
-
@import url('./chat-embed.css');
|
|
37
|
-
</style>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// 生成文件名
|
|
2
|
-
function generateFileName(fileName: string): string {
|
|
3
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)
|
|
4
|
-
const safeName = fileName.replace(/[^a-zA-Z0-9\u4e00-\u9fa5]/g, '_')
|
|
5
|
-
return `${safeName}_${timestamp}.json`
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// 核心下载方法
|
|
9
|
-
function downloadJsonFile(data: any, fileName: string) {
|
|
10
|
-
// 将数据转换为格式化的 JSON 字符串
|
|
11
|
-
const jsonString = JSON.stringify(data, null, 2)
|
|
12
|
-
|
|
13
|
-
// 创建 Blob 对象
|
|
14
|
-
const blob = new Blob([jsonString], {
|
|
15
|
-
type: 'application/json;charset=utf-8'
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
// 创建下载链接
|
|
19
|
-
const url = URL.createObjectURL(blob)
|
|
20
|
-
const link = document.createElement('a')
|
|
21
|
-
link.href = url
|
|
22
|
-
link.download = fileName
|
|
23
|
-
|
|
24
|
-
// 触发下载
|
|
25
|
-
document.body.appendChild(link)
|
|
26
|
-
link.click()
|
|
27
|
-
|
|
28
|
-
// 清理
|
|
29
|
-
document.body.removeChild(link)
|
|
30
|
-
URL.revokeObjectURL(url)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { generateFileName, downloadJsonFile }
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-dialog
|
|
3
|
-
append-to-body
|
|
4
|
-
v-model="showJsonVisible"
|
|
5
|
-
:append-to-body="appendToBody"
|
|
6
|
-
:title="title"
|
|
7
|
-
width="600"
|
|
8
|
-
@close="close"
|
|
9
|
-
>
|
|
10
|
-
<json-view :jsonObject="jsonObject" />
|
|
11
|
-
</el-dialog>
|
|
12
|
-
</template>
|
|
13
|
-
<script lang="ts" setup>
|
|
14
|
-
import { ref, defineEmits, defineProps, defineOptions, watch } from 'vue'
|
|
15
|
-
defineOptions({
|
|
16
|
-
name: 'JsonViewDialog',
|
|
17
|
-
inheritAttrs: false
|
|
18
|
-
})
|
|
19
|
-
import JsonView from './json-view.vue'
|
|
20
|
-
const props = defineProps({
|
|
21
|
-
jsonObject: {
|
|
22
|
-
type: Object,
|
|
23
|
-
default: () => {}
|
|
24
|
-
},
|
|
25
|
-
appendToBody: {
|
|
26
|
-
type: Boolean,
|
|
27
|
-
default: false
|
|
28
|
-
},
|
|
29
|
-
modelValue: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
default: false
|
|
32
|
-
},
|
|
33
|
-
title: {
|
|
34
|
-
type: String,
|
|
35
|
-
default: 'JSON 预览'
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
const emits = defineEmits(['update:modelValue'])
|
|
39
|
-
const showJsonVisible = ref(false)
|
|
40
|
-
watch(
|
|
41
|
-
() => props.modelValue,
|
|
42
|
-
(newVal) => {
|
|
43
|
-
if (newVal) {
|
|
44
|
-
showJsonVisible.value = true
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
const close = () => {
|
|
49
|
-
showJsonVisible.value = false
|
|
50
|
-
emits('update:modelValue', false)
|
|
51
|
-
}
|
|
52
|
-
</script>
|
|
53
|
-
<style scoped></style>
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
:style="{
|
|
4
|
-
width: '100%'
|
|
5
|
-
}"
|
|
6
|
-
ref="cfCodemirrorJsonViewRef"
|
|
7
|
-
id="cf-codemirror-view-json"
|
|
8
|
-
></div>
|
|
9
|
-
</template>
|
|
10
|
-
<script lang="ts" setup>
|
|
11
|
-
import { ref, defineProps, defineOptions, watch, nextTick, onMounted } from 'vue'
|
|
12
|
-
defineOptions({
|
|
13
|
-
name: 'JsonView',
|
|
14
|
-
inheritAttrs: false
|
|
15
|
-
})
|
|
16
|
-
import { basicSetup, EditorView } from 'codemirror'
|
|
17
|
-
import { jsonLanguage } from '@codemirror/lang-json'
|
|
18
|
-
import { EditorState, Facet } from '@codemirror/state'
|
|
19
|
-
|
|
20
|
-
const props = defineProps({
|
|
21
|
-
jsonObject: {
|
|
22
|
-
type: Object,
|
|
23
|
-
default: () => {}
|
|
24
|
-
},
|
|
25
|
-
height: {
|
|
26
|
-
type: Number,
|
|
27
|
-
default: 0
|
|
28
|
-
},
|
|
29
|
-
theme: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: null
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
const editor = ref<any>(null)
|
|
35
|
-
const cfCodemirrorJsonViewRef = ref()
|
|
36
|
-
const codemirrorHeight = ref('400px')
|
|
37
|
-
watch(
|
|
38
|
-
() => props.jsonObject,
|
|
39
|
-
(newVal) => {
|
|
40
|
-
if (editor.value) {
|
|
41
|
-
// 更新 CodeMirror 中的值
|
|
42
|
-
loadEditor()
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{ deep: true }
|
|
46
|
-
)
|
|
47
|
-
onMounted(() => {
|
|
48
|
-
nextTick(() => {
|
|
49
|
-
loadEditor()
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
function loadEditor() {
|
|
54
|
-
if (editor.value) {
|
|
55
|
-
editor.value.destroy()
|
|
56
|
-
}
|
|
57
|
-
const jsonStr = props.jsonObject ? JSON.stringify(props.jsonObject, null, 2) : ''
|
|
58
|
-
if (props.height) {
|
|
59
|
-
codemirrorHeight.value = props.height + 'px'
|
|
60
|
-
} else {
|
|
61
|
-
if (cfCodemirrorJsonViewRef.value) {
|
|
62
|
-
const rect = cfCodemirrorJsonViewRef.value.getBoundingClientRect()
|
|
63
|
-
if (rect.y || rect.y === 0) {
|
|
64
|
-
console.log('window.innerHeight - rect.y', window.innerHeight, rect.y)
|
|
65
|
-
codemirrorHeight.value = window.innerHeight - rect.y - 100 + 'px'
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const state = getEditorState(jsonStr)
|
|
70
|
-
let element: Element | null = document.getElementById('cf-codemirror-view-json')
|
|
71
|
-
if (element) {
|
|
72
|
-
editor.value = new EditorView({
|
|
73
|
-
state,
|
|
74
|
-
parent: element
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// 获取编辑器状态
|
|
79
|
-
function getEditorState(jsonStr: string) {
|
|
80
|
-
// 获取主题
|
|
81
|
-
const mytheme = getTheme()
|
|
82
|
-
// 基本主题样式,主要设置字体大小和高度
|
|
83
|
-
const baseTheme = EditorView.theme({
|
|
84
|
-
'.cm-content, .cm-gutter': { minHeight: codemirrorHeight.value },
|
|
85
|
-
'&': {
|
|
86
|
-
height: codemirrorHeight.value,
|
|
87
|
-
maxHeight: codemirrorHeight.value,
|
|
88
|
-
fontSize: '12px'
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
return EditorState.create({
|
|
92
|
-
doc: jsonStr,
|
|
93
|
-
extensions: [
|
|
94
|
-
EditorState.tabSize.of(16),
|
|
95
|
-
basicSetup,
|
|
96
|
-
jsonLanguage,
|
|
97
|
-
mytheme,
|
|
98
|
-
baseTheme,
|
|
99
|
-
readOnlyFacet.of(true),
|
|
100
|
-
preventChanges
|
|
101
|
-
]
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// 创建一个新的 Facet
|
|
106
|
-
const readOnlyFacet = Facet.define<boolean, boolean>({ combine: (values) => values.some((a) => a) })
|
|
107
|
-
|
|
108
|
-
// 创建一个新的 StateField 来监听更改
|
|
109
|
-
const preventChanges = EditorState.transactionFilter.of((tr: any) => {
|
|
110
|
-
if (tr.isUserEvent && tr.docChanged && tr.state.facet(readOnlyFacet)) {
|
|
111
|
-
return {
|
|
112
|
-
changes: {
|
|
113
|
-
from: tr.changes.from,
|
|
114
|
-
to: tr.changes.to,
|
|
115
|
-
insert: tr.startState.doc.sliceString(tr.changes.from, tr.changes.to)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return tr
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
function getTheme() {
|
|
123
|
-
return EditorView.theme({})
|
|
124
|
-
}
|
|
125
|
-
</script>
|
|
126
|
-
<style scoped></style>
|
|
Binary file
|