Repository navigation
fix: Fix the incompatibility issues caused by version upgrade #7750
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 |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ export const knowledgeRoutes: RouteRecordRaw[] = [ | |
| path: 'image', | ||
| name: 'workspace-knowledge-image-list', | ||
| component: () => import('@/views/knowledge-detail/library/image/index.vue'), | ||
| meta: { permission: ({ params }) => perm.knowledge.workspace.image.read(String(params.knowledgeId)), next: 'workspace-knowledge-tag', title: '图片', order: 20, detailMenuVisible: (params) => params.type === KNOWLEDGE_TYPE_KEY.BASE }, | ||
| meta: { permission: ({ params }) => perm.knowledge.workspace.image.read(String(params.knowledgeId)), next: 'workspace-knowledge-tag', title: '图片', order: 20, detailMenuVisible: (params) => params.type === KNOWLEDGE_TYPE_KEY.BASE || params.type === KNOWLEDGE_TYPE_KEY.WORKFLOW }, | ||
| }, | ||
| { | ||
| path: 'tag', | ||
|
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. Here is the analysis of the provided code diff: 1. Irregularities / Issues
2. Potential Concerns
3. Optimization Suggestions ✅ Recommended Improvement: Use an Allowlist ArrayReplace the chained Before:detailMenuVisible: (params) => params.type === KNOWLEDGE_TYPE_KEY.BASE || params.type === KNOWLEDGE_TYPE_KEY.WORKFLOWAfter:const ALLOWED_TYPES_FOR_IMAGE = [
KNOWLEDGE_TYPE_KEY.BASE,
KNOWLEDGE_TYPE_KEY.WORKFLOW,
// Add other types here easily in the future
];
// Inside meta:
detailMenuVisible: (params) => ALLOWED_TYPES_FOR_IMAGE.includes(params.type),💡 Additional Best PracticeIf For example: // utils/menu-utils.ts
export const isVisibleForWorkspaceTypes = (allowedTypes: string[]) =>
(params: any) => allowedTypes.includes(params.type);
// In Route config:
meta: {
...
detailMenuVisible: isVisibleForWorkspaceTypes([KNOWLEDGE_TYPE_KEY.BASE, KNOWLEDGE_TYPE_KEY.WORKFLOW])
} |
||
|
|
||
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.
Here is a concise review of the code changes with potential issues and optimizations:
1. Potential Issue: Race Condition & Performance
await nextTick()inside an event handler: WhilenextTickensures the DOM updates after Vue re-render, usingasync/awaithere adds unnecessary microtask overhead. IfhasOpened.value = truetriggers a massive re-render (e.g., mounting complex dropdown menus), delaying this assignment might cause a visible flash or layout shift if the UI depends on this flag immediately.onMountedhook before changing this value, standard synchronous assignment is faster and safer:nextTickif you are waiting for specific child lifecycles.2. Code Clarity & Naming
if (!visible || hasOpened.value) return) is cleaner than the original. 👍3. Optimization Suggestions
FragmentandisVNodeare still used elsewhere in the file. If they were only imported for logic removed elsewhere, clean them up.DropdownInstancecorrectly typeshandleVisibleChange. Element Plus dropdowns usually emit@visible-change, so confirm the parameter type matches.4. Edge Case Risk
nextTickresolves, the secondtruecall will skip due tohasOpened.value, but theawait nextTickfrom the first call might still resolve later, redundantly settinghasOpened.value = trueagain (minor, but inefficient).Recommendation
Revert to synchronous assignment unless there is a proven visual bug requiring
nextTick. Async operations in visibility handlers should be avoided unless strictly necessary for timing-sensitive animations.