Commit e0aa2f98 authored by 纪泽龙's avatar 纪泽龙

跳转bigwindow加动画效果

parent a450c54b
<!--
* @Author: your name
* @Date: 2022-02-26 22:22:56
* @LastEditTime: 2022-03-31 15:28:05
* @LastEditors: Please set LastEditors
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: /gassafety-progress/gassafetyprogress-web/src/App.vue
-->
<template> <template>
<div id="app"> <div id="app">
<router-view /> <transition name="fade" mode="out-in">
<router-view />
</transition>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'App' name: "App",
} };
</script> </script>
import router from './router' import router from "./router";
import store from './store' import store from "./store";
import { Message } from 'element-ui' import { Message } from "element-ui";
import NProgress from 'nprogress' import NProgress from "nprogress";
import 'nprogress/nprogress.css' import "nprogress/nprogress.css";
import { getToken } from '@/utils/auth' import { getToken } from "@/utils/auth";
NProgress.configure({ showSpinner: false }) NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] const whiteList = ["/login", "/auth-redirect", "/bind", "/register"];
// 路由前置守卫
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start();
// 如果cookie里有token
if (getToken()) { if (getToken()) {
/* has token*/ /* has token*/
if (to.path === '/login') { // 如果要去login,就直接去默认页面
next({ path: '/' }) if (to.path === "/login") {
NProgress.done() next({ path: "/" });
NProgress.done();
} else { } else {
// 如果没有获得当前用户的所有信息
if (store.getters.roles.length === 0) { if (store.getters.roles.length === 0) {
// 判断当前用户是否已拉取完user_info信息 // 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(() => { store
store.dispatch('GenerateRoutes').then(accessRoutes => { .dispatch("GetInfo")
// 根据roles权限生成可访问的路由表 .then(() => {
router.addRoutes(accessRoutes) // 动态添加可访问路由表 // 生成路有树
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 store.dispatch("GenerateRoutes").then((accessRoutes) => {
}) // 根据roles权限生成可访问的路由表
}).catch(err => { router.addRoutes(accessRoutes); // 动态添加可访问路由表
store.dispatch('LogOut').then(() => { next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
Message.error(err) });
next({ path: '/' })
})
}) })
.catch((err) => {
store.dispatch("LogOut").then(() => {
Message.error(err);
next({ path: "/" });
});
});
} else { } else {
next() next();
// // 判断各种浏览器,找到正确的方法
// function launchFullscreen(element) {
// if (element.requestFullscreen) {
// element.requestFullscreen();
// } else if (element.mozRequestFullScreen) {
// element.mozRequestFullScreen();
// } else if (element.webkitRequestFullscreen) {
// element.webkitRequestFullscreen();
// } else if (element.msRequestFullscreen) {
// element.msRequestFullscreen();
// }
// }
// launchFullscreen(document.documentElement)
} }
} }
} else { } else {
// 没有token // 没有token
if (whiteList.indexOf(to.path) !== -1) { if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入 // 在免登录白名单,直接进入
next() next();
} else { } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
NProgress.done() NProgress.done();
} }
} }
}) });
router.afterEach(() => { router.afterEach(() => {
NProgress.done() NProgress.done();
}) });
...@@ -39,6 +39,8 @@ const permission = { ...@@ -39,6 +39,8 @@ const permission = {
getRouters().then(res => { getRouters().then(res => {
const sdata = JSON.parse(JSON.stringify(res.data)) const sdata = JSON.parse(JSON.stringify(res.data))
const rdata = JSON.parse(JSON.stringify(res.data)) const rdata = JSON.parse(JSON.stringify(res.data))
const sidebarRoutes = filterAsyncRouter(sdata) const sidebarRoutes = filterAsyncRouter(sdata)
const rewriteRoutes = filterAsyncRouter(rdata, false, true) const rewriteRoutes = filterAsyncRouter(rdata, false, true)
rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment