f
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import NProgress from 'nprogress'
|
||||
import GlobalLayout from '@/layouts/GlobalLayout.vue'
|
||||
import { getInquireCategoryTitle } from '@/config/inquireCategories'
|
||||
import HomeLayout from '@/layouts/HomeLayout.vue'
|
||||
import PageLayout from '@/layouts/PageLayout.vue'
|
||||
import index from '@/views/index.vue'
|
||||
@@ -16,13 +17,10 @@ const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
// 路由切换时的滚动行为
|
||||
scrollBehavior(to, from, savedPosition) {
|
||||
// 如果有保存的位置(浏览器前进/后退)
|
||||
if (savedPosition) {
|
||||
return savedPosition;
|
||||
} else {
|
||||
// 否则滚动到顶部
|
||||
return { top: 0, behavior: "smooth" };
|
||||
}
|
||||
return { top: 0 };
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
@@ -149,6 +147,12 @@ const router = createRouter({
|
||||
component: () => import('@/views/AgentServiceAgreement.vue'),
|
||||
meta: { title: '信息技术服务合同' },
|
||||
},
|
||||
{
|
||||
path: '/inquire/category/:category',
|
||||
name: 'inquireCategory',
|
||||
component: () => import('@/views/InquireCategory.vue'),
|
||||
meta: { title: '选择查询' },
|
||||
},
|
||||
{
|
||||
path: '/inquire/:feature',
|
||||
name: 'inquire',
|
||||
@@ -361,6 +365,10 @@ NProgress.configure({
|
||||
// 路由导航守卫
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
NProgress.start(); // 启动进度条
|
||||
// 二级查询分类页:根据 category 动态设置导航栏标题
|
||||
if (to.name === 'inquireCategory' && to.params.category) {
|
||||
to.meta.title = getInquireCategoryTitle(to.params.category);
|
||||
}
|
||||
const isAuthenticated = localStorage.getItem("token");
|
||||
const agentStore = useAgentStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
Reference in New Issue
Block a user