Files
huangguo_dhz/src/router/index.ts
T
2026-10-09 18:18:35 +07:00

68 lines
1.6 KiB
TypeScript

import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import Home from '@/views/home/index.vue';
import pcRouter from './pcRouter';
import mobileRouter from './mobileRouter';
import MobilePrivacyPolicy from '@/views/mobile/privacyPolicy/index.vue';
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'home',
component: Home,
redirect: '/home',
meta: {
title: '首页',
},
children: [...pcRouter, ...mobileRouter],
},
{
path: '/mobilePrivacyPolicy',
name: 'mobilePrivacyPolicy',
component: MobilePrivacyPolicy,
meta: {
title: '隐私政策',
},
},
{
path: '/mobileConnectInfo',
name: 'mobileConnectInfo',
component: () => import('@/views/mobile/connectInfo/index.vue'),
meta: {
title: '联系官方',
},
},
// {
// path: '/mobileClassification',
// name: 'mobileClassification',
// component: () => import('@/views/mobile/classification/index.vue'),
// meta: {
// title: '分类列表',
// },
// },
{
path: '/mobileBusiness',
name: 'mobileBusiness',
component: () => import('@/views/mobile/mobileBusiness/index.vue'),
meta: {
title: '商务合作',
},
},
];
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: routes,
});
router.beforeEach((to, from, next) => {
const home = document.querySelector('#home');
home && home.scrollTo(0, 0);
document.title = '黄果导航站';
const token = localStorage.getItem('token');
if (token || to.path === '/home') {
next();
} else {
next('/home');
}
});
export default router;