setup.global.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export default defineNuxtRouteMiddleware(async (to, from) => {
  2. // const router = useRouter()
  3. // const responseRoute = await $fetch('http://apipre1.bjzxtw.org.cn:29501/web/getWebsiteParentCategory', {
  4. // headers: {
  5. // 'Content-Type': 'application/json',
  6. // 'Userurl': 'http://apipre1.bjzxtw.org.cn:29501',
  7. // 'Origin': 'http://apipre1.bjzxtw.org.cn:29501'
  8. // }
  9. // })
  10. // //添加所有分类页路由
  11. // for(let index in responseRoute.data.parent){
  12. // if(responseRoute.data.parent[index].path!=undefined){
  13. // router.addRoute({
  14. // path: responseRoute.data.parent[index].path,
  15. // component: () => import('~/pages/primaryNavigation/[id].vue'),
  16. // meta: {
  17. // isAlias: true,
  18. // routeId: responseRoute.data.parent[index].cid,
  19. // routeName: responseRoute.data.parent[index].name
  20. // }
  21. // })
  22. // }
  23. // }
  24. // //添加所有列表路由
  25. // for(let index in responseRoute.data.child){
  26. // if(responseRoute.data.child[index].path!=undefined){
  27. // router.addRoute({
  28. // path: responseRoute.data.child[index].path,
  29. // component: () => import('~/pages/newsList/[id].vue'),
  30. // meta: {
  31. // isAlias: true,
  32. // routeId: responseRoute.data.child[index].cid,
  33. // routeName: responseRoute.data.child[index].name
  34. // }
  35. // })
  36. // }
  37. // }
  38. // console.log('进入路由中间件,目标路由:', to.path, "当前路由:", from.path);
  39. })