fix(stage-tamagotchi): loading model progress data lost
This commit is contained in:
+5
-5
@@ -48,7 +48,7 @@ const totalProgress = computed(() => {
|
||||
Preparing external resources...
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="props.progressInfo.size > 0" w-full flex flex-col gap-2>
|
||||
<div v-if="Array(props.progressInfo.values()).length > 0" w-full flex flex-col gap-2>
|
||||
<div
|
||||
v-for="file in Array.from(progressInfo.values())"
|
||||
:key="file.value.filename"
|
||||
@@ -67,15 +67,15 @@ const totalProgress = computed(() => {
|
||||
</div>
|
||||
<div>{{ file.value.progress.toFixed(2) }}%</div>
|
||||
</div>
|
||||
<div relative>
|
||||
<div relative overflow-hidden rounded-md>
|
||||
<div
|
||||
bg="primary-300 dark:primary-300/50"
|
||||
absolute h-4 rounded-md will-change-width
|
||||
:style="{ width: `${file.value.progress}%` }"
|
||||
absolute h-4 will-change-width
|
||||
:style="{ width: `${Math.min(file.value.progress, 0.5)}%` }"
|
||||
transition="width duration-500 ease-in-out"
|
||||
/>
|
||||
<div
|
||||
bg="neutral-100 dark:neutral-900" h-4 w-full rounded-md
|
||||
bg="neutral-100 dark:neutral-900" h-4 w-full
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -79,11 +79,6 @@ export function useTauriEvent<ES = Events>() {
|
||||
}
|
||||
|
||||
async function listen<E extends keyof ES>(event: E, callback: EventCallback<ES[E]>) {
|
||||
if (platform.value === 'web') {
|
||||
console.warn(`Attempted to listen to Tauri event "${String(event)}" in web platform, however, currently we are not in a Tauri environment.`)
|
||||
return () => {}
|
||||
}
|
||||
|
||||
let cleanupListener: UnlistenFn | undefined
|
||||
|
||||
_listen(event, callback).then((listener) => {
|
||||
|
||||
@@ -85,12 +85,11 @@ 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))
|
||||
unListenFuncs.push(await listen('tauri-app:model-load-progress', useResourcesStore().appendResource))
|
||||
|
||||
// Load models
|
||||
invoke('load_models')
|
||||
unListenFuncs.push(await listen('tauri-app:model-load-progress', useResourcesStore().appendResource))
|
||||
|
||||
if (connected.value)
|
||||
return
|
||||
@@ -114,12 +113,14 @@ if (import.meta.hot) { // For better DX
|
||||
import.meta.hot.on('vite:beforeUpdate', () => {
|
||||
unListenFuncs.forEach(fn => fn?.())
|
||||
unListenFuncs.length = 0
|
||||
|
||||
invoke('stop_monitor')
|
||||
})
|
||||
import.meta.hot.on('vite:afterUpdate', async () => {
|
||||
if (unListenFuncs.length === 0) {
|
||||
unListenFuncs.push(await listen('tauri-app:window-click-through:position-cursor-and-window-frame', onTauriPositionCursorAndWindowFrameEvent))
|
||||
}
|
||||
|
||||
invoke('start_monitor')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,12 +17,14 @@ export const useResourcesStore = defineStore('resources', () => {
|
||||
|
||||
const appendResource = (event: { payload: [string, number] }) => {
|
||||
const [filename, progress] = event.payload
|
||||
|
||||
const fileRef = ref<ProgressInfoItem>({
|
||||
filename,
|
||||
progress,
|
||||
currentSize: 0,
|
||||
totalSize: 100,
|
||||
})
|
||||
|
||||
resources.value.set(filename, fileRef)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user