diff --git a/src/api/axios.ts b/src/api/axios.ts index ed8b846..25b1450 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -19,7 +19,7 @@ export interface MyRequestInstance extends Axios { (config: AxiosRequestConfig): Promise> } -const axiosInstance = axios.create({ +const a = axios.create({ baseURL: `${import.meta.env.PROD ? import.meta.env.VITE_PRO_PATH : ''}${axiosPre}`, timeout: ResultEnum.TIMEOUT }) as unknown as MyRequestInstance diff --git a/src/packages/components/Charts/ConfinedSpace/AlarmNowList/index.vue b/src/packages/components/Charts/ConfinedSpace/AlarmNowList/index.vue index e79906d..feda12f 100644 --- a/src/packages/components/Charts/ConfinedSpace/AlarmNowList/index.vue +++ b/src/packages/components/Charts/ConfinedSpace/AlarmNowList/index.vue @@ -139,7 +139,7 @@ import axiosInstance from '@/api/axios' import VChart from 'vue-echarts' import SmallBorder from '../SmallBorder01Co/index.vue' import { height } from 'dom-helpers' -import axios from 'axios' + const props = defineProps({ chartConfig: { type: Object as PropType, @@ -273,10 +273,11 @@ const formatAlarmItem = (item) => { const fetchRecentAlarms = async () => { try { isLoading.value = true; - const res = await axios.get( + const res = await axiosInstance.get( `/awjt/space/getRecentAlarms`, { responseType: 'json', + baseURL: '', } ); if (res.data.state === true) { diff --git a/src/packages/components/Charts/HazardousChemicalsSpace/AlarmListHazC/index.vue b/src/packages/components/Charts/HazardousChemicalsSpace/AlarmListHazC/index.vue index 69cf55e..fba69fe 100644 --- a/src/packages/components/Charts/HazardousChemicalsSpace/AlarmListHazC/index.vue +++ b/src/packages/components/Charts/HazardousChemicalsSpace/AlarmListHazC/index.vue @@ -59,7 +59,8 @@ import { PropType, computed, ref, onMounted, onUnmounted } from 'vue' import { option as configOption } from './config' import SmallBorder from '../SmallBorder/index.vue' -import axios from 'axios' +import axiosInstance from '@/api/axios' + const props = defineProps({ chartConfig: { type: Object as PropType<{ option: typeof configOption }>, @@ -87,10 +88,11 @@ const convertTimestampToDateTime = (timestamp: number | string) => { const fetchRecentAlarms = async () => { try { - const res = await axios.get( + const res = await axiosInstance.get( `/awjt/space/getRecentAlarms`, // 手动添加 dev { responseType: 'json', + baseURL:'' } ); diff --git a/src/packages/components/Charts/HazardousChemicalsSpace/LineDropdownHaz/index.vue b/src/packages/components/Charts/HazardousChemicalsSpace/LineDropdownHaz/index.vue index 43930ec..62563a6 100644 --- a/src/packages/components/Charts/HazardousChemicalsSpace/LineDropdownHaz/index.vue +++ b/src/packages/components/Charts/HazardousChemicalsSpace/LineDropdownHaz/index.vue @@ -38,7 +38,7 @@ import { mergeTheme } from '@/packages/public/chart' import config, { includes } from './config' import { DatasetComponent, GridComponent, TooltipComponent } from 'echarts/components' import CustomSelect from './select.vue' -import axios from 'axios' +import axiosInstance from '@/api/axios' const props = defineProps({ themeSetting: { @@ -74,7 +74,8 @@ use([DatasetComponent, CanvasRenderer, LineChart, GridComponent, TooltipComponen // API调用函数 const fetchChartData = async (timeType: string, riskLevel: number) => { try { - const response = await axios.get(`/awjt/screen/alarmByOption/${timeType}/${riskLevel}`) + const response = await axiosInstance.get(`/awjt/screen/alarmByOption/${timeType}/${riskLevel}`, + {baseURL:''}) if (response.data.state === true) { return response.data.value || [] } else { diff --git a/src/packages/components/Charts/HazardousChemicalsSpace/LineGraph01Haz/index.vue b/src/packages/components/Charts/HazardousChemicalsSpace/LineGraph01Haz/index.vue index d81d0a4..2700e26 100644 --- a/src/packages/components/Charts/HazardousChemicalsSpace/LineGraph01Haz/index.vue +++ b/src/packages/components/Charts/HazardousChemicalsSpace/LineGraph01Haz/index.vue @@ -49,7 +49,7 @@ import { useChartDataFetch } from '@/hooks' import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components' import isObject from 'lodash/isObject' import CustomSelect from './select.vue' -import axios from 'axios' +import axiosInstance from '@/api/axios' const props = defineProps({ themeSetting: { @@ -82,7 +82,7 @@ const selectedTimeRange = ref('day') // API调用函数 const fetchChartData = async (option: string) => { try { - const response = await axios.get(`/awjt/screen/handleByOption/${option}`) + const response = await axiosInstance.get(`/awjt/screen/handleByOption/${option}`,{baseURL:''}) if (response.data.state === true) { return response.data.value || [] } else { diff --git a/src/packages/components/Charts/HazardousChemicalsSpace/PieCenterHaz/index.vue b/src/packages/components/Charts/HazardousChemicalsSpace/PieCenterHaz/index.vue index cc2a78c..afb090f 100644 --- a/src/packages/components/Charts/HazardousChemicalsSpace/PieCenterHaz/index.vue +++ b/src/packages/components/Charts/HazardousChemicalsSpace/PieCenterHaz/index.vue @@ -24,7 +24,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent, GraphicComponent } from 'echarts/components' import CustomSelect from './select.vue' import dataJson from './data.json' -import axios from 'axios' +import axiosInstance from '@/api/axios' const props = defineProps({ themeSetting: { @@ -236,11 +236,12 @@ function generateTimeRange(period: string): { startTime: string; endTime: string // 异步获取报警数据 async function fetchAlarmData({ startTime, endTime }: { startTime: string; endTime: string }) { try { - const res = await axios.get( + const res = await axiosInstance.get( `/awjt/getAlarmdataRecord`, { params: { startTime, endTime }, // 请求参数 responseType: 'json', + baseURL:'' } ); diff --git a/src/packages/components/Charts/HazardousChemicalsSpace/TopAlarmsHaz/index.vue b/src/packages/components/Charts/HazardousChemicalsSpace/TopAlarmsHaz/index.vue index e5969a6..0b29203 100644 --- a/src/packages/components/Charts/HazardousChemicalsSpace/TopAlarmsHaz/index.vue +++ b/src/packages/components/Charts/HazardousChemicalsSpace/TopAlarmsHaz/index.vue @@ -55,7 +55,7 @@ import { ref, computed, PropType, onMounted } from 'vue' import { option as configOption } from './config' import SmallBorder from '../SmallBorder/index.vue' import CustomSelect from './select.vue' -import axios from 'axios' +import axiosInstance from '@/api/axios' const props = defineProps({ chartConfig: { @@ -89,7 +89,7 @@ const calculateWidth = (value: number) => { // 新增:API调用函数 const fetchCorpsData = async (option: string) => { try { - const response = await axios.get(`/awjt/screen/corpsFive/${option}`) + const response = await axiosInstance.get(`/awjt/screen/corpsFive/${option}`,{baseURL:''}) if (response.data.state === true) { displayData.value = response.data.value || [] } else { diff --git a/vite.config.ts b/vite.config.ts index 8a83b97..0f46979 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -66,9 +66,15 @@ export default ({ mode }) => rewrite: (path) => path.replace(/^\/aw/, '') }, '/awjt/': { - target: 'http://127.0.0.1:8921/', - changeOrigin: true - }, '/dev': { + target: 'http://127.0.0.1:8080/', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/awjt/, '') + }, + // '/awjt/': { + // target: 'http://127.0.0.1:8921/', + // changeOrigin: true + // }, + '/dev': { target: 'http://127.0.0.1:8080', changeOrigin: true, rewrite: (path) => path.replace(/^\/dev/, '')