fix(test-app): use Capacitor for platform detection in views
Replace hardcoded platform values and appStore.platform with Capacitor.getPlatform() for accurate runtime platform detection. Changes: - HomeView: Use Capacitor.getPlatform() instead of appStore.platform - StatusView: Use Capacitor.getPlatform() for initial diagnostics - diagnostics-export: Replace hardcoded 'Android' with Capacitor detection - StatusView: Fix timezone to use actual timezone instead of 'Unknown' - diagnostics-export: Show 'N/A' for API Level on iOS/web (Android-specific) Fixes platform badge showing "web" on iOS native and diagnostics showing incorrect platform information.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
import {
|
||||
type PermissionStatus,
|
||||
type NotificationStatus,
|
||||
@@ -119,10 +120,17 @@ export class DiagnosticsExporter {
|
||||
// Calculate performance metrics
|
||||
const loadTime = performance.now() - startTime
|
||||
|
||||
// Detect platform using Capacitor
|
||||
const platform = Capacitor.getPlatform()
|
||||
const platformDisplayName = platform.charAt(0).toUpperCase() + platform.slice(1)
|
||||
|
||||
// API Level is Android-specific, show N/A for iOS/web
|
||||
const apiLevel = platform === 'android' ? 'Unknown' : 'N/A'
|
||||
|
||||
return {
|
||||
appVersion: '1.0.0', // TODO: Get from app info
|
||||
platform: 'Android', // TODO: Detect platform
|
||||
apiLevel: 'Unknown', // TODO: Get from device info
|
||||
platform: platformDisplayName,
|
||||
apiLevel: apiLevel, // TODO: Get from device info for Android
|
||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
lastUpdated: new Date().toLocaleString(),
|
||||
postNotificationsGranted: permissions.notifications === 'granted',
|
||||
|
||||
@@ -134,11 +134,11 @@ const isRequestingPermissions = ref(false)
|
||||
const nativeFetcherConfigured = ref(false)
|
||||
|
||||
const platformName = computed(() => {
|
||||
const platform = appStore.platform
|
||||
const platform = Capacitor.getPlatform()
|
||||
return platform.charAt(0).toUpperCase() + platform.slice(1)
|
||||
})
|
||||
|
||||
const platformClass = computed(() => `platform-${appStore.platform}`)
|
||||
const platformClass = computed(() => `platform-${Capacitor.getPlatform()}`)
|
||||
|
||||
const statusClass = computed(() => {
|
||||
const status = appStore.notificationStatus
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component, toNative } from 'vue-facing-decorator'
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
import router from '../router'
|
||||
import StatusCard from '../components/cards/StatusCard.vue'
|
||||
import { createTypedPlugin } from '../lib/typed-plugin'
|
||||
@@ -126,9 +127,12 @@ class StatusView extends Vue {
|
||||
}
|
||||
diagnostics: Diagnostics = {
|
||||
appVersion: '1.0.0',
|
||||
platform: 'Android',
|
||||
apiLevel: 'Unknown',
|
||||
timezone: 'Unknown',
|
||||
platform: (() => {
|
||||
const platform = Capacitor.getPlatform()
|
||||
return platform.charAt(0).toUpperCase() + platform.slice(1)
|
||||
})(),
|
||||
apiLevel: Capacitor.getPlatform() === 'android' ? 'Unknown' : 'N/A',
|
||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
lastUpdated: 'Never',
|
||||
postNotificationsGranted: false,
|
||||
exactAlarmGranted: false,
|
||||
|
||||
Reference in New Issue
Block a user