From 9fceb1fa5222a729e860fe78551164d22054de4d Mon Sep 17 00:00:00 2001 From: ulleo Date: Mon, 26 May 2025 16:48:26 +0800 Subject: [PATCH] feat: Chat UI --- frontend/src/api/chat.ts | 12 +- frontend/src/views/chat/ChatBlock.vue | 26 +++ frontend/src/views/chat/ChatRow.vue | 58 +++++ frontend/src/views/chat/WelcomeBlock.vue | 125 +++++++++++ frontend/src/views/chat/index.vue | 110 +++++----- frontend/src/views/ds/DatasourceItemCard.vue | 148 +++++++++++++ frontend/src/views/ds/index.vue | 210 +++++-------------- 7 files changed, 477 insertions(+), 212 deletions(-) create mode 100644 frontend/src/views/chat/ChatBlock.vue create mode 100644 frontend/src/views/chat/ChatRow.vue create mode 100644 frontend/src/views/chat/WelcomeBlock.vue create mode 100644 frontend/src/views/ds/DatasourceItemCard.vue diff --git a/frontend/src/api/chat.ts b/frontend/src/api/chat.ts index c7d7e28a..8234805f 100644 --- a/frontend/src/api/chat.ts +++ b/frontend/src/api/chat.ts @@ -16,6 +16,14 @@ export const questionApi = { query: (id: number) => request.get(`/chat/question/${id}`) } +export interface ChatMessage { + role: 'user' | 'assistant' + create_time?: Date | string + content?: string | number + isTyping?: boolean + isWelcome?: boolean +} + export class ChatRecord { id?: number chat_id?: number @@ -147,11 +155,11 @@ function startChat(data: any): Promise { return request.post('/chat/start', data) } -function renameChat(chat_id: number, brief: string): Promise { +function renameChat(chat_id: number | undefined, brief: string): Promise { return request.post('/chat/rename', {id: chat_id, brief: brief}) } -function deleteChat(id: number): Promise { +function deleteChat(id: number | undefined): Promise { return request.get(`/chat/delete/${id}`) } diff --git a/frontend/src/views/chat/ChatBlock.vue b/frontend/src/views/chat/ChatBlock.vue new file mode 100644 index 00000000..c1a29948 --- /dev/null +++ b/frontend/src/views/chat/ChatBlock.vue @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/chat/ChatRow.vue b/frontend/src/views/chat/ChatRow.vue new file mode 100644 index 00000000..3ffe1449 --- /dev/null +++ b/frontend/src/views/chat/ChatRow.vue @@ -0,0 +1,58 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/chat/WelcomeBlock.vue b/frontend/src/views/chat/WelcomeBlock.vue new file mode 100644 index 00000000..1d1ed658 --- /dev/null +++ b/frontend/src/views/chat/WelcomeBlock.vue @@ -0,0 +1,125 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index 0cb849dc..856f3453 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -19,39 +19,33 @@ -
- {{ message.role }}: {{ message.content }} -
- - - -
-
+
- -
-
- -
- - - - - -
-
+ +
+ +
+
+ + + + + +
@@ -62,23 +56,14 @@ + + + + \ No newline at end of file diff --git a/frontend/src/views/ds/index.vue b/frontend/src/views/ds/index.vue index 1a2379f1..61de0a30 100644 --- a/frontend/src/views/ds/index.vue +++ b/frontend/src/views/ds/index.vue @@ -3,15 +3,17 @@
@@ -20,33 +22,17 @@
-
-
- - - - - - - -
-
-
{{ ds.name }}
-
{{ ds.type_name }}
-
{{ ds.description }}
-
{{ datetimeFormat(ds.create_time) }}
-
-
{{ ds.status }}
-
- - - - -
-
+
@@ -55,18 +41,13 @@ import IconOpeAdd from '@/assets/svg/operate/ope-add.svg' import IconOpeEdit from '@/assets/svg/operate/ope-edit.svg' import IconOpeDelete from '@/assets/svg/operate/ope-delete.svg' -import MysqlDs from '@/assets/svg/ds/mysql-ds.svg' -import SQLServerDs from '@/assets/svg/ds/sqlServer-ds.svg' -import PgDs from '@/assets/svg/ds/pg-ds.svg' -import ExcelDs from '@/assets/svg/ds/Excel-ds.svg' -import OracleDs from '@/assets/svg/ds/oracle-ds.svg' -import { Search, List, CreditCard } from '@element-plus/icons-vue' -import { ref, onMounted } from 'vue' +import {Search, List, CreditCard} from '@element-plus/icons-vue' +import {ref, onMounted} from 'vue' import DsForm from './form.vue' -import { datasourceApi } from '@/api/datasource' -import { datetimeFormat } from '@/utils/utils' -import { ElMessageBox } from 'element-plus-secondary' -import { useRouter } from 'vue-router' +import {datasourceApi} from '@/api/datasource' +import {ElMessageBox} from 'element-plus-secondary' +import {useRouter} from 'vue-router' +import DatasourceItemCard from "@/views/ds/DatasourceItemCard.vue"; const searchValue = ref('') const dsForm = ref() @@ -75,21 +56,12 @@ const allDsList = ref([])// all ds list const router = useRouter() const loading = ref(false) -const getStatus = (status: string) => { - if (status === 'Success') { - return 'connected' - } - if (status === 'Fail') { - return 'failed' - } - if (status === 'Checking') { - return 'needs-verification' - } -} function searchHandle() { - if(searchValue.value) { - dsList.value = JSON.parse(JSON.stringify(allDsList.value)).filter((item: any) => {return item.name.toLowerCase().includes(searchValue.value.toLowerCase())}) + if (searchValue.value) { + dsList.value = JSON.parse(JSON.stringify(allDsList.value)).filter((item: any) => { + return item.name.toLowerCase().includes(searchValue.value.toLowerCase()) + }) } else { dsList.value = JSON.parse(JSON.stringify(allDsList.value)) } @@ -118,22 +90,22 @@ const editTables = (item: any) => { const deleteDs = (item: any) => { ElMessageBox.confirm( - 'Delete this datasource?', - 'Delete', - { - confirmButtonText: 'Confirm', - cancelButtonText: 'Cancel', - type: 'warning', - } + 'Delete this datasource?', + 'Delete', + { + confirmButtonText: 'Confirm', + cancelButtonText: 'Cancel', + type: 'warning', + } ) - .then(() => { - datasourceApi.delete(item.id).then(() => { - console.log('success') - list() - }) - }) - .catch(() => { - }) + .then(() => { + datasourceApi.delete(item.id).then(() => { + console.log('success') + list() + }) + }) + .catch(() => { + }) } const getTables = (id: number, name: string) => { @@ -157,7 +129,7 @@ onMounted(() => {