fix: 修复API请求配置和代理设置

This commit is contained in:
Free-sss 2025-09-02 14:41:58 +08:00
parent 49b4b663d2
commit 161b180e01
7 changed files with 24 additions and 25 deletions

View File

@ -30,7 +30,6 @@ import {
TitleComponent, GraphicComponent TitleComponent, GraphicComponent
} from 'echarts/components' } from 'echarts/components'
import axios from 'axios'
import axiosInstance from '@/api/axios' import axiosInstance from '@/api/axios'

View File

@ -528,7 +528,7 @@ const getDataSource = (newData: any) => {
const fetchCameraTree = async () => { const fetchCameraTree = async () => {
console.log('fetchCameraTree: 正在获取摄像头树数据...'); console.log('fetchCameraTree: 正在获取摄像头树数据...');
try { try {
const res = await axiosInstance.get('/awjt/api/camera/tree', { baseURL: '' }); const res = await axiosInstance.get('/awjt/api/camera/tree', { baseURL: '' ,responseType: 'json' });
console.log("API 响应数据 (Camera Tree):", res); console.log("API 响应数据 (Camera Tree):", res);
if (res && res.state === true) { if (res && res.state === true) {
console.log("API 响应数据 (Camera Tree):", res.value); console.log("API 响应数据 (Camera Tree):", res.value);

View File

@ -88,8 +88,8 @@ const convertTimestampToDateTime = (timestamp: number | string) => {
const fetchRecentAlarms = async () => { const fetchRecentAlarms = async () => {
try { try {
const res = await axiosInstance.get( const res:any = await axiosInstance.get(
`/awjt/space/getRecentAlarms`, // dev `/awjt/space/getRecentAlarms`,
{ {
responseType: 'json', responseType: 'json',
baseURL:'' baseURL:''
@ -97,12 +97,12 @@ const fetchRecentAlarms = async () => {
); );
if (res.data.state === true) { if (res.state === true) {
let rawData = []; let rawData = [];
if (Array.isArray(res.data.value.items)) { if (Array.isArray(res.value.items)) {
rawData = res.data.value.items; rawData = res.data.value.items;
} else if (Array.isArray(res.data.value)) { } else if (Array.isArray(res.value)) {
rawData = res.data.value; rawData = res.value;
} }
const formattedData = rawData.map((item: any) => { const formattedData = rawData.map((item: any) => {

View File

@ -74,12 +74,12 @@ use([DatasetComponent, CanvasRenderer, LineChart, GridComponent, TooltipComponen
// API // API
const fetchChartData = async (timeType: string, riskLevel: number) => { const fetchChartData = async (timeType: string, riskLevel: number) => {
try { try {
const response = await axiosInstance.get(`/awjt/screen/alarmByOption/${timeType}/${riskLevel}`, const response:any = await axiosInstance.get(`/awjt/screen/alarmByOption/${timeType}/${riskLevel}`,
{baseURL:''}) {baseURL:''})
if (response.data.state === true) { if (response.state === true) {
return response.data.value || [] return response.value || []
} else { } else {
console.error('API调用失败:', response.data) console.error('API调用失败:', response)
return [] return []
} }
} catch (error) { } catch (error) {

View File

@ -82,11 +82,11 @@ const selectedTimeRange = ref('day')
// API // API
const fetchChartData = async (option: string) => { const fetchChartData = async (option: string) => {
try { try {
const response = await axiosInstance.get(`/awjt/screen/handleByOption/${option}`,{baseURL:''}) const response:any = await axiosInstance.get(`/awjt/screen/handleByOption/${option}`,{baseURL:''})
if (response.data.state === true) { if (response.state === true) {
return response.data.value || [] return response.value || []
} else { } else {
console.error('API调用失败:', response.data) console.error('API调用失败:', response)
return [] return []
} }
} catch (error) { } catch (error) {

View File

@ -236,7 +236,7 @@ function generateTimeRange(period: string): { startTime: string; endTime: string
// //
async function fetchAlarmData({ startTime, endTime }: { startTime: string; endTime: string }) { async function fetchAlarmData({ startTime, endTime }: { startTime: string; endTime: string }) {
try { try {
const res = await axiosInstance.get( const res:any = await axiosInstance.get(
`/awjt/getAlarmdataRecord`, `/awjt/getAlarmdataRecord`,
{ {
params: { startTime, endTime }, // params: { startTime, endTime }, //
@ -245,12 +245,12 @@ async function fetchAlarmData({ startTime, endTime }: { startTime: string; endTi
} }
); );
if (res.status === 200 && res.data) { if ( res) {
console.log("API 响应数据:", res.data); console.log("API 响应数据:", res);
// //
return { return {
dimensions: ['name', 'value'], dimensions: ['name', 'value'],
source: res.data.map((item: any) => ({ source: res.map((item: any) => ({
name: item.alarmLevel, name: item.alarmLevel,
value: item.alarmNun value: item.alarmNun
})) }))

View File

@ -68,7 +68,7 @@ const option = computed(() => props.chartConfig.option)
const selectedOption = ref(props.chartConfig.option.dropdownDefault) const selectedOption = ref(props.chartConfig.option.dropdownDefault)
// API // API
const displayData = ref([]) const displayData: any = ref([])
const dropdownOptions = computed(() => { const dropdownOptions = computed(() => {
return props.chartConfig.option.dropdownOptions.map(opt => ({ return props.chartConfig.option.dropdownOptions.map(opt => ({
@ -89,11 +89,11 @@ const calculateWidth = (value: number) => {
// API // API
const fetchCorpsData = async (option: string) => { const fetchCorpsData = async (option: string) => {
try { try {
const response = await axiosInstance.get(`/awjt/screen/corpsFive/${option}`,{baseURL:''}) const response: any = await axiosInstance.get(`/awjt/screen/corpsFive/${option}`, { baseURL: '' })
if (response.data.state === true) { if (response.state === true) {
displayData.value = response.data.value || [] displayData.value = response.value || []
} else { } else {
console.error('API调用失败:', response.data) console.error('API调用失败:', response)
displayData.value = [] displayData.value = []
} }
} catch (error) { } catch (error) {