feat: 添加平台检测功能,优化路由动画效果

This commit is contained in:
2025-12-28 01:53:08 +07:00
parent 7fc1c84329
commit b6cb514bcd
3 changed files with 28 additions and 1 deletions

2
auto-imports.d.ts vendored
View File

@@ -248,6 +248,7 @@ declare global {
const useParentElement: typeof import('@vueuse/core').useParentElement
const usePerformanceObserver: typeof import('@vueuse/core').usePerformanceObserver
const usePermission: typeof import('@vueuse/core').usePermission
const usePlatform: typeof import('./src/composables/usePlatform').usePlatform
const usePointer: typeof import('@vueuse/core').usePointer
const usePointerLock: typeof import('@vueuse/core').usePointerLock
const usePointerSwipe: typeof import('@vueuse/core').usePointerSwipe
@@ -610,6 +611,7 @@ declare module 'vue' {
readonly useParentElement: UnwrapRef<typeof import('@vueuse/core')['useParentElement']>
readonly usePerformanceObserver: UnwrapRef<typeof import('@vueuse/core')['usePerformanceObserver']>
readonly usePermission: UnwrapRef<typeof import('@vueuse/core')['usePermission']>
readonly usePlatform: UnwrapRef<typeof import('./src/composables/usePlatform')['usePlatform']>
readonly usePointer: UnwrapRef<typeof import('@vueuse/core')['usePointer']>
readonly usePointerLock: UnwrapRef<typeof import('@vueuse/core')['usePointerLock']>
readonly usePointerSwipe: UnwrapRef<typeof import('@vueuse/core')['usePointerSwipe']>

View File

@@ -6,6 +6,7 @@ const { isAuthenticated } = storeToRefs(userStore);
const { locale, loadSavedLanguage } = useLanguage();
const { initializeWallet } = useWalletStore();
const { updateProfile } = useUserStore();
const platform = usePlatform();
onMounted(() => {
if (!isAuthenticated.value)
@@ -31,7 +32,7 @@ watch(locale, (newLocale) => {
<template>
<IonApp>
<Suspense>
<IonRouterOutlet :animated="false" />
<IonRouterOutlet :animated="platform !== 'browser'" />
</Suspense>
</IonApp>
</template>

View File

@@ -0,0 +1,24 @@
import { Capacitor } from "@capacitor/core";
import { getPlatforms } from "@ionic/vue";
export function usePlatform() {
const platforms = getPlatforms();
// 优先检测浏览器环境
if (platforms.includes("desktop") || platforms.includes("mobileweb")) {
return "browser";
}
// 检测原生环境
if (Capacitor.isNativePlatform()) {
if (platforms.includes("ios")) {
return "ios";
}
if (platforms.includes("android")) {
return "android";
}
}
return "browser";
}