Skip to content

Commit 9be33f6

Browse files
perf: workflow search style
1 parent e793bf1 commit 9be33f6

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

ui/src/workflow/common/NodeContainer.vue

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
:size="24"
2222
:item="nodeModel?.properties.node_data"
2323
/>
24-
<h4 class="ellipsis-1 break-all">{{ nodeModel.properties.stepName }}</h4>
24+
<h4
25+
class="ellipsis-1 break-all"
26+
v-html="highlightedStepName(nodeModel.properties.stepName)"
27+
></h4>
2528
</div>
2629

2730
<div @mousemove.stop @mousedown.stop @keydown.stop @click.stop>
@@ -288,7 +291,7 @@ const mousedown = (event?: any) => {
288291
set(props.nodeModel, 'isHovered', !props.nodeModel.isSelected)
289292
props.nodeModel.graphModel.toFront(props.nodeModel.id)
290293
}
291-
const showicon = ref<number | null>(null)
294+
const showicon = ref<number | string | null>(null)
292295
const copyNode = () => {
293296
props.nodeModel.graphModel.clearSelectElements()
294297
const cloneNode = props.nodeModel.graphModel.cloneNode(props.nodeModel.id)
@@ -436,23 +439,51 @@ const closeNodeMenu = () => {
436439
* 检索选中时候触发
437440
* @param kw
438441
*/
442+
443+
const keyWord = ref('')
444+
const currentKeyWord = ref(false)
439445
const selectOn = (kw: string) => {
440446
props.nodeModel.setSelected(true)
447+
keyWord.value = kw
448+
currentKeyWord.value = false
441449
console.log('selectOn', kw)
442450
}
443451
/**
444452
* 定位时触发
445453
* @param kw
446454
*/
447455
const focusOn = (kw: string) => {
456+
currentKeyWord.value = true
448457
console.log('focusOn', kw)
449458
}
450459
/**
451460
* 清除时触发
452461
*/
453462
const clearSelectOn = () => {
463+
keyWord.value = ''
464+
currentKeyWord.value = false
454465
console.log('onClearSearchSelect')
455466
}
467+
468+
// 高亮选中关键字
469+
470+
const highlightedStepName = (contentText: string) => {
471+
let res = contentText
472+
if (keyWord.value === '') {
473+
return res
474+
} else {
475+
const wordsArray = contentText.split('')
476+
for (let i = 0; i < wordsArray.length; i++) {
477+
if (keyWord.value.includes(wordsArray[i])) {
478+
wordsArray[i] = currentKeyWord.value
479+
? `<span style='background: #FF8800;'>${wordsArray[i]}</span>`
480+
: `<span style='background: #FFC60A;'>${wordsArray[i]}</span>`
481+
}
482+
}
483+
res = wordsArray.join('')
484+
return res
485+
}
486+
}
456487
onMounted(() => {
457488
set(props.nodeModel, 'openNodeMenu', (anchorData: any) => {
458489
showAnchor.value ? closeNodeMenu() : openNodeMenu(anchorData)

ui/src/workflow/common/NodeSearch.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<span class="lighter" v-if="selectedCount && selectedCount > 0">
2424
{{ currentIndex + 1 }}/{{ selectedCount }}
2525
</span>
26-
<span class="lighter" v-else-if="searchText.length > 0"> 无结果 </span>
26+
<span class="lighter color-secondary" style="width: 42px;" v-else-if="searchText.length > 0"> 无结果 </span>
2727
<el-divider direction="vertical" />
2828

2929
<el-button text>
@@ -48,7 +48,6 @@
4848

4949
<script setup lang="ts">
5050
import { ref, onMounted, onUnmounted, nextTick, computed } from 'vue'
51-
import { MsgSuccess, MsgWarning } from '@/utils/message'
5251
// Props定义
5352
interface Props {
5453
lf?: any
@@ -75,7 +74,6 @@ const handleKeyDown = (e: KeyboardEvent) => {
7574
}
7675
7776
const focusOn = (node: any) => {
78-
console.log(node)
7977
props.lf?.graphModel.transformModel.focusOn(
8078
node.x,
8179
node.y,

ui/src/workflow/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- 辅助工具栏 -->
44
<Control class="workflow-control" v-if="lf" :lf="lf"></Control>
55
<TeleportContainer :flow-id="flowId" />
6-
<NodeSearch class="workflow-search" :lf="lf"></NodeSearch>
6+
<NodeSearch :lf="lf"></NodeSearch>
77
</template>
88
<script setup lang="ts">
99
import LogicFlow from '@logicflow/core'

0 commit comments

Comments
 (0)