发布接口

This commit is contained in:
wangdan-fit2cloud 2024-06-18 18:05:19 +08:00
parent e6c94750df
commit 40b515dae6
15 changed files with 88 additions and 43 deletions

View File

@ -45,8 +45,7 @@ const postApplication: (
/**
*
* @param
* @param
*/
const putApplication: (
application_id: String,
@ -228,6 +227,18 @@ const getApplicationModel: (
return get(`${prefix}/${application_id}/model`, loading)
}
/**
*
* @param
*/
const putPublishApplication: (
application_id: String,
data: ApplicationFormType,
loading?: Ref<boolean>
) => Promise<Result<any>> = (application_id, data, loading) => {
return put(`${prefix}/${application_id}/publish`, data, undefined, loading)
}
export default {
getAllAppilcation,
getApplication,
@ -245,5 +256,6 @@ export default {
getProfile,
putChatVote,
getApplicationHitTest,
getApplicationModel
getApplicationModel,
putPublishApplication
}

View File

@ -12,6 +12,7 @@ interface ApplicationFormType {
problem_optimization?: boolean
icon?: string | undefined
type?: string
work_flow?: any
}
interface chatType {
id: string

View File

@ -1,6 +1,11 @@
<template>
<div v-if="!menu.meta || !menu.meta.hidden" class="sidebar-item">
<el-menu-item ref="subMenu" :index="menu.path" popper-class="sidebar-popper">
<el-menu-item
ref="subMenu"
:index="menu.path"
popper-class="sidebar-popper"
@click="clickHandle(menu)"
>
<template #title>
<AppIcon v-if="menu.meta && menu.meta.icon" :iconName="menuIcon" class="sidebar-icon" />
<span v-if="menu.meta && menu.meta.title">{{ menu.meta.title }}</span>
@ -11,12 +16,25 @@
<script setup lang="ts">
import { computed } from 'vue'
import { type RouteRecordRaw } from 'vue-router'
import { useRouter, useRoute, type RouteRecordRaw } from 'vue-router'
const props = defineProps<{
menu: RouteRecordRaw
activeMenu: any
}>()
const route = useRoute()
const router = useRouter()
const {
params: { id, type }
} = route as any
function clickHandle(item: any) {
if (item.name === 'AppSetting' && type === 'WORK_FLOW') {
router.push({ path: `/application/${id}/workflow` })
}
}
const menuIcon = computed(() => {
if (props.activeMenu === props.menu.path) {
return props.menu.meta?.iconActive || props.menu?.meta?.icon

View File

@ -20,7 +20,7 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { useRouter, useRoute } from 'vue-router'
import { getChildRouteListByPathAndName } from '@/router/index'
import SidebarItem from './SidebarItem.vue'
import AppBreadcrumb from './../breadcrumb/index.vue'

View File

@ -68,9 +68,9 @@ export default {
confirm: '确认',
cancel: '取消',
create: '创建',
createSuccess: '创建',
createSuccess: '创建成功',
save: '保存',
saveSuccess: '保存'
saveSuccess: '保存成功'
},
dialogues: {
addDataset: '添加关联知识库',

View File

@ -18,7 +18,7 @@ const applicationRouter = {
hidden: true
},
{
path: '/application/:id',
path: '/application/:id/:type',
name: 'ApplicationDetail',
meta: { title: '应用详情', activeMenu: '/application' },
component: Layout,
@ -32,20 +32,20 @@ const applicationRouter = {
iconActive: 'app-all-menu-active',
title: '概览',
active: 'overview',
parentPath: '/application/:id',
parentPath: '/application/:id/:type',
parentName: 'ApplicationDetail'
},
component: () => import('@/views/application-overview/index.vue')
},
{
path: 'setting',
path: 'setting',
name: 'AppSetting',
meta: {
icon: 'app-setting',
iconActive: 'app-setting-active',
title: '设置',
active: 'setting',
parentPath: '/application/:id',
parentPath: '/application/:id/:type',
parentName: 'ApplicationDetail'
},
component: () => import('@/views/application/CreateAndSetting.vue')
@ -57,7 +57,7 @@ const applicationRouter = {
icon: 'app-hit-test',
title: '命中测试',
active: 'hit-test',
parentPath: '/application/:id',
parentPath: '/application/:id/:type',
parentName: 'ApplicationDetail'
},
component: () => import('@/views/hit-test/index.vue')
@ -70,7 +70,7 @@ const applicationRouter = {
iconActive: 'app-document-active',
title: '对话日志',
active: 'log',
parentPath: '/application/:id',
parentPath: '/application/:id/:type',
parentName: 'ApplicationDetail'
},
component: () => import('@/views/log/index.vue')
@ -79,12 +79,12 @@ const applicationRouter = {
},
// 创建编排
{
path: '/application/workflow',
path: '/application/:id/workflow',
name: 'ApplicationWorkflow',
meta: { activeMenu: '/application' },
component: () => import('@/views/application-workflow/index.vue'),
hidden: true
},
}
]
}

View File

@ -6,13 +6,11 @@
<h4>创建应用</h4>
</div>
<div>
<button @click="validate">点击校验</button>
<button @click="getGraphData">点击获取流程数据</button>
<el-button icon="Plus" @click="showPopover = !showPopover" v-click-outside="clickoutside">
添加组件
</el-button>
<el-button> 调试 </el-button>
<el-button type="primary"> 保存 </el-button>
<el-button type="primary" @click="publicHandle"> 保存 </el-button>
</div>
</div>
<!-- 下拉框 -->
@ -37,14 +35,34 @@
</template>
<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount, computed } from 'vue'
import { useRoute } from 'vue-router'
import Workflow from '@/workflow/index.vue'
import { menuNodes } from '@/workflow/common/data'
import { iconComponent } from '@/workflow/icons/utils'
import applicationApi from '@/api/application'
import { MsgSuccess, MsgConfirm } from '@/utils/message'
const route = useRoute()
const {
params: { id }
} = route as any
const workflowRef = ref()
const loading = ref(false)
const showPopover = ref(false)
function publicHandle() {
workflowRef.value?.validate().then(() => {
const obj = {
work_flow: getGraphData()
}
applicationApi.putPublishApplication(id as String, obj, loading).then(() => {
MsgSuccess('发布成功')
})
})
}
function clickoutside() {
showPopover.value = false
}
@ -53,11 +71,8 @@ function onmousedown(item: any) {
workflowRef.value?.onmousedown(item)
}
function validate() {
workflowRef.value?.validate()
}
function getGraphData() {
workflowRef.value?.getGraphData()
return workflowRef.value?.getGraphData()
}
onMounted(() => {})

View File

@ -80,7 +80,6 @@ import type { ApplicationFormType } from '@/api/type/application'
import type { FormInstance, FormRules } from 'element-plus'
import applicationApi from '@/api/application'
import { MsgSuccess } from '@/utils/message'
import useStore from '@/stores'
import { t } from '@/locales'
const router = useRouter()
@ -173,11 +172,12 @@ const submitHandle = async (formEl: FormInstance | undefined) => {
await formEl.validate((valid) => {
if (valid) {
applicationApi.postApplication(applicationForm.value, loading).then((res) => {
console.log(res)
MsgSuccess(t('views.application.applicationForm.buttons.createSuccess'))
if (applicationForm.value.type === 'WORK_FLOW') {
router.push({ path: `/application//workflow?id=${res.data.id}` })
router.push({ path: `/application/${res.data.id}/workflow` })
} else {
router.push({ path: `/application/${res.data.id}/setting` })
router.push({ path: `/application/${res.data.id}/${item.type}/setting` })
}
dialogVisible.value = false

View File

@ -41,7 +41,7 @@
:title="item.name"
:description="item.desc"
class="application-card cursor"
@click="router.push({ path: `/application/${item.id}/overview` })"
@click="router.push({ path: `/application/${item.id}/${item.type}/overview` })"
>
<template #icon>
<AppAvatar
@ -82,7 +82,9 @@
>
<el-button
text
@click.stop="router.push({ path: `/application/${item.id}/setting` })"
@click.stop="
router.push({ path: `/application/${item.id}/${item.type}/setting` })
"
>
<AppIcon iconName="Setting"></AppIcon>
</el-button>

View File

@ -11,7 +11,7 @@ import Control from './common/NodeControl.vue'
import { baseNodes } from '@/workflow/common/data'
import '@logicflow/extension/lib/style/index.css'
import '@logicflow/core/dist/style/index.css'
import {initDefaultShortcut} from '@/workflow/common/shortcut'
import { initDefaultShortcut } from '@/workflow/common/shortcut'
const nodes: any = import.meta.glob('./nodes/**/index.ts', { eager: true })
defineOptions({ name: 'WorkFlow' })
@ -490,8 +490,8 @@ const graphData = {
}
const lf = ref()
const TRANSLATION_DISTANCE = 40;
let CHILDREN_TRANSLATION_DISTANCE = 40;
const TRANSLATION_DISTANCE = 40
let CHILDREN_TRANSLATION_DISTANCE = 40
onMounted(() => {
const container: any = document.querySelector('#container')
if (container) {
@ -509,8 +509,7 @@ onMounted(() => {
}
},
keyboard: {
enabled: true,
enabled: true
},
isSilentMode: false,
container: container
@ -521,7 +520,7 @@ onMounted(() => {
strokeWidth: 1
}
})
initDefaultShortcut(lf.value,lf.value.graphModel)
initDefaultShortcut(lf.value, lf.value.graphModel)
lf.value.batchRegister([...Object.keys(nodes).map((key) => nodes[key].default), AppEdge])
lf.value.setDefaultEdgeType('app-edge')
@ -535,12 +534,10 @@ onMounted(() => {
}
})
const validate = () => {
lf.value.graphModel.nodes.forEach((element: any) => {
element?.validate?.()
})
return Promise.all(lf.value.graphModel.nodes.map((element: any) => element?.validate?.()))
}
const getGraphData = () => {
console.log(JSON.stringify(lf.value.getGraphData()))
return JSON.stringify(lf.value.getGraphData())
}
const onmousedown = (shapeItem: ShapeItem) => {

View File

@ -184,7 +184,7 @@ const modelOptions = ref<any>(null)
const providerOptions = ref<Array<Provider>>([])
const validate = () => {
aiChatNodeFormRef.value?.validate()
return aiChatNodeFormRef.value?.validate()
}
function getModel() {

View File

@ -82,7 +82,7 @@ const form_data = computed({
const baseNodeFormRef = ref<FormInstance>()
const validate = () => {
baseNodeFormRef.value?.validate()
return baseNodeFormRef.value?.validate()
}
onMounted(() => {

View File

@ -176,7 +176,7 @@ const form_data = computed({
const ConditionNodeFormRef = ref<FormInstance>()
const validate = () => {
ConditionNodeFormRef.value?.validate()
return ConditionNodeFormRef.value?.validate()
}
function addBranch() {

View File

@ -183,7 +183,7 @@ const modelOptions = ref<any>(null)
const providerOptions = ref<Array<Provider>>([])
const validate = () => {
questionNodeFormRef.value?.validate()
return questionNodeFormRef.value?.validate()
}
function getModel() {

View File

@ -190,7 +190,7 @@ function refresh() {
}
const validate = () => {
DatasetNodeFormRef.value?.validate()
return DatasetNodeFormRef.value?.validate()
}
onMounted(() => {