From 1285218eea770fb7937efb20034655bbafa114f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B0=A2=E9=9B=A8?= <554737215@qq.com> Date: Thu, 6 Mar 2025 14:07:05 +0800 Subject: [PATCH] =?UTF-8?q?fetch:=20=E9=A1=B5=E9=9D=A2=E7=A7=BB=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 对话数据、账单统计移植 --- src/api/new-ai/conversation.ts | 23 +++ src/api/new-ai/message.ts | 63 +++++++ src/api/new-ai/statictic.ts | 33 ++++ .../ai/chat/new-chat/message/Message.vue | 16 +- src/views/ai/message/columns.ts | 107 ++++++++++++ src/views/ai/message/composables/index.ts | 165 ++++++++++++++++++ src/views/ai/message/conversation/columns.ts | 12 ++ .../conversation/components/InfoList.vue | 68 ++++++++ .../message/conversation/composables/index.ts | 107 ++++++++++++ src/views/ai/message/conversation/index.vue | 45 +++++ src/views/ai/message/index.vue | 57 ++++++ src/views/ai/order/components/Chart.vue | 79 +++++++++ src/views/ai/order/components/List.vue | 53 ++++++ src/views/ai/order/components/columns.ts | 56 ++++++ src/views/ai/order/composables/index.ts | 39 +++++ src/views/ai/order/index.vue | 15 ++ .../dataset-form/components/edit-doc.vue | 2 +- 17 files changed, 924 insertions(+), 16 deletions(-) create mode 100644 src/api/new-ai/conversation.ts create mode 100644 src/api/new-ai/message.ts create mode 100644 src/api/new-ai/statictic.ts create mode 100644 src/views/ai/message/columns.ts create mode 100644 src/views/ai/message/composables/index.ts create mode 100644 src/views/ai/message/conversation/columns.ts create mode 100644 src/views/ai/message/conversation/components/InfoList.vue create mode 100644 src/views/ai/message/conversation/composables/index.ts create mode 100644 src/views/ai/message/conversation/index.vue create mode 100644 src/views/ai/message/index.vue create mode 100644 src/views/ai/order/components/Chart.vue create mode 100644 src/views/ai/order/components/List.vue create mode 100644 src/views/ai/order/components/columns.ts create mode 100644 src/views/ai/order/composables/index.ts create mode 100644 src/views/ai/order/index.vue diff --git a/src/api/new-ai/conversation.ts b/src/api/new-ai/conversation.ts new file mode 100644 index 0000000..ef7a12a --- /dev/null +++ b/src/api/new-ai/conversation.ts @@ -0,0 +1,23 @@ + + + +import request from '@/config/axios' + +export function page(params: any) { + return request.get({ + url: '/chat/aigc/conversation/page', + params, + }); +} + +export function del(id: string) { + return request.delete({ + url: `/chat/aigc/conversation/${id}`, + }); +} + +export function getMessages(conversationId: string) { + return request.get({ + url: `/chat/aigc/conversation/messages/${conversationId}`, + }); +} diff --git a/src/api/new-ai/message.ts b/src/api/new-ai/message.ts new file mode 100644 index 0000000..a7ebdf8 --- /dev/null +++ b/src/api/new-ai/message.ts @@ -0,0 +1,63 @@ + + +import request from '@/config/axios' + +/** + * 消息列表接口参数 + */ +export interface MessageParams { + text?: string; + username?: string; + role?: string; + pageNum?: number; + pageSize?: number; +} + +/** + * 获取消息列表 + */ +export function list(params: MessageParams) { + return request.get({ + url: '/chat/aigc/message/list', + params + }) +} + +/** + * 分页获取消息列表 + */ +export function page(params: MessageParams) { + return request.get({ + url: '/chat/aigc/message/page', + params + }) +} + +/** + * 添加消息 + */ +export function add(data: any) { + return request.post({ + url: '/chat/aigc/message', + data + }) +} + +/** + * 更新消息 + */ +export function update(data: any) { + return request.put({ + url: '/chat/aigc/message', + data + }) +} + +/** + * 删除消息 + */ +export function del(id: string) { + return request.delete({ + url: `/chat/aigc/message/${id}` + }) +} diff --git a/src/api/new-ai/statictic.ts b/src/api/new-ai/statictic.ts new file mode 100644 index 0000000..3ed400b --- /dev/null +++ b/src/api/new-ai/statictic.ts @@ -0,0 +1,33 @@ + + +import request from '@/config/axios' + +export function getReqChartBy30() { + return request.get({ + url: `/chat/aigc/statistic/requestBy30`, + }); +} + +export function getReqChart() { + return request.get({ + url: `/chat/aigc/statistic/request`, + }); +} + +export function getTokenChartBy30() { + return request.get({ + url: `/chat/aigc/statistic/tokenBy30`, + }); +} + +export function getTokenChart() { + return request.get({ + url: `/chat/aigc/statistic/token`, + }); +} + +export function getHomeData() { + return request.get({ + url: `/chat/aigc/statistic/home`, + }); +} diff --git a/src/views/ai/chat/new-chat/message/Message.vue b/src/views/ai/chat/new-chat/message/Message.vue index e4e26de..9584608 100644 --- a/src/views/ai/chat/new-chat/message/Message.vue +++ b/src/views/ai/chat/new-chat/message/Message.vue @@ -1,18 +1,4 @@ - + + + + + diff --git a/src/views/ai/message/conversation/composables/index.ts b/src/views/ai/message/conversation/composables/index.ts new file mode 100644 index 0000000..47326c7 --- /dev/null +++ b/src/views/ai/message/conversation/composables/index.ts @@ -0,0 +1,107 @@ +import { ref, computed, onMounted } from 'vue' +import type { FormSchema } from '@/types/form' +import type { TableColumn } from '@/types/table' +import { useTable } from '@/hooks/web/useTable' +import { ElTag, dayjs } from 'element-plus' +import { h } from 'vue' +import * as ConversationApi from '@/api/new-ai/conversation' + +export default function () { + const searchParams = ref({}) + const infoRef = ref() + + const schema = ref([ + { + field: 'text', + component: 'Input', + label: '内容', + componentProps: { + placeholder: '请输入内容' + }, + colProps: { + span: 6 + } + } + ]) + + const columns = ref([ + { + label: '用户名', + field: 'username', + align: 'center' + }, + { + label: '窗口标题', + field: 'title', + align: 'center' + }, + { + label: '对话次数', + field: 'chatTotal', + align: 'center', + width: 180 + }, + { + label: 'Token消耗量', + field: 'tokenUsed', + align: 'center', + width: 180 + }, + { + label: '最后一次对话时间', + field: 'endTime', + align: 'center', + width: 180, + formatter: (row: any) => { + return dayjs(row.endTime).format('YYYY-MM-DD HH:mm:ss') + } + }, + { + label: '创建时间', + field: 'createTime', + width: 180, + align: 'center', + formatter: (row: any) => { + return dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') + } + } + ]) + + const { register, tableObject, methods } = useTable({ + getListApi: ConversationApi.page, + defaultParams: searchParams.value, + delListApi: ConversationApi.del + }) + + const handleSearch = (values: any) => { + methods.setSearchParams(values) + } + + const pagination = computed(() => { + return { + total: tableObject.total, + pageSize: tableObject.pageSize, + currentPage: tableObject.currentPage + } + }) + + const handleShowInfo = (row: any) => { + infoRef.value?.show(row) + } + + onMounted(() => { + methods.getList() + }) + + return { + schema, + columns, + register, + handleSearch, + methods, + tableObject, + pagination, + handleShowInfo, + infoRef + } +} diff --git a/src/views/ai/message/conversation/index.vue b/src/views/ai/message/conversation/index.vue new file mode 100644 index 0000000..51dd132 --- /dev/null +++ b/src/views/ai/message/conversation/index.vue @@ -0,0 +1,45 @@ + + + + + + + diff --git a/src/views/ai/message/index.vue b/src/views/ai/message/index.vue new file mode 100644 index 0000000..ffcffea --- /dev/null +++ b/src/views/ai/message/index.vue @@ -0,0 +1,57 @@ + + + + + + diff --git a/src/views/ai/order/components/Chart.vue b/src/views/ai/order/components/Chart.vue new file mode 100644 index 0000000..b4b24ca --- /dev/null +++ b/src/views/ai/order/components/Chart.vue @@ -0,0 +1,79 @@ + + + diff --git a/src/views/ai/order/components/List.vue b/src/views/ai/order/components/List.vue new file mode 100644 index 0000000..73ddbe4 --- /dev/null +++ b/src/views/ai/order/components/List.vue @@ -0,0 +1,53 @@ + + + + + + + diff --git a/src/views/ai/order/components/columns.ts b/src/views/ai/order/components/columns.ts new file mode 100644 index 0000000..2628593 --- /dev/null +++ b/src/views/ai/order/components/columns.ts @@ -0,0 +1,56 @@ +import type { FormSchema } from '@/types/form'; + +export const columns = [ + { + label: '用户名', + field: 'username', + align: 'center', + }, + { + label: '模型名称', + field: 'model', + align: 'center', + }, + { + label: 'Tokens', + field: 'tokens', + align: 'center', + }, + { + label: 'Prompt Tokens', + field: 'promptTokens', + align: 'center', + }, + { + label: 'Prompt Tokens', + field: 'promptTokens', + align: 'center', + }, + { + label: 'IP地址', + field: 'ip', + align: 'center', + }, + { + label: '调用时间', + field: 'createTime', + align: 'center', + width: 180, + }, +]; + +export const searchSchemas: FormSchema[] = [ + { + field: 'name', + component: 'Input', + label: '用户名', + componentProps: { + placeholder: '请输入用户名查询' + }, + colProps: { + span: 6 + } + }, + + +] diff --git a/src/views/ai/order/composables/index.ts b/src/views/ai/order/composables/index.ts new file mode 100644 index 0000000..aba3ae1 --- /dev/null +++ b/src/views/ai/order/composables/index.ts @@ -0,0 +1,39 @@ +import { ref, computed, onMounted } from 'vue' + +import type { TableColumn } from '@/types/table' +import { useTable } from '@/hooks/web/useTable' +import { dayjs } from 'element-plus' +import {page, del} from '@/api/new-ai/message' + +export default function () { + const searchParams = ref({}) + const { register, tableObject, methods } = useTable({ + getListApi:page, + defaultParams: searchParams.value, + delListApi:del + }) + + const handleSearch = (values: any) => { + methods.setSearchParams(values) + } + + const pagination = computed(() => { + return { + total: tableObject.total, + pageSize: tableObject.pageSize, + currentPage: tableObject.currentPage + } + }) + + onMounted(() => { + methods.getList() + }) + + return { + register, + handleSearch, + methods, + tableObject, + pagination + } +} diff --git a/src/views/ai/order/index.vue b/src/views/ai/order/index.vue new file mode 100644 index 0000000..c663a40 --- /dev/null +++ b/src/views/ai/order/index.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/src/views/knowledge/dataset-form/components/edit-doc.vue b/src/views/knowledge/dataset-form/components/edit-doc.vue index 5440616..5bf3890 100644 --- a/src/views/knowledge/dataset-form/components/edit-doc.vue +++ b/src/views/knowledge/dataset-form/components/edit-doc.vue @@ -114,4 +114,4 @@ defineExpose({ show }) - +