From 73ab7214eb9d5fae05b843f7ee140a6b1b213427 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Mon, 7 Jul 2025 14:23:36 +0800 Subject: [PATCH] feat: create application template --- ui/src/components/card-box/index.vue | 1 + ui/src/components/folder-tree/index.vue | 2 +- ui/src/components/layout-container/index.vue | 2 +- .../locales/lang/en-US/views/application.ts | 9 +- .../locales/lang/zh-CN/views/application.ts | 11 +- .../locales/lang/zh-Hant/views/application.ts | 10 +- .../component/CreateApplicationDialog.vue | 34 +- ui/src/views/application/index.vue | 4 +- ui/src/views/application/template.ts | 465 ++++++++++++++++++ .../tool/component/ToolListContainer.vue | 2 +- 10 files changed, 519 insertions(+), 21 deletions(-) create mode 100644 ui/src/views/application/template.ts diff --git a/ui/src/components/card-box/index.vue b/ui/src/components/card-box/index.vue index 31f2ad94..4432bc4a 100644 --- a/ui/src/components/card-box/index.vue +++ b/ui/src/components/card-box/index.vue @@ -87,6 +87,7 @@ function subHoveredEnter() { position: relative; min-height: var(--card-min-height); min-width: var(--card-min-width); + line-height: 20px !important; .card-header { margin-top: -5px; } diff --git a/ui/src/components/folder-tree/index.vue b/ui/src/components/folder-tree/index.vue index a59e98c3..5b279bf8 100644 --- a/ui/src/components/folder-tree/index.vue +++ b/ui/src/components/folder-tree/index.vue @@ -251,7 +251,7 @@ function refreshFolder() { } .tree-height { padding-top: 4px; - height: calc(100vh - 210px); + height: calc(100vh - 175px); } } :deep(.overflow-inherit_node__children) { diff --git a/ui/src/components/layout-container/index.vue b/ui/src/components/layout-container/index.vue index 39804fdf..fbd68f1f 100644 --- a/ui/src/components/layout-container/index.vue +++ b/ui/src/components/layout-container/index.vue @@ -53,7 +53,7 @@ const showBack = computed(() => { .layout-container__left_content { width: 100%; - height: 100%; + // height: 100%; } &.hidden { diff --git a/ui/src/locales/lang/en-US/views/application.ts b/ui/src/locales/lang/en-US/views/application.ts index 2d558679..d39c3a4c 100644 --- a/ui/src/locales/lang/en-US/views/application.ts +++ b/ui/src/locales/lang/en-US/views/application.ts @@ -53,8 +53,13 @@ export default { workflowPlaceholder: 'Suitable for advanced users to customize the workflow of assistant', }, appTemplate: { - blankApp: 'Blank APP', - assistantApp: 'Knowledge Assistant', + blankApp: { + title: 'Blank APP', + }, + assistantApp: { + title: 'Knowledge Assistant', + description: 'Suitable for advanced users to customize the workflow of assistant', + }, }, aiModel: { label: 'AI Model', diff --git a/ui/src/locales/lang/zh-CN/views/application.ts b/ui/src/locales/lang/zh-CN/views/application.ts index 46092f13..7230a490 100644 --- a/ui/src/locales/lang/zh-CN/views/application.ts +++ b/ui/src/locales/lang/zh-CN/views/application.ts @@ -1,3 +1,5 @@ +import type { title } from 'process' + export default { title: '应用', createApplication: '创建简易应用', @@ -49,8 +51,13 @@ export default { workflowPlaceholder: '适合高级用户自定义小助手的工作流', }, appTemplate: { - blankApp: '空白应用', - assistantApp: '知识库问答助手', + blankApp: { + title: '空白创建', + }, + assistantApp: { + title: '知识库问答助手', + description: '基于用户问题,检索知识库相关内容作为AI模型的参考内容', + }, }, aiModel: { label: 'AI 模型', diff --git a/ui/src/locales/lang/zh-Hant/views/application.ts b/ui/src/locales/lang/zh-Hant/views/application.ts index ee7498a9..961f18a8 100644 --- a/ui/src/locales/lang/zh-Hant/views/application.ts +++ b/ui/src/locales/lang/zh-Hant/views/application.ts @@ -47,9 +47,15 @@ export default { simplePlaceholder: '適合新手建立小助手', workflowPlaceholder: '適合高階用戶自訂小助手的工作流程', }, + appTemplate: { - blankApp: '空白應用', - assistantApp: '知識庫問答助手', + blankApp: { + title: '空白创建', + }, + assistantApp: { + title: '知識庫問答助手', + description: '基於用戶問題,檢索知識庫相關內容作爲AI模型的參考內容', + }, }, aiModel: { label: 'AI 模型', diff --git a/ui/src/views/application/component/CreateApplicationDialog.vue b/ui/src/views/application/component/CreateApplicationDialog.vue index 1d29bd11..eb57deb5 100644 --- a/ui/src/views/application/component/CreateApplicationDialog.vue +++ b/ui/src/views/application/component/CreateApplicationDialog.vue @@ -47,23 +47,35 @@ - {{ $t('views.application.form.appTemplate.blankApp') }} +
+ + {{ $t('views.application.form.appTemplate.blankApp.title') }} +
- - {{ $t('views.application.form.appTemplate.assistantApp') }} - + + +
@@ -90,6 +102,7 @@ import applicationApi from '@/api/application/application' import { MsgSuccess, MsgAlert } from '@/utils/message' import { isWorkFlow } from '@/utils/application' import { baseNodes } from '@/workflow/common/data' +import { applicationTemplate } from '@/views/application/template' import { t } from '@/locales' import useStore from '@/stores' const { user } = useStore() @@ -220,7 +233,7 @@ const submitHandle = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate((valid) => { if (valid) { - if (isWorkFlow(applicationForm.value.type) && appTemplate.value === 'blank') { + if (isWorkFlow(applicationForm.value.type)) { workflowDefault.value.nodes[0].properties.node_data.desc = applicationForm.value.desc workflowDefault.value.nodes[0].properties.node_data.name = applicationForm.value.name applicationForm.value['work_flow'] = workflowDefault.value @@ -248,17 +261,18 @@ const submitHandle = async (formEl: FormInstance | undefined) => { function selectedType(type: string) { appTemplate.value = type + workflowDefault.value = applicationTemplate[type] } defineExpose({ open }) diff --git a/ui/src/views/application/index.vue b/ui/src/views/application/index.vue index 9b99c6b2..c24db17b 100644 --- a/ui/src/views/application/index.vue +++ b/ui/src/views/application/index.vue @@ -101,7 +101,7 @@ :limit="1" :on-change="(file: any, fileList: any) => importApplication(file)" > - +
@@ -129,7 +129,7 @@
', + reasoning_content_start: '', + reasoning_content_enable: false, + }, + dialogue_number: 1, + }, + }, + }, + { + id: '04dd6c1e-95f9-4757-bb3e-134d503fce54', + type: 'reply-node', + x: 1890, + y: 1798.383, + properties: { + config: { + fields: [ + { + label: '内容', + value: 'answer', + }, + ], + }, + height: 504, + showNode: true, + stepName: '指定回复1', + condition: 'AND', + node_data: { + fields: [], + content: '抱歉,没有在知识库查询到相关内容,请提供更详细的信息。', + is_result: true, + reply_type: 'content', + }, + }, + }, + ], + edges: [ + { + id: '73f8992c-65ef-409a-a151-378d0927f2aa', + type: 'app-edge', + sourceNodeId: 'start-node', + targetNodeId: 'fd0324fc-f5e4-4fa6-a2d9-cb251b467605', + startPoint: { + x: 280, + y: 929.6914999999999, + }, + endPoint: { + x: 550, + y: 929.6914999999999, + }, + properties: {}, + pointsList: [ + { + x: 280, + y: 929.6914999999999, + }, + { + x: 390, + y: 929.6914999999999, + }, + { + x: 440, + y: 929.6914999999999, + }, + { + x: 550, + y: 929.6914999999999, + }, + ], + sourceAnchorId: 'start-node_right', + targetAnchorId: 'fd0324fc-f5e4-4fa6-a2d9-cb251b467605_left', + }, + { + id: '6a8d23d9-5179-424e-80c2-f08d37cdb8d4', + type: 'app-edge', + sourceNodeId: 'fd0324fc-f5e4-4fa6-a2d9-cb251b467605', + targetNodeId: '420a6e4f-44ff-4847-bb81-0923630846b5', + startPoint: { + x: 870, + y: 929.6914999999999, + }, + endPoint: { + x: 1010, + y: 929.6914999999999, + }, + properties: {}, + pointsList: [ + { + x: 870, + y: 929.6914999999999, + }, + { + x: 980, + y: 929.6914999999999, + }, + { + x: 900, + y: 929.6914999999999, + }, + { + x: 1010, + y: 929.6914999999999, + }, + ], + sourceAnchorId: 'fd0324fc-f5e4-4fa6-a2d9-cb251b467605_right', + targetAnchorId: '420a6e4f-44ff-4847-bb81-0923630846b5_left', + }, + { + id: '56006748-d9fe-491b-a14b-04fd568cac08', + type: 'app-edge', + sourceNodeId: '420a6e4f-44ff-4847-bb81-0923630846b5', + targetNodeId: '36a440a9-5b00-4d82-b13a-8e7819112918', + startPoint: { + x: 1590, + y: 793.3089999999999, + }, + endPoint: { + x: 1730, + y: 120, + }, + properties: {}, + pointsList: [ + { + x: 1590, + y: 793.3089999999999, + }, + { + x: 1700, + y: 793.3089999999999, + }, + { + x: 1620, + y: 120, + }, + { + x: 1730, + y: 120, + }, + ], + sourceAnchorId: '420a6e4f-44ff-4847-bb81-0923630846b5_7887_right', + targetAnchorId: '36a440a9-5b00-4d82-b13a-8e7819112918_left', + }, + { + id: '9bc8721b-07aa-4730-9347-910ed64e26b9', + type: 'app-edge', + sourceNodeId: '420a6e4f-44ff-4847-bb81-0923630846b5', + targetNodeId: 'f7c3b4a2-cb80-4e47-b050-7fef0315daaf', + startPoint: { + x: 1590, + y: 922.6919999999999, + }, + endPoint: { + x: 1730, + y: 929.6914999999999, + }, + properties: {}, + pointsList: [ + { + x: 1590, + y: 922.6919999999999, + }, + { + x: 1700, + y: 922.6919999999999, + }, + { + x: 1620, + y: 929.6914999999999, + }, + { + x: 1730, + y: 929.6914999999999, + }, + ], + sourceAnchorId: '420a6e4f-44ff-4847-bb81-0923630846b5_6847_right', + targetAnchorId: 'f7c3b4a2-cb80-4e47-b050-7fef0315daaf_left', + }, + { + id: 'c276a5b6-ec29-4ab9-b911-a0a929ff193f', + type: 'app-edge', + sourceNodeId: '420a6e4f-44ff-4847-bb81-0923630846b5', + targetNodeId: '04dd6c1e-95f9-4757-bb3e-134d503fce54', + startPoint: { + x: 1590, + y: 1013.3834999999998, + }, + endPoint: { + x: 1730, + y: 1798.383, + }, + properties: {}, + pointsList: [ + { + x: 1590, + y: 1013.3834999999998, + }, + { + x: 1700, + y: 1013.3834999999998, + }, + { + x: 1620, + y: 1798.383, + }, + { + x: 1730, + y: 1798.383, + }, + ], + sourceAnchorId: '420a6e4f-44ff-4847-bb81-0923630846b5_2794_right', + targetAnchorId: '04dd6c1e-95f9-4757-bb3e-134d503fce54_left', + }, + ], + }, +} diff --git a/ui/src/views/tool/component/ToolListContainer.vue b/ui/src/views/tool/component/ToolListContainer.vue index ed4216bb..5857c1ef 100644 --- a/ui/src/views/tool/component/ToolListContainer.vue +++ b/ui/src/views/tool/component/ToolListContainer.vue @@ -65,7 +65,7 @@ :on-change="(file: any, fileList: any) => importTool(file)" class="import-button" > - +