Repository navigation
feat: system shared auth to workspace permission #7795
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 |
|---|---|---|
|
|
@@ -179,7 +179,7 @@ function handleOpenWorkflow(tool: ToolItem, event: MouseEvent) { | |
| :tool="tool" | ||
| /> | ||
| <!-- 授权工作空间 --> | ||
| <AuthorizedWorkspaceAction label="授权工作空间" :resource="tool" :resource-type="RESOURCE_TYPE.TOOL" /> | ||
| <AuthorizedWorkspaceAction v-if="perm.tool.share.authToWorkspace()" label="授权工作空间" :resource="tool" :resource-type="RESOURCE_TYPE.TOOL" /> | ||
|
|
||
| <!-- 查看关联资源 --> | ||
| <RelatedResourcesToolAction | ||
|
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. Analysis of the Code Change1. Critical Syntax Error: <!-- ❌ Invalid Vue syntax -->
v-if="perm.tool.share.authToWorkspace()"In Vue templates, you cannot call a function by name without binding it to an object that exists in the component’s scope context. 2. Anti-pattern: Function Call in Template 3. Semantic Clarification ✅ Recommended FixAssuming you have a reactive permission state (e.g., from a Pinia/Vuex store or injected permission service), define a computed property or use an existing boolean flag. Here’s how to fix it properly: Option A: Use a Computed Property (Vue 3
|
||
|
|
||
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 code snippet introduces a
v-ifdirective with a method call:perm.model.share.authToWorkspace(). The primary issue here is performance and reliability.Vue evaluates expressions in templates on every re-render. Calling a function inside
v-ifmeans the function executes repeatedly during template rendering cycles (e.g., when reactive dependencies change). This can lead to:Recommendation
Move the permission check into a computed property so it is cached and only re-evaluated when its reactive dependencies change.
✅ Optimized Approach
Script Setup (
<script setup>):Template:
Benefits: