Browse Source

情绪大模型新增校验QXNLZHQ的逻辑,当后端接口返回数据不全时,不渲染图表;

songjie/feature-20250628160649-上线前优化
宋杰 21 hours ago
parent
commit
d151f7937b
  1. 77
      src/views/AiEmotion.vue

77
src/views/AiEmotion.vue

@ -1160,6 +1160,54 @@ async function fetchData(code, market, stockName, queryText) {
}
}
//
function hasValidData(obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
//
const allowedEmptyArrays = ['lowxh', 'qixh', 'topxh'];
//
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
//
if (typeof value === 'string') {
//
if (value.trim() !== '') {
return true;
}
}
//
else if (Array.isArray(value)) {
//
if (value.length > 0) {
return true;
}
}
// 0
else if (typeof value === 'number' && value !== 0) {
return true;
}
// true
else if (typeof value === 'boolean' && value === true) {
return true;
}
//
else if (typeof value === 'object' && value !== null) {
if (hasValidData(value)) {
return true;
}
}
}
}
return false;
}
//
function renderCharts(data) {
console.log('开始渲染图表,数据:', data);
@ -1172,10 +1220,17 @@ function renderCharts(data) {
marketTemperature: !!(clonedData.GSWDJ && clonedData.GSWDJ.length > 0),
emotionDecod: !!(clonedData.QXJMQ && clonedData.QXJMQ.length > 0),
emotionalBottomRadar: !!(clonedData.QXTDLD && clonedData.QXTDLD.length > 0),
emoEnergyConverter: !!(clonedData.QXNLZHQ && clonedData.QXNLZHQ.length > 0)
emoEnergyConverter: !!(clonedData.QXNLZHQ && (Array.isArray(clonedData.QXNLZHQ) ? clonedData.QXNLZHQ.length > 0 : hasValidData(clonedData.QXNLZHQ)))
};
console.log('图表显示状态:', chartVisibility.value);
console.log('数据检查:', {
GSWDJ: !!(clonedData.GSWDJ && clonedData.GSWDJ.length > 0),
QXJMQ: !!(clonedData.QXJMQ && clonedData.QXJMQ.length > 0),
QXTDLD: !!(clonedData.QXTDLD && clonedData.QXTDLD.length > 0),
QXNLZHQ: !!(clonedData.QXNLZHQ && (Array.isArray(clonedData.QXNLZHQ) ? clonedData.QXNLZHQ.length > 0 : hasValidData(clonedData.QXNLZHQ)))
});
console.log('QXNLZHQ数据详情:', clonedData.QXNLZHQ);
nextTick(() => {
// DOM
@ -1188,6 +1243,26 @@ function renderCharts(data) {
emoEnergyConverterRef: !!emoEnergyConverterRef.value
});
// DOM
console.log('DOM元素检查:', {
marketTemperatureDOM: !!document.querySelector('.class03'),
emotionDecodDOM: !!document.querySelector('.class04'),
emotionalBottomRadarDOM: !!document.querySelector('.class05'),
emoEnergyConverterDOM: !!document.querySelector('.class06')
});
//
const emoEnergyElement = document.querySelector('emo-energy-converter');
console.log('emoEnergyConverter元素:', emoEnergyElement);
// ref
setTimeout(() => {
console.log('延迟检查emoEnergyConverterRef:', !!emoEnergyConverterRef.value);
if (emoEnergyConverterRef.value) {
console.log('emoEnergyConverter方法:', typeof emoEnergyConverterRef.value.initQXNLZHEcharts);
}
}, 1000);
//
if (marketTemperatureRef.value && chartVisibility.value.marketTemperature) {
console.log('开始渲染股市温度计图表');

Loading…
Cancel
Save