diff --git a/apps/stage-tamagotchi/src/components/Widgets/ResourceStatusIsland/LoadingProgress.vue b/apps/stage-tamagotchi/src/components/Widgets/ResourceStatusIsland/LoadingProgress.vue index 21bcbfb86..9e12e8c5e 100644 --- a/apps/stage-tamagotchi/src/components/Widgets/ResourceStatusIsland/LoadingProgress.vue +++ b/apps/stage-tamagotchi/src/components/Widgets/ResourceStatusIsland/LoadingProgress.vue @@ -1,70 +1,16 @@ @@ -76,7 +22,7 @@ onMounted(() => { w="[calc(100%-1.5rem)]" >
-
+
Preparing external resources... @@ -84,7 +30,7 @@ onMounted(() => {
diff --git a/apps/stage-tamagotchi/src/components/Widgets/ResourceStatusIsland/index.vue b/apps/stage-tamagotchi/src/components/Widgets/ResourceStatusIsland/index.vue index 314c2fada..430ef66f8 100644 --- a/apps/stage-tamagotchi/src/components/Widgets/ResourceStatusIsland/index.vue +++ b/apps/stage-tamagotchi/src/components/Widgets/ResourceStatusIsland/index.vue @@ -1,7 +1,12 @@ diff --git a/apps/stage-tamagotchi/src/pages/index.vue b/apps/stage-tamagotchi/src/pages/index.vue index 753b64e16..316663414 100644 --- a/apps/stage-tamagotchi/src/pages/index.vue +++ b/apps/stage-tamagotchi/src/pages/index.vue @@ -10,6 +10,7 @@ import { computed, onMounted, onUnmounted, ref } from 'vue' import ResourceStatusIsland from '../components/Widgets/ResourceStatusIsland/index.vue' import { useAppRuntime } from '../composables/runtime' import { useWindowShortcuts } from '../composables/window-shortcuts' +import { useResourcesStore } from '../stores/resources' import { useWindowControlStore } from '../stores/window-controls' import { WindowControlMode } from '../types/window-controls' import { startClickThrough, stopClickThrough } from '../utils/windows' @@ -97,9 +98,10 @@ function onTauriPositionCursorAndWindowFrameEvent(event: { payload: [Point, Wind onMounted(async () => { // Listen for click-through state changes unListenFuncs.push(await listen('tauri-app:window-click-through:position-cursor-and-window-frame', onTauriPositionCursorAndWindowFrameEvent)) + + // Load models invoke('load_models') - // eslint-disable-next-line no-console - unListenFuncs.push(await listen('tauri-app:model-load-progress', console.log)) + unListenFuncs.push(await listen('tauri-app:model-load-progress', useResourcesStore().appendResource)) if (connected.value) return diff --git a/apps/stage-tamagotchi/src/stores/resources.ts b/apps/stage-tamagotchi/src/stores/resources.ts new file mode 100644 index 000000000..50739df7a --- /dev/null +++ b/apps/stage-tamagotchi/src/stores/resources.ts @@ -0,0 +1,33 @@ +import type { Ref } from 'vue' + +import { defineStore } from 'pinia' +import { ref } from 'vue' + +export interface ProgressInfoItem { + filename: string + progress: number + currentSize: number + totalSize: number +} + +export type ProgressInfo = Map> + +export const useResourcesStore = defineStore('resources', () => { + const resources = ref(new Map()) + + const appendResource = (event: { payload: [string, number] }) => { + const [filename, progress] = event.payload + const fileRef = ref({ + filename, + progress, + currentSize: 0, + totalSize: 100, + }) + resources.value.set(filename, fileRef) + } + + return { + resources, + appendResource, + } +})