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
|
* @version 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Capacitor } from '@capacitor/core'
|
||||||
import {
|
import {
|
||||||
type PermissionStatus,
|
type PermissionStatus,
|
||||||
type NotificationStatus,
|
type NotificationStatus,
|
||||||
@@ -119,10 +120,17 @@ export class DiagnosticsExporter {
|
|||||||
// Calculate performance metrics
|
// Calculate performance metrics
|
||||||
const loadTime = performance.now() - startTime
|
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 {
|
return {
|
||||||
appVersion: '1.0.0', // TODO: Get from app info
|
appVersion: '1.0.0', // TODO: Get from app info
|
||||||
platform: 'Android', // TODO: Detect platform
|
platform: platformDisplayName,
|
||||||
apiLevel: 'Unknown', // TODO: Get from device info
|
apiLevel: apiLevel, // TODO: Get from device info for Android
|
||||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
lastUpdated: new Date().toLocaleString(),
|
lastUpdated: new Date().toLocaleString(),
|
||||||
postNotificationsGranted: permissions.notifications === 'granted',
|
postNotificationsGranted: permissions.notifications === 'granted',
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ const isRequestingPermissions = ref(false)
|
|||||||
const nativeFetcherConfigured = ref(false)
|
const nativeFetcherConfigured = ref(false)
|
||||||
|
|
||||||
const platformName = computed(() => {
|
const platformName = computed(() => {
|
||||||
const platform = appStore.platform
|
const platform = Capacitor.getPlatform()
|
||||||
return platform.charAt(0).toUpperCase() + platform.slice(1)
|
return platform.charAt(0).toUpperCase() + platform.slice(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
const platformClass = computed(() => `platform-${appStore.platform}`)
|
const platformClass = computed(() => `platform-${Capacitor.getPlatform()}`)
|
||||||
|
|
||||||
const statusClass = computed(() => {
|
const statusClass = computed(() => {
|
||||||
const status = appStore.notificationStatus
|
const status = appStore.notificationStatus
|
||||||
|
|||||||
@@ -92,6 +92,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Vue, Component, toNative } from 'vue-facing-decorator'
|
import { Vue, Component, toNative } from 'vue-facing-decorator'
|
||||||
|
import { Capacitor } from '@capacitor/core'
|
||||||
import router from '../router'
|
import router from '../router'
|
||||||
import StatusCard from '../components/cards/StatusCard.vue'
|
import StatusCard from '../components/cards/StatusCard.vue'
|
||||||
import { createTypedPlugin } from '../lib/typed-plugin'
|
import { createTypedPlugin } from '../lib/typed-plugin'
|
||||||
@@ -126,9 +127,12 @@ class StatusView extends Vue {
|
|||||||
}
|
}
|
||||||
diagnostics: Diagnostics = {
|
diagnostics: Diagnostics = {
|
||||||
appVersion: '1.0.0',
|
appVersion: '1.0.0',
|
||||||
platform: 'Android',
|
platform: (() => {
|
||||||
apiLevel: 'Unknown',
|
const platform = Capacitor.getPlatform()
|
||||||
timezone: 'Unknown',
|
return platform.charAt(0).toUpperCase() + platform.slice(1)
|
||||||
|
})(),
|
||||||
|
apiLevel: Capacitor.getPlatform() === 'android' ? 'Unknown' : 'N/A',
|
||||||
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
lastUpdated: 'Never',
|
lastUpdated: 'Never',
|
||||||
postNotificationsGranted: false,
|
postNotificationsGranted: false,
|
||||||
exactAlarmGranted: false,
|
exactAlarmGranted: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user