Skip to content

Commit 9caf192

Browse files
committed
feat: copy sql
1 parent 2626f92 commit 9caf192

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed
Lines changed: 3 additions & 0 deletions
Loading

frontend/src/i18n/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"earlier": "Earlier",
119119
"no_time": "No Time",
120120
"rename_conversation_title": "Rename conversation title",
121-
"conversation_title": "Conversation title"
121+
"conversation_title": "Conversation title",
122+
"copied": "Copied"
122123
},
123124
"ds": {
124125
"title": "Data Source",
@@ -513,4 +514,4 @@
513514
"back_community": "Restore to Community Edition",
514515
"confirm_tips": "Are you sure to restore to Community Edition?"
515516
}
516-
}
517+
}

frontend/src/i18n/zh-CN.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
"earlier": "更早以前",
122122
"no_time": "没有时间",
123123
"rename_conversation_title": "重命名对话标题",
124-
"conversation_title": "对话标题"
124+
"conversation_title": "对话标题",
125+
"copied": "已复制"
125126
},
126127
"ds": {
127128
"title": "数据源",
@@ -525,4 +526,4 @@
525526
"back_community": "还原至社区版",
526527
"confirm_tips": "确定还原至社区版?"
527528
}
528-
}
529+
}

frontend/src/views/chat/chat-block/ChartBlock.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import icon_export_outlined from '@/assets/svg/icon_export_outlined.svg'
1515
import icon_into_item_outlined from '@/assets/svg/icon_into-item_outlined.svg'
1616
import icon_window_max_outlined from '@/assets/svg/icon_window-max_outlined.svg'
1717
import icon_window_mini_outlined from '@/assets/svg/icon_window-mini_outlined.svg'
18+
import icon_copy_outlined from '@/assets/svg/icon_copy_outlined.svg'
1819
import { useI18n } from 'vue-i18n'
1920
import SQLComponent from '@/views/chat/component/SQLComponent.vue'
2021
@@ -189,6 +190,13 @@ function showSql() {
189190
function addToDashboard() {
190191
console.log('todo')
191192
}
193+
194+
function copy() {
195+
if (props.message?.record?.sql) {
196+
navigator.clipboard.writeText(props.message.record.sql)
197+
ElMessage.info(t('qa.copied'))
198+
}
199+
}
192200
</script>
193201

194202
<template>
@@ -318,12 +326,17 @@ function addToDashboard() {
318326
direction="rtl"
319327
body-class="chart-sql-drawer-body"
320328
>
321-
<div>
329+
<div class="sql-block">
322330
<SQLComponent
323331
v-if="message.record?.sql"
324332
:sql="message.record?.sql"
325333
style="margin-top: 12px"
326334
/>
335+
<el-button v-if="message.record?.sql" circle class="input-icon" @click="copy">
336+
<el-icon size="16">
337+
<icon_copy_outlined />
338+
</el-icon>
339+
</el-button>
327340
</div>
328341
</el-drawer>
329342
</div>
@@ -490,4 +503,18 @@ function addToDashboard() {
490503
margin-top: 16px;
491504
}
492505
}
506+
507+
.sql-block {
508+
position: relative;
509+
510+
.input-icon {
511+
min-width: unset;
512+
position: absolute;
513+
top: 12px;
514+
right: 12px;
515+
516+
border-color: #dee0e3;
517+
box-shadow: 0px 4px 8px 0px #1f23291a;
518+
}
519+
}
493520
</style>

0 commit comments

Comments
 (0)