-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Chat log add error #4137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Chat log add error #4137
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,7 +256,7 @@ import { loadSharedApi } from '@/utils/dynamics-api/shared-api' | |
| import { Permission } from '@/utils/permission/type' | ||
| import { hasPermission } from '@/utils/permission' | ||
| import { PermissionConst, RoleConst } from '@/utils/permission/data' | ||
|
|
||
| const route = useRoute() | ||
|
|
||
| const apiType = computed(() => { | ||
|
|
@@ -354,17 +354,22 @@ const filter = ref<any>({ | |
| min_trample: 0, | ||
| comparer: 'and', | ||
| }) | ||
| const postKnowledgeHandler = (knowledgeList: Array<any>) => { | ||
| const postKnowledgeHandler = (knowledgeList: Array<any>) => { | ||
| return knowledgeList.filter(item => { | ||
| if (apiType.value === 'workspace') { | ||
| return hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole(), | ||
| new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspacePermissionWorkspaceManageRole, | ||
| new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspaceResourcePermission('KNOWLEDGE', item.id)], 'OR') | ||
| if (item.resource_type === 'folder') { | ||
| return true | ||
| } | ||
| if (item.resource_type === 'knowledge') { | ||
| return hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole(), | ||
| new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspacePermissionWorkspaceManageRole, | ||
| new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspaceResourcePermission('KNOWLEDGE', item.id)], 'OR') | ||
| } | ||
| } else if (apiType.value === 'systemManage') { | ||
| return hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_KNOWLEDGE_DOCUMENT_EDIT],'OR') | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| } | ||
| function filterChange(val: string) { | ||
| if (val === 'clear') { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code has several areas that may require attention or improvement: Irregularities/Missing Code:
Potential Issues:
Optimization Suggestions:
Here's an improved version of the code following these guidelines: const filter = ref({
min_trample: 0,
comparer: 'and',
});
// Refine postKnowledgeHandler function
function postKnowledgeHandler(knowledgeList: Array<any>): Array<any> {
return knowledgeList.filter((item): boolean => {
if (apiType.value === 'workspace') {
// Ensure only non-folder items meet the permission criteria
return (
item.resource_type !== 'folder' &&
hasPermission([
PermissionConst.WORKSPACE_MANAGE.getWorkspaceRole(),
new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspacePermission('WORKSPACE'),
new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspaceResourcePermission('KNOWLEDGE', item.id),
])
);
} else if (apiType.value === 'systemManage') {
return hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_KNOWLEDGE_DOCUMENT_EDIT], 'OR');
}
});
}
function filterChange(val: string) {
if (val === 'clear') {
// Clear filtering logic here if needed
}
}By addressing these points, you can enhance the clarity, efficiency, and accuracy of the codebase, contributing to its robustness and performance. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no significant issues with the code provided. However, I have some minor suggestions for improvement:
Optimizations:
promptTemplatessection, indicating what it contains.Updated Code snippet:
Final Result:
After these improvements, the code is concise yet retains its intended functionality. The prompt template now includes a brief description, and the re-answer click event logic has been updated to include feedback about previous responses and dialogue history.