feat: 添加平台检测功能,优化路由动画效果
This commit is contained in:
@@ -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>
|
||||
|
||||
24
src/composables/usePlatform.ts
Normal file
24
src/composables/usePlatform.ts
Normal 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";
|
||||
}
|
||||
Reference in New Issue
Block a user