Allow users to opt-out of changing favicon

This commit is contained in:
filtered
2025-05-14 07:44:06 +10:00
parent b152f67d95
commit a0a00bacdd
3 changed files with 39 additions and 11 deletions

View File

@@ -1,23 +1,41 @@
import { useFavicon } from '@vueuse/core'
import { watch } from 'vue'
import { type WatchHandle, ref, watch } from 'vue'
import { useExecutionStore } from '@/stores/executionStore'
import { useSettingStore } from '@/stores/settingStore'
export const useProgressFavicon = () => {
const defaultFavicon = '/assets/images/favicon_progress_16x16/frame_9.png'
const favicon = useFavicon(defaultFavicon)
const executionStore = useExecutionStore()
const settingsStore = useSettingStore()
const totalFrames = 10
watch(
[() => executionStore.executionProgress, () => executionStore.isIdle],
([progress, isIdle]) => {
if (isIdle) {
favicon.value = defaultFavicon
} else {
const frame = Math.floor(progress * totalFrames)
favicon.value = `/assets/images/favicon_progress_16x16/frame_${frame}.png`
const watchHandle = ref<WatchHandle>()
function watchProgress() {
watchHandle.value = watch(
[() => executionStore.executionProgress, () => executionStore.isIdle],
([progress, isIdle]) => {
if (isIdle) {
favicon.value = defaultFavicon
} else {
const frame = Math.floor(progress * totalFrames)
favicon.value = `/assets/images/favicon_progress_16x16/frame_${frame}.png`
}
}
}
)
}
watch(
() => settingsStore.get('Comfy.Window.TabIconProgress'),
(showProgress) => {
if (showProgress) {
watchProgress()
} else {
watchHandle.value?.stop()
}
},
{ immediate: true }
)
}

View File

@@ -828,5 +828,14 @@ export const CORE_SETTINGS: SettingParams[] = [
type: 'boolean',
defaultValue: false,
versionAdded: '1.19.1'
},
{
id: 'Comfy.Window.TabIconProgress',
name: 'Browser tab icon shows progress',
tooltip:
'Updates the browser tab icon to show the progress of the current task.',
type: 'boolean',
defaultValue: true,
versionAdded: '1.20.0'
}
]

View File

@@ -463,7 +463,8 @@ const zSettings = z.object({
'main.sub.setting.name': z.any(),
'single.setting': z.any(),
'LiteGraph.Node.DefaultPadding': z.boolean(),
'LiteGraph.Pointer.TrackpadGestures': z.boolean()
'LiteGraph.Pointer.TrackpadGestures': z.boolean(),
'Comfy.Window.TabIconProgress': z.boolean()
})
export type EmbeddingsResponse = z.infer<typeof zEmbeddingsResponse>