import { createRouter, createWebHashHistory } from "vue-router";
import Index from "../pages/file/index.vue";
import Voice from "../pages/voice/webrtcVoice.vue";
import PointShader from "../pages/pointShader/pointShader.vue";
import { disablePwaPrompt, enablePwaPrompt } from '../utils/pwa';

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: "/",
            component: Index,
            meta: {
                showPwaPrompt: true
            }
        },
        {
            path: "/voice",
            component: Voice,
            meta: {
                showPwaPrompt: false
            }
        },
        {
            path: "/pointShader",
            component: PointShader,
            meta: {
                showPwaPrompt: false
            }
        },
    ],
});

// 路由守卫控制 PWA 提示
router.beforeEach((to, from, next) => {
    if (to.meta.showPwaPrompt) {
        enablePwaPrompt();
    } else {
        disablePwaPrompt();
    }
    next();
});

export default router;
