|
| 1 | +<template> |
| 2 | + <InteractionDialog |
| 3 | + v-model="showArchWarningDialog" |
| 4 | + title="Performance Warning" |
| 5 | + variant="text-only" |
| 6 | + :actions="dialogActions" |
| 7 | + max-width="820" |
| 8 | + > |
| 9 | + <template #content> |
| 10 | + <div class="flex items-center justify-center mb-2"> |
| 11 | + <v-icon class="text-yellow text-[60px] mx-8">mdi-alert-rhombus</v-icon> |
| 12 | + <div class="flex flex-col font-medium gap-y-3 w-full"> |
| 13 | + You are running the x64 version of Cockpit on an Apple Silicon Mac (M series), which causes severely degraded |
| 14 | + performance, including: |
| 15 | + <ul class="mt- ml-4"> |
| 16 | + <li>- 3-4x slower application startup times</li> |
| 17 | + <li>- 2x the memory usage</li> |
| 18 | + <li>- Reduced overall performance</li> |
| 19 | + </ul> |
| 20 | + <p class="text-sm text-gray-600 mt-2"> |
| 21 | + This warning cannot be disabled - we strongly recommend that you download and install the intended version |
| 22 | + for your system. |
| 23 | + </p> |
| 24 | + </div> |
| 25 | + </div> |
| 26 | + </template> |
| 27 | + </InteractionDialog> |
| 28 | +</template> |
| 29 | + |
| 30 | +<script setup lang="ts"> |
| 31 | +import { onBeforeMount, ref } from 'vue' |
| 32 | +
|
| 33 | +import InteractionDialog, { type Action } from '@/components/InteractionDialog.vue' |
| 34 | +import { isElectron } from '@/libs/utils' |
| 35 | +import { PlatformUtils } from '@/types/platform' |
| 36 | +
|
| 37 | +const showArchWarningDialog = ref(false) |
| 38 | +
|
| 39 | +const dialogActions = [ |
| 40 | + { |
| 41 | + text: 'Dismiss', |
| 42 | + action: () => { |
| 43 | + showArchWarningDialog.value = false |
| 44 | + }, |
| 45 | + }, |
| 46 | + { |
| 47 | + text: 'Download ARM64 Version', |
| 48 | + action: () => { |
| 49 | + window.open('https://github.com/bluerobotics/cockpit/releases/', '_blank') |
| 50 | + showArchWarningDialog.value = false |
| 51 | + }, |
| 52 | + }, |
| 53 | +] as Action[] |
| 54 | +
|
| 55 | +/** |
| 56 | + * Check if we're running x64 version on ARM64 Mac and show warning |
| 57 | + */ |
| 58 | +const checkArchitectureAndWarn = async (): Promise<void> => { |
| 59 | + if (!window.electronAPI?.getSystemInfo) { |
| 60 | + console.warn('getSystemInfo not available in electronAPI') |
| 61 | + return |
| 62 | + } |
| 63 | +
|
| 64 | + try { |
| 65 | + const systemInfo = await window.electronAPI.getSystemInfo() |
| 66 | +
|
| 67 | + // Only show warning if we detect x64 on ARM64 Mac |
| 68 | + showArchWarningDialog.value = PlatformUtils.isX64OnArm64Mac( |
| 69 | + systemInfo.platform, |
| 70 | + systemInfo.arch, |
| 71 | + systemInfo.processArch |
| 72 | + ) |
| 73 | + } catch (error) { |
| 74 | + console.error('Failed to get system info for architecture check:', error) |
| 75 | + } |
| 76 | +} |
| 77 | +
|
| 78 | +onBeforeMount(() => { |
| 79 | + if (!isElectron()) { |
| 80 | + console.info('Not in Electron environment. ArchitectureWarning will not be initialized.') |
| 81 | + return |
| 82 | + } |
| 83 | +
|
| 84 | + if (!window.electronAPI) { |
| 85 | + console.error('window.electronAPI is not defined. ArchitectureWarning will not be initialized.') |
| 86 | + return |
| 87 | + } |
| 88 | +
|
| 89 | + // Wait a bit before showing the warning to not interfere with app startup |
| 90 | + setTimeout(() => { |
| 91 | + checkArchitectureAndWarn() |
| 92 | + }, 3000) |
| 93 | +}) |
| 94 | +</script> |
0 commit comments