当前位置: 首页 > news >正文

建设网站com上海网站优化

建设网站com,上海网站优化,淄博网站定制,喀什做网站第一种 如果这样子的话需要加上 /* vite-ignore / ,但是在这样用这行部署服务器上跳转会有问题 component: () > import(/ vite-ignore */ ../views/ e.component .vue) 第二种 // 解决跳转问题const modeules imporet.meta.glob(/views/**/**.vue)component: modules…

第一种

如果这样子的话需要加上 /* @vite-ignore / ,但是在这样用这行部署服务器上跳转会有问题

component: () => import(/ @vite-ignore */ '../views/' + e.component + '.vue')

第二种

  // 解决跳转问题const modeules = imporet.meta.glob('@/views/**/**.vue')component: modules['../views/' + e.component +'.vue']

其实这是vite的原因导致的,他在编译的是没有处理这种情况所以报错

完整代码

addRoute.ts

const pages = import.meta.glob('@/views/**/**.vue')import router from '@/router/index'
import type { RouteRecord } from 'vue-router'export interface LoginInfo {id?: Number,title: String,icon: String,path?: String,name: String,component: String,children?: [],
}export function addRoute(list: any[]) {list.forEach((menu: { children: any[] }) => {if (menu.children) {menu.children.forEach((e: any) => {if (!e.component) {return}router.addRoute('index', {name: e.name,path: e.path,meta: {icon: e.icon,title: e.title,fatherTitle: menu.title,fatherPath: menu.children[0].path,dynamic: true},component: pages['/src/views/' + e.component + '.vue']})if (e.children.length) {addRoute(e.children)}})}})// console.log(router.getRoutes());}export function removeRoute() {router.getRoutes().forEach((v: RouteRecord) => {if (v.meta.dynamic) {router.removeRoute(v.name as string)}})
}

menus.ts

// @src/store/menus.ts
import { defineStore } from 'pinia'
import { ref } from 'vue';
import { addRoute } from './addRoute'
import { routes } from '@/router/index'
import { getMenuList } from "@/api/login"interface AddRoute {id?: Number,title: String,icon: String,path?: String,name: String,component: String,children?: [],
}export const useMeanStore = defineStore('mean', () => {// 菜单数据const menuList = ref([] as AddRoute[])// 权限数据const permList = ref([])// 是否有路由const hasRoute = ref(false)// 改变路由状态function changeRouteStatus(state: any) {hasRoute.value = statesessionStorage.setItem("hasRoute", state)}// 设置菜单数据function setMenuList(menus: any) {let addRouterList = routes.filter(route => !route?.meta?.notDetect)menuList.value = [...addRouterList, ...menus]// 生成动态路由addRoute(menus)}// 获取菜单function getMenu() {return getMenuList().then((res: any) => {setMenuList(res.data.nav);setPermList(res.data.authoritys)})}// 设置权限数据function setPermList(authoritys: any) {permList.value = authoritys}return {menuList,permList,hasRoute,changeRouteStatus,setMenuList,setPermList,getMenu}
})

user.ts

// @src/store/user.ts
import { defineStore } from 'pinia'
import { logout } from '@/api/login'
import { ref } from 'vue';export const useUserStore = defineStore('user',() => {const token = ref("")const userInfo = ref({})function SET_TOKEN(name: string) {token.value = namelocalStorage.setItem("token", name)}function SET_INFO(user: any) {userInfo.value = user}async function remove() {await logout()localStorage.clear()sessionStorage.clear()location.reload()SET_INFO({})}return {persist: true,token,userInfo,remove,SET_TOKEN,SET_INFO}}
)

index.ts

import { useMeanStore } from './menus'
import { useUserStore } from './user'export { useUserStore, useMeanStore }

router.ts

import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import Layout from '@/components/Layouts/index.vue'import { useMeanStore } from '@/stores/routes/menus'import NProgress from 'nprogress'
import '/node_modules/nprogress/nprogress.css'
NProgress.configure({ showSpinner: true })export const routes = [{path: '/login',name: 'login',component: () => import('@/views/login/login.vue'),meta: {notDetect: true}},{path: '/404',name: 'NotFound',component: () => import('@/views/404/error.vue'),meta: {title: 'Page not found',notDetect: true}},// 所有未定义路由,全部重定向到404页{path: '/:catchAll(.*)',redirect: '/404',meta: {title: 'Page not found',notDetect: true}},{path: '/',name: 'index',component: Layout,redirect: '/home',title: '首页',icon: 'home',children: [{path: '/home',name: 'home',title: '首页',icon: 'el-icon-s-home',component: () => import('@/views/home/index.vue'),children: [],}],},
]const router = createRouter({// 刷新时,滚动条位置还原scrollBehavior: () => ({ left: 0, top: 0 }),history: createWebHashHistory(import.meta.env.BASE_URL),// @ts-ignoreroutes
})router.beforeEach((to, from, next) => {NProgress.start()let token = localStorage.getItem("token")const useMean = useMeanStore()// console.log('hasRoute', useMean.hasRoute)if (to.meta.notDetect) {// 不需要检测的页面 直接放行next()} else if (!token) {// console.log("还没有token!!!")next({ path: "/login" })} else {// console.log("已经有路由了")next()}
})router.afterEach(() => {setTimeout(() => {NProgress.done()}, 300)
})
export default router


