feat: Resource application permission

This commit is contained in:
zhangzhanwei 2025-08-01 17:25:04 +08:00 committed by zhanweizhang7
parent 83a1ffb891
commit d4312ee9ea
4 changed files with 432 additions and 481 deletions

View File

@ -22,26 +22,35 @@ const ApplicationDetailRouter = {
parentPath: '/application/:from/:id/:type', parentPath: '/application/:from/:id/:type',
parentName: 'ApplicationDetail', parentName: 'ApplicationDetail',
permission: [ permission: [
() => {
const to: any = get_next_route()
return new ComplexPermission([RoleConst.USER],[PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission( to ? to.params.id : '',)],[],'AND')},
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.APPLICATION_OVERVIEW_READ.getWorkspacePermissionWorkspaceManageRole,
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
return PermissionConst.APPLICATION_OVERVIEW_READ.getApplicationWorkspaceResourcePermission( if (to.params.from == 'resource-management') { } else {
to ? to.params.id : '', return new ComplexPermission([RoleConst.USER], [PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND')
) }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) {return RoleConst.ADMIN} if (to.params.from == 'resource-management') { } else { return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
console.log('ss',to) if (to.params.from == 'resource-management') { } else { return PermissionConst.APPLICATION_OVERVIEW_READ.getWorkspacePermissionWorkspaceManageRole }
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_OVERVIEW_READ} },
() => {
const to: any = get_next_route()
if (to.params.from == 'resource-management') { } else {
return PermissionConst.APPLICATION_OVERVIEW_READ.getApplicationWorkspaceResourcePermission(
to ? to.params.id : '',
)
}
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_OVERVIEW_READ }
}, },
] ]
}, },
@ -58,24 +67,39 @@ const ApplicationDetailRouter = {
parentPath: '/application/:from/:id/:type', parentPath: '/application/:from/:id/:type',
parentName: 'ApplicationDetail', parentName: 'ApplicationDetail',
permission: [ permission: [
() => {
const to: any = get_next_route()
return new ComplexPermission([RoleConst.USER],[PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission( to ? to.params.id : '',)],[],'AND')},
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.APPLICATION_EDIT.getWorkspacePermissionWorkspaceManageRole,
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
return PermissionConst.APPLICATION_EDIT.getApplicationWorkspaceResourcePermission( if (to.params.from == 'resource-management') { } else {
to ? to.params.id : '', return new ComplexPermission([RoleConst.USER], [PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND')
) }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) {return RoleConst.ADMIN} if (to.params.from == 'resource-management') { } else {
return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole
}
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_EDIT} if (to.params.from == 'resource-management') { } else {
return PermissionConst.APPLICATION_EDIT.getWorkspacePermissionWorkspaceManageRole
}
},
() => {
const to: any = get_next_route()
if (to.params.from == 'resource-management') { } else {
return PermissionConst.APPLICATION_EDIT.getApplicationWorkspaceResourcePermission(
to ? to.params.id : '',
)
}
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_EDIT }
}, },
] ]
}, },
@ -93,21 +117,34 @@ const ApplicationDetailRouter = {
parentName: 'ApplicationDetail', parentName: 'ApplicationDetail',
permission: [ permission: [
() => { () => {
const to: any = get_next_route()
return new ComplexPermission([RoleConst.USER],[PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission( to ? to.params.id : '',)],[EditionConst.IS_EE, EditionConst.IS_PE],'AND')},
new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,],[PermissionConst.APPLICATION_ACCESS_READ.getWorkspacePermissionWorkspaceManageRole],[EditionConst.IS_EE, EditionConst.IS_PE],'OR'),
new ComplexPermission([],[() => {
const to: any = get_next_route() const to: any = get_next_route()
return PermissionConst.APPLICATION_ACCESS_READ.getApplicationWorkspaceResourcePermission( if (to.params.from == 'resource-management') { } else {
to ? to.params.id : '',) return new ComplexPermission([RoleConst.USER], [PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission(to ? to.params.id : '',)], [EditionConst.IS_EE, EditionConst.IS_PE], 'AND')
}],[EditionConst.IS_EE, EditionConst.IS_PE],'OR'), }
},
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) {return RoleConst.ADMIN} if (to.params.from == 'resource-management') { } else {
return new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,], [PermissionConst.APPLICATION_ACCESS_READ.getWorkspacePermissionWorkspaceManageRole], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR')
}
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_ACCESS_READ} if (to.params.from == 'resource-management') { } else {
return new ComplexPermission([], [() => {
const to: any = get_next_route()
return PermissionConst.APPLICATION_ACCESS_READ.getApplicationWorkspaceResourcePermission(
to ? to.params.id : '',)
}], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR')
}
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_ACCESS_READ }
}, },
] ]
}, },
@ -125,23 +162,32 @@ const ApplicationDetailRouter = {
parentName: 'ApplicationDetail', parentName: 'ApplicationDetail',
resourceType: SourceTypeEnum.APPLICATION, resourceType: SourceTypeEnum.APPLICATION,
permission: [ permission: [
() => {
const to: any = get_next_route()
return new ComplexPermission([RoleConst.USER],[PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission( to ? to.params.id : '',)],[EditionConst.IS_EE, EditionConst.IS_PE],'AND')},
new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],[PermissionConst.APPLICATION_CHAT_USER_READ.getWorkspacePermissionWorkspaceManageRole],[EditionConst.IS_EE, EditionConst.IS_PE],'OR')
,
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
return new ComplexPermission([],[PermissionConst.APPLICATION_CHAT_USER_READ.getApplicationWorkspaceResourcePermission( if (to.params.from == 'resource-management') { } else {
to ? to.params.id : '',)],[EditionConst.IS_EE, EditionConst.IS_PE],'OR') return new ComplexPermission([RoleConst.USER], [PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission(to ? to.params.id : '',)], [EditionConst.IS_EE, EditionConst.IS_PE], 'AND')
}
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) {return RoleConst.ADMIN} if (to.params.from == 'resource-management') { } else {
return new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole], [PermissionConst.APPLICATION_CHAT_USER_READ.getWorkspacePermissionWorkspaceManageRole], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR')
}
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_CHAT_USER_READ} if (to.params.from == 'resource-management') { } else {
return new ComplexPermission([], [PermissionConst.APPLICATION_CHAT_USER_READ.getApplicationWorkspaceResourcePermission(
to ? to.params.id : '',)], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR')
}
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_CHAT_USER_READ }
}, },
] ]
}, },
@ -158,24 +204,39 @@ const ApplicationDetailRouter = {
parentPath: '/application/:from/:id/:type', parentPath: '/application/:from/:id/:type',
parentName: 'ApplicationDetail', parentName: 'ApplicationDetail',
permission: [ permission: [
() => {
const to: any = get_next_route()
return new ComplexPermission([RoleConst.USER],[PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission( to ? to.params.id : '',)],[],'AND')},
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.APPLICATION_CHAT_LOG_READ.getWorkspacePermissionWorkspaceManageRole,
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
return PermissionConst.APPLICATION_CHAT_LOG_READ.getApplicationWorkspaceResourcePermission( if (to.params.from == 'resource-management') { } else {
to ? to.params.id : '', return new ComplexPermission([RoleConst.USER], [PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND')
) }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) {return RoleConst.ADMIN} if (to.params.from == 'resource-management') { } else {
return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole
}
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_READ} if (to.params.from == 'resource-management') { } else {
return PermissionConst.APPLICATION_CHAT_LOG_READ.getWorkspacePermissionWorkspaceManageRole
}
},
() => {
const to: any = get_next_route()
if (to.params.from == 'resource-management') { } else {
return PermissionConst.APPLICATION_CHAT_LOG_READ.getApplicationWorkspaceResourcePermission(
to ? to.params.id : '',
)
}
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_READ }
}, },
] ]
}, },

