diff --git a/apps/app-frontend/src/App.vue b/apps/app-frontend/src/App.vue index 7993b6c..d7eb03e 100644 --- a/apps/app-frontend/src/App.vue +++ b/apps/app-frontend/src/App.vue @@ -79,6 +79,7 @@ import MinecraftAuthErrorModal from '@/components/ui/minecraft-auth-error-modal/ import MinecraftCrashModal from '@/components/ui/MinecraftCrashModal.vue' import AuthGrantFlowWaitModal from '@/components/ui/modal/AuthGrantFlowWaitModal.vue' import CurseForgeManualDownloadsModal from '@/components/ui/modal/CurseForgeManualDownloadsModal.vue' +import TaggedModDownloadsModal from '@/components/instance/TaggedModDownloadsModal.vue' import InstallToPlayModal from '@/components/ui/modal/InstallToPlayModal.vue' import InstanceIconPickerModal from '@/components/ui/modal/InstanceIconPickerModal.vue' import JavaDownloadConfirmationModal from '@/components/ui/modal/JavaDownloadConfirmationModal.vue' @@ -2569,6 +2570,7 @@ provideAppUpdateDownloadProgress(appUpdateDownload) @install="handleContentInstallModpackInstall" @cancel="handleContentInstallModpackInstallCancel" /> + import { DownloadIcon } from '@modrinth/assets' -import { defineMessages, useVIntl } from '@modrinth/ui' +import { defineMessages, ProgressBar, useVIntl } from '@modrinth/ui' import { computed, onUnmounted, ref } from 'vue' import { loading_listener } from '@/helpers/events' import type { LoadingBar } from '@/helpers/state' +import { progress_bars_list } from '@/helpers/state' const { formatMessage } = useVIntl() @@ -15,6 +15,7 @@ const messages = defineMessages({ }) interface LoadingEventPayload { + total?: number | null event: LoadingBar['bar_type'] loader_uuid: string fraction: number | null @@ -22,6 +23,7 @@ interface LoadingEventPayload { } interface LaunchProgressItem { + waiting: boolean key: string message: string fraction: number | null @@ -29,6 +31,7 @@ interface LaunchProgressItem { // 启动相关(以及准备)阶段会发的 loading 类型;安装/下载也一并显示,便于用户看到进度 const LAUNCH_BAR_TYPES = new Set([ + 'hosted_pack_sync', 'minecraft_download', 'instance_update', 'zip_extract', @@ -54,6 +57,7 @@ function applyEvent(payload: LoadingEventPayload) { if (!isVisible(payload.event)) return activeMap.set(payload.loader_uuid, { + waiting: payload.total === 0, key: payload.loader_uuid, message: payload.message, fraction: payload.fraction, @@ -64,13 +68,28 @@ function applyEvent(payload: LoadingEventPayload) { const hasProgress = computed(() => progressItems.value.length > 0) function percent(item: LaunchProgressItem): string { - if (item.fraction == null || !Number.isFinite(item.fraction)) return '' + if (item.waiting || item.fraction == null || !Number.isFinite(item.fraction)) return '' return `${Math.round(Math.max(0, Math.min(1, item.fraction)) * 100)}%` } +let initializing = true +const buffered: LoadingEventPayload[] = [] const unlistenLoading = await loading_listener((payload: LoadingEventPayload) => { - applyEvent(payload) + if (initializing) buffered.push(payload) + else applyEvent(payload) }) +const bars = await progress_bars_list().catch(() => ({})) +for (const bar of Object.values(bars)) { + applyEvent({ + event: bar.bar_type, + loader_uuid: String(bar.loading_bar_uuid), + fraction: bar.total ? (bar.current ?? 0) / bar.total : 0, + total: bar.total, + message: bar.message ?? '', + }) +} +initializing = false +for (const payload of buffered) applyEvent(payload) onUnmounted(() => { unlistenLoading?.() @@ -96,12 +115,7 @@ onUnmounted(() => { {{ percent(item) }} -
-
-
+ diff --git a/apps/app-frontend/src/components/instance/HostedModpacks.vue b/apps/app-frontend/src/components/instance/HostedModpacks.vue index 3ed031f..46ef409 100644 --- a/apps/app-frontend/src/components/instance/HostedModpacks.vue +++ b/apps/app-frontend/src/components/instance/HostedModpacks.vue @@ -39,7 +39,7 @@ }) }}

-

{{ formatMessage(messages.syncing) }}

+

{{ @@ -59,10 +59,9 @@

-

{{ formatMessage(messages.empty) }}

+
@@ -73,16 +72,7 @@

@@ -92,28 +82,29 @@ + +