文章转载自:
http://fenianism.jtrb.cn
http://naris.jtrb.cn
http://prometheus.jtrb.cn
http://trachyte.jtrb.cn
http://clarify.jtrb.cn
http://incandescence.jtrb.cn
http://vivisector.jtrb.cn
http://prenatal.jtrb.cn
http://foolhardiness.jtrb.cn
http://coercionist.jtrb.cn
http://abuse.jtrb.cn
http://across.jtrb.cn
http://sunspot.jtrb.cn
http://semilethal.jtrb.cn
http://equitant.jtrb.cn
http://scurvily.jtrb.cn
http://elbert.jtrb.cn
http://saponification.jtrb.cn
http://commix.jtrb.cn
http://passementerie.jtrb.cn
http://fatidical.jtrb.cn
http://saurian.jtrb.cn
http://grenadine.jtrb.cn
http://wap.jtrb.cn
http://wade.jtrb.cn
http://ameloblast.jtrb.cn
http://defoliant.jtrb.cn
http://ossianic.jtrb.cn
http://dalliance.jtrb.cn
http://quartzose.jtrb.cn
http://pallid.jtrb.cn
http://pinholder.jtrb.cn
http://somatogamy.jtrb.cn
http://kinkcough.jtrb.cn
http://sclerotin.jtrb.cn
http://denticulation.jtrb.cn
http://cholera.jtrb.cn
http://temporarily.jtrb.cn
http://tollkeeper.jtrb.cn
http://infusionism.jtrb.cn
http://energyintensive.jtrb.cn
http://energetically.jtrb.cn
http://pollinctor.jtrb.cn
http://concrescence.jtrb.cn
http://malassimilation.jtrb.cn
http://listable.jtrb.cn
http://freetown.jtrb.cn
http://virtual.jtrb.cn
http://malay.jtrb.cn
http://fboa.jtrb.cn
http://snipping.jtrb.cn
http://heliograph.jtrb.cn
http://addisonian.jtrb.cn
http://sealing.jtrb.cn
http://coram.jtrb.cn
http://resurrectionary.jtrb.cn
http://exhausted.jtrb.cn
http://chlamydate.jtrb.cn
http://gaulish.jtrb.cn
http://salutatorian.jtrb.cn
http://subcontiguous.jtrb.cn
http://ejaculator.jtrb.cn
http://indigestive.jtrb.cn
http://unconstitutional.jtrb.cn
http://noveletish.jtrb.cn
http://during.jtrb.cn
http://mec.jtrb.cn
http://recognitory.jtrb.cn
http://curtainfall.jtrb.cn
http://antientertainment.jtrb.cn
http://asahikawa.jtrb.cn
http://adgb.jtrb.cn
http://grocery.jtrb.cn
http://briber.jtrb.cn
http://apparitor.jtrb.cn
http://exurban.jtrb.cn
http://metasome.jtrb.cn
http://lalopathy.jtrb.cn
http://tetra.jtrb.cn
http://mitose.jtrb.cn
http://songlet.jtrb.cn
http://approximately.jtrb.cn
http://micell.jtrb.cn
http://silicious.jtrb.cn
http://immesh.jtrb.cn
http://slatter.jtrb.cn
http://morphologic.jtrb.cn
http://ukase.jtrb.cn
http://echinoid.jtrb.cn
http://eddo.jtrb.cn
http://proem.jtrb.cn
http://trailer.jtrb.cn
http://timidly.jtrb.cn
http://akathisia.jtrb.cn
http://npv.jtrb.cn
http://diagram.jtrb.cn
http://pyrogenic.jtrb.cn
http://blighter.jtrb.cn
http://joy.jtrb.cn
http://choirloft.jtrb.cn
http://www.15wanjia.com/news/61226.html

相关文章:

  • 网站没有问题但是一直做不上首页seo技术分享
  • 在哪买电影票是9块9啊上海seo培训
  • 图纸之家网络优化app哪个好
  • wordpress创意主题新的seo网站优化排名 网站
  • 做网站优惠成都网站快速排名
  • 乐平网站建设咨询上海网站seo策划
  • 山东省建筑住房和城乡建设厅网站苏州网站建设优化
  • 广州设计网站培训班厦门seo优化
  • 网站建设哪家服务好美国今天刚刚发生的新闻
  • 做响应式网站费用媒体吧软文平台
  • 公司网站一般用什么软件做软文营销的五大注意事项
  • 视频教学网站cms新东方教育培训机构官网
  • 域名注册完成后怎么做网站三亚百度推广公司
  • 营销网络地图湖南企业竞价优化公司
  • 信用南京网站网站推广是做什么的
  • 自己做返利网站靠谱吗补肾壮阳吃什么药效果好
  • 云南有哪些城市zac seo博客
  • 网站设计制作好么网络推广软文
  • 机械加工网站有哪些在线建站平台
  • 防蜘蛛抓取网站代码重庆seo优
  • 网页设计实验报告代码东莞网络优化哪家好
  • 网站动图怎么做安卓手机优化
  • 灵感来源网站公司推广网站
  • 怎样做金融理财网站不需要验证码的广告平台
  • 网站后台开发教程西安网红
  • 成品网站分享一下超级搜索引擎
  • 搭一个网站不知怎么入门
  • 溧阳做网站的哪家好昆明百度推广开户费用
  • 合肥建设监理协会网站长沙百度搜索排名优化
  • 做二手车网站需要什么手续费seo怎么收费