Skip to content

Commit

Permalink
perf: optimize render performance
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Jan 18, 2024
1 parent 9ad6dca commit 3e0ff9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/renderer/components/DefaultPreviewerRender.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,13 @@ onBeforeUnmount(() => {
})
watch([currentContent, fileUri, inComposition], () => {
autoPreview.value && updateRender()
if (autoPreview.value) {
if (renderCount === 0) {
render()
} else {
updateRender()
}
}
}, { flush: 'post' })
watch(fileUri, () => {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</template>

<script lang="ts" setup>
import { computed, nextTick, onBeforeUnmount, onMounted, shallowRef, watchEffect } from 'vue'
import { computed, nextTick, onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'
import { getAllCustomEditors, isDefault, getValue, setValue, switchEditor } from '@fe/services/editor'
import { registerAction, removeAction } from '@fe/core/action'
import { registerHook, removeHook, triggerHook } from '@fe/core/hook'
Expand Down Expand Up @@ -145,7 +145,7 @@ onBeforeUnmount(() => {
FileTabs.removeActionBtnTapper(tabsActionBtnTapper)
})
watchEffect(() => {
watch(() => store.state.editor, () => {
triggerHook('EDITOR_CURRENT_EDITOR_CHANGE', { current: currentEditor.value })
FileTabs.refreshActionBtns()
recordEditorUsageTime(currentEditor.value?.name || 'default')
Expand Down

1 comment on commit 3e0ff9b

@vercel
Copy link

@vercel vercel bot commented on 3e0ff9b Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.