nazhua/src/router/index.js
hi2hi bf30e14c30 新增自定义背景图片
 新增浅色系背景设定,适配自定义背景图片
🪄 修改图表的渲染方式为SVG
🔧 优化页面路由切换的状态记录
2024-12-20 16:43:48 +00:00

49 lines
979 B
JavaScript

import {
createRouter,
createWebHistory,
createWebHashHistory,
} from 'vue-router';
import config from '@/config';
import pageTitle from '@/utils/page-title';
const constantRoutes = [{
name: 'Home',
path: '/',
component: () => import('@/views/home.vue'),
}, {
name: 'ServerDetail',
path: '/:serverId(\\d+)',
component: () => import('@/views/detail.vue'),
meta: {
title: '节点详情',
},
props: true,
}, {
path: '/:pathMatch(.*)*',
redirect: {
name: 'Home',
},
}];
const routerOptions = {
history: config.nazhua.routeMode === 'h5' ? createWebHistory() : createWebHashHistory(),
scrollBehavior: (to, from, savedPosition) => {
if (savedPosition) {
return savedPosition;
}
return {
top: 0,
behavior: 'smooth',
};
},
routes: constantRoutes,
};
const router = createRouter(routerOptions);
router.beforeResolve((to, from, next) => {
pageTitle(to?.meta?.title);
next();
});
export default router;