Browse Source

解决结论先全部出现后打字机的问题。

milestone-20250710-上线前优化
宋杰 2 days ago
parent
commit
ba3d683f3c
  1. 61
      src/views/AiEmotion.vue

61
src/views/AiEmotion.vue

@ -694,9 +694,15 @@ const stockAudioStates = ref(new Map());
//
const getStockUniqueId = (stock) => {
// 使uniqueId
if (stock.uniqueId) {
return stock.uniqueId;
}
//
const stockCode = stock.stockInfo?.code || stock.stockInfo?.symbol;
const timestamp = stock.timestamp;
return stockCode && timestamp ? `${stockCode}_${timestamp}` : stockCode;
return stockCode && timestamp ? `${stockCode}_${timestamp}` : null;
};
//
const currentOnCompleteCallback = ref(null);
@ -943,7 +949,7 @@ watch(
hasTriggeredAudio.value = false;
hasTriggeredTypewriter.value = false;
//
// 使uniqueId
const stockUniqueId = getStockUniqueId(newStock);
// URL
@ -955,10 +961,10 @@ watch(
? newStock.conclusionData
: JSON.parse(newStock.conclusionData);
//
if (stockUniqueId && stockTypewriterShown.value.has(stockUniqueId)) {
//
// URL
const shouldShowTypewriter = stockUniqueId && stockTypewriterTexts.value.has(stockUniqueId);
if (!shouldShowTypewriter) {
// URL
let voiceUrl = null;
// 使one1_urlURL
@ -2176,16 +2182,44 @@ async function handleSendMessage(input, onComplete) {
};
console.log("第二个接口参数:", conclusionParams);
// Promise.all
const stockUniqueId = `${parsedData.code}_${parsedData.market}_${new Date().toISOString()}`;
const isFirstTime = !stockTypewriterShown.value.has(stockUniqueId);
//
if (isFirstTime && isUserInitiated.value) {
//
console.log('预设股票为打字机模式:', parsedData.name);
stockTypewriterTexts.value.set(stockUniqueId, {
one1: "", one2: "", two: "", three: "", four: "", disclaimer: ""
});
stockTypewriterVisibility.value.set(stockUniqueId, {
one: false, two: false, three: false, four: false, disclaimer: false
});
} else {
//
console.log('预设股票为完整显示模式:', parsedData.name);
stockTypewriterTexts.value.delete(stockUniqueId);
stockTypewriterVisibility.value.delete(stockUniqueId);
//
if (isFirstTime) {
stockTypewriterShown.value.set(stockUniqueId, true);
stockAudioPlayed.value.set(stockUniqueId, true);
}
}
// fetchData
const [conclusionResult, fetchDataResult] = await Promise.all([
getConclusionAPI(conclusionParams),
fetchData(
parsedData.code,
parsedData.market,
parsedData.name || "未知股票",
input.trim(),
parsedData.stockId
),
parsedData.code,
parsedData.market,
parsedData.name || "未知股票",
input.trim(),
parsedData.stockId,
stockUniqueId //
),
]);
//
@ -2436,7 +2470,7 @@ async function handleSendMessage(input, onComplete) {
}
//
async function fetchData(code, market, stockName, queryText, stockId) {
async function fetchData(code, market, stockName, queryText, stockId, presetUniqueId = null) {
try {
const stockDataParams = {
stockId: stockId,
@ -2516,6 +2550,7 @@ async function fetchData(code, market, stockName, queryText, stockId) {
apiData: stockDataResponse.data,
conclusionData: conclusionData.value, //
timestamp: new Date().toISOString(),
uniqueId: presetUniqueId || `${code}_${market}_${new Date().toISOString()}`, //
};
// storeStockTabs
emotionStore.addStock(stockData);

Loading…
Cancel
Save