View File

@ -23,24 +23,24 @@ const DocumentRouter = {
permission: [ permission: [
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND') } else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND') }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { if (to.params.folderId == 'shared') {
return RoleConst.ADMIN return RoleConst.ADMIN
} else { } else if (to.params.folderId == 'resource-management') { }
else {
return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole()
} }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { if (to.params.folderId == 'shared') {
return PermissionConst.SHARED_KNOWLEDGE_DOCUMENT_READ return PermissionConst.SHARED_KNOWLEDGE_DOCUMENT_READ
} else { } else if (to.params.folderId == 'resource-management') { }
else {
return PermissionConst.KNOWLEDGE_DOCUMENT_READ.getKnowledgeWorkspaceResourcePermission( return PermissionConst.KNOWLEDGE_DOCUMENT_READ.getKnowledgeWorkspaceResourcePermission(
to ? to.params.id : '', to ? to.params.id : '',
) )
@ -48,27 +48,30 @@ const DocumentRouter = {
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else { if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else {
return PermissionConst.KNOWLEDGE_DOCUMENT_READ.getWorkspacePermissionWorkspaceManageRole() return PermissionConst.KNOWLEDGE_DOCUMENT_READ.getWorkspacePermissionWorkspaceManageRole()
} }
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if(to.params.folderId == 'share') { if (to.params.folderId == 'share') {
return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_DOCUMENT_READ.getWorkspacePermission()], [], 'AND') } return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_DOCUMENT_READ.getWorkspacePermission()], [], 'AND')
}
}, },
()=>{ () => {
const to: any = get_next_route()
if(to.params.folderId == 'share') {
return RoleConst.USER.getWorkspaceRole() }
},
()=>{
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN} if (to.params.folderId == 'share') {
return RoleConst.USER.getWorkspaceRole()
}
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_DOCUMENT_READ} if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_DOCUMENT_READ }
}, },
], ],
}, },
@ -88,16 +91,18 @@ const DocumentRouter = {
permission: [ permission: [
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND') } else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND') }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else { return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return PermissionConst.SHARED_KNOWLEDGE_PROBLEM_READ } else { if (to.params.folderId == 'shared') { return PermissionConst.SHARED_KNOWLEDGE_PROBLEM_READ } else if (to.params.folderId == 'resource-management') { }
else {
return PermissionConst.KNOWLEDGE_PROBLEM_READ.getKnowledgeWorkspaceResourcePermission( return PermissionConst.KNOWLEDGE_PROBLEM_READ.getKnowledgeWorkspaceResourcePermission(
to ? to.params.id : '', to ? to.params.id : '',
) )
@ -105,25 +110,28 @@ const DocumentRouter = {
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else { return PermissionConst.KNOWLEDGE_PROBLEM_READ.getWorkspacePermissionWorkspaceManageRole() } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return PermissionConst.KNOWLEDGE_PROBLEM_READ.getWorkspacePermissionWorkspaceManageRole() }
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if(to.params.folderId == 'share') { if (to.params.folderId == 'share') {
return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_PROBLEM_READ.getWorkspacePermission()], [], 'AND') } return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_PROBLEM_READ.getWorkspacePermission()], [], 'AND')
}
}, },
()=>{ () => {
const to: any = get_next_route()
if(to.params.folderId == 'share') {
return RoleConst.USER.getWorkspaceRole() }
},
()=>{
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN} if (to.params.folderId == 'share') {
return RoleConst.USER.getWorkspaceRole()
}
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_PROBLEM_READ} if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_PROBLEM_READ }
}, },
], ],
}, },
@ -142,16 +150,18 @@ const DocumentRouter = {
permission: [ permission: [
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND') } else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND') }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else { return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return PermissionConst.SHARED_KNOWLEDGE_HIT_TEST_READ } else { if (to.params.folderId == 'shared') { return PermissionConst.SHARED_KNOWLEDGE_HIT_TEST_READ } else if (to.params.folderId == 'resource-management') { }
else {
return PermissionConst.KNOWLEDGE_HIT_TEST_READ.getKnowledgeWorkspaceResourcePermission( return PermissionConst.KNOWLEDGE_HIT_TEST_READ.getKnowledgeWorkspaceResourcePermission(
to ? to.params.id : '', to ? to.params.id : '',
) )
@ -159,25 +169,28 @@ const DocumentRouter = {
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else { return PermissionConst.KNOWLEDGE_HIT_TEST_READ.getWorkspacePermissionWorkspaceManageRole() } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return PermissionConst.KNOWLEDGE_HIT_TEST_READ.getWorkspacePermissionWorkspaceManageRole() }
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if(to.params.folderId == 'share') { if (to.params.folderId == 'share') {
return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_HIT_TEST_READ.getWorkspacePermission()], [], 'AND') } return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_HIT_TEST_READ.getWorkspacePermission()], [], 'AND')
}
}, },
()=>{ () => {
const to: any = get_next_route()
if(to.params.folderId == 'share') {
return RoleConst.USER.getWorkspaceRole() }
},
()=>{
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN} if (to.params.folderId == 'share') {
return RoleConst.USER.getWorkspaceRole()
}
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_HIT_TEST} if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_HIT_TEST }
}, },
], ],
}, },
@ -200,7 +213,8 @@ const DocumentRouter = {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { if (to.params.folderId == 'shared') {
return RoleConst.ADMIN return RoleConst.ADMIN
} else { } else if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN }
else {
return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole()
} }
},], [ },], [
@ -208,7 +222,8 @@ const DocumentRouter = {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { if (to.params.folderId == 'shared') {
return PermissionConst.SHARED_KNOWLEDGE_CHAT_USER_READ return PermissionConst.SHARED_KNOWLEDGE_CHAT_USER_READ
} else { } else if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_CHAT_USER_READ }
else {
return PermissionConst.KNOWLEDGE_CHAT_USER_READ.getKnowledgeWorkspaceResourcePermission( return PermissionConst.KNOWLEDGE_CHAT_USER_READ.getKnowledgeWorkspaceResourcePermission(
to ? to.params.id : '', to ? to.params.id : '',
) )
@ -218,33 +233,36 @@ const DocumentRouter = {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folder_id == 'shared') { if (to.params.folder_id == 'shared') {
return PermissionConst.SHARED_KNOWLEDGE_CHAT_USER_READ return PermissionConst.SHARED_KNOWLEDGE_CHAT_USER_READ
} else { return PermissionConst.KNOWLEDGE_CHAT_USER_READ.getWorkspacePermissionWorkspaceManageRole() } } else if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_CHAT_USER_READ }
else { return PermissionConst.KNOWLEDGE_CHAT_USER_READ.getWorkspacePermissionWorkspaceManageRole() }
}, },
], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR'), ], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR'),
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [EditionConst.IS_EE, EditionConst.IS_PE], 'AND') } else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [EditionConst.IS_EE, EditionConst.IS_PE], 'AND') }
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if(to.params.folderId == 'share') { if (to.params.folderId == 'share') {
return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_CHAT_USER_READ.getWorkspacePermission()], [], 'AND') } return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_CHAT_USER_READ.getWorkspacePermission()], [], 'AND')
}, }
()=>{ },
const to: any = get_next_route() () => {
if(to.params.folderId == 'share') { const to: any = get_next_route()
return RoleConst.USER.getWorkspaceRole() } if (to.params.folderId == 'share') {
}, return RoleConst.USER.getWorkspaceRole()
()=>{ }
const to: any = get_next_route() },
if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN} () => {
}, const to: any = get_next_route()
()=>{ if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN }
const to: any = get_next_route() },
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_CHAT_USER_READ} () => {
}, const to: any = get_next_route()
] if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_CHAT_USER_READ }
},
]
}, },
component: () => import('@/views/chat-user/index.vue'), component: () => import('@/views/chat-user/index.vue'),
}, },
@ -262,16 +280,18 @@ const DocumentRouter = {
permission: [ permission: [
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND') } else { return new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(to ? to.params.id : '',)], [], 'AND') }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else { return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() }
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return PermissionConst.SHARED_KNOWLEDGE_EDIT } else { if (to.params.folderId == 'shared') { return PermissionConst.SHARED_KNOWLEDGE_EDIT } else if (to.params.folderId == 'resource-management') { }
else {
return PermissionConst.KNOWLEDGE_EDIT.getKnowledgeWorkspaceResourcePermission( return PermissionConst.KNOWLEDGE_EDIT.getKnowledgeWorkspaceResourcePermission(
to ? to.params.id : '', to ? to.params.id : '',
) )
@ -279,25 +299,28 @@ const DocumentRouter = {
}, },
() => { () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else { return PermissionConst.KNOWLEDGE_EDIT.getWorkspacePermissionWorkspaceManageRole() } if (to.params.folderId == 'shared') { return RoleConst.ADMIN } else if (to.params.folderId == 'resource-management') { }
else { return PermissionConst.KNOWLEDGE_EDIT.getWorkspacePermissionWorkspaceManageRole() }
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if(to.params.folderId == 'share') { if (to.params.folderId == 'share') {
return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_EDIT.getWorkspacePermission()], [], 'AND') } return new ComplexPermission([RoleConst.EXTENDS_USER.getWorkspaceRole()], [PermissionConst.KNOWLEDGE_EDIT.getWorkspacePermission()], [], 'AND')
}
}, },
()=>{ () => {
const to: any = get_next_route()
if(to.params.folderId == 'share') {
return RoleConst.USER.getWorkspaceRole() }
},
()=>{
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN} if (to.params.folderId == 'share') {
return RoleConst.USER.getWorkspaceRole()
}
}, },
()=>{ () => {
const to: any = get_next_route() const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_EDIT} if (to.params.folderId == 'resource-management') { return RoleConst.ADMIN }
},
() => {
const to: any = get_next_route()
if (to.params.folderId == 'resource-management') { return PermissionConst.RESOURCE_KNOWLEDGE_EDIT }
}, },
], ],
}, },

