Browse Source

Merge branch 'songjie/feature-20250628160649-上线前优化' into milestone-20250710-上线前优化

songjie/feature-20250628160649-上线前优化
宋杰 17 hours ago
parent
commit
b2337e15c3
  1. 77
      src/views/AiEmotion.vue
  2. 12
      src/views/homePage.vue

77
src/views/AiEmotion.vue

@ -625,7 +625,7 @@ watch(parsedConclusion, (newConclusion) => {
}, { immediate: true });
//
function startTypewriterEffect(conclusion) {
function startTypewriterEffect(conclusion, onComplete) {
console.log('开始打字机效果,结论数据:', conclusion);
//
@ -758,10 +758,14 @@ function startTypewriterEffect(conclusion) {
for (let i = 0; i <= disclaimerText.length; i++) {
const timer = setTimeout(() => {
displayedTexts.value.disclaimer = disclaimerText.substring(0, i);
//
//
if (i === disclaimerText.length) {
setTimeout(() => {
scrollToBottom();
//
if (onComplete && typeof onComplete === 'function') {
onComplete();
}
}, 100);
}
}, totalDelay + i * typeSpeed);
@ -877,7 +881,7 @@ function startImageRotation() {
//
async function handleSendMessage(input) {
async function handleSendMessage(input, onComplete) {
console.log("发送内容:", input);
//
isUserInitiated.value = true;
@ -885,6 +889,10 @@ async function handleSendMessage(input) {
//
if (!input || !input.trim()) {
ElMessage.warning("输入内容不能为空");
//
if (onComplete && typeof onComplete === 'function') {
onComplete();
}
return;
}
@ -903,6 +911,10 @@ async function handleSendMessage(input) {
//
isRotating.value = false;
messages.value = [...previousMessages, ...messages.value];
//
if (onComplete && typeof onComplete === 'function') {
onComplete();
}
return;
}
@ -920,6 +932,10 @@ async function handleSendMessage(input) {
//
isRotating.value = false;
messages.value = [...previousMessages, ...messages.value];
//
if (onComplete && typeof onComplete === 'function') {
onComplete();
}
return;
}
@ -947,7 +963,6 @@ async function handleSendMessage(input) {
const result = await getReplyAPI(params);
const response = await result.json();
const parsedData = JSON.parse(response.data);
console.log("第一个接口解析后的数据:", parsedData);
//
if (!parsedData || !parsedData.market || !parsedData.code) {
@ -956,6 +971,10 @@ async function handleSendMessage(input) {
messages.value.push(aiMessage);
isRotating.value = false;
messages.value = [...previousMessages, ...messages.value];
//
if (onComplete && typeof onComplete === 'function') {
onComplete();
}
return;
}
@ -963,7 +982,6 @@ async function handleSendMessage(input) {
//
isLoading.value = true;
console.log("工作流接口返回股票信息:", parsedData);
isPageLoaded.value = false;
//
@ -985,7 +1003,6 @@ async function handleSendMessage(input) {
//
const conclusionResponse = await conclusionResult.json();
console.log("第二个工作流接口返回数据:", conclusionResponse);
//
if (conclusionResponse && conclusionResponse.data && fetchDataResult) {
@ -1006,26 +1023,28 @@ async function handleSendMessage(input) {
console.error('更新用户次数失败:', error);
}
console.log('所有数据加载完成,开始渲染页面');
//
nextTick(() => {
if (currentStock.value && currentStock.value.apiData) {
renderCharts(currentStock.value.apiData);
console.log('数据加载完成后开始渲染图表');
//
if (isUserInitiated.value && parsedConclusion.value && audioUrl.value) {
const stockCode = currentStock.value.stockInfo?.code || currentStock.value.stockInfo?.symbol;
if (stockCode && !stockTypewriterShown.value.has(stockCode)) {
console.log('用户主动搜索,立即触发音频和打字机效果');
startTypewriterEffect(parsedConclusion.value);
startTypewriterEffect(parsedConclusion.value, onComplete);
if (!stockAudioPlayed.value.has(stockCode)) {
stockAudioPlayed.value.set(stockCode, true);
playAudio(audioUrl.value);
}
stockTypewriterShown.value.set(stockCode, true);
} else {
//
if (onComplete && typeof onComplete === 'function') {
onComplete();
}
}
}
@ -1040,6 +1059,10 @@ async function handleSendMessage(input) {
messages.value.push(aiMessage);
isRotating.value = false;
messages.value = [...previousMessages, ...messages.value];
//
if (onComplete && typeof onComplete === 'function') {
onComplete();
}
return;
}
} catch (error) {
@ -1048,6 +1071,10 @@ async function handleSendMessage(input) {
//
isRotating.value = false;
messages.value = [...previousMessages, ...messages.value];
//
if (onComplete && typeof onComplete === 'function') {
onComplete();
}
return;
} finally {
//
@ -1082,11 +1109,8 @@ async function fetchData(code, market, stockName, queryText) {
);
const stockDataResponse = stockDataResult.data; //
console.log('图表数据接口返回数据:', stockDataResponse.data);
if (stockDataResponse.code === 200 && stockDataResponse.data) {
console.log(stockDataResponse.code)
//
const stockData = {
queryText: queryText,
@ -1108,7 +1132,6 @@ async function fetchData(code, market, stockName, queryText) {
return false; //
}
} catch (error) {
console.error('fetchData error:', error);
const aiMessage = reactive({ sender: 'ai', text: '图表数据请求失败,请检查网络连接' });
messages.value.push(aiMessage);
return false; //
@ -1123,42 +1146,26 @@ function renderCharts(data) {
try {
//
const clonedData = JSON.parse(JSON.stringify(data));
console.log('已深拷贝数据,避免污染原始数据');
console.log('所有数据1111111111111:', clonedData)
//
if (marketTemperatureRef.value && clonedData.GSWDJ) {
console.log("开始渲染股市温度计图表");
console.log("股市温度计数据", clonedData.GSWDJ);
marketTemperatureRef.value.initChart(clonedData.GSWDJ, clonedData.KLine20, clonedData.WDRL);
console.log("股市温度计图表已渲染");
}
//
if (emotionDecodRef.value && clonedData.QXJMQ) {
console.log("开始渲染情绪解码器图表");
console.log("情绪解码器数据", clonedData.QXJMQ);
emotionDecodRef.value.initQXNLZHEcharts(clonedData.KLine20, clonedData.QXJMQ);
console.log("情绪解码器图表已渲染");
}
//
if (emotionalBottomRadarRef.value && clonedData.QXTDLD) {
console.log("开始渲染情绪探底雷达图表");
console.log("探底雷达数据", clonedData.QXTDLD);
emotionalBottomRadarRef.value.initEmotionalBottomRadar(
clonedData.KLine20,
clonedData.QXTDLD
);
console.log("情绪探底雷达图表已渲染");
}
//
if (emoEnergyConverterRef.value && clonedData.QXNLZHQ) {
console.log("开始渲染情绪能量转化器图表");
console.log("KLine20:", clonedData.KLine20);
console.log("QXNLZHQ:", clonedData.QXNLZHQ);
emoEnergyConverterRef.value.initQXNLZHEcharts(clonedData.KLine20, clonedData.QXNLZHQ);
console.log("情绪能量转化器图表已渲染");
}
} catch (error) {
console.error('图表渲染过程中发生错误:', error);
const aiMessage = reactive({ sender: 'ai', text: '图表渲染失败,请重试' });
messages.value.push(aiMessage);
}
@ -1518,6 +1525,8 @@ defineExpose({
.disclaimer-item {
p {
color: #ffffff !important;
font-size: 20px;
font-weight: bold;
}
}
@ -2657,17 +2666,15 @@ defineExpose({
}
.disclaimer-item {
margin-top: 30px;
/* margin-top: 30px; */
padding: 20px;
border-top: 1px solid rgba(153, 153, 153, 0.2);
text-align: center;
p.disclaimer-text {
p {
color: #ffffff !important;
font-size: 14px;
font-size: 16px;
margin: 0;
font-style: italic;
opacity: 0.8;
letter-spacing: 1px;
}
}

12
src/views/homePage.vue

@ -154,6 +154,8 @@ const messages = ref([]);
const isLoading = computed(() => {
chatStore.isLoading;
});
//
const isInputDisabled = ref(false);
//
const updateMessage = (title) => {
@ -179,8 +181,13 @@ const sendMessage = async () => {
// AiEmotion
if (activeTab.value === "AiEmotion") {
//
isInputDisabled.value = true;
// AiEmotion handleSendMessage
aiEmotionRef.value?.handleSendMessage(message.value);
aiEmotionRef.value?.handleSendMessage(message.value, () => {
//
isInputDisabled.value = false;
});
message.value = ""; //
return;
}
@ -673,7 +680,8 @@ onUnmounted(() => {
:autosize="{ minRows: 1, maxRows: 4 }"
placeholder="请输入股票名称或股票代码..."
class="msg-input"
@keydown.enter.exact.prevent="isLoading ? null : sendMessage()"
@keydown.enter.exact.prevent="(isLoading || isInputDisabled) ? null : sendMessage()"
:disabled="isInputDisabled"
resize="none"
>
</el-input>

Loading…
Cancel
Save