Skip to content

Commit e5d2630

Browse files
committed
refactor: dropdownMenu
1 parent 3e4aac3 commit e5d2630

File tree

5 files changed

+67
-44
lines changed

5 files changed

+67
-44
lines changed

ui/src/locales/lang/en-US/views/application-workflow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ export default {
7979
cannotEndNode: 'This node cannot be used as an end node'
8080
},
8181
nodes: {
82+
classify: {
83+
aiCapability: 'AI capability',
84+
businessLogic: 'Business logic',
85+
other: 'Other'
86+
},
8287
startNode: {
8388
label: 'Start',
8489
question: 'User Question',

ui/src/locales/lang/zh-CN/views/application-workflow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ export default {
8080
cannotEndNode: '节点不能当做结束节点'
8181
},
8282
nodes: {
83+
classify: {
84+
aiCapability: 'AI能力',
85+
businessLogic: '业务逻辑',
86+
other: '其他'
87+
},
8388
startNode: {
8489
label: '开始',
8590
question: '用户问题',

ui/src/locales/lang/zh-Hant/views/application-workflow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ export default {
8080
cannotEndNode: '節點不能當做結束節點'
8181
},
8282
nodes: {
83+
classify: {
84+
aiCapability: 'AI能力',
85+
businessLogic: '業務邏輯',
86+
other: '其他'
87+
},
8388
startNode: {
8489
label: '開始',
8590
question: '用戶問題',

ui/src/views/application-workflow/component/DropdownMenu.vue

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<template>
22
<div v-show="show" class="workflow-dropdown-menu border border-r-6">
33
<el-tabs v-model="activeName" class="workflow-dropdown-tabs">
4-
<div style="display: flex; width: 100%; justify-content: center" class="mb-4">
5-
<el-input
6-
v-model="search_text"
7-
style="width: 240px"
8-
:placeholder="$t('views.applicationWorkflow.searchBar.placeholder')"
9-
>
4+
<div style="display: flex; width: 100%; justify-content: center;" class="mb-12">
5+
<el-input v-model="search_text" class="mr-12 ml-12"
6+
:placeholder="$t('views.applicationWorkflow.searchBar.placeholder')">
107
<template #suffix>
118
<el-icon class="el-input__icon"><search /></el-icon>
129
</template>
@@ -16,17 +13,27 @@
1613
<el-tab-pane :label="$t('views.applicationWorkflow.baseComponent')" name="base">
1714
<el-scrollbar height="400">
1815
<div v-if="filter_menu_nodes.length > 0">
19-
<template v-for="(item, index) in filter_menu_nodes" :key="index">
20-
<div
21-
class="workflow-dropdown-item cursor flex p-8-12"
22-
@click.stop="clickNodes(item)"
23-
@mousedown.stop="onmousedown(item)"
24-
>
25-
<component :is="iconComponent(`${item.type}-icon`)" class="mr-8 mt-4" :size="32" />
26-
<div class="pre-wrap">
27-
<div class="lighter">{{ item.label }}</div>
28-
<el-text type="info" size="small">{{ item.text }}</el-text>
29-
</div>
16+
<template v-for="(node, index) in filter_menu_nodes" :key="index">
17+
<el-text type="info" size="small" class="color-secondary ml-12">{{ node.label }}</el-text>
18+
<div class="flex-wrap mt-8">
19+
<template v-for="(item, index) in node.list" :key="index">
20+
<el-popover placement="right" :width="280">
21+
<template #reference>
22+
<div class="flex align-center border border-r-6 mb-12 p-8-12 cursor ml-12" style="width: 39%; " @click.stop="clickNodes(item)"
23+
@mousedown.stop="onmousedown(item)">
24+
<component :is="iconComponent(`${item.type}-icon`)" class="mr-8" :size="32" />
25+
<div class="lighter">{{ item.label }}</div>
26+
</div>
27+
</template>
28+
<template #default>
29+
<div class="flex align-center mb-8">
30+
<component :is="iconComponent(`${item.type}-icon`)" class="mr-8" :size="32" />
31+
<div class="lighter color-text-primary">{{ item.label }}</div>
32+
</div>
33+
<el-text type="info" size="small" class="color-secondary lighter">{{ item.text }}</el-text>
34+
</template>
35+
</el-popover>
36+
</template>
3037
</div>
3138
</template>
3239
</div>
@@ -167,10 +174,21 @@ const filter_application_list = computed(() => {
167174
})
168175
169176
const filter_menu_nodes = computed(() => {
170-
return menuNodes.filter((item) =>
171-
item.label.toLocaleLowerCase().includes(search_text.value.toLocaleLowerCase()),
172-
)
173-
})
177+
if (!search_text.value) return menuNodes;
178+
const searchTerm = search_text.value.toLowerCase();
179+
180+
return menuNodes.reduce((result, item) => {
181+
const filteredList = item.list.filter(listItem =>
182+
listItem.label.toLowerCase().includes(searchTerm)
183+
);
184+
185+
if (filteredList.length) {
186+
result.push({ ...item, list: filteredList });
187+
}
188+
189+
return result;
190+
}, []);
191+
});
174192
function clickNodes(item: any, data?: any, type?: string) {
175193
if (data) {
176194
item['properties']['stepName'] = data.name
@@ -197,10 +215,10 @@ function clickNodes(item: any, data?: any, type?: string) {
197215
...(!fileUploadSetting
198216
? {}
199217
: {
200-
...(fileUploadSetting.document ? { document_list: [] } : {}),
201-
...(fileUploadSetting.image ? { image_list: [] } : {}),
202-
...(fileUploadSetting.audio ? { audio_list: [] } : {}),
203-
}),
218+
...(fileUploadSetting.document ? { document_list: [] } : {}),
219+
...(fileUploadSetting.image ? { image_list: [] } : {}),
220+
...(fileUploadSetting.audio ? { audio_list: [] } : {}),
221+
}),
204222
}
205223
} else {
206224
item['properties']['node_data'] = {
@@ -242,10 +260,10 @@ function onmousedown(item: any, data?: any, type?: string) {
242260
...(!fileUploadSetting
243261
? {}
244262
: {
245-
...(fileUploadSetting.document ? { document_list: [] } : {}),
246-
...(fileUploadSetting.image ? { image_list: [] } : {}),
247-
...(fileUploadSetting.audio ? { audio_list: [] } : {}),
248-
}),
263+
...(fileUploadSetting.document ? { document_list: [] } : {}),
264+
...(fileUploadSetting.image ? { image_list: [] } : {}),
265+
...(fileUploadSetting.audio ? { audio_list: [] } : {}),
266+
}),
249267
}
250268
} else {
251269
item['properties']['node_data'] = {
@@ -285,7 +303,7 @@ onMounted(() => {
285303
top: 49px;
286304
right: 122px;
287305
z-index: 99;
288-
width: 268px;
306+
width: 400px;
289307
box-shadow: 0px 4px 8px 0px var(--app-text-color-light-1);
290308
background: #ffffff;
291309
padding-bottom: 8px;

ui/src/workflow/common/data.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -338,20 +338,10 @@ export const textToSpeechNode = {
338338
}
339339
}
340340
export const menuNodes = [
341-
aiChatNode,
342-
imageUnderstandNode,
343-
imageGenerateNode,
344-
searchKnowledgeNode,
345-
rerankerNode,
346-
conditionNode,
347-
replyNode,
348-
formNode,
349-
questionNode,
350-
documentExtractNode,
351-
speechToTextNode,
352-
textToSpeechNode,
353-
variableAssignNode,
354-
mcpNode
341+
{ label: t('views.applicationWorkflow.nodes.classify.aiCapability'), list: [aiChatNode, questionNode, imageGenerateNode, imageUnderstandNode, textToSpeechNode, speechToTextNode] },
342+
{ label: t('views.knowledge.title'), list: [searchKnowledgeNode, rerankerNode] },
343+
{ label: t('views.applicationWorkflow.nodes.classify.businessLogic'), list: [conditionNode, formNode, variableAssignNode, replyNode] },
344+
{ label: t('views.applicationWorkflow.nodes.classify.other'), list: [mcpNode, documentExtractNode] },
355345
]
356346

357347
/**

0 commit comments

Comments
 (0)