| | |
| | | /* |
| | | * @Author: GuLiMmo 2820890765@qq.com |
| | | * @Date: 2024-08-23 10:51:53 |
| | | * @LastEditors: GuLiMmo 2820890765@qq.com |
| | | * @LastEditTime: 2024-08-29 14:10:56 |
| | | * @FilePath: /drone-web-manage/src/permission.js |
| | | * @Description: |
| | | * Copyright (c) 2024 by GuLiMmo, All Rights Reserved. |
| | | */ |
| | | import router from './router/'; |
| | | import store from './store'; |
| | | import { getToken } from '@/utils/auth'; |
| | | import { getUrlParams } from './utils/validate' |
| | | import NProgress from 'nprogress'; // progress bar |
| | | import 'nprogress/nprogress.css'; // progress bar style |
| | | NProgress.configure({ showSpinner: false }); |
| | | const lockPage = '/lock'; //锁屏页 |
| | | const urlParams = getUrlParams(window.location.href) |
| | | |
| | | router.beforeEach((to, from, next) => { |
| | | const meta = to.meta || {}; |
| | | const isMenu = meta.menu === undefined ? to.query.menu : meta.menu; |
| | |
| | | //如果登录成功访问登录页跳转到主页 |
| | | next({ path: '/' }); |
| | | } else { |
| | | if (store.getters.token.length === 0) { |
| | | const systemToken = store.getters.token || urlParams?.token |
| | | if (systemToken === 0) { |
| | | store.dispatch('FedLogOut').then(() => { |
| | | next({ path: '/login' }); |
| | | }); |