fix: 修复API请求配置和代理设置
This commit is contained in:
parent
49b4b663d2
commit
161b180e01
@ -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'
|
||||||
|
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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) => {
|
||||||
|
@ -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) {
|
||||||
|
@ -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) {
|
||||||
|
@ -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
|
||||||
}))
|
}))
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user