View File

@ -5,15 +5,12 @@
<back-button @click="back"></back-button> <back-button @click="back"></back-button>
<h4 class="ellipsis" style="max-width: 300px" :title="detail?.name">{{ detail?.name }}</h4> <h4 class="ellipsis" style="max-width: 300px" :title="detail?.name">{{ detail?.name }}</h4>
<div v-if="showHistory && disablePublic"> <div v-if="showHistory && disablePublic">
<el-text type="info" class="ml-16 color-secondary" <el-text type="info" class="ml-16 color-secondary">{{ $t('views.applicationWorkflow.info.previewVersion') }}
>{{ $t('views.applicationWorkflow.info.previewVersion') }} {{ currentVersion.name || datetimeFormat(currentVersion.update_time) }}</el-text>
{{ currentVersion.name || datetimeFormat(currentVersion.update_time) }}</el-text
>
</div> </div>
<el-text type="info" class="ml-16 color-secondary" v-else-if="saveTime" <el-text type="info" class="ml-16 color-secondary" v-else-if="saveTime">{{
>{{ $t('views.applicationWorkflow.info.saveTime') $t('views.applicationWorkflow.info.saveTime')
}}{{ datetimeFormat(saveTime) }}</el-text }}{{ datetimeFormat(saveTime) }}</el-text>
>
</div> </div>
<div v-if="showHistory && disablePublic"> <div v-if="showHistory && disablePublic">
<el-button type="primary" class="mr-8" @click="refreshVersion()"> <el-button type="primary" class="mr-8" @click="refreshVersion()">
@ -21,7 +18,9 @@
</el-button> </el-button>
<el-divider direction="vertical" /> <el-divider direction="vertical" />
<el-button text @click="closeHistory"> <el-button text @click="closeHistory">
<el-icon><Close /></el-icon> <el-icon>
<Close />
</el-icon>
</el-button> </el-button>
</div> </div>
<div v-else> <div v-else>
@ -30,8 +29,8 @@
</el-button> </el-button>
<el-button @click="clickShowDebug" :disabled="showDebug"> <el-button @click="clickShowDebug" :disabled="showDebug">
<AppIcon iconName="app-debug-outlined" class="mr-4"></AppIcon> <AppIcon iconName="app-debug-outlined" class="mr-4"></AppIcon>
{{ $t('views.applicationWorkflow.setting.debug') }}</el-button {{ $t('views.applicationWorkflow.setting.debug') }}
> </el-button>
<el-button @click="saveApplication(true)"> <el-button @click="saveApplication(true)">
<AppIcon iconName="app-save-outlined" class="mr-4"></AppIcon> <AppIcon iconName="app-save-outlined" class="mr-4"></AppIcon>
{{ $t('common.save') }} {{ $t('common.save') }}
@ -71,14 +70,8 @@
</div> </div>
<!-- 下拉框 --> <!-- 下拉框 -->
<el-collapse-transition> <el-collapse-transition>
<DropdownMenu <DropdownMenu :show="showPopover" :id="id" v-click-outside="clickoutside" @clickNodes="clickNodes"
:show="showPopover" @onmousedown="onmousedown" :workflowRef="workflowRef" />
:id="id"
v-click-outside="clickoutside"
@clickNodes="clickNodes"
@onmousedown="onmousedown"
:workflowRef="workflowRef"
/>
</el-collapse-transition> </el-collapse-transition>
<!-- 主画布 --> <!-- 主画布 -->
<div class="workflow-main" ref="workflowMainRef"> <div class="workflow-main" ref="workflowMainRef">
@ -91,12 +84,7 @@
<div class="flex-between"> <div class="flex-between">
<div class="flex align-center"> <div class="flex align-center">
<div class="mr-12 ml-24 flex"> <div class="mr-12 ml-24 flex">
<el-avatar <el-avatar v-if="isAppIcon(detail?.icon)" shape="square" :size="32" style="background: none">
v-if="isAppIcon(detail?.icon)"
shape="square"
:size="32"
style="background: none"
>
<img :src="resetUrl(detail?.icon)" alt="" /> <img :src="resetUrl(detail?.icon)" alt="" />
</el-avatar> </el-avatar>
<LogoIcon v-else height="32px" /> <LogoIcon v-else height="32px" />
@ -108,14 +96,14 @@
</div> </div>
<div class="mr-16"> <div class="mr-16">
<el-button link @click="enlarge = !enlarge"> <el-button link @click="enlarge = !enlarge">
<AppIcon <AppIcon :iconName="enlarge ? 'app-minify' : 'app-magnify'" class="color-secondary"
:iconName="enlarge ? 'app-minify' : 'app-magnify'" style="font-size: 20px">
class="color-secondary" </AppIcon>
style="font-size: 20px"
></AppIcon>
</el-button> </el-button>
<el-button link @click="showDebug = false"> <el-button link @click="showDebug = false">
<el-icon :size="20" class="color-secondary"><Close /></el-icon> <el-icon :size="20" class="color-secondary">
<Close />
</el-icon>
</el-button> </el-button>
</div> </div>
</div> </div>
@ -126,12 +114,8 @@
</div> </div>
</el-collapse-transition> </el-collapse-transition>
<!-- 发布历史 --> <!-- 发布历史 -->
<PublishHistory <PublishHistory v-if="showHistory" @click="checkVersion" v-click-outside="clickoutsideHistory"
v-if="showHistory" @refreshVersion="refreshVersion" />
@click="checkVersion"
v-click-outside="clickoutsideHistory"
@refreshVersion="refreshVersion"
/>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -311,15 +295,15 @@ const publish = () => {
if (typeof err_message == 'string') { if (typeof err_message == 'string') {
MsgError( MsgError(
res.node.properties?.stepName + res.node.properties?.stepName +
` ${t('views.applicationWorkflow.node').toLowerCase()} ` + ` ${t('views.applicationWorkflow.node').toLowerCase()} ` +
err_message.toLowerCase(), err_message.toLowerCase(),
) )
} else { } else {
const keys = Object.keys(err_message) const keys = Object.keys(err_message)
MsgError( MsgError(
node.properties?.stepName + node.properties?.stepName +
` ${t('views.applicationWorkflow.node').toLowerCase()} ` + ` ${t('views.applicationWorkflow.node').toLowerCase()} ` +
err_message[keys[0]]?.[0]?.message.toLowerCase(), err_message[keys[0]]?.[0]?.message.toLowerCase(),
) )
} }
}) })
@ -335,8 +319,8 @@ const publish = () => {
const keys = Object.keys(err_message) const keys = Object.keys(err_message)
MsgError( MsgError(
node.properties?.stepName + node.properties?.stepName +
` ${t('views.applicationWorkflow.node')}` + ` ${t('views.applicationWorkflow.node')}` +
err_message[keys[0]]?.[0]?.message, err_message[keys[0]]?.[0]?.message,
) )
} }
}) })
@ -373,8 +357,8 @@ const clickShowDebug = () => {
const keys = Object.keys(err_message) const keys = Object.keys(err_message)
MsgError( MsgError(
node.properties?.stepName + node.properties?.stepName +
` ${t('views.applicationWorkflow.node')}` + ` ${t('views.applicationWorkflow.node')}` +
err_message[keys[0]]?.[0]?.message, err_message[keys[0]]?.[0]?.message,
) )
} }
}) })
@ -400,20 +384,20 @@ function getDetail() {
.map((v: any) => { .map((v: any) => {
apiInputParams.value = v.properties.api_input_field_list apiInputParams.value = v.properties.api_input_field_list
? v.properties.api_input_field_list.map((v: any) => { ? v.properties.api_input_field_list.map((v: any) => {
return { return {
name: v.variable, name: v.variable,
value: v.default_value, value: v.default_value,
} }
}) })
: v.properties.input_field_list : v.properties.input_field_list
? v.properties.input_field_list ? v.properties.input_field_list
.filter((v: any) => v.assignment_method === 'api_input') .filter((v: any) => v.assignment_method === 'api_input')
.map((v: any) => { .map((v: any) => {
return { return {
name: v.variable, name: v.variable,
value: v.default_value, value: v.default_value,
} }
}) })
: [] : []
}) })
loadSharedApi({ type: 'application', systemType: apiType.value }) loadSharedApi({ type: 'application', systemType: apiType.value })
@ -459,7 +443,20 @@ function saveApplication(bool?: boolean, back?: boolean) {
}) })
} }
const go = () => { const go = () => {
return router.push({ path: get_route() }) if (route.path.includes('workspace')) { return router.push({ path: get_route() }) }
else { return router.push({ path: get_resource_management_route() }) }
};
const get_resource_management_route = () => {
if (hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_APPLICATION_OVERVIEW_READ], 'OR')) { return `/application/${from}/${id}/WORK_FLOW/overview` } else if
(hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_APPLICATION_ACCESS_READ], 'OR')) {
return `/application/${from}/${id}/WORK_FLOW/access`
} else if (hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_APPLICATION_CHAT_USER_READ], 'OR')) {
return `/application/${from}/${id}/WORK_FLOW/chat-user`
} else if (hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_READ], 'OR')) {
return `/application/${from}/${id}/WORK_FLOW/chat-log`
} else { return `/system/resource-management/application` }
} }
const get_route = () => { const get_route = () => {
@ -593,6 +590,7 @@ onBeforeUnmount(() => {
.application-workflow { .application-workflow {
background: var(--app-layout-bg-color); background: var(--app-layout-bg-color);
height: 100%; height: 100%;
.workflow-main { .workflow-main {
height: calc(100vh - 62px); height: calc(100vh - 62px);
box-sizing: border-box; box-sizing: border-box;
@ -618,6 +616,7 @@ onBeforeUnmount(() => {
overflow: hidden; overflow: hidden;
width: 460px; width: 460px;
height: 680px; height: 680px;
.workflow-debug-header { .workflow-debug-header {
background: var(--app-header-bg-color); background: var(--app-header-bg-color);
height: var(--app-header-height); height: var(--app-header-height);
@ -625,21 +624,25 @@ onBeforeUnmount(() => {
box-sizing: border-box; box-sizing: border-box;
border-bottom: 1px solid var(--el-border-color); border-bottom: 1px solid var(--el-border-color);
} }
.scrollbar-height { .scrollbar-height {
height: calc(100% - var(--app-header-height) - 24px); height: calc(100% - var(--app-header-height) - 24px);
padding-top: 24px; padding-top: 24px;
} }
&.enlarge { &.enlarge {
width: 50% !important; width: 50% !important;
height: 100% !important; height: 100% !important;
bottom: 0 !important; bottom: 0 !important;
right: 0 !important; right: 0 !important;
} }
.chat-width { .chat-width {
max-width: 100% !important; max-width: 100% !important;
margin: 0 auto; margin: 0 auto;
} }
} }
@media only screen and (max-height: 680px) { @media only screen and (max-height: 680px) {
.workflow-debug-container { .workflow-debug-container {
height: 600px; height: 600px;

View File

@ -5,20 +5,12 @@
{{ $t('common.setting') }} {{ $t('common.setting') }}
</h3> </h3>
<div> <div>
<el-button <el-button type="primary" @click="submit(applicationFormRef)" :disabled="loading"
type="primary" v-if="permissionPrecise.edit(id)">
@click="submit(applicationFormRef)"
:disabled="loading"
v-if="permissionPrecise.edit(id)"
>
{{ $t('common.save') }} {{ $t('common.save') }}
</el-button> </el-button>
<el-button <el-button type="primary" @click="publish(applicationFormRef)" :disabled="loading"
type="primary" v-if="permissionPrecise.edit(id)">
@click="publish(applicationFormRef)"
:disabled="loading"
v-if="permissionPrecise.edit(id)"
>
{{ $t('views.application.operation.publish') }} {{ $t('views.application.operation.publish') }}
</el-button> </el-button>
</div> </div>
@ -34,42 +26,23 @@
</div> </div>
<div class="scrollbar-height-left"> <div class="scrollbar-height-left">
<el-scrollbar> <el-scrollbar>
<el-form <el-form hide-required-asterisk ref="applicationFormRef" :model="applicationForm" :rules="rules"
hide-required-asterisk label-position="top" require-asterisk-position="right" class="p-24" style="padding-top: 0">
ref="applicationFormRef"
:model="applicationForm"
:rules="rules"
label-position="top"
require-asterisk-position="right"
class="p-24"
style="padding-top: 0"
>
<el-form-item prop="name"> <el-form-item prop="name">
<template #label> <template #label>
<div class="flex-between"> <div class="flex-between">
<span <span>{{ $t('views.application.form.appName.label') }}
>{{ $t('views.application.form.appName.label') }} <span class="color-danger">*</span></span>
<span class="color-danger">*</span></span
>
</div> </div>
</template> </template>
<el-input <el-input v-model="applicationForm.name" maxlength="64"
v-model="applicationForm.name" :placeholder="$t('views.application.form.appName.placeholder')" show-word-limit
maxlength="64" @blur="applicationForm.name = applicationForm.name?.trim()" />
:placeholder="$t('views.application.form.appName.placeholder')"
show-word-limit
@blur="applicationForm.name = applicationForm.name?.trim()"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('views.application.form.appDescription.label')"> <el-form-item :label="$t('views.application.form.appDescription.label')">
<el-input <el-input v-model="applicationForm.desc" type="textarea"
v-model="applicationForm.desc" :placeholder="$t('views.application.form.appDescription.placeholder')" :rows="3" maxlength="256"
type="textarea" show-word-limit />
:placeholder="$t('views.application.form.appDescription.placeholder')"
:rows="3"
maxlength="256"
show-word-limit
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('views.application.form.aiModel.label')"> <el-form-item :label="$t('views.application.form.aiModel.label')">
@ -77,91 +50,53 @@
<div class="flex-between"> <div class="flex-between">
<span>{{ $t('views.application.form.aiModel.label') }}</span> <span>{{ $t('views.application.form.aiModel.label') }}</span>
<el-button <el-button type="primary" link @click="openAIParamSettingDialog"
type="primary" :disabled="!applicationForm.model_id">
link
@click="openAIParamSettingDialog"
:disabled="!applicationForm.model_id"
>
{{ $t('common.paramSetting') }} {{ $t('common.paramSetting') }}
</el-button> </el-button>
</div> </div>
</template> </template>
<ModelSelect <ModelSelect v-model="applicationForm.model_id"
v-model="applicationForm.model_id" :placeholder="$t('views.application.form.aiModel.placeholder')" :options="modelOptions"
:placeholder="$t('views.application.form.aiModel.placeholder')" @change="model_change" @submitModel="getSelectModel" showFooter :model-type="'LLM'">
:options="modelOptions" </ModelSelect>
@change="model_change"
@submitModel="getSelectModel"
showFooter
:model-type="'LLM'"
></ModelSelect>
</el-form-item> </el-form-item>
<el-form-item :label="$t('views.application.form.roleSettings.label')"> <el-form-item :label="$t('views.application.form.roleSettings.label')">
<MdEditorMagnify <MdEditorMagnify :title="$t('views.application.form.roleSettings.label')"
:title="$t('views.application.form.roleSettings.label')" v-model="applicationForm.model_setting.system" style="height: 120px"
v-model="applicationForm.model_setting.system"
style="height: 120px"
@submitDialog="submitSystemDialog" @submitDialog="submitSystemDialog"
:placeholder="$t('views.application.form.roleSettings.placeholder')" :placeholder="$t('views.application.form.roleSettings.placeholder')" />
/>
</el-form-item> </el-form-item>
<el-form-item <el-form-item prop="model_setting.no_references_prompt" :rules="{
prop="model_setting.no_references_prompt" required: applicationForm.model_id,
:rules="{ message: $t('views.application.form.prompt.requiredMessage'),
required: applicationForm.model_id, trigger: 'blur',
message: $t('views.application.form.prompt.requiredMessage'), }">
trigger: 'blur',
}"
>
<template #label> <template #label>
<div class="flex align-center"> <div class="flex align-center">
<span class="mr-4" <span class="mr-4">{{
>{{ $t('views.application.form.prompt.label') +
$t('views.application.form.prompt.label') + $t('views.application.form.prompt.noReferences')
$t('views.application.form.prompt.noReferences') }}
}}
</span> </span>
<el-tooltip <el-tooltip effect="dark" :content="$t('views.application.form.prompt.noReferencesTooltip', {
effect="dark" question: '{question}',
:content=" })
$t('views.application.form.prompt.noReferencesTooltip', { " placement="right" popper-class="max-w-350">
question: '{question}',
})
"
placement="right"
popper-class="max-w-350"
>
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon> <AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
</el-tooltip> </el-tooltip>
<span class="color-danger ml-4" v-if="applicationForm.model_id">*</span> <span class="color-danger ml-4" v-if="applicationForm.model_id">*</span>
</div> </div>
</template> </template>
<MdEditorMagnify <MdEditorMagnify :title="$t('views.application.form.prompt.label') +
:title=" $t('views.application.form.prompt.noReferences')
$t('views.application.form.prompt.label') + " v-model="applicationForm.model_setting.no_references_prompt" style="height: 120px"
$t('views.application.form.prompt.noReferences') @submitDialog="submitNoReferencesPromptDialog" placeholder="{question}" />
"
v-model="applicationForm.model_setting.no_references_prompt"
style="height: 120px"
@submitDialog="submitNoReferencesPromptDialog"
placeholder="{question}"
/>
</el-form-item> </el-form-item>
<el-form-item <el-form-item :label="$t('views.application.form.historyRecord.label')" @click.prevent>
:label="$t('views.application.form.historyRecord.label')" <el-input-number v-model="applicationForm.dialogue_number" :min="0" :value-on-clear="0"
@click.prevent controls-position="right" class="w-full" :step="1" :step-strictly="true" />
>
<el-input-number
v-model="applicationForm.dialogue_number"
:min="0"
:value-on-clear="0"
controls-position="right"
class="w-full"
:step="1"
:step-strictly="true"
/>
</el-form-item> </el-form-item>
<el-form-item label="$t('views.application.form.relatedKnowledgeBase')"> <el-form-item label="$t('views.application.form.relatedKnowledgeBase')">
<template #label> <template #label>
@ -182,34 +117,19 @@
</div> </div>
</template> </template>
<div class="w-full"> <div class="w-full">
<el-text type="info" v-if="applicationForm.knowledge_id_list?.length === 0" <el-text type="info" v-if="applicationForm.knowledge_id_list?.length === 0">{{
>{{ $t('views.application.form.relatedKnowledge.placeholder') }} $t('views.application.form.relatedKnowledge.placeholder') }}
</el-text> </el-text>
<el-row :gutter="12" v-else> <el-row :gutter="12" v-else>
<el-col <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb-8"
:xs="24" v-for="(item, index) in applicationForm.knowledge_id_list" :key="index">
:sm="24"
:md="24"
:lg="12"
:xl="12"
class="mb-8"
v-for="(item, index) in applicationForm.knowledge_id_list"
:key="index"
>
<el-card class="relate-knowledge-card border-r-6" shadow="never"> <el-card class="relate-knowledge-card border-r-6" shadow="never">
<div class="flex-between"> <div class="flex-between">
<div class="flex align-center" style="width: 80%"> <div class="flex align-center" style="width: 80%">
<KnowledgeIcon <KnowledgeIcon :type="relatedObject(knowledgeList, item, 'id')?.type" class="mr-12" />
:type="relatedObject(knowledgeList, item, 'id')?.type"
class="mr-12"
/>
<span <span class="ellipsis cursor" :title="relatedObject(knowledgeList, item, 'id')?.name">
class="ellipsis cursor" {{ relatedObject(knowledgeList, item, 'id')?.name }}</span>
:title="relatedObject(knowledgeList, item, 'id')?.name"
>
{{ relatedObject(knowledgeList, item, 'id')?.name }}</span
>
</div> </div>
<el-button text @click="removeKnowledge(item)"> <el-button text @click="removeKnowledge(item)">
<el-icon> <el-icon>
@ -222,56 +142,36 @@
</el-row> </el-row>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item <el-form-item :label="$t('views.application.form.prompt.label')" prop="model_setting.prompt" :rules="{
:label="$t('views.application.form.prompt.label')" required: applicationForm.model_id,
prop="model_setting.prompt" message: $t('views.application.form.prompt.requiredMessage'),
:rules="{ trigger: 'blur',
required: applicationForm.model_id, }">
message: $t('views.application.form.prompt.requiredMessage'),
trigger: 'blur',
}"
>
<template #label> <template #label>
<div class="flex align-center"> <div class="flex align-center">
<span class="mr-4"> <span class="mr-4">
{{ $t('views.application.form.prompt.label') }} {{ $t('views.application.form.prompt.label') }}
{{ $t('views.application.form.prompt.references') }} {{ $t('views.application.form.prompt.references') }}
</span> </span>
<el-tooltip <el-tooltip effect="dark" :content="$t('views.application.form.prompt.referencesTooltip', {
effect="dark" data: '{data}',
:content=" question: '{question}',
$t('views.application.form.prompt.referencesTooltip', { })
data: '{data}', " popper-class="max-w-350" placement="right">
question: '{question}',
})
"
popper-class="max-w-350"
placement="right"
>
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon> <AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
</el-tooltip> </el-tooltip>
<span class="color-danger ml-4" v-if="applicationForm.model_id">*</span> <span class="color-danger ml-4" v-if="applicationForm.model_id">*</span>
</div> </div>
</template> </template>
<MdEditorMagnify <MdEditorMagnify :title="$t('views.application.form.prompt.label') +
:title=" $t('views.application.form.prompt.references')
$t('views.application.form.prompt.label') + " v-model="applicationForm.model_setting.prompt" style="height: 150px"
$t('views.application.form.prompt.references') @submitDialog="submitPromptDialog" :placeholder="defaultPrompt" />
"
v-model="applicationForm.model_setting.prompt"
style="height: 150px"
@submitDialog="submitPromptDialog"
:placeholder="defaultPrompt"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('views.application.form.prologue')"> <el-form-item :label="$t('views.application.form.prologue')">
<MdEditorMagnify <MdEditorMagnify :title="$t('views.application.form.prologue')" v-model="applicationForm.prologue"
:title="$t('views.application.form.prologue')" style="height: 150px" @submitDialog="submitPrologueDialog" />
v-model="applicationForm.prologue"
style="height: 150px"
@submitDialog="submitPrologueDialog"
/>
</el-form-item> </el-form-item>
<el-form-item @click.prevent> <el-form-item @click.prevent>
<template #label> <template #label>
@ -282,27 +182,23 @@
<div class="flex"> <div class="flex">
<el-button type="primary" link @click="openReasoningParamSettingDialog"> <el-button type="primary" link @click="openReasoningParamSettingDialog">
<el-icon><Setting /></el-icon> <el-icon>
<Setting />
</el-icon>
</el-button> </el-button>
<el-switch <el-switch class="ml-8" size="small"
class="ml-8"
size="small"
v-model="applicationForm.model_setting.reasoning_content_enable" v-model="applicationForm.model_setting.reasoning_content_enable"
@change="sttModelEnableChange" @change="sttModelEnableChange" />
/>
</div> </div>
</div> </div>
</template> </template>
</el-form-item> </el-form-item>
<el-form-item <el-form-item prop="stt_model_id" :rules="{
prop="stt_model_id" required: applicationForm.stt_model_enable,
:rules="{ message: $t('views.application.form.voiceInput.requiredMessage'),
required: applicationForm.stt_model_enable, trigger: 'change',
message: $t('views.application.form.voiceInput.requiredMessage'), }">
trigger: 'change',
}"
>
<template #label> <template #label>
<div class="flex-between"> <div class="flex-between">
<span class="mr-4"> <span class="mr-4">
@ -311,95 +207,61 @@
</span> </span>
<div class="flex"> <div class="flex">
<el-checkbox <el-checkbox v-if="applicationForm.stt_model_enable" v-model="applicationForm.stt_autosend">{{
v-if="applicationForm.stt_model_enable" $t('views.application.form.voiceInput.autoSend') }}</el-checkbox>
v-model="applicationForm.stt_autosend" <el-switch class="ml-8" size="small" v-model="applicationForm.stt_model_enable"
>{{ $t('views.application.form.voiceInput.autoSend') }}</el-checkbox @change="sttModelEnableChange" />
>
<el-switch
class="ml-8"
size="small"
v-model="applicationForm.stt_model_enable"
@change="sttModelEnableChange"
/>
</div> </div>
</div> </div>
</template> </template>
<ModelSelect <ModelSelect v-show="applicationForm.stt_model_enable" v-model="applicationForm.stt_model_id"
v-show="applicationForm.stt_model_enable" :placeholder="$t('views.application.form.voiceInput.placeholder')" :options="sttModelOptions"
v-model="applicationForm.stt_model_id" :model-type="'STT'">
:placeholder="$t('views.application.form.voiceInput.placeholder')" </ModelSelect>
:options="sttModelOptions"
:model-type="'STT'"
></ModelSelect>
</el-form-item> </el-form-item>
<el-form-item <el-form-item prop="tts_model_id" :rules="{
prop="tts_model_id" required:
:rules="{ applicationForm.tts_type === 'TTS' && applicationForm.tts_model_enable,
required: message: $t('views.application.form.voicePlay.requiredMessage'),
applicationForm.tts_type === 'TTS' && applicationForm.tts_model_enable, trigger: 'change',
message: $t('views.application.form.voicePlay.requiredMessage'), }">
trigger: 'change',
}"
>
<template #label> <template #label>
<div class="flex-between"> <div class="flex-between">
<span class="mr-4" <span class="mr-4">{{ $t('views.application.form.voicePlay.label') }}
>{{ $t('views.application.form.voicePlay.label') }} <span class="color-danger" v-if="
<span applicationForm.tts_type === 'TTS' && applicationForm.tts_model_enable
class="color-danger" ">*</span>
v-if="
applicationForm.tts_type === 'TTS' && applicationForm.tts_model_enable
"
>*</span
>
</span> </span>
<div class="flex"> <div class="flex">
<el-checkbox <el-checkbox v-if="applicationForm.tts_model_enable" v-model="applicationForm.tts_autoplay">{{
v-if="applicationForm.tts_model_enable" $t('views.application.form.voicePlay.autoPlay') }}</el-checkbox>
v-model="applicationForm.tts_autoplay" <el-switch class="ml-8" size="small" v-model="applicationForm.tts_model_enable"
>{{ $t('views.application.form.voicePlay.autoPlay') }}</el-checkbox @change="ttsModelEnableChange" />
>
<el-switch
class="ml-8"
size="small"
v-model="applicationForm.tts_model_enable"
@change="ttsModelEnableChange"
/>
</div> </div>
</div> </div>
</template> </template>
<div class="w-full"> <div class="w-full">
<el-radio-group <el-radio-group v-model="applicationForm.tts_type" v-show="applicationForm.tts_model_enable"
v-model="applicationForm.tts_type" class="mb-8">
v-show="applicationForm.tts_model_enable"
class="mb-8"
>
<el-radio value="BROWSER">{{ <el-radio value="BROWSER">{{
$t('views.application.form.voicePlay.browser') $t('views.application.form.voicePlay.browser')
}}</el-radio> }}</el-radio>
<el-radio value="TTS">{{ <el-radio value="TTS">{{
$t('views.application.form.voicePlay.tts') $t('views.application.form.voicePlay.tts')
}}</el-radio> }}</el-radio>
</el-radio-group> </el-radio-group>
</div> </div>
<div class="flex-between w-full"> <div class="flex-between w-full">
<ModelSelect <ModelSelect v-if="applicationForm.tts_type === 'TTS' && applicationForm.tts_model_enable"
v-if="applicationForm.tts_type === 'TTS' && applicationForm.tts_model_enable"
v-model="applicationForm.tts_model_id" v-model="applicationForm.tts_model_id"
:placeholder="$t('views.application.form.voicePlay.placeholder')" :placeholder="$t('views.application.form.voicePlay.placeholder')" :options="ttsModelOptions"
:options="ttsModelOptions" @change="ttsModelChange()" :model-type="'TTS'"></ModelSelect>
@change="ttsModelChange()"
:model-type="'TTS'"
></ModelSelect>
<el-button <el-button v-if="applicationForm.tts_type === 'TTS'" @click="openTTSParamSettingDialog"
v-if="applicationForm.tts_type === 'TTS'" :disabled="!applicationForm.tts_model_id" class="ml-8">
@click="openTTSParamSettingDialog" <el-icon>
:disabled="!applicationForm.tts_model_id" <Operation />
class="ml-8" </el-icon>
>
<el-icon><Operation /></el-icon>
</el-button> </el-button>
</div> </div>
</el-form-item> </el-form-item>
@ -423,21 +285,14 @@
<AIModeParamSettingDialog ref="AIModeParamSettingDialogRef" @refresh="refreshForm" /> <AIModeParamSettingDialog ref="AIModeParamSettingDialogRef" @refresh="refreshForm" />
<TTSModeParamSettingDialog ref="TTSModeParamSettingDialogRef" @refresh="refreshTTSForm" /> <TTSModeParamSettingDialog ref="TTSModeParamSettingDialogRef" @refresh="refreshTTSForm" />
<ParamSettingDialog ref="ParamSettingDialogRef" @refresh="refreshParam" /> <ParamSettingDialog ref="ParamSettingDialogRef" @refresh="refreshParam" />
<AddKnowledgeDialog <AddKnowledgeDialog ref="AddKnowledgeDialogRef" @addData="addKnowledge" :data="knowledgeList"
ref="AddKnowledgeDialogRef" :loading="knowledgeLoading" />
@addData="addKnowledge" <ReasoningParamSettingDialog ref="ReasoningParamSettingDialogRef" @refresh="submitReasoningDialog" />
:data="knowledgeList"
:loading="knowledgeLoading"
/>
<ReasoningParamSettingDialog
ref="ReasoningParamSettingDialogRef"
@refresh="submitReasoningDialog"
/>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, onMounted, computed } from 'vue' import { reactive, ref, onMounted, computed, onBeforeMount } from 'vue'
import { useRoute } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { groupBy } from 'lodash' import { groupBy } from 'lodash'
import AIModeParamSettingDialog from './component/AIModeParamSettingDialog.vue' import AIModeParamSettingDialog from './component/AIModeParamSettingDialog.vue'
import ParamSettingDialog from './component/ParamSettingDialog.vue' import ParamSettingDialog from './component/ParamSettingDialog.vue'
@ -454,7 +309,7 @@ import { EditionConst } from '@/utils/permission/data'
import { hasPermission } from '@/utils/permission/index' import { hasPermission } from '@/utils/permission/index'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api' import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const route = useRoute() const route = useRoute()
const router = useRouter()
const { const {
params: { id }, params: { id },
} = route as any } = route as any
@ -687,12 +542,12 @@ function getSelectModel() {
const obj = const obj =
apiType.value === 'systemManage' apiType.value === 'systemManage'
? { ? {
model_type: 'LLM', model_type: 'LLM',
workspace_id: applicationForm.value?.workspace_id, workspace_id: applicationForm.value?.workspace_id,
} }
: { : {
model_type: 'LLM', model_type: 'LLM',
} }
loadSharedApi({ type: 'model', systemType: apiType.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.getSelectModelList(obj) .getSelectModelList(obj)
.then((res: any) => { .then((res: any) => {
@ -709,12 +564,12 @@ function getSTTModel() {
const obj = const obj =
apiType.value === 'systemManage' apiType.value === 'systemManage'
? { ? {
model_type: 'STT', model_type: 'STT',
workspace_id: applicationForm.value?.workspace_id, workspace_id: applicationForm.value?.workspace_id,
} }
: { : {
model_type: 'STT', model_type: 'STT',
} }
loadSharedApi({ type: 'model', systemType: apiType.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.getSelectModelList(obj) .getSelectModelList(obj)
.then((res: any) => { .then((res: any) => {
@ -731,12 +586,12 @@ function getTTSModel() {
const obj = const obj =
apiType.value === 'systemManage' apiType.value === 'systemManage'
? { ? {
model_type: 'TTS', model_type: 'TTS',
workspace_id: applicationForm.value?.workspace_id, workspace_id: applicationForm.value?.workspace_id,
} }
: { : {
model_type: 'TTS', model_type: 'TTS',
} }
loadSharedApi({ type: 'model', systemType: apiType.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.getSelectModelList(obj) .getSelectModelList(obj)
.then((res: any) => { .then((res: any) => {
@ -768,7 +623,16 @@ function sttModelEnableChange() {
applicationForm.value.stt_model_id = undefined applicationForm.value.stt_model_id = undefined
} }
} }
onBeforeMount(() => {
if (route.path.includes('WORK_FLOW')) {
if (apiType.value == 'workspace') {
router.push(`/application/workspace/${route.params.id}/workflow`)
} else {
router.push(`/application/resource-management/${route.params.id}/workflow`)
}
}
})
onMounted(() => { onMounted(() => {
getSelectModel() getSelectModel()
getDetail() getDetail()