From 506dd9ed37c62e6f0ec8ddc1f17801b09306cc94 Mon Sep 17 00:00:00 2001 From: cheng <1240800450@qq.com> Date: Wed, 22 May 2024 23:42:40 +0800 Subject: [PATCH] feat: add triad.vue --- package.json | 1 + pnpm-lock.yaml | 11 +- src/api/qa.ts | 84 ++++++++ src/main.ts | 5 + src/views/qa/triad/index.vue | 381 +++++++++++++++++++++++++++++++++-- 5 files changed, 458 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 8b530d2..f686fa8 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "not op_mini all" ], "dependencies": { + "@element-plus/icons-vue": "^2.3.1", "@pureadmin/descriptions": "^1.1.1", "@pureadmin/table": "^2.3.2", "@pureadmin/utils": "^1.9.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b49132f..a7655cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + "@element-plus/icons-vue": + specifier: ^2.3.1 + version: 2.3.1(vue@3.3.4) "@pureadmin/descriptions": specifier: ^1.1.1 version: 1.1.1(element-plus@2.3.6) @@ -1225,10 +1228,10 @@ packages: engines: { node: ">=10" } dev: false - /@element-plus/icons-vue@2.1.0(vue@3.3.4): + /@element-plus/icons-vue@2.3.1(vue@3.3.4): resolution: { - integrity: sha512-PSBn3elNoanENc1vnCfh+3WA9fimRC7n+fWkf3rE5jvv+aBohNHABC/KAR5KWPecxWxDTVT1ERpRbOMRcOV/vA== + integrity: sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg== } peerDependencies: vue: ^3.2.0 @@ -1853,7 +1856,7 @@ packages: peerDependencies: element-plus: ^2.0.0 dependencies: - "@element-plus/icons-vue": 2.1.0(vue@3.3.4) + "@element-plus/icons-vue": 2.3.1(vue@3.3.4) element-plus: 2.3.6(vue@3.3.4) vue: 3.3.4 dev: false @@ -4164,7 +4167,7 @@ packages: vue: ^3.2.0 dependencies: "@ctrl/tinycolor": 3.6.0 - "@element-plus/icons-vue": 2.1.0(vue@3.3.4) + "@element-plus/icons-vue": 2.3.1(vue@3.3.4) "@floating-ui/dom": 1.4.2 "@popperjs/core": /@sxzz/popperjs-es@2.11.7 "@types/lodash": 4.14.195 diff --git a/src/api/qa.ts b/src/api/qa.ts index 88c8454..2d5e6b3 100644 --- a/src/api/qa.ts +++ b/src/api/qa.ts @@ -1,5 +1,6 @@ import { http } from "@/utils/http"; +// chat export type ChatResult = { status: string; chat_history: Array<{ @@ -36,3 +37,86 @@ export const terminateModel = () => { "http://127.0.0.1:5005/qa/terminate_model" ); }; + +// --------------------------------------------- +// traid +export type Triple = { + subject: string; + relation: string; + object: string; +}; + +export type GetTriplesResult = { + data: Triple[]; + total: number; +}; + +export type AddOrUpdateResult = { + message: string; +}; + +export type DeleteResult = { + message: string; +}; + +/** 获取三元组 */ +export const getTraids = (page = 1, limit = 10) => { + return http.request( + "get", + "http://127.0.0.1:5005/traid/get_traids", + { + params: { page, limit } + } + ); +}; + +/** 搜索三元组 */ +export const searchTraid = (keyword: string) => { + return http.request( + "get", + "http://127.0.0.1:5005/traid/search", + { + params: { keyword } + } + ); +}; + +/** 添加三元组 */ +export const addTraid = (data: Triple) => { + return http.request( + "post", + "http://127.0.0.1:5005/traid/add", + { + data + } + ); +}; + +/** 更新三元组 */ +export const updateTraid = (data: { + old_subject: string; + old_relation: string; + old_object: string; + new_subject: string; + new_relation: string; + new_object: string; +}) => { + return http.request( + "put", + "http://127.0.0.1:5005/traid/update", + { + data + } + ); +}; + +/** 删除三元组 */ +export const deleteTraid = (data: Triple) => { + return http.request( + "delete", + "http://127.0.0.1:5005/traid/delete", + { + data + } + ); +}; diff --git a/src/main.ts b/src/main.ts index 60db439..8f51b39 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,6 +7,7 @@ import { createApp, Directive } from "vue"; import { MotionPlugin } from "@vueuse/motion"; // import { useEcharts } from "@/plugins/echarts"; import { injectResponsiveStorage } from "@/utils/responsive"; +import * as ElementPlusIconsVue from "@element-plus/icons-vue"; // import Table from "@pureadmin/table"; // import PureDescriptions from "@pureadmin/descriptions"; @@ -55,3 +56,7 @@ getServerConfig(app).then(async config => { // .use(PureDescriptions); app.mount("#app"); }); + +for (const [key, component] of Object.entries(ElementPlusIconsVue)) { + app.component(key, component); +} diff --git a/src/views/qa/triad/index.vue b/src/views/qa/triad/index.vue index 186f593..890692b 100644 --- a/src/views/qa/triad/index.vue +++ b/src/views/qa/triad/index.vue @@ -1,27 +1,368 @@ - - +