吉安感知网项目-前端
罗广辉
2026-02-05 2a0e798513986b5ecfae7fdacfcdbea0bc7b5087
applications/mobile-web-view/src/axios.js
@@ -20,7 +20,7 @@
import { getStore } from '@/utils/store'
import { showToast } from 'vant'
let baseUrl = import.meta.env.VITE_APP_API
let { VITE_APP_ENV,VITE_APP_XT_URL,VITE_APP_API } = import.meta.env
// 全局未授权错误提示状态,只提示一次
let isErrorShown = false
// 全局锁机制相关变量
@@ -48,18 +48,21 @@
      // 初始化错误提示状态
      isErrorShown = false
      //地址为已经配置状态则不添加前缀
      if (!isBase && !isURL(config.url) && !config.url.startsWith(baseUrl)) {
         config.url = baseUrl + config.url
      if (!isBase && !isURL(config.url) && !config.url.startsWith(VITE_APP_API)) {
         config.url = VITE_APP_API + config.url
      }
      config.url = VITE_APP_ENV === 'development' ? config.url : VITE_APP_XT_URL + config.url
      config.headers['areaCode'] = store.state.user.selectedAreaCode
      //安全请求header
      config.headers['Blade-Requested-With'] = 'BladeHttpRequest'
      //headers判断是否需要
      const authorization = config.authorization === false
      if (!authorization) {
         config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`
      }
      // const authorization = config.authorization === false
      // if (!authorization) {
      //    config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`
      // }
      let authorization = store.state.user.token
      config.headers['Authorization'] = authorization
      // 根据后端要求,post的data为空的话传{}
      if (config.method === 'post') {
         config.data = config.data || {}