feat(api): 添加语料库相关接口
- 新增语料库列表查询、详细查询、添加、修改和删除接口 - 更新环境变量配置,修改API基础地址 - 优化流程图工具箱功能,增加节点参数和输出参数处理
This commit is contained in:
commit
aed84e31b4
@ -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
|
||||
|
||||
|
||||
44
src/api/vi/corpus.js
Normal file
44
src/api/vi/corpus.js
Normal file
@ -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'
|
||||
})
|
||||
}
|
||||
@ -88,7 +88,7 @@ app.use(ElementPlus, {
|
||||
|
||||
app.use(WebSocketPlugin, {
|
||||
// url: import.meta.env.VITE_WS_URL,
|
||||
url: 'ws://127.0.0.1:13080/ws',
|
||||
url: 'ws://192.168.0.100:13080/ws',
|
||||
// url: 'ws://10.148.209.5:13080/ws',
|
||||
userId: 'your_user_id'
|
||||
});
|
||||
|
||||
@ -1,73 +1,73 @@
|
||||
import router from './router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { isHttp, isPathMatch } from '@/utils/validate'
|
||||
import { isRelogin } from '@/utils/request'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import useSettingsStore from '@/store/modules/settings'
|
||||
import usePermissionStore from '@/store/modules/permission'
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
const whiteList = ['/login', '/register']
|
||||
|
||||
const isWhiteList = (path) => {
|
||||
return whiteList.some(pattern => isPathMatch(pattern, path))
|
||||
}
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta?.noLogin) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
NProgress.start()
|
||||
if (getToken()) {
|
||||
to.meta.title && useSettingsStore().setTitle(to.meta.title)
|
||||
/* has token*/
|
||||
if (to.path === '/login') {
|
||||
next({ path: '/' })
|
||||
NProgress.done()
|
||||
} else if (isWhiteList(to.path)) {
|
||||
next()
|
||||
} else {
|
||||
if (useUserStore().roles.length === 0) {
|
||||
isRelogin.show = true
|
||||
// 判断当前用户是否已拉取完user_info信息
|
||||
useUserStore().getInfo().then(() => {
|
||||
isRelogin.show = false
|
||||
usePermissionStore().generateRoutes().then(accessRoutes => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
accessRoutes.forEach(route => {
|
||||
if (!isHttp(route.path)) {
|
||||
router.addRoute(route) // 动态添加可访问路由表
|
||||
}
|
||||
})
|
||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||
})
|
||||
}).catch(err => {
|
||||
useUserStore().logOut().then(() => {
|
||||
ElMessage.error(err)
|
||||
next({ path: '/' })
|
||||
})
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有token
|
||||
if (isWhiteList(to.path)) {
|
||||
// 在免登录白名单,直接进入
|
||||
next()
|
||||
} else {
|
||||
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||
NProgress.done()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done()
|
||||
})
|
||||
import router from './router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { isHttp, isPathMatch } from '@/utils/validate'
|
||||
import { isRelogin } from '@/utils/request'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import useSettingsStore from '@/store/modules/settings'
|
||||
import usePermissionStore from '@/store/modules/permission'
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
const whiteList = ['/login', '/register']
|
||||
|
||||
const isWhiteList = (path) => {
|
||||
return whiteList.some(pattern => isPathMatch(pattern, path))
|
||||
}
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta?.noLogin) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
NProgress.start()
|
||||
if (getToken()) {
|
||||
to.meta.title && useSettingsStore().setTitle(to.meta.title)
|
||||
/* has token*/
|
||||
if (to.path === '/login') {
|
||||
next({ path: '/' })
|
||||
NProgress.done()
|
||||
} else if (isWhiteList(to.path)) {
|
||||
next()
|
||||
} else {
|
||||
if (useUserStore().roles.length === 0) {
|
||||
isRelogin.show = true
|
||||
// 判断当前用户是否已拉取完user_info信息
|
||||
useUserStore().getInfo().then(() => {
|
||||
isRelogin.show = false
|
||||
usePermissionStore().generateRoutes().then(accessRoutes => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
accessRoutes.forEach(route => {
|
||||
if (!isHttp(route.path)) {
|
||||
router.addRoute(route) // 动态添加可访问路由表
|
||||
}
|
||||
})
|
||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||
})
|
||||
}).catch(err => {
|
||||
useUserStore().logOut().then(() => {
|
||||
ElMessage.error(err)
|
||||
next({ path: '/' })
|
||||
})
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有token
|
||||
if (isWhiteList(to.path)) {
|
||||
// 在免登录白名单,直接进入
|
||||
next()
|
||||
} else {
|
||||
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||
NProgress.done()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done()
|
||||
})
|
||||
|
||||
@ -1,69 +1,69 @@
|
||||
import useTagsViewStore from '@/store/modules/tagsView'
|
||||
import router from '@/router'
|
||||
|
||||
export default {
|
||||
// 刷新当前tab页签
|
||||
refreshPage(obj) {
|
||||
const { path, query, matched } = router.currentRoute.value;
|
||||
if (obj === undefined) {
|
||||
matched.forEach((m) => {
|
||||
if (m.components && m.components.default && m.components.default.name) {
|
||||
if (!['Layout', 'ParentView'].includes(m.components.default.name)) {
|
||||
obj = { name: m.components.default.name, path: path, query: query };
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return useTagsViewStore().delCachedView(obj).then(() => {
|
||||
const { path, query } = obj
|
||||
router.replace({
|
||||
path: '/redirect' + path,
|
||||
query: query
|
||||
})
|
||||
})
|
||||
},
|
||||
// 关闭当前tab页签,打开新页签
|
||||
closeOpenPage(obj) {
|
||||
useTagsViewStore().delView(router.currentRoute.value);
|
||||
if (obj !== undefined) {
|
||||
return router.push(obj);
|
||||
}
|
||||
},
|
||||
// 关闭指定tab页签
|
||||
closePage(obj) {
|
||||
if (obj === undefined) {
|
||||
return useTagsViewStore().delView(router.currentRoute.value).then(({ visitedViews }) => {
|
||||
const latestView = visitedViews.slice(-1)[0]
|
||||
if (latestView) {
|
||||
return router.push(latestView.fullPath)
|
||||
}
|
||||
return router.push('/');
|
||||
});
|
||||
}
|
||||
return useTagsViewStore().delView(obj);
|
||||
},
|
||||
// 关闭所有tab页签
|
||||
closeAllPage() {
|
||||
return useTagsViewStore().delAllViews();
|
||||
},
|
||||
// 关闭左侧tab页签
|
||||
closeLeftPage(obj) {
|
||||
return useTagsViewStore().delLeftTags(obj || router.currentRoute.value);
|
||||
},
|
||||
// 关闭右侧tab页签
|
||||
closeRightPage(obj) {
|
||||
return useTagsViewStore().delRightTags(obj || router.currentRoute.value);
|
||||
},
|
||||
// 关闭其他tab页签
|
||||
closeOtherPage(obj) {
|
||||
return useTagsViewStore().delOthersViews(obj || router.currentRoute.value);
|
||||
},
|
||||
// 打开tab页签
|
||||
openPage(url) {
|
||||
return router.push(url);
|
||||
},
|
||||
// 修改tab页签
|
||||
updatePage(obj) {
|
||||
return useTagsViewStore().updateVisitedView(obj);
|
||||
}
|
||||
}
|
||||
import useTagsViewStore from '@/store/modules/tagsView'
|
||||
import router from '@/router'
|
||||
|
||||
export default {
|
||||
// 刷新当前tab页签
|
||||
refreshPage(obj) {
|
||||
const { path, query, matched } = router.currentRoute.value;
|
||||
if (obj === undefined) {
|
||||
matched.forEach((m) => {
|
||||
if (m.components && m.components.default && m.components.default.name) {
|
||||
if (!['Layout', 'ParentView'].includes(m.components.default.name)) {
|
||||
obj = { name: m.components.default.name, path: path, query: query };
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return useTagsViewStore().delCachedView(obj).then(() => {
|
||||
const { path, query } = obj
|
||||
router.replace({
|
||||
path: '/redirect' + path,
|
||||
query: query
|
||||
})
|
||||
})
|
||||
},
|
||||
// 关闭当前tab页签,打开新页签
|
||||
closeOpenPage(obj) {
|
||||
useTagsViewStore().delView(router.currentRoute.value);
|
||||
if (obj !== undefined) {
|
||||
return router.push(obj);
|
||||
}
|
||||
},
|
||||
// 关闭指定tab页签
|
||||
closePage(obj) {
|
||||
if (obj === undefined) {
|
||||
return useTagsViewStore().delView(router.currentRoute.value).then(({ visitedViews }) => {
|
||||
const latestView = visitedViews.slice(-1)[0]
|
||||
if (latestView) {
|
||||
return router.push(latestView.fullPath)
|
||||
}
|
||||
return router.push('/');
|
||||
});
|
||||
}
|
||||
return useTagsViewStore().delView(obj);
|
||||
},
|
||||
// 关闭所有tab页签
|
||||
closeAllPage() {
|
||||
return useTagsViewStore().delAllViews();
|
||||
},
|
||||
// 关闭左侧tab页签
|
||||
closeLeftPage(obj) {
|
||||
return useTagsViewStore().delLeftTags(obj || router.currentRoute.value);
|
||||
},
|
||||
// 关闭右侧tab页签
|
||||
closeRightPage(obj) {
|
||||
return useTagsViewStore().delRightTags(obj || router.currentRoute.value);
|
||||
},
|
||||
// 关闭其他tab页签
|
||||
closeOtherPage(obj) {
|
||||
return useTagsViewStore().delOthersViews(obj || router.currentRoute.value);
|
||||
},
|
||||
// 打开tab页签
|
||||
openPage(url) {
|
||||
return router.push(url);
|
||||
},
|
||||
// 修改tab页签
|
||||
updatePage(obj) {
|
||||
return useTagsViewStore().updateVisitedView(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1,274 +1,276 @@
|
||||
import { Group, SelectionSelect } from "@logicflow/extension";
|
||||
import { registerCommon } from "./nodes/common/index";
|
||||
|
||||
import { registerFunction } from './nodes/function'
|
||||
|
||||
import cameraSvg from './icon/camera.svg'
|
||||
import videoSvg from './icon/video.svg'
|
||||
import loopSvg from './icon/loop.svg'
|
||||
import stopLoopSvg from './icon/stopLoop.svg'
|
||||
import switchSvg from './icon/switch.svg'
|
||||
import startSvg from './icon/start.svg'
|
||||
import endSvg from './icon/end.svg'
|
||||
import microphoneSvg from './icon/microphone.svg'
|
||||
import sleepSvg from './icon/sleep.svg'
|
||||
|
||||
import { v4 as randomUUID } from 'uuid'
|
||||
|
||||
import { useFlowStore } from "@/store/modules/flow";
|
||||
|
||||
const flowStore = useFlowStore();
|
||||
|
||||
|
||||
export const lfConfig = {
|
||||
idGenerator: () => {
|
||||
// 生成标准UUID并移除连字符
|
||||
// return crypto.randomUUID().replace(/-/g, '');
|
||||
return randomUUID().replace(/-/g, '')
|
||||
},
|
||||
background: {
|
||||
backgroundColor: "#f6f8fa",
|
||||
},
|
||||
grid: false,
|
||||
plugins: [Group, SelectionSelect],
|
||||
animation: true,
|
||||
adjustEdgeStartAndEnd: false,
|
||||
// multipleSelectKey: "ctrl",
|
||||
// disabledTools: ["multipleSelect"],
|
||||
partial: true,
|
||||
// group: {
|
||||
// foldable: true, // 启用折叠功能
|
||||
// foldSize: 30, // 折叠后显示的图标尺寸
|
||||
// },
|
||||
edgeType: "bezier",
|
||||
style: {
|
||||
anchor: {
|
||||
show: true, // 强制全局锚点显示
|
||||
hoverOn: false,
|
||||
visibility: "visible",
|
||||
fill: "#FF5722", // 实心绿色
|
||||
stroke: "#FF5722", // 边框同色
|
||||
strokeWidth: 0, // 消除边框
|
||||
r: 7, // 锚点半径
|
||||
hover: { fill: "#FF5722" }, // 禁用悬停变色
|
||||
},
|
||||
anchorLine: {
|
||||
stroke: "#FF5722",
|
||||
strokeWidth: 2,
|
||||
strokeDasharray: "3,2",
|
||||
},
|
||||
bezier: {
|
||||
stroke: "#FF5722",
|
||||
strokeWidth: 2,
|
||||
arrow: false, // 关闭箭头显示
|
||||
animation: true, // 开启动画效果
|
||||
animationSpeed: 3,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 注册自定义节点
|
||||
export const registerCustomizeNode = (lf) => {
|
||||
registerCommon(lf)
|
||||
registerFunction(lf)
|
||||
};
|
||||
|
||||
const deviceOptions = () => {
|
||||
return ['cam1', 'cam2', 'cam3', 'cam4']
|
||||
}
|
||||
|
||||
const audioOptions = () => {
|
||||
return ['spk1']
|
||||
}
|
||||
|
||||
export const collapseList = [
|
||||
{
|
||||
collapseTitle: "相机",
|
||||
nodeList: [
|
||||
{
|
||||
icon: cameraSvg,
|
||||
name: "开启相机",
|
||||
type: "serviceNode",
|
||||
desc: "在获取相机照片时,需要先启动相机",
|
||||
action: 'CAMERA_START',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: cameraSvg,
|
||||
name: "获取图片",
|
||||
type: "serviceNode",
|
||||
desc: "获取相机拍摄的照片",
|
||||
action: 'CAMERA_GETRGBIMAGE',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'img',
|
||||
outputParams: [{ name: 'imageUrl', type: 'Array<String>', desc: '图片地址数组'}]
|
||||
},
|
||||
{
|
||||
icon: cameraSvg,
|
||||
name: "关闭相机",
|
||||
type: "serviceNode",
|
||||
desc: "获取相机照片后,关闭该相机",
|
||||
action: 'CAMERA_STOP',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "录像",
|
||||
nodeList: [
|
||||
{
|
||||
icon: videoSvg,
|
||||
name: "开启录像",
|
||||
type: "serviceNode",
|
||||
desc: "开启摄像头,并开始录像",
|
||||
action: 'CAMERA_RECORDING_START',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: videoSvg,
|
||||
name: "结束录像",
|
||||
type: "serviceNode",
|
||||
desc: "停止录像,并关闭摄像头",
|
||||
action: 'CAMERA_RECORDING_STOP',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'video',
|
||||
outputParams: [{ name: 'videoUrl', type: 'Array<String>', desc: '视频播放地址数组'}]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "功能",
|
||||
nodeList: [
|
||||
{
|
||||
icon: loopSvg,
|
||||
name: "循环",
|
||||
type: "loop",
|
||||
action: 'START_LOOP',
|
||||
desc: "实现对列表对象循环执行一系列任务",
|
||||
},
|
||||
{
|
||||
icon: stopLoopSvg,
|
||||
name: "结束循环",
|
||||
type: "stopLoop",
|
||||
action: 'STOP_LOOP',
|
||||
desc: "用于立即终止当前所在的循环,跳出循环体",
|
||||
},
|
||||
{
|
||||
icon: startSvg,
|
||||
name: "单次循环开始",
|
||||
type: "subStart",
|
||||
action: 'SUB_START',
|
||||
desc: "循环体内部工作流的开始节点,开始循环体内部的单次流程",
|
||||
},
|
||||
{
|
||||
icon: endSvg,
|
||||
name: "单次循环结束",
|
||||
type: "subEnd",
|
||||
action: 'SUB_END',
|
||||
desc: "循环体内部工作流的终止节点,结束循环体内部的单次流程",
|
||||
},
|
||||
{
|
||||
icon: switchSvg,
|
||||
name: "分支",
|
||||
type: "branch",
|
||||
action: 'BRANCH',
|
||||
desc: "连接多个下游分支,根据设定的条件按照顺序查找的方式来匹配运行的分支,如果匹配到某条件则只运行该条件对应的分支,否则继续匹配下一条件直至结束",
|
||||
},
|
||||
{
|
||||
icon: sleepSvg,
|
||||
name: "睡眠",
|
||||
type: "sleep",
|
||||
desc: "用于睡眠整个流程,表示延迟多少毫秒",
|
||||
action: 'sleep',
|
||||
nodeParams: [
|
||||
{ name: "delayMs", type: "input", componentType: 'number', input: "", disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "机器人",
|
||||
nodeList: [
|
||||
{
|
||||
icon: videoSvg,
|
||||
name: "机械臂",
|
||||
type: "serviceNode",
|
||||
desc: "控制机器人的手臂",
|
||||
action: 'ALM',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "音频",
|
||||
nodeList: [
|
||||
{
|
||||
icon: microphoneSvg,
|
||||
name: "启动麦克风",
|
||||
type: "serviceNode",
|
||||
desc: "用于启动麦克风的节点",
|
||||
action: 'MICROPHONE_START',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: microphoneSvg,
|
||||
name: "停止麦克风",
|
||||
type: "serviceNode",
|
||||
desc: "用于停止麦克风的节点",
|
||||
action: 'MICROPHONE_START',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: microphoneSvg,
|
||||
name: "播放音频",
|
||||
type: "serviceNode",
|
||||
desc: "用于播放音频的节点",
|
||||
action: 'SPEAKER_PLAYAUDIO',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: audioOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "大模型",
|
||||
nodeList: [
|
||||
{
|
||||
icon: microphoneSvg,
|
||||
name: "获取触控坐标",
|
||||
type: "serviceNode",
|
||||
desc: "用于获取触控坐标的节点",
|
||||
action: 'TOUCH_COORDINATES',
|
||||
nodeParams: [
|
||||
{ name: "words", type: "input", input: "", disabled: true }
|
||||
],
|
||||
outputType: 'json',
|
||||
outputParams: [{ name: 'coordinates', type: 'Object', desc: '坐标对象'}]
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
import { Group, SelectionSelect } from "@logicflow/extension";
|
||||
import { registerCommon } from "./nodes/common/index";
|
||||
|
||||
import { registerFunction } from './nodes/function'
|
||||
|
||||
import cameraSvg from './icon/camera.svg'
|
||||
import videoSvg from './icon/video.svg'
|
||||
import loopSvg from './icon/loop.svg'
|
||||
import stopLoopSvg from './icon/stopLoop.svg'
|
||||
import switchSvg from './icon/switch.svg'
|
||||
import startSvg from './icon/start.svg'
|
||||
import endSvg from './icon/end.svg'
|
||||
import microphoneSvg from './icon/microphone.svg'
|
||||
import sleepSvg from './icon/sleep.svg'
|
||||
|
||||
import { v4 as randomUUID } from 'uuid'
|
||||
|
||||
import { useFlowStore } from "@/store/modules/flow";
|
||||
|
||||
const flowStore = useFlowStore();
|
||||
|
||||
|
||||
export const lfConfig = {
|
||||
idGenerator: () => {
|
||||
// 生成标准UUID并移除连字符
|
||||
// return crypto.randomUUID().replace(/-/g, '');
|
||||
return randomUUID().replace(/-/g, '')
|
||||
},
|
||||
background: {
|
||||
backgroundColor: "#f6f8fa",
|
||||
},
|
||||
grid: false,
|
||||
plugins: [Group, SelectionSelect],
|
||||
animation: true,
|
||||
adjustEdgeStartAndEnd: false,
|
||||
// multipleSelectKey: "ctrl",
|
||||
// disabledTools: ["multipleSelect"],
|
||||
partial: true,
|
||||
// group: {
|
||||
// foldable: true, // 启用折叠功能
|
||||
// foldSize: 30, // 折叠后显示的图标尺寸
|
||||
// },
|
||||
edgeType: "bezier",
|
||||
style: {
|
||||
anchor: {
|
||||
show: true, // 强制全局锚点显示
|
||||
hoverOn: false,
|
||||
visibility: "visible",
|
||||
fill: "#FF5722", // 实心绿色
|
||||
stroke: "#FF5722", // 边框同色
|
||||
strokeWidth: 0, // 消除边框
|
||||
r: 7, // 锚点半径
|
||||
hover: { fill: "#FF5722" }, // 禁用悬停变色
|
||||
},
|
||||
anchorLine: {
|
||||
stroke: "#FF5722",
|
||||
strokeWidth: 2,
|
||||
strokeDasharray: "3,2",
|
||||
},
|
||||
bezier: {
|
||||
stroke: "#FF5722",
|
||||
strokeWidth: 2,
|
||||
arrow: false, // 关闭箭头显示
|
||||
animation: true, // 开启动画效果
|
||||
animationSpeed: 3,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 注册自定义节点
|
||||
export const registerCustomizeNode = (lf) => {
|
||||
registerCommon(lf)
|
||||
registerFunction(lf)
|
||||
};
|
||||
|
||||
const deviceOptions = () => {
|
||||
return ['cam1', 'cam2', 'cam3', 'cam4']
|
||||
}
|
||||
|
||||
const audioOptions = () => {
|
||||
return ['spk1']
|
||||
}
|
||||
|
||||
export const collapseList = [
|
||||
{
|
||||
collapseTitle: "相机",
|
||||
nodeList: [
|
||||
{
|
||||
icon: cameraSvg,
|
||||
name: "开启相机",
|
||||
type: "serviceNode",
|
||||
desc: "在获取相机照片时,需要先启动相机",
|
||||
action: 'CAMERA_START',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: cameraSvg,
|
||||
name: "获取图片",
|
||||
type: "serviceNode",
|
||||
desc: "获取相机拍摄的照片",
|
||||
action: 'CAMERA_GETRGBIMAGE',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'img',
|
||||
outputParams: [{ name: 'imageUrl', type: 'Array<String>', desc: '图片地址数组'}]
|
||||
},
|
||||
{
|
||||
icon: cameraSvg,
|
||||
name: "关闭相机",
|
||||
type: "serviceNode",
|
||||
desc: "获取相机照片后,关闭该相机",
|
||||
action: 'CAMERA_STOP',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "录像",
|
||||
nodeList: [
|
||||
{
|
||||
icon: videoSvg,
|
||||
name: "开启录像",
|
||||
type: "serviceNode",
|
||||
desc: "开启摄像头,并开始录像",
|
||||
action: 'CAMERA_RECORDING_START',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: videoSvg,
|
||||
name: "结束录像",
|
||||
type: "serviceNode",
|
||||
desc: "停止录像,并关闭摄像头",
|
||||
action: 'CAMERA_RECORDING_STOP',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'video',
|
||||
outputParams: [{ name: 'videoUrl', type: 'Array<String>', desc: '视频播放地址数组'}]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "功能",
|
||||
nodeList: [
|
||||
{
|
||||
icon: loopSvg,
|
||||
name: "循环",
|
||||
type: "loop",
|
||||
action: 'START_LOOP',
|
||||
desc: "实现对列表对象循环执行一系列任务",
|
||||
},
|
||||
{
|
||||
icon: stopLoopSvg,
|
||||
name: "结束循环",
|
||||
type: "stopLoop",
|
||||
action: 'STOP_LOOP',
|
||||
desc: "用于立即终止当前所在的循环,跳出循环体",
|
||||
},
|
||||
{
|
||||
icon: startSvg,
|
||||
name: "单次循环开始",
|
||||
type: "subStart",
|
||||
action: 'SUB_START',
|
||||
desc: "循环体内部工作流的开始节点,开始循环体内部的单次流程",
|
||||
},
|
||||
{
|
||||
icon: endSvg,
|
||||
name: "单次循环结束",
|
||||
type: "subEnd",
|
||||
action: 'SUB_END',
|
||||
desc: "循环体内部工作流的终止节点,结束循环体内部的单次流程",
|
||||
},
|
||||
{
|
||||
icon: switchSvg,
|
||||
name: "分支",
|
||||
type: "branch",
|
||||
action: 'BRANCH',
|
||||
desc: "连接多个下游分支,根据设定的条件按照顺序查找的方式来匹配运行的分支,如果匹配到某条件则只运行该条件对应的分支,否则继续匹配下一条件直至结束",
|
||||
},
|
||||
{
|
||||
icon: sleepSvg,
|
||||
name: "睡眠",
|
||||
type: "sleep",
|
||||
desc: "用于睡眠整个流程,表示延迟多少毫秒",
|
||||
action: 'sleep',
|
||||
nodeParams: [
|
||||
{ name: "delayMs", type: "input", componentType: 'number', input: "", disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "机器人",
|
||||
nodeList: [
|
||||
{
|
||||
icon: videoSvg,
|
||||
name: "机械臂",
|
||||
type: "serviceNode",
|
||||
desc: "控制机器人的手臂",
|
||||
action: 'ALM',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "音频",
|
||||
nodeList: [
|
||||
{
|
||||
icon: microphoneSvg,
|
||||
name: "启动麦克风",
|
||||
type: "serviceNode",
|
||||
desc: "用于启动麦克风的节点",
|
||||
action: 'MICROPHONE_START',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: microphoneSvg,
|
||||
name: "停止麦克风",
|
||||
type: "serviceNode",
|
||||
desc: "用于停止麦克风的节点",
|
||||
action: 'MICROPHONE_START',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: microphoneSvg,
|
||||
name: "播放音频",
|
||||
type: "serviceNode",
|
||||
desc: "用于播放音频的节点",
|
||||
action: 'SPEAKER_PLAYAUDIO',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: audioOptions(), disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
collapseTitle: "大模型",
|
||||
nodeList: [
|
||||
{
|
||||
icon: microphoneSvg,
|
||||
name: "获取触控坐标",
|
||||
type: "serviceNode",
|
||||
desc: "用于获取触控坐标的节点",
|
||||
action: 'TOUCH_COORDINATES',
|
||||
nodeParams: [
|
||||
{ name: "targetFeature", type: "input", input: "运动模式", disabled: true },
|
||||
{ name: "manufacturer", type: "input", input: "xiaomi", disabled: true },
|
||||
{ name: "vehType", type: "input", input: "su7", disabled: true },
|
||||
],
|
||||
outputType: 'json',
|
||||
outputParams: [{ name: 'coordinates', type: 'Object', desc: '坐标对象'}]
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,201 +1,200 @@
|
||||
<template>
|
||||
<div class="group__container" @mouseleave="setNodeProperties">
|
||||
<NodeTitle :icon="loop" :nodeId="props.model.id" :nodeProperties="props.properties" :nodeName="props.properties?.name || '循环'" nodeDesc="循环执行一系列任务,直至输出所有结果" />
|
||||
<div class="loop__container">
|
||||
<div>
|
||||
<el-form :inline="true" :model="formData" :rules="rules" ref="dynamicForm" label-position="top" label-width="auto" :disabled="flowStore.disableForm">
|
||||
<div v-for="(property, index) in formData.nodeParams" :key="index">
|
||||
<el-row>
|
||||
<el-form-item :label="index === 0 ? '参数名' : ''" :prop="`nodeParams.${index}.name`" :rules="[{ required: true, message: '请输入参数名', trigger: 'blur' }]">
|
||||
<el-input :disabled="index === 0" v-model="property.name" placeholder="请输入" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="index === 0 ? '参数值' : ''" :prop="`nodeParams.${index}.type`" >
|
||||
<el-select v-model="property.type" @change="handleTypeChange(index)">
|
||||
<el-option label="引用" value="quote" />
|
||||
<el-option label="输入" value="input" />
|
||||
</el-select>
|
||||
<el-form-item v-if="property.type === 'input'" :rules="[{ required: true, message: '请输入参数值', trigger: 'blur' }]" :prop="`nodeParams.${index}.input`">
|
||||
<el-input-number v-model="property.input" :min="0" :controls="false" :step-strictly="true" placeholder="请输入" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="property.type === 'quote'" :rules="[{ required: true, message: '请选择参数值', trigger: 'blur' }]" :prop="`nodeParams.${index}.quote`">
|
||||
<el-cascader v-model="property.quote" :options="quoteOptions" placeholder="请选择" @visible-change="visibleChange"/>
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
<div>循环体</div>
|
||||
<div class="child__container" @drop="handleDrop" @dragover="handleDragover">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import NodeTitle from '../../components/NodeTitle.vue'
|
||||
import loop from '../../icon/loop.svg'
|
||||
import { useFlowStore } from '@/store/modules/flow'
|
||||
import { addNewEdge, getInputNumber } from '@/utils/flow'
|
||||
|
||||
const props = defineProps({
|
||||
model: Object,
|
||||
graphModel: Object,
|
||||
properties: Object,
|
||||
nowTime: Number,
|
||||
});
|
||||
|
||||
const flowStore = useFlowStore()
|
||||
const formData = reactive({
|
||||
nodeParams: [
|
||||
{ name: "loopNum", type: "input", input: null, quote: "" }
|
||||
]
|
||||
})
|
||||
|
||||
const quoteOptions = ref([])
|
||||
const handleTypeChange = (index) => {
|
||||
if (formData.nodeParams[index].type === 'input') {
|
||||
formData.nodeParams[index].quote = ""
|
||||
} else {
|
||||
formData.nodeParams[index].input = null
|
||||
const option = getInputNumber(props.model.id)
|
||||
if (option) {
|
||||
quoteOptions.value = option
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rules = reactive({})
|
||||
|
||||
const emits = defineEmits(['bindRef', 'addToGroup', 'contentChange'])
|
||||
|
||||
const handleDragover = (e) => {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
const handleDrop = (e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation();
|
||||
|
||||
// const type = e.dataTransfer.getData('nodeType');
|
||||
let flowNode = e.dataTransfer.getData('flowNode');
|
||||
flowNode = JSON.parse(flowNode)
|
||||
const point = lf.getPointByClient(e.clientX, e.clientY)
|
||||
const { type, ...other } = flowNode
|
||||
const node = lf.addNode({
|
||||
type,
|
||||
x: point.canvasOverlayPosition.x,
|
||||
y: point.canvasOverlayPosition.y,
|
||||
properties: {
|
||||
parentId: props.model.id,
|
||||
...other
|
||||
}
|
||||
})
|
||||
|
||||
emits('addToGroup', node.id)
|
||||
setTimeout(() => {
|
||||
addNewEdge(props.model.id)
|
||||
}, 50)
|
||||
}
|
||||
|
||||
const dynamicForm = ref()
|
||||
|
||||
const setNodeProperties = async () => {
|
||||
try {
|
||||
const valid = await dynamicForm.value.validate()
|
||||
if (valid) {
|
||||
const data = toRaw(formData)
|
||||
setTimeout(() => {
|
||||
const properties = lf.getProperties(props.model.id)
|
||||
window.lf.setProperties(props.model.id, {
|
||||
...properties,
|
||||
...data
|
||||
})
|
||||
}, 50)
|
||||
}
|
||||
} catch (error) {
|
||||
dynamicForm.value.clearValidate()
|
||||
}
|
||||
}
|
||||
|
||||
const visibleChange = (value) => {
|
||||
if (value) {
|
||||
const option = getInput(props.model.id)
|
||||
if (option) {
|
||||
quoteOptions.value = option
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.properties,
|
||||
() => {
|
||||
if (props.properties.nodeParams && props.properties.nodeParams.length > 0) {
|
||||
formData.nodeParams = props.properties.nodeParams
|
||||
const option = getInputNumber(props.model.id)
|
||||
if (option) {
|
||||
quoteOptions.value = option
|
||||
}
|
||||
}
|
||||
}, {
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
emits('bindRef', dynamicForm.value)
|
||||
})
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.group__container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #fff;
|
||||
padding: 12px;
|
||||
cursor: default;
|
||||
border-radius: 12px;
|
||||
border: 2px solid white;
|
||||
box-shadow: 0 5px 15px 0#00000008;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
|
||||
.title {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
:deep(.loop__container) {
|
||||
height: 80px;
|
||||
|
||||
.el-input {
|
||||
width: 92px;
|
||||
}
|
||||
|
||||
.el-input-number {
|
||||
width: 92px;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
width: 92px;
|
||||
}
|
||||
|
||||
.el-cascader {
|
||||
width: 92px;
|
||||
}
|
||||
}
|
||||
|
||||
.child__container {
|
||||
min-height: 80px;
|
||||
flex: 1;
|
||||
background-color: #f6f8fa;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.el-row {
|
||||
align-items: end;
|
||||
}
|
||||
}
|
||||
<template>
|
||||
<div class="group__container" @mouseleave="setNodeProperties">
|
||||
<NodeTitle :icon="loop" :nodeId="props.model.id" :nodeProperties="props.properties" :nodeName="props.properties?.name || '循环'" nodeDesc="循环执行一系列任务,直至输出所有结果" />
|
||||
<div class="loop__container">
|
||||
<div>
|
||||
<el-form :inline="true" :model="formData" :rules="rules" ref="dynamicForm" label-position="top" label-width="auto" :disabled="flowStore.disableForm">
|
||||
<div v-for="(property, index) in formData.nodeParams" :key="index">
|
||||
<el-row>
|
||||
<el-form-item :label="index === 0 ? '参数名' : ''" :prop="`nodeParams.${index}.name`" :rules="[{ required: true, message: '请输入参数名', trigger: 'blur' }]">
|
||||
<el-input :disabled="index === 0" v-model="property.name" placeholder="请输入" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="index === 0 ? '参数值' : ''" :prop="`nodeParams.${index}.type`" >
|
||||
<el-select v-model="property.type" @change="handleTypeChange(index)">
|
||||
<el-option label="引用" value="quote" />
|
||||
<el-option label="输入" value="input" />
|
||||
</el-select>
|
||||
<el-form-item v-if="property.type === 'input'" :rules="[{ required: true, message: '请输入参数值', trigger: 'blur' }]" :prop="`nodeParams.${index}.input`">
|
||||
<el-input-number v-model="property.input" :min="0" :controls="false" :step-strictly="true" placeholder="请输入" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="property.type === 'quote'" :rules="[{ required: true, message: '请选择参数值', trigger: 'blur' }]" :prop="`nodeParams.${index}.quote`">
|
||||
<el-cascader v-model="property.quote" :options="quoteOptions" placeholder="请选择" @visible-change="visibleChange"/>
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
<div>循环体</div>
|
||||
<div class="child__container" @drop="handleDrop" @dragover="handleDragover">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import NodeTitle from '../../components/NodeTitle.vue'
|
||||
import loop from '../../icon/loop.svg'
|
||||
import { useFlowStore } from '@/store/modules/flow'
|
||||
import { addNewEdge, getInput } from '@/utils/flow'
|
||||
|
||||
const props = defineProps({
|
||||
model: Object,
|
||||
graphModel: Object,
|
||||
properties: Object,
|
||||
nowTime: Number,
|
||||
});
|
||||
|
||||
const flowStore = useFlowStore()
|
||||
const formData = reactive({
|
||||
nodeParams: [
|
||||
{ name: "loopNum", type: "input", input: null, quote: "" }
|
||||
]
|
||||
})
|
||||
|
||||
const quoteOptions = ref([])
|
||||
const handleTypeChange = (index) => {
|
||||
if (formData.nodeParams[index].type === 'input') {
|
||||
formData.nodeParams[index].quote = ""
|
||||
} else {
|
||||
formData.nodeParams[index].input = null
|
||||
const option = getInput(props.model.id)
|
||||
if (option) {
|
||||
quoteOptions.value = option
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rules = reactive({})
|
||||
|
||||
const emits = defineEmits(['bindRef', 'addToGroup', 'contentChange'])
|
||||
|
||||
const handleDragover = (e) => {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
const handleDrop = (e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation();
|
||||
|
||||
let flowNode = e.dataTransfer.getData('flowNode');
|
||||
flowNode = JSON.parse(flowNode)
|
||||
const point = lf.getPointByClient(e.clientX, e.clientY)
|
||||
const { type, ...other } = flowNode
|
||||
const node = lf.addNode({
|
||||
type,
|
||||
x: point.canvasOverlayPosition.x,
|
||||
y: point.canvasOverlayPosition.y,
|
||||
properties: {
|
||||
parentId: props.model.id,
|
||||
...other
|
||||
}
|
||||
})
|
||||
|
||||
emits('addToGroup', node.id)
|
||||
setTimeout(() => {
|
||||
addNewEdge(props.model.id)
|
||||
}, 50)
|
||||
}
|
||||
|
||||
const dynamicForm = ref()
|
||||
|
||||
const setNodeProperties = async () => {
|
||||
try {
|
||||
const valid = await dynamicForm.value.validate()
|
||||
if (valid) {
|
||||
const data = toRaw(formData)
|
||||
setTimeout(() => {
|
||||
const properties = lf.getProperties(props.model.id)
|
||||
window.lf.setProperties(props.model.id, {
|
||||
...properties,
|
||||
...data
|
||||
})
|
||||
}, 50)
|
||||
}
|
||||
} catch (error) {
|
||||
dynamicForm.value.clearValidate()
|
||||
}
|
||||
}
|
||||
|
||||
const visibleChange = (value) => {
|
||||
if (value) {
|
||||
const option = getInput(props.model.id)
|
||||
if (option) {
|
||||
quoteOptions.value = option
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.properties,
|
||||
() => {
|
||||
if (props.properties.nodeParams && props.properties.nodeParams.length > 0) {
|
||||
formData.nodeParams = props.properties.nodeParams
|
||||
const option = getInputNumber(props.model.id)
|
||||
if (option) {
|
||||
quoteOptions.value = option
|
||||
}
|
||||
}
|
||||
}, {
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
emits('bindRef', dynamicForm.value)
|
||||
})
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.group__container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #fff;
|
||||
padding: 12px;
|
||||
cursor: default;
|
||||
border-radius: 12px;
|
||||
border: 2px solid white;
|
||||
box-shadow: 0 5px 15px 0#00000008;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
|
||||
.title {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
:deep(.loop__container) {
|
||||
height: 80px;
|
||||
|
||||
.el-input {
|
||||
width: 92px;
|
||||
}
|
||||
|
||||
.el-input-number {
|
||||
width: 92px;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
width: 92px;
|
||||
}
|
||||
|
||||
.el-cascader {
|
||||
width: 92px;
|
||||
}
|
||||
}
|
||||
|
||||
.child__container {
|
||||
min-height: 80px;
|
||||
flex: 1;
|
||||
background-color: #f6f8fa;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.el-row {
|
||||
align-items: end;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
322
src/views/vi/corpus/awaken/index.vue
Normal file
322
src/views/vi/corpus/awaken/index.vue
Normal file
@ -0,0 +1,322 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="语料名称" prop="corpusName">
|
||||
<el-input
|
||||
v-model="queryParams.corpusName"
|
||||
placeholder="请输入语料名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="音色" prop="voiceType">
|
||||
<el-select v-model="queryParams.voiceType" placeholder="请选择音色" clearable style="width: 200px">
|
||||
<el-option
|
||||
v-for="dict in vi_voice_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="语种" prop="dialect">
|
||||
<el-select v-model="queryParams.voiceType" placeholder="请选择语种" clearable style="width: 200px">
|
||||
<el-option
|
||||
v-for="dict in vi_dialect_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="预期结果" prop="expectedResult">
|
||||
<el-input
|
||||
v-model="queryParams.expectedResult"
|
||||
placeholder="请输入预期结果"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['vi:corpus:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['vi:corpus:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['vi:corpus:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['vi:corpus:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="corpusList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="语料名称" align="center" prop="corpusName" />
|
||||
<el-table-column label="语料类型" align="center" prop="type" />
|
||||
<el-table-column label="语音文本" align="center" prop="textContent" />
|
||||
<el-table-column label="语音文件路径" align="center" prop="audioPath" />
|
||||
<el-table-column label="音色" align="center" prop="voiceType" />
|
||||
<el-table-column label="语种" align="center" prop="dialect" />
|
||||
<el-table-column label="预期结果" align="center" prop="expectedResult" />
|
||||
<el-table-column label="顺序" align="center" prop="sortOrder" />
|
||||
<el-table-column label="状态" align="center" prop="status" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['vi:corpus:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['vi:corpus:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改语料库对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="580px" append-to-body>
|
||||
<el-form ref="corpusRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="语料名称" prop="corpusName">
|
||||
<el-input v-model="form.corpusName" placeholder="请输入语料名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="语音文本">
|
||||
<el-input v-model="form.textContent" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文件路径" prop="audioPath">
|
||||
<el-input v-model="form.audioPath" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="音色" prop="voiceType">
|
||||
<el-select v-model="form.voiceType" placeholder="请选择音色" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in vi_voice_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="语种" prop="dialect">
|
||||
<el-select v-model="form.voiceType" placeholder="请选择语种" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in vi_dialect_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="预期结果" prop="expectedResult">
|
||||
<el-input v-model="form.audioPath" type="textarea" placeholder="请输入预期结果" />
|
||||
</el-form-item>
|
||||
<el-form-item label="顺序" prop="sortOrder">
|
||||
<el-input v-model="form.sortOrder" placeholder="请输入同一父语料下的顺序" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Corpus">
|
||||
import { listCorpus, getCorpus, delCorpus, addCorpus, updateCorpus } from "@/api/vi/corpus"
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { vi_voice_type, vi_dialect_type } = proxy.useDict("vi_voice_type", "vi_dialect_type")
|
||||
const corpusList = ref([])
|
||||
const open = ref(false)
|
||||
const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const ids = ref([])
|
||||
const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref("")
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
corpusName: null,
|
||||
type: 'WAKE',
|
||||
textContent: null,
|
||||
audioPath: null,
|
||||
voiceType: null,
|
||||
dialect: null,
|
||||
expectedResult: null,
|
||||
sortOrder: null,
|
||||
status: null,
|
||||
},
|
||||
rules: {
|
||||
type: [
|
||||
{ required: true, message: "语料类型不能为空", trigger: "change" }
|
||||
],
|
||||
textContent: [
|
||||
{ required: true, message: "语音对应的文本不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
/** 查询语料库列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listCorpus(queryParams.value).then(response => {
|
||||
corpusList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
}).catch(err => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
corpusId: null,
|
||||
corpusName: null,
|
||||
type: null,
|
||||
textContent: null,
|
||||
audioPath: null,
|
||||
voiceType: null,
|
||||
dialect: null,
|
||||
expectedResult: null,
|
||||
sortOrder: null,
|
||||
status: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null
|
||||
}
|
||||
proxy.resetForm("corpusRef")
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.corpusId)
|
||||
single.value = selection.length != 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = "添加语料库"
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const _corpusId = row.corpusId || ids.value
|
||||
getCorpus(_corpusId).then(response => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = "修改语料库"
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["corpusRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (form.value.corpusId != null) {
|
||||
updateCorpus(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addCorpus(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _corpusIds = row.corpusId || ids.value
|
||||
proxy.$modal.confirm('是否确认删除语料库编号为"' + _corpusIds + '"的数据项?').then(function() {
|
||||
return delCorpus(_corpusIds)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('vi/corpus/export', {
|
||||
...queryParams.value
|
||||
}, `corpus_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
getList()
|
||||
</script>
|
||||
335
src/views/vi/corpus/test/index.vue
Normal file
335
src/views/vi/corpus/test/index.vue
Normal file
@ -0,0 +1,335 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="语料名称" prop="corpusName">
|
||||
<el-input
|
||||
v-model="queryParams.corpusName"
|
||||
placeholder="请输入语料名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="音色" prop="voiceType">
|
||||
<el-select v-model="queryParams.voiceType" placeholder="请选择音色" clearable style="width: 200px">
|
||||
<el-option
|
||||
v-for="dict in vi_voice_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="语种" prop="dialect">
|
||||
<el-select v-model="queryParams.voiceType" placeholder="请选择语种" clearable style="width: 200px">
|
||||
<el-option
|
||||
v-for="dict in vi_dialect_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="预期结果" prop="expectedResult">
|
||||
<el-input
|
||||
v-model="queryParams.expectedResult"
|
||||
placeholder="请输入预期结果"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['vi:corpus:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['vi:corpus:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['vi:corpus:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['vi:corpus:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="corpusList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="语料名称" align="center" prop="corpusName" />
|
||||
<el-table-column label="语料类型" align="center" prop="type" />
|
||||
<el-table-column label="语音文本" align="center" prop="textContent" />
|
||||
<el-table-column label="语音文件路径" align="center" prop="audioPath" />
|
||||
<el-table-column label="音色" align="center" prop="voiceType" />
|
||||
<el-table-column label="语种" align="center" prop="dialect" />
|
||||
<el-table-column label="预期结果" align="center" prop="expectedResult" />
|
||||
<el-table-column label="顺序" align="center" prop="sortOrder" />
|
||||
<el-table-column label="状态" align="center" prop="status" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['vi:corpus:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['vi:corpus:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改语料库对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="640px" append-to-body>
|
||||
<el-form ref="corpusRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="语料名称" prop="corpusName">
|
||||
<el-input v-model="form.corpusName" placeholder="请输入语料名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="音色" prop="voiceType">
|
||||
<el-select v-model="form.voiceType" placeholder="请选择音色" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in vi_voice_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="语种" prop="dialect">
|
||||
<el-select v-model="form.voiceType" placeholder="请选择语种" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in vi_dialect_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="tableData">
|
||||
<el-table-column prop="num" label="序号">
|
||||
<template #default="{ row }">
|
||||
<el-inputNumber style="width: 100px;" v-model="row.num" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="textContent" label="语料文本">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.textContent" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="audioPath" label="音频文件">
|
||||
<el-button>上传文件</el-button>
|
||||
</el-table-column>
|
||||
<el-table-column prop="expectedResult" label="预期结果">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.expectedResult" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="action" label="操作">
|
||||
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Corpus">
|
||||
import { listCorpus, getCorpus, delCorpus, addCorpus, updateCorpus } from "@/api/vi/corpus"
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { vi_voice_type, vi_dialect_type } = proxy.useDict("vi_voice_type", "vi_dialect_type")
|
||||
const corpusList = ref([])
|
||||
const open = ref(false)
|
||||
const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const ids = ref([])
|
||||
const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref("")
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
corpusName: null,
|
||||
type: null,
|
||||
textContent: null,
|
||||
audioPath: null,
|
||||
voiceType: null,
|
||||
dialect: null,
|
||||
expectedResult: null,
|
||||
sortOrder: null,
|
||||
status: null,
|
||||
},
|
||||
rules: {
|
||||
type: [
|
||||
{ required: true, message: "语料类型不能为空", trigger: "change" }
|
||||
],
|
||||
textContent: [
|
||||
{ required: true, message: "语音对应的文本不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
/** 查询语料库列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listCorpus(queryParams.value).then(response => {
|
||||
corpusList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
}).catch(err => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
corpusId: null,
|
||||
corpusName: null,
|
||||
type: null,
|
||||
textContent: null,
|
||||
audioPath: null,
|
||||
voiceType: null,
|
||||
dialect: null,
|
||||
expectedResult: null,
|
||||
sortOrder: null,
|
||||
status: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null
|
||||
}
|
||||
proxy.resetForm("corpusRef")
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.corpusId)
|
||||
single.value = selection.length != 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = "添加语料库"
|
||||
}
|
||||
|
||||
const tableData = ref([{}])
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const _corpusId = row.corpusId || ids.value
|
||||
getCorpus(_corpusId).then(response => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = "修改语料库"
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["corpusRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (form.value.corpusId != null) {
|
||||
updateCorpus(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addCorpus(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _corpusIds = row.corpusId || ids.value
|
||||
proxy.$modal.confirm('是否确认删除语料库编号为"' + _corpusIds + '"的数据项?').then(function() {
|
||||
return delCorpus(_corpusIds)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('vi/corpus/export', {
|
||||
...queryParams.value
|
||||
}, `corpus_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
getList()
|
||||
</script>
|
||||
@ -32,11 +32,11 @@ export default defineConfig(({mode, command}) => {
|
||||
proxy: {
|
||||
// https://cn.vitejs.dev/config/#server-proxy
|
||||
'/dev-api': {
|
||||
//杨 http://10.148.108.95: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://127.0.0.1:13080',
|
||||
target: command === 'build' ? VITE_API_URL : 'http://192.168.0.10:13080',
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user