Line data Source code
1 : import { useFavicon } from '@vueuse/core'
2 : import { watch } from 'vue'
3 :
4 : import { useExecutionStore } from '@/stores/executionStore'
5 :
6 2355 : export const useProgressFavicon = () => {
7 2355 : const defaultFavicon = '/assets/images/favicon_progress_16x16/frame_9.png'
8 2355 : const favicon = useFavicon(defaultFavicon)
9 2355 : const executionStore = useExecutionStore()
10 2355 : const totalFrames = 10
11 :
12 2355 : watch(
13 : [() => executionStore.executionProgress, () => executionStore.isIdle],
14 : ([progress, isIdle]) => {
15 318 : if (isIdle) {
16 87 : favicon.value = defaultFavicon
17 : } else {
18 231 : const frame = Math.min(
19 : Math.max(0, Math.floor(progress * totalFrames)),
20 : totalFrames - 1
21 : )
22 231 : favicon.value = `/assets/images/favicon_progress_16x16/frame_${frame}.png`
23 : }
24 : }
25 : )
26 : }
|