无人机管理后台前端(已迁走)
张含笑
2025-07-15 3e95801a935a0091bb2502c05fb02e6062246935
feat:开发环境不跳大屏登陆页面
2 files modified
74 ■■■■ changed files
src/axios.js 69 ●●●● patch | view | raw | blame | history
src/page/index/top/index.vue 5 ●●●●● patch | view | raw | blame | history
src/axios.js
@@ -9,32 +9,17 @@
import axios from 'axios';
import store from '@/store/';
import router from '@/router/';
import {
    serialize
} from '@/utils/util';
import {
    getToken,
    removeToken,
    removeRefreshToken
} from '@/utils/auth';
import {
    isURL,
    validatenull
} from '@/utils/validate';
import {
    ElMessage
} from 'element-plus';
import { serialize } from '@/utils/util';
import { getToken, removeToken, removeRefreshToken } from '@/utils/auth';
import { isURL, validatenull } from '@/utils/validate';
import { ElMessage } from 'element-plus';
import website from '@/config/website';
import NProgress from 'nprogress'; // progress bar
import 'nprogress/nprogress.css'; // progress bar style
import {
    Base64
} from 'js-base64';
import {
    baseUrl
} from '@/config/env';
import { Base64 } from 'js-base64';
import { baseUrl } from '@/config/env';
import crypto from '@/utils/crypto';
const adminUrl = import.meta.env.VITE_APP_DASHBOARD_URL
const adminUrl = import.meta.env.VITE_APP_DASHBOARD_URL;
// 全局未授权错误提示状态,只提示一次
let isErrorShown = false;
@@ -63,7 +48,7 @@
            config.url = baseUrl + config.url;
        }
        //安全请求header
        config.headers['areaCode'] = store?.state?.user?.userInfo?.detail?.areaCode
    config.headers['areaCode'] = store?.state?.user?.userInfo?.detail?.areaCode;
        config.headers['Blade-Requested-With'] = 'BladeHttpRequest';
        //headers判断是否需要
        const authorization = config.authorization === false;
@@ -81,9 +66,9 @@
        const cryptoData = config.cryptoData === true;
        const token = getToken();
        if (token && !isToken) {
            config.headers[website.tokenHeader] = cryptoToken ?
                'crypto ' + crypto.encryptAES(token, crypto.cryptoKey) :
                'bearer ' + token;
      config.headers[website.tokenHeader] = cryptoToken
        ? 'crypto ' + crypto.encryptAES(token, crypto.cryptoKey)
        : 'bearer ' + token;
        }
        // 开启报文加密
        // if (cryptoData) {
@@ -128,9 +113,11 @@
            const currentRouteName = router.currentRoute.value.name;
            // 如果当前路由不是登录页,则跳转到登录页
            if (currentRouteName !== '登录页') {
                store.dispatch('FedLogOut').then(() => router.push({
                    path: '/login'
                }));
        store.dispatch('FedLogOut').then(() =>
          router.push({
            path: '/login',
          })
        );
            }
            return Promise.reject(new Error(message));
        }
@@ -150,9 +137,9 @@
                    // 获取刷新后的token
                    const token = getToken();
                    if (token && !isToken) {
                        config.headers[website.tokenHeader] = cryptoToken ?
                            'crypto ' + crypto.encryptAES(token, crypto.cryptoKey) :
                            'bearer ' + token;
            config.headers[website.tokenHeader] = cryptoToken
              ? 'crypto ' + crypto.encryptAES(token, crypto.cryptoKey)
              : 'bearer ' + token;
                    }
                    // 重新发送原来的请求
                    return axios(config);
@@ -169,11 +156,18 @@
                    // 清除token信息
                    removeToken();
                    removeRefreshToken();
          const env = import.meta.env.VITE_APP_ENV;
                    // 重定向到登录页
                    // store.dispatch('FedLogOut').then(() => router.push({
                    //     path: '/login'
                    // }));
                    store.dispatch('FedLogOut').then(() =>  window.location.replace(`${adminUrl}#/login`));
          env === 'development'
            ? store.dispatch('FedLogOut').then(() =>
                router.push({
                  path: '/login',
                })
              )
            : store.dispatch('FedLogOut').then(() => window.location.replace(`${adminUrl}#/login`));
                    return Promise.reject(new Error(message));
                });
        }
@@ -194,7 +188,14 @@
            // store.dispatch('FedLogOut').then(() => router.push({
            //     path: '/login'
            // }));
            store.dispatch('FedLogOut').then(() =>  window.location.replace(`${adminUrl}#/login`));
      const env = import.meta.env.VITE_APP_ENV;
      env === 'development'
        ? store.dispatch('FedLogOut').then(() =>
            router.push({
              path: '/login',
            })
          )
        : store.dispatch('FedLogOut').then(() => window.location.replace(`${adminUrl}#/login`));
            return Promise.reject(new Error(message));
        }
        // 如果请求为oauth2错误码则首次报错时提示
src/page/index/top/index.vue
@@ -102,9 +102,10 @@
        type: 'warning',
      }).then(() => {
        this.$store.dispatch('LogOut').then(() => {
          // this.$router.push({ path: '/login' })
        const env = import.meta.env.VITE_APP_ENV
          const adminUrl = import.meta.env.VITE_APP_DASHBOARD_URL
          window.location.replace(`${adminUrl}#/login`)
           env === 'development' ? this.$router.push({ path: '/login' }):window.location.replace(`${adminUrl}#/login`)
        })
      })
    },