cop-web/src/views/task/graph/software/components/index.ts

23 lines
924 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { upperFirst } from 'lodash-es'
import { getModules } from 'utils/autoImport'
const codeMap = new Map([
['task.software.iscsi', 'IscsiServer'],
['task.software.memcache', 'MemCache'],
['task.software.rocketmq', 'RocketMq'],
['task.software.sqlserver', 'SqlServer'],
['task.software.postgresql', 'PgSql'],
['task.software.rabbitmq', 'RabbitMq'],
['task.software.activemq', 'ActiveMq'],
['task.software.tongweb', 'Tongtech']
])
// const vueFiles = require.context('./', true, /\.vue$/);
const vueFiles = (import.meta as any).globEager('./*.vue')
export const components = getModules(vueFiles)
// 优先在map里取值 组件命名规范 task.software.nginx => NginxItem task.software.iscsi.client=>IscsiClient
export function getCurrentComponent(code: string) {
const [f, s = 'Item'] = code.split('task.software.')[1].split('.')
return codeMap.get(code) || `${upperFirst(f)}${upperFirst(s)}`
}