-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: After one click beautification in the loop body, the workflow of the loop body becomes smaller and smaller. #4464
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <template> | ||
| <LoopBodyContainer :nodeModel="nodeModel"> | ||
| <LoopBodyContainer :nodeModel="nodeModel" ref="LoopBodyContainerRef"> | ||
| <div ref="containerRef" @wheel.stop style="height: 100%; width: 100%"></div> | ||
| </LoopBodyContainer> | ||
| </template> | ||
|
|
@@ -19,7 +19,7 @@ const loop_workflow_mode = inject('loopWorkflowMode') || WorkflowMode.Applicatio | |
| const nodes: any = import.meta.glob('@/workflow/nodes/**/index.ts', { eager: true }) | ||
| const props = defineProps<{ nodeModel: any }>() | ||
| const containerRef = ref() | ||
|
|
||
| const LoopBodyContainerRef = ref<InstanceType<typeof LoopBodyContainer>>() | ||
| const validate = () => { | ||
| const workflow = new WorkFlowInstance(lf.value.getGraphData(), WorkflowMode.ApplicationLoop) | ||
| return Promise.all(lf.value.graphModel.nodes.map((element: any) => element?.validate?.())) | ||
|
|
@@ -159,6 +159,7 @@ const renderGraphData = (data?: any) => { | |
| } | ||
|
|
||
| const loopLayout = () => { | ||
| LoopBodyContainerRef.value?.zoom() | ||
| lf.value?.extension?.dagre.layout() | ||
| } | ||
| onMounted(() => { | ||
|
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. Your code seems mostly clean, but there are a few improvements and optimizations you can consider:
Here's an optimized version: <template>
<LoopBodyContainer :nodeModel="nodeModel" ref="LoopBodyContainerRef">
<div ref="containerRef" @wheel.stop style="height: 100%; width: 100%"></div>
</LoopBodyContainer>
</template>
<script lang="ts">
import { ref } from 'vue';
import LoopBodyContainer from '@/components/LoopBodyContainer.vue';
export default {
components: {
LoopBodyContainer,
},
setup() {
const loopWorkflowMode = inject('loopWorkflowMode') || WorkflowMode.ApplicationLoop;
const nodes: any = import.meta.glob('@/workflow/nodes/**/index.ts', { eager: true });
const props = defineProps<{ nodeModel: any }>();
const containerRef = ref();
const LoopBodyContainerRef = ref();
const validate = () => {
const workflow = new WorkFlowInstance(lf.value.getGraphData(), WorkflowMode.ApplicationLoop);
return Promise.all(lf.value.graphModel.nodes.map((element: any) => element?.validate?.())));
};
const renderGraphData = (data?: any) => {};
const loopLayout = async () => {
await LoopBodyContainerRef.value!.zoom(); // Use ! to assert non-null safety temporarily
lf.value.extension.dagre.layout();
};
onMounted(async () => {
await validate();
await loopLayout();
});
return {
containerRef,
LoopBodyContainerRef,
};
},
};
</script>
<style scoped>
/* Add your styles here */
</style>Key Improvements:
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 looks mostly correct but has a small issue: The
zoomfunction is defined within the same component block where it's called. This can lead to confusion about scope in larger projects, especially when using TypeScript.To address this:
zoomFunction: Define thezoomfunction outside of the template area but inside the setup function. This will improve readability and separation of concerns.Here's the revised code snippet with these changes:
Explanation:
Scope Improvement: By moving the
zoomfunction outside of the script block, it adheres better to standard Vue conventions regarding module-level functions. This makes it easier to manage dependencies and avoid conflicts when components grow more complex.Vue Composition API Reference: I used
refto create a reactive reference forenlarge. If you use composition API syntax correctly, ensure that all variables or reactive data are properly declared outside of event handlers likezoom.This change should make your code more organized and maintainable without affecting its functionality.