feat: 添加 usePlatform 组合函数并在 App 组件中使用,优化路由动画效果

This commit is contained in:
2026-01-20 16:02:21 +07:00
parent 7704b8eabd
commit b8ac4bf1f2
3 changed files with 28 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import { App as CapacitorApp } from "@capacitor/app";
const userStore = useUserStore();
const { isAuthenticated } = storeToRefs(userStore);
const { loadSavedLanguage } = useLanguage();
const platform = usePlatform();
onBeforeMount(() => {
loadSavedLanguage();
@@ -24,7 +25,7 @@ onMounted(() => {
<template>
<IonApp>
<Suspense>
<IonRouterOutlet />
<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";
}