提交 c797a3a4 编写于 作者: 郝先瑞

fix: 跳转不存在的路由空白页面问题修复

上级 f4420986
......@@ -69,7 +69,7 @@ import LangSelect from '@/components/LangSelect/index.vue';
// 图标依赖
import { CaretBottom } from '@element-plus/icons-vue';
const { app, user } = useStore();
const { app, user, tagsView } = useStore();
const route = useRoute();
const router = useRouter();
......@@ -88,9 +88,14 @@ function logout() {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
user.logout().then(() => {
router.push(`/login?redirect=${route.fullPath}`);
});
user
.logout()
.then(() => {
tagsView.delAllViews();
})
.then(() => {
router.push(`/login?redirect=${route.fullPath}`);
});
});
}
</script>
......
......@@ -9,7 +9,6 @@ NProgress.configure({ showSpinner: false }); // 进度环显示/隐藏
const whiteList = ['/login', '/auth-redirect'];
router.beforeEach(async (to, from, next) => {
console.log('beforeEach', to);
NProgress.start();
const { user, permission } = useStore();
const hasToken = user.token;
......@@ -21,7 +20,11 @@ router.beforeEach(async (to, from, next) => {
} else {
const hasGetUserInfo = user.roles.length > 0;
if (hasGetUserInfo) {
next();
if (to.matched.length === 0) {
from.name ? next({ name: from.name }) : next('/');
} else {
next();
}
} else {
try {
await user.getUserInfo();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册