diff --git a/.env.development b/.env.development index a8b8cec..a578732 100644 --- a/.env.development +++ b/.env.development @@ -1,17 +1,14 @@ -# 页面标题 -VITE_APP_TITLE = 招商车研物联网平台 - -# 开发环境配置 -VITE_APP_ENV = 'development' - -# 招商车研物联网平台/开发环境 -VITE_APP_BASE_API = '/dev-api' - -VITE_API_URL = http://10.148.20.34:13080 -VITE_WS_URL = ws://10.148.20.34:13080/ws -# VITE_API_URL = http://10.148.108.95:13080 //杨溪IP -# VITE_API_URL = http://10.148.108.58:13080 //赵培利IP - -#node-red 服务地址 -#VITE_NODE_RED_URL = 'http://10.148.20.34:13080' -VITE_NODE_RED_URL = 'http://10.148.108.59:1880' +# 页面标题 +VITE_APP_TITLE = 招商车研物联网平台 + +# 开发环境配置 +VITE_APP_ENV = 'development' + +# 招商车研物联网平台/开发环境 +VITE_APP_BASE_API = '/dev-api' + +VITE_API_URL = http://192.168.0.100:13080 +VITE_WS_URL = ws://192.168.0.100:13080/ws +# VITE_API_URL = http://10.148.108.95:13080 //杨溪IP +# VITE_API_URL = http://10.148.108.58:13080 //赵培利IP + diff --git a/src/api/vi/corpus.js b/src/api/vi/corpus.js new file mode 100644 index 0000000..5089b57 --- /dev/null +++ b/src/api/vi/corpus.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询语料库列表 +export function listCorpus(query) { + return request({ + url: '/vi/corpus/list', + method: 'get', + params: query + }) +} + +// 查询语料库详细 +export function getCorpus(corpusId) { + return request({ + url: '/vi/corpus/' + corpusId, + method: 'get' + }) +} + +// 新增语料库 +export function addCorpus(data) { + return request({ + url: '/vi/corpus', + method: 'post', + data: data + }) +} + +// 修改语料库 +export function updateCorpus(data) { + return request({ + url: '/vi/corpus', + method: 'put', + data: data + }) +} + +// 删除语料库 +export function delCorpus(corpusId) { + return request({ + url: '/vi/corpus/' + corpusId, + method: 'delete' + }) +} diff --git a/src/main.js b/src/main.js index 458558b..58595ea 100644 --- a/src/main.js +++ b/src/main.js @@ -1,96 +1,96 @@ -import { createApp } from 'vue' - -import Cookies from 'js-cookie' - -import ElementPlus from 'element-plus' -import 'element-plus/dist/index.css' -import 'element-plus/theme-chalk/dark/css-vars.css' -import locale from 'element-plus/es/locale/lang/zh-cn' - -import '@/assets/styles/index.scss' // global css - -import App from './App' -import store from './store' -import router from './router' -import directive from './directive' // directive -import WebSocketPlugin from './plugins/websocket'; - -// 注册指令 -import plugins from './plugins' // plugins -import { download } from '@/utils/request' - -// svg图标 -import 'virtual:svg-icons-register' -import SvgIcon from '@/components/SvgIcon' -import elementIcons from '@/components/SvgIcon/svgicon' - -import './permission' // permission control - -import { useDict } from '@/utils/dict' -import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi' - -// 分页组件 -import Pagination from '@/components/Pagination' -// 自定义表格工具组件 -import RightToolbar from '@/components/RightToolbar' -// 富文本组件 -import Editor from "@/components/Editor" -// 文件上传组件 -import FileUpload from "@/components/FileUpload" -// 图片上传组件 -import ImageUpload from "@/components/ImageUpload" -// 图片预览组件 -import ImagePreview from "@/components/ImagePreview" -// 字典标签组件 -import DictTag from '@/components/DictTag' - -// ace.config.js(独立配置文件) -import ace from 'ace-builds'; -import modeJsonUrl from 'ace-builds/src-noconflict/mode-json?url'; -ace.config.setModuleUrl('ace/mode/json', modeJsonUrl); // 动态绑定语法模块路径 - -const app = createApp(App) - -// 全局方法挂载 -app.config.globalProperties.useDict = useDict - app.config.globalProperties.download = download -app.config.globalProperties.parseTime = parseTime -app.config.globalProperties.resetForm = resetForm -app.config.globalProperties.handleTree = handleTree -app.config.globalProperties.addDateRange = addDateRange -app.config.globalProperties.selectDictLabel = selectDictLabel -app.config.globalProperties.selectDictLabels = selectDictLabels - -// 全局组件挂载 -app.component('DictTag', DictTag) -app.component('Pagination', Pagination) -app.component('FileUpload', FileUpload) -app.component('ImageUpload', ImageUpload) -app.component('ImagePreview', ImagePreview) -app.component('RightToolbar', RightToolbar) -app.component('Editor', Editor) - -app.use(router) -app.use(store) -app.use(plugins) -app.use(elementIcons) -app.component('svg-icon', SvgIcon) - -directive(app) - -// 使用element-plus 并且设置全局的大小 -app.use(ElementPlus, { - locale: locale, - // 支持 large、default、small - size: Cookies.get('size') || 'default' -}) - - -app.use(WebSocketPlugin, { - // url: import.meta.env.VITE_WS_URL, - url: 'ws://10.148.108.95:13080/ws', - // url: 'ws://10.148.209.5:13080/ws', - userId: 'your_user_id' -}); - -app.mount('#app') +import { createApp } from 'vue' + +import Cookies from 'js-cookie' + +import ElementPlus from 'element-plus' +import 'element-plus/dist/index.css' +import 'element-plus/theme-chalk/dark/css-vars.css' +import locale from 'element-plus/es/locale/lang/zh-cn' + +import '@/assets/styles/index.scss' // global css + +import App from './App' +import store from './store' +import router from './router' +import directive from './directive' // directive +import WebSocketPlugin from './plugins/websocket'; + +// 注册指令 +import plugins from './plugins' // plugins +import { download } from '@/utils/request' + +// svg图标 +import 'virtual:svg-icons-register' +import SvgIcon from '@/components/SvgIcon' +import elementIcons from '@/components/SvgIcon/svgicon' + +import './permission' // permission control + +import { useDict } from '@/utils/dict' +import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi' + +// 分页组件 +import Pagination from '@/components/Pagination' +// 自定义表格工具组件 +import RightToolbar from '@/components/RightToolbar' +// 富文本组件 +import Editor from "@/components/Editor" +// 文件上传组件 +import FileUpload from "@/components/FileUpload" +// 图片上传组件 +import ImageUpload from "@/components/ImageUpload" +// 图片预览组件 +import ImagePreview from "@/components/ImagePreview" +// 字典标签组件 +import DictTag from '@/components/DictTag' + +// ace.config.js(独立配置文件) +import ace from 'ace-builds'; +import modeJsonUrl from 'ace-builds/src-noconflict/mode-json?url'; +ace.config.setModuleUrl('ace/mode/json', modeJsonUrl); // 动态绑定语法模块路径 + +const app = createApp(App) + +// 全局方法挂载 +app.config.globalProperties.useDict = useDict + app.config.globalProperties.download = download +app.config.globalProperties.parseTime = parseTime +app.config.globalProperties.resetForm = resetForm +app.config.globalProperties.handleTree = handleTree +app.config.globalProperties.addDateRange = addDateRange +app.config.globalProperties.selectDictLabel = selectDictLabel +app.config.globalProperties.selectDictLabels = selectDictLabels + +// 全局组件挂载 +app.component('DictTag', DictTag) +app.component('Pagination', Pagination) +app.component('FileUpload', FileUpload) +app.component('ImageUpload', ImageUpload) +app.component('ImagePreview', ImagePreview) +app.component('RightToolbar', RightToolbar) +app.component('Editor', Editor) + +app.use(router) +app.use(store) +app.use(plugins) +app.use(elementIcons) +app.component('svg-icon', SvgIcon) + +directive(app) + +// 使用element-plus 并且设置全局的大小 +app.use(ElementPlus, { + locale: locale, + // 支持 large、default、small + size: Cookies.get('size') || 'default' +}) + + +app.use(WebSocketPlugin, { + // url: import.meta.env.VITE_WS_URL, + url: 'ws://192.168.0.100:13080/ws', + // url: 'ws://10.148.209.5:13080/ws', + userId: 'your_user_id' +}); + +app.mount('#app') diff --git a/src/utils/flow.js b/src/utils/flow.js index 9fdf404..e00c5c1 100644 --- a/src/utils/flow.js +++ b/src/utils/flow.js @@ -1,210 +1,221 @@ -export const getInput = (nodeId, isStrict = true) => { - const data = lf.getGraphData(); - let flag = false - if (isStrict) { - data.edges.forEach(item => { - if (item.targetNodeId === nodeId) { - flag = true - } - }); - } else { - flag = true - } - - if (flag) { - const arr = [] - data.nodes.forEach(item => { - if (item.id === nodeId) { - return - } - - if (item.properties.inputParams) { - const obj = { - value: item.id, - label: item.properties.name, - children: [] - } - const optionData = transformTree(item.properties.inputParams, obj.children) - obj.children.push(optionData) - arr.push(obj) - } - if (item.properties.nodeParams) { - const obj = { - value: item.id, - label: item.properties.name, - children: [] - } - const optionData = transformTree(item.properties.nodeParams, obj.children) - obj.children.push(optionData) - arr.push(obj) - } - }) - return arr - } - return flag -} - -const transformTree = (arr, parent = []) => { - arr.forEach(item => { - const currentNode = { - value: item.name, - label: item.name, - children: [] - }; - parent.push(currentNode); - - if (item.children?.length > 0) { - transformTree(item.children, currentNode.children); - } else { - delete currentNode.children - } - }); - return parent; -}; - -export const getStartNodeFormData = () => { - const flowData = lf.getGraphData(); - const startNode = flowData.nodes.find(item => item.type === 'start') - const data = addValueProperty(startNode.properties?.inputParams || []) - return data -} - -export const addValueProperty = (data) => { - // 处理单个对象或对象数组 - const processItem = (item, index, path) => { - // 根据类型设置默认值 - item.value = ''; - item.propPath = `${path}.${index}.` - if (item.type.includes('array') && !item.type.includes('object')) { - const type = item.type.match(/<([^>]+)>/)[1] - item.children = [{ name: 'Array Item', type, value: '', propPath: item.propPath + '.0'}] - } - // 递归处理子项 - if (item.children && item.children.length > 0) { - item.children = item.children.map((cItem, cIndex) => { - return processItem(cItem, cIndex , item.propPath + 'children') - }); - } - - return item; - }; - - // 如果传入的是数组,处理每个元素;否则处理单个对象 - return Array.isArray(data) ? data.map((item, index) => processItem(item, index, '')) : processItem(data, 0, '') -} - -export const recursiveFilter = (data, id, type = ['loop', 'customGroup'], result = []) => { - data.forEach((item) => { - if (type.includes(item.type) && item.children && item.children.includes(id)) { - result.push(item) - recursiveFilter(data, item.id, result) - } - }); - return result -} - -export const formatTableData = (arr, data = {}) => { - arr.forEach(item => { - data[item.name] = item.value - if (item?.children && item.children.length > 0) { - data[item.name] = {} - formatTableData(item.children, data[item.name]) - } - }) - return data -} - -export const addNewEdge = (nodeId) => { - const { edges } = lf.getGraphData(); - const arr = JSON.parse(JSON.stringify(edges)) - arr.forEach(_edge => { - const { sourceNodeId, targetNodeId, sourceAnchorId, targetAnchorId } = _edge - if (sourceNodeId === nodeId || targetNodeId === nodeId) { - lf.deleteEdge(_edge.id); - lf.addEdge({ - type: "bezier", - sourceNodeId: sourceNodeId, - targetNodeId: targetNodeId, - sourceAnchorId: sourceAnchorId, - targetAnchorId: targetAnchorId - }); - } - }) -} - -export const getInputNumber = (nodeId) => { - const data = lf.getGraphData(); - let flag = false - data.edges.forEach(item => { - if (item.targetNodeId === nodeId) { - flag = true - } - }); - if (flag) { - const arr = [] - data.nodes.forEach(item => { - if (item.properties.inputParams) { - item.properties.inputParams.forEach(item => { - if (item.type === 'number') { - arr.push(item) - } - }) - } - }) - return arr - } - return flag -} - -export const removeSwitchEdge = (nodeId, sourceAnchorId) => { - const { edges } = lf.getGraphData(); - const edge = edges.find(item => { - return item.sourceNodeId === nodeId && item.sourceAnchorId === sourceAnchorId - }) - - if (edge) { - lf.deleteEdge(edge.id); - } -} - -export const convertToTree = (data) => { - // 创建 id 到节点的映射 - const nodeMap = new Map(); - data.forEach(node => { - nodeMap.set(node.id, { ...node, name: node.properties.name || '' }); // 浅拷贝节点 - }); - - // 标记非根节点(被其他节点引用的节点) - const nonRootIds = new Set(); - data.forEach(node => { - if (node.children) { - node.children.forEach(childId => { - nonRootIds.add(childId); - }); - } - }); - - // 构建树形结构 - const result = []; - data.forEach(node => { - // 只处理根节点(未被引用的节点) - if (!nonRootIds.has(node.id)) { - const rootNode = nodeMap.get(node.id); - // 递归处理子节点 - const processNode = (currentNode) => { - if (currentNode.children) { - currentNode.children = currentNode.children.map(childId => { - const childNode = nodeMap.get(childId); - processNode(childNode); // 递归处理子节点 - return childNode; - }); - } - return currentNode; - }; - - result.push(processNode(rootNode)); - } - }); - - return result; +export const getInput = (nodeId, isStrict = true) => { + const data = lf.getGraphData(); + let flag = false + if (isStrict) { + data.edges.forEach(item => { + if (item.targetNodeId === nodeId) { + flag = true + } + }); + } else { + flag = true + } + + if (flag) { + const arr = [] + data.nodes.forEach(item => { + if (item.id === nodeId) { + return + } + + if (item.properties.inputParams) { + const obj = { + value: item.id, + label: item.properties.name, + children: [] + } + const optionData = transformTree(item.properties.inputParams, obj.children) + obj.children.push(optionData) + arr.push(obj) + } + if (item.properties.nodeParams) { + const obj = { + value: item.id, + label: item.properties.name + '(输入)', + children: [] + } + const optionData = transformTree(item.properties.nodeParams, obj.children) + obj.children.push(optionData) + arr.push(obj) + } + + if (item.properties.outputParams) { + const obj = { + value: item.id, + label: item.properties.name + '(输出)', + children: [] + } + const optionData = transformTree(item.properties.outputParams, obj.children) + obj.children.push(optionData) + arr.push(obj) + } + }) + return arr + } + return flag +} + +const transformTree = (arr, parent = []) => { + arr.forEach(item => { + const currentNode = { + value: item.name, + label: item.name, + children: [] + }; + parent.push(currentNode); + + if (item.children?.length > 0) { + transformTree(item.children, currentNode.children); + } else { + delete currentNode.children + } + }); + return parent; +}; + +export const getStartNodeFormData = () => { + const flowData = lf.getGraphData(); + const startNode = flowData.nodes.find(item => item.type === 'start') + const data = addValueProperty(startNode.properties?.inputParams || []) + return data +} + +export const addValueProperty = (data) => { + // 处理单个对象或对象数组 + const processItem = (item, index, path) => { + // 根据类型设置默认值 + item.value = ''; + item.propPath = `${path}.${index}.` + if (item.type.includes('array') && !item.type.includes('object')) { + const type = item.type.match(/<([^>]+)>/)[1] + item.children = [{ name: 'Array Item', type, value: '', propPath: item.propPath + '.0'}] + } + // 递归处理子项 + if (item.children && item.children.length > 0) { + item.children = item.children.map((cItem, cIndex) => { + return processItem(cItem, cIndex , item.propPath + 'children') + }); + } + + return item; + }; + + // 如果传入的是数组,处理每个元素;否则处理单个对象 + return Array.isArray(data) ? data.map((item, index) => processItem(item, index, '')) : processItem(data, 0, '') +} + +export const recursiveFilter = (data, id, type = ['loop', 'customGroup'], result = []) => { + data.forEach((item) => { + if (type.includes(item.type) && item.children && item.children.includes(id)) { + result.push(item) + recursiveFilter(data, item.id, result) + } + }); + return result +} + +export const formatTableData = (arr, data = {}) => { + arr.forEach(item => { + data[item.name] = item.value + if (item?.children && item.children.length > 0) { + data[item.name] = {} + formatTableData(item.children, data[item.name]) + } + }) + return data +} + +export const addNewEdge = (nodeId) => { + const { edges } = lf.getGraphData(); + const arr = JSON.parse(JSON.stringify(edges)) + arr.forEach(_edge => { + const { sourceNodeId, targetNodeId, sourceAnchorId, targetAnchorId } = _edge + if (sourceNodeId === nodeId || targetNodeId === nodeId) { + lf.deleteEdge(_edge.id); + lf.addEdge({ + type: "bezier", + sourceNodeId: sourceNodeId, + targetNodeId: targetNodeId, + sourceAnchorId: sourceAnchorId, + targetAnchorId: targetAnchorId + }); + } + }) +} + +export const getInputNumber = (nodeId) => { + const data = lf.getGraphData(); + let flag = false + data.edges.forEach(item => { + if (item.targetNodeId === nodeId) { + flag = true + } + }); + if (flag) { + const arr = [] + data.nodes.forEach(item => { + if (item.properties.inputParams) { + item.properties.inputParams.forEach(item => { + if (item.type === 'number') { + arr.push(item) + } + }) + } + }) + return arr + } + return flag +} + +export const removeSwitchEdge = (nodeId, sourceAnchorId) => { + const { edges } = lf.getGraphData(); + const edge = edges.find(item => { + return item.sourceNodeId === nodeId && item.sourceAnchorId === sourceAnchorId + }) + + if (edge) { + lf.deleteEdge(edge.id); + } +} + +export const convertToTree = (data) => { + // 创建 id 到节点的映射 + const nodeMap = new Map(); + data.forEach(node => { + nodeMap.set(node.id, { ...node, name: node.properties.name || '' }); // 浅拷贝节点 + }); + + // 标记非根节点(被其他节点引用的节点) + const nonRootIds = new Set(); + data.forEach(node => { + if (node.children) { + node.children.forEach(childId => { + nonRootIds.add(childId); + }); + } + }); + + // 构建树形结构 + const result = []; + data.forEach(node => { + // 只处理根节点(未被引用的节点) + if (!nonRootIds.has(node.id)) { + const rootNode = nodeMap.get(node.id); + // 递归处理子节点 + const processNode = (currentNode) => { + if (currentNode.children) { + currentNode.children = currentNode.children.map(childId => { + const childNode = nodeMap.get(childId); + processNode(childNode); // 递归处理子节点 + return childNode; + }); + } + return currentNode; + }; + + result.push(processNode(rootNode)); + } + }); + + return result; } \ No newline at end of file diff --git a/src/views/flow/nodes/function/loop.vue b/src/views/flow/nodes/function/loop.vue index f12df82..a94c087 100644 --- a/src/views/flow/nodes/function/loop.vue +++ b/src/views/flow/nodes/function/loop.vue @@ -1,201 +1,200 @@ - - - \ No newline at end of file diff --git a/src/views/vi/corpus/awaken/index.vue b/src/views/vi/corpus/awaken/index.vue new file mode 100644 index 0000000..1538ee3 --- /dev/null +++ b/src/views/vi/corpus/awaken/index.vue @@ -0,0 +1,322 @@ + + + diff --git a/src/views/vi/corpus/test/index.vue b/src/views/vi/corpus/test/index.vue new file mode 100644 index 0000000..4ab2845 --- /dev/null +++ b/src/views/vi/corpus/test/index.vue @@ -0,0 +1,335 @@ + + + diff --git a/vite.config.js b/vite.config.js index 4fde0b1..4c3f939 100644 --- a/vite.config.js +++ b/vite.config.js @@ -32,11 +32,11 @@ export default defineConfig(({mode, command}) => { proxy: { // https://cn.vitejs.dev/config/#server-proxy '/dev-api': { - //杨 http://192.168.1.10:13080 + //杨 http://192.168.0.10:13080 //赵 http://10.148.108.58:13080 // dev http://10.148.20.34:13080 // target: command === 'build' ? VITE_API_URL : 'http://10.148.20.34:13080', - target: command === 'build' ? VITE_API_URL : 'http://192.168.1.10:13080', + target: command === 'build' ? VITE_API_URL : 'http://192.168.0.10:13080', changeOrigin: true, rewrite: (p) => p.replace(/^\/dev-api/, '') }