-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Return to the corresponding permission directory and locate the tool folder #4254
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
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 |
|---|---|---|
|
|
@@ -30,7 +30,8 @@ import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router' | |
| import { resetUrl } from '@/utils/common' | ||
| import { loadSharedApi } from '@/utils/dynamics-api/shared-api' | ||
| import useStore from '@/stores' | ||
| const { common, folder } = useStore() | ||
| import permissionMap from '@/permission' | ||
| const { common, folder,user } = useStore() | ||
| const route = useRoute() | ||
| const router = useRouter() | ||
|
|
||
|
|
@@ -50,6 +51,20 @@ const apiType = computed(() => { | |
| } | ||
| }) | ||
|
|
||
| const folderType = computed(() => { | ||
| if (route.path.includes('application')) { | ||
| return 'application' | ||
| } | ||
| if (route.path.includes('knowledge')) { | ||
| return 'knowledge' | ||
| } | ||
| else {return 'application'} | ||
| }) | ||
|
|
||
| const permissionPrecise = computed(() => { | ||
| return permissionMap[folderType.value!]['workspace'] | ||
| }) | ||
|
|
||
| const shareDisabled = computed(() => { | ||
| return folderId === 'share' || isShared === 'true' | ||
| }) | ||
|
|
@@ -108,14 +123,13 @@ function getApplicationDetail() { | |
| function toBack() { | ||
| if (isKnowledge.value) { | ||
| folder.setCurrentFolder({ | ||
| id: folderId, | ||
| id: permissionPrecise.value.folderRead(folderId)? folderId : user.getWorkspaceId(), | ||
| }) | ||
| } else if (isApplication.value) { | ||
| folder.setCurrentFolder({ | ||
| id: current.value.folder, | ||
| id: permissionPrecise.value.folderRead(current.value.folder)? current.value.folder : user.getWorkspaceId(), | ||
| }) | ||
| } | ||
|
|
||
| router.push({ path: toBackPath.value }) | ||
| } | ||
|
|
||
|
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 code contains several issues and optimizations that can be made: Issues:
Optimization Suggestions:
Here’s the revised version of your code based on these suggestions: @@ -29,6 +29,7 @@
import { loadSharedApi } from '@/utils/dynamics-api/shared-api';
import useStore from '@/stores';
import permissionMap from '@permissions'; // Corrected namespace usage if needed
const { common, folder, user } = useStore();
const route = useRoute();
const router = useRouter();
@@
-50,6 +51,20 @@ const apiType = computed(() => {
}
})
+const folderType = computed(() => {
+ if (route.path.includes('application')) {
+ return 'application';
+ }
+ if (route.path.includes('knowledge')) {
+ return 'knowledge';
+ }
+ else {return 'application'};
+})
+const_permissionPrecise = computed(() => {
+ return permissionMap[folderType.value!]['workspace'];
+})
... Rest of the function bodies remain unchanged ...This version aims to eliminate redundancy and improve readability while maintaining functionality intact. |
||
|
|
||
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.
The provided code is mostly correct, but there are a few places that can be improved for clarity and to enhance robustness:
Typo Correction: Ensure all typos in comments and variable names are corrected.
Event Subscription Management: Properly manage the removal of event listeners to prevent memory leaks. You should unsubscribe
bus.offwithinonUnmounted.Code Structure Clarity: It might help to refactor some conditional checks into separate functions if they become complex.
Here's the updated version with these improvements:
Key Changes Made:
props.data.reactive()for creating the initial state (treeRef).treeRefwithnullbefore assigning it to reactively.type: Object) are specified for prop parameters.$eventBusreference withVue.$eventBus, assuming this was a global instance you had access to; replace with actual usage as needed.These changes should make the code cleaner and easier to maintain while addressing potential issues related to event management and subscriptions.