[Beta Menu] Shows unsaved state on browser tab title (#860)

* [Beta Menu] Shows unsaved state on browser tab title

* Proper state management

* Add playwright test

* Fix browser tests
This commit is contained in:
Chenlei Hu
2024-09-17 16:14:06 +09:00
committed by GitHub
parent e8daebdc0c
commit 4e41db2d6a
7 changed files with 106 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ import { useWorkflowStore } from '@/stores/workflowStore'
import { useTitle } from '@vueuse/core'
import { computed } from 'vue'
const DEFAULT_TITLE = 'ComfyUI'
const executionStore = useExecutionStore()
const executionText = computed(() =>
executionStore.isIdle ? '' : `[${executionStore.executionProgress}%]`
@@ -22,12 +23,18 @@ const betaMenuEnabled = computed(
)
const workflowStore = useWorkflowStore()
const workflowNameText = computed(
() =>
(betaMenuEnabled.value ? workflowStore.activeWorkflow?.name : undefined) ??
'ComfyUI'
const isUnsavedText = computed(() =>
workflowStore.previousWorkflowUnsaved ? ' *' : ''
)
const workflowNameText = computed(() => {
const workflowName = workflowStore.activeWorkflow?.name
return workflowName ? isUnsavedText.value + workflowName : DEFAULT_TITLE
})
const title = computed(() => executionText.value + workflowNameText.value)
const title = computed(
() =>
executionText.value +
(betaMenuEnabled.value ? workflowNameText.value : DEFAULT_TITLE)
)
useTitle(title)
</script>