修复流程编排页面侧边栏不显示节点的问题
This commit is contained in:
parent
419beb76b2
commit
b924e4bd41
@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, watch, nextTick } from 'vue';
|
||||
import { ref, computed, watch, nextTick, onMounted } from 'vue';
|
||||
import { useFlowStore } from '../../store/flowStore';
|
||||
import { NODE_GROUPS, getAllNodeTypes } from '../../utils/nodeMetadata';
|
||||
import { NODE_GROUPS, getAllNodeTypes, preloadNodeMetadata } from '../../utils/nodeMetadata';
|
||||
import { t } from '@/shared/i18n'
|
||||
|
||||
// Props
|
||||
@ -9,7 +9,7 @@ const props = defineProps({
|
||||
class: { type: String, default: '' }
|
||||
})
|
||||
|
||||
const ALL_NODE_TYPES = getAllNodeTypes();
|
||||
const ALL_NODE_TYPES = ref([]);
|
||||
const flowStore = useFlowStore();
|
||||
const draggedNode = ref(null);
|
||||
const searchText = ref('');
|
||||
@ -20,6 +20,12 @@ const tooltip = ref({ show: false, text: '', x: 0, y: 0, width: 200, direction:
|
||||
const isFullscreen = ref(false);
|
||||
let tooltipTimer = null;
|
||||
|
||||
// 异步加载节点元数据
|
||||
onMounted(async () => {
|
||||
await preloadNodeMetadata();
|
||||
ALL_NODE_TYPES.value = getAllNodeTypes();
|
||||
});
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('recent-node-updated', () => { recent.value = JSON.parse(localStorage.getItem('ai-agent-node-recent') || '[]'); });
|
||||
window.addEventListener('fullscreenchange', () => { isFullscreen.value = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement); });
|
||||
@ -50,9 +56,28 @@ function addRecent(type) { recent.value = [type, ...recent.value.filter(t => t !
|
||||
|
||||
const nodeTypeCount = computed(() => { const counts = {}; flowStore.nodes.forEach(node => { counts[node.type] = (counts[node.type] || 0) + 1; }); return counts; });
|
||||
|
||||
const allNodeTypes = computed(() => { let list = ALL_NODE_TYPES; if (searchText.value.trim()) { const kw = searchText.value.trim().toLowerCase(); list = list.filter(n => n.label.toLowerCase().includes(kw) || n.type.toLowerCase().includes(kw)); } return list; });
|
||||
const allNodeTypes = computed(() => {
|
||||
let list = ALL_NODE_TYPES.value;
|
||||
if (searchText.value.trim()) {
|
||||
const kw = searchText.value.trim().toLowerCase();
|
||||
list = list.filter(n => n.label.toLowerCase().includes(kw) || n.type.toLowerCase().includes(kw));
|
||||
}
|
||||
return list;
|
||||
});
|
||||
|
||||
const filteredNodeTypes = computed(() => { let list = ALL_NODE_TYPES; if (searchText.value.trim()) { const kw = searchText.value.trim().toLowerCase(); list = list.filter(n => n.label.toLowerCase().includes(kw) || n.type.toLowerCase().includes(kw)); } if (activeTab.value === 'favorite') { list = list.filter(n => favorites.value.includes(n.type)); } else if (activeTab.value === 'recent') { list = recent.value.map(type => list.find(n => n.type === type)).filter(Boolean); } return list; });
|
||||
const filteredNodeTypes = computed(() => {
|
||||
let list = ALL_NODE_TYPES.value;
|
||||
if (searchText.value.trim()) {
|
||||
const kw = searchText.value.trim().toLowerCase();
|
||||
list = list.filter(n => n.label.toLowerCase().includes(kw) || n.type.toLowerCase().includes(kw));
|
||||
}
|
||||
if (activeTab.value === 'favorite') {
|
||||
list = list.filter(n => favorites.value.includes(n.type));
|
||||
} else if (activeTab.value === 'recent') {
|
||||
list = recent.value.map(type => list.find(n => n.type === type)).filter(Boolean);
|
||||
}
|
||||
return list;
|
||||
});
|
||||
|
||||
const groupedNodeTypes = computed(() => {
|
||||
const groups = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user