From e50b5cc05184d0d20e19f6587c155147e5d3ad04 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Thu, 15 May 2025 18:21:38 +0800 Subject: [PATCH] feat: tool --- ui/src/api/tool/tool.ts | 31 ++ ui/src/api/type/tool.ts | 13 + ui/src/components/app-icon/index.ts | 22 +- ui/src/components/card-box/index.vue | 34 +- .../dynamics-form/items/radio/RadioRow.vue | 2 +- .../items/table/TableCheckbox.vue | 2 +- .../dynamics-form/items/table/TableRadio.vue | 2 +- ui/src/locales/lang/en-US/common.ts | 8 +- ui/src/locales/lang/zh-CN/common.ts | 8 +- ui/src/locales/lang/zh-Hant/common.ts | 8 +- ui/src/styles/app.scss | 3 + ui/src/styles/element-plus.scss | 8 +- ui/src/views/model/component/ModelCard.vue | 86 ++- ui/src/views/model/component/Provider.vue | 2 +- .../component/AddInternalFunctionDialog.vue | 88 +++ .../views/tool/component/EditAvatarDialog.vue | 127 +++++ .../views/tool/component/FieldFormDialog.vue | 129 +++++ .../tool/component/FunctionDebugDrawer.vue | 184 +++++++ .../tool/component/FunctionFormDrawer.vue | 518 ++++++++++++++++++ .../views/tool/component/InitParamDrawer.vue | 94 ++++ .../tool/component/InternalDescDrawer.vue | 100 ++++ .../views/tool/component/PermissionDialog.vue | 106 ++++ ui/src/views/tool/index.vue | 169 +++++- 23 files changed, 1659 insertions(+), 85 deletions(-) create mode 100644 ui/src/api/type/tool.ts create mode 100644 ui/src/views/tool/component/AddInternalFunctionDialog.vue create mode 100644 ui/src/views/tool/component/EditAvatarDialog.vue create mode 100644 ui/src/views/tool/component/FieldFormDialog.vue create mode 100644 ui/src/views/tool/component/FunctionDebugDrawer.vue create mode 100644 ui/src/views/tool/component/FunctionFormDrawer.vue create mode 100644 ui/src/views/tool/component/InitParamDrawer.vue create mode 100644 ui/src/views/tool/component/InternalDescDrawer.vue create mode 100644 ui/src/views/tool/component/PermissionDialog.vue diff --git a/ui/src/api/tool/tool.ts b/ui/src/api/tool/tool.ts index f8bbdf7dc..2d5d3b64a 100644 --- a/ui/src/api/tool/tool.ts +++ b/ui/src/api/tool/tool.ts @@ -2,6 +2,7 @@ import { Result } from '@/request/Result' import { get, post, del, put } from '@/request/index' import { type Ref } from 'vue' import type { pageRequest } from '@/api/type/common' +import type { toolData } from '@/api/type/tool' const prefix = '/workspace' /** @@ -38,7 +39,37 @@ const getToolList: ( ) } +/** + * 修改工具 + * @param 参数 + + */ +const putToolLib: ( + wordspace_id: string, + tool_id: string, + data: toolData, + loading?: Ref, +) => Promise> = (wordspace_id, tool_id, data, loading) => { + return put(`${prefix}/${wordspace_id}/tool/${tool_id}`, data, undefined, loading) +} + +/** + * 获取工具详情 + * @param tool_id 工具id + * @param loading 加载器 + * @returns 函数详情 + */ +const getToolById: ( + wordspace_id: string, + tool_id: String, + loading?: Ref, +) => Promise> = (wordspace_id, function_lib_id, loading) => { + return get(`${prefix}/${wordspace_id}/tool/${function_lib_id}`, undefined, loading) +} + export default { getToolByFolder, getToolList, + putToolLib, + getToolById } diff --git a/ui/src/api/type/tool.ts b/ui/src/api/type/tool.ts new file mode 100644 index 000000000..85b77a827 --- /dev/null +++ b/ui/src/api/type/tool.ts @@ -0,0 +1,13 @@ +interface toolData { + id?: String + name?: String + icon?: String + desc?: String + code?: String + input_field_list?: Array + init_field_list?: Array + is_active?: Boolean + folder_id?: String +} + +export type { toolData } diff --git a/ui/src/components/app-icon/index.ts b/ui/src/components/app-icon/index.ts index 65f578f19..bb6d0d9ce 100644 --- a/ui/src/components/app-icon/index.ts +++ b/ui/src/components/app-icon/index.ts @@ -117,7 +117,27 @@ export const iconMap: any = { ]) }, }, - + 'app-disabled': { + iconReader: () => { + return h('i', [ + h( + 'svg', + { + style: { height: '100%', width: '100%' }, + viewBox: '0 0 1024 1024', + version: '1.1', + xmlns: 'http://www.w3.org/2000/svg', + }, + [ + h('path', { + d: 'M512 21.333333C241.024 21.333333 21.333333 241.024 21.333333 512S241.024 1002.666667 512 1002.666667 1002.666667 782.976 1002.666667 512 782.976 21.333333 512 21.333333z m297.685333 697.856L304.810667 214.314667a362.666667 362.666667 0 0 1 504.874666 504.874666zM149.333333 512c0-77.056 24.021333-148.48 64.981334-207.189333l504.874666 504.874666A362.666667 362.666667 0 0 1 149.333333 512z', + fill: 'currentColor', + }), + ], + ), + ]) + }, + }, // 动态加载的图标 ...dynamicIcons, } diff --git a/ui/src/components/card-box/index.vue b/ui/src/components/card-box/index.vue index 76672c1a1..abf368214 100644 --- a/ui/src/components/card-box/index.vue +++ b/ui/src/components/card-box/index.vue @@ -2,12 +2,14 @@
-
- - - - - +
+
+ + + + + +
@@ -21,16 +23,19 @@
-
+
{{ description }}
-
- -
-