Browse Source

换工作流

hxl
hongxilin 2 months ago
parent
commit
5b76a9c1d8
  1. 2
      src/api/AIxiaocaishen.js
  2. 142
      src/views/AIchat.vue
  3. 126
      src/views/homePage.vue

2
src/api/AIxiaocaishen.js

@ -135,7 +135,7 @@ export const getReplyAPI = function (params) {
return fetch('https://api.coze.cn/v1/workflow/run', {
method: 'POST',
body: JSON.stringify({
"workflow_id": "7481159261435854860",
"workflow_id": "7484443705572556826",
"parameters": params,
}),
headers: {

142
src/views/AIchat.vue

@ -246,24 +246,25 @@ watch(
//
const result = (await getReplyAPI(params)).json();
const ans = ref();
// console.log(result, "result");
// data JSON
//
const ans = ref();
await result.then((res) => {
// console.log(res.data, "res");
// data JSON
ans.value = JSON.parse(res.data);
})
// console.log(ans.value, "ans");
const AIcontent = ref("");
// answer
if (ans.value.platform !== "" && ans.value.platform !== null) { //
AIcontent.value = ans.value.platform;
} else if (ans.value.news !== "" && ans.value.news !== null) { //
AIcontent.value = ans.value.news;
} else if (ans.value.other !== "" && ans.value.other !== null) { //
AIcontent.value = ans.value.other;
} else { //
var status;
if (ans.value.resp !== "") {
status = JSON.parse(ans.value.resp);
@ -271,12 +272,12 @@ watch(
status = null;
}
console.log(status, "status")
if (status === null || status.code == 200) {
if (ans.value.answerG !== "") {
AIcontent.value = ans.value.answerG;
if (status === null || status.code == 200) { //
if (ans.value.stock !== "") {
AIcontent.value = ans.value.stock;
const code = ans.value.code;
const market = ans.value.market;
const data = JSON.parse(ans.value.duobaoData);
const data = JSON.parse(ans.value.data);
console.log("处理 K 线数据 - 开始");
console.log(data, "data");
@ -291,11 +292,6 @@ watch(
console.log("K线数据名称:", Kline20.name);
console.log("K线数据数组长度:", Kline20.Kline ? Kline20.Kline.length : 0);
//
if (Kline20.Kline && Kline20.Kline.length > 0) {
console.log("K线首个数据点:", Kline20.Kline[0]);
}
//
hasValidData.value = true;
console.log("hasValidData设置为:", hasValidData.value);
@ -351,13 +347,99 @@ watch(
console.warn("未找到K线消息");
}
});
} else if (ans.value.answerN !== "") {
AIcontent.value = ans.value.answerN;
} else if (ans.value.answerO !== "") {
AIcontent.value = ans.value.answerO;
} else {
AIcontent.value = status.msg;
}
}
}
// if (status === null || status.code == 200) {
// if (ans.value.answerG !== "") {
// AIcontent.value = ans.value.answerG;
// const code = ans.value.code;
// const market = ans.value.market;
// const data = JSON.parse(ans.value.duobaoData);
// console.log(" K 线 - ");
// console.log(data, "data");
// const Kline20 = {
// name: data.data.HomePage.StockInformation.Name,
// Kline: data.data.AIBull.KLine20
// }
// // K线
// console.log("K线:", Kline20);
// console.log("K线:", Kline20.name);
// console.log("K线:", Kline20.Kline ? Kline20.Kline.length : 0);
// //
// if (Kline20.Kline && Kline20.Kline.length > 0) {
// console.log("K线:", Kline20.Kline[0]);
// }
// //
// hasValidData.value = true;
// console.log("hasValidData:", hasValidData.value);
// chatStore.messages.pop();
// // K线
// const klineMessageId = `kline-${Date.now()}`;
// console.log("K线ID:", klineMessageId);
// chatStore.messages.push({
// sender: "ai",
// type: "kline",
// chartData: Kline20,
// messageId: klineMessageId,
// hasValidData: true // hasValidData
// });
// console.log("K线");
// //
// chatStore.messages.push({
// sender: "ai",
// content: "AI..."
// });
// //
// nextTick(() => {
// console.log("nextTick - ");
// console.log(":", chatStore.messages);
// // K线
// let klineIndex = -1;
// for (let i = 0; i < chatStore.messages.length; i++) {
// if (chatStore.messages[i].messageId === klineMessageId) {
// klineIndex = i;
// break;
// }
// }
// console.log("K线:", klineIndex);
// if (klineIndex !== -1) {
// const containerId = `kline-container-${klineIndex}`;
// console.log("ID:", containerId);
// // DOM
// setTimeout(() => {
// console.log("DOM");
// KlineCanvsEcharts(containerId);
// }, 100); // DOM
// } else {
// console.warn("K线");
// }
// });
// } else if (ans.value.answerN !== "") {
// AIcontent.value = ans.value.answerN;
// } else if (ans.value.answerO !== "") {
// AIcontent.value = ans.value.answerO;
// }
// // 使markedMarkdownHTML
// AIcontent.value = marked(AIcontent.value,);
// // 使 KaTeX
@ -444,15 +526,15 @@ watch(
});
}
}, 50); // 50ms/
} else {
chatStore.messages.pop();
chatStore.messages.push({
sender: "ai",
content: status.msg
});
// } else {
// chatStore.messages.pop();
// chatStore.messages.push({
// sender: "ai",
// content: status.msg
// });
chatStore.setLoading(false);
}
// chatStore.setLoading(false);
// }
}

126
src/views/homePage.vue

@ -92,11 +92,6 @@ const ensureAIchat = () => {
};
//
// const UserCount = ref(0);
// const getUserCount = async () => {
// const result = await getUserCountAPI({ token: localStorage.getItem('localToken') });
// UserCount.value = result.data.hasCount;
// };
const UserCount = computed(() => chatStore.UserCount)
@ -281,20 +276,6 @@ setTimeout(() => {
fnGetToken()
}, 800)
// const tabContainer = tabContent.value
// let befortop = 0
// tabContainer.addEventListener('scroll', () => {
// const aftertop = tabContainer.scrollTop
// if (aftertop - befortop > 0) {
// console.log('')
// isScrolling.value = true
// } else {
// console.log('')
// isScrolling.value = false
// }
// befortop = aftertop
// })
const heightListener = () => {
const tabContainer = tabContent.value;
let befortop = 0;
@ -330,87 +311,6 @@ const heightListener = () => {
const throttledHeightListener = _.throttle(heightListener, 500, { trailing: false });
//
// const handleInputFocus = () => {
// console.log('');
// const inputElement = document.querySelector('#input');
// if (!inputElement) return;
// //
// const isMobileDevice = /phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/i.test(
// navigator.userAgent
// );
// console.log(':', isMobileDevice, navigator.userAgent);
// if (isMobileDevice) {
// console.log('');
// //
// const meta = document.querySelector('meta[name="viewport"]');
// if (!meta) {
// const newMeta = document.createElement('meta');
// newMeta.name = 'viewport';
// newMeta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover';
// document.getElementsByTagName('head')[0].appendChild(newMeta);
// } else {
// meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover';
// }
// //
// updateAppHeight();
// // iOS
// const isIOS = /iPhone|iPad|iPod|ios/i.test(navigator.userAgent);
// console.log('iOS:', isIOS);
// if (isIOS) {
// console.log('iOS');
// // 使 visualViewport API
// if (window.visualViewport) {
// window.visualViewport.addEventListener('resize', () => {
// const headerHeight = document.querySelector('.el-header').offsetHeight;
// const footerHeight = document.querySelector('.el-footer').offsetHeight;
// const keyboardHeight = window.visualViewport.height; //
// const totalHeight = headerHeight + footerHeight; //
// // el-main
// const newMainHeight = window.innerHeight - totalHeight - keyboardHeight;
// // el-main
// document.querySelector('.el-main').style.height = `${newMainHeight}px`;
// });
// }
// } else {
// // Android
// console.log('Android');
// window.addEventListener('resize', _.debounce(() => {
// console.log(':', window.innerHeight);
// updateAppHeight();
// //
// const msgInput = document.querySelector('.msg-input');
// if (document.activeElement === msgInput) {
// setTimeout(() => {
// console.log('');
// inputElement.scrollIntoView({ block: 'end', behavior: 'smooth' });
// const tabContentElement = document.querySelector('.tab-content');
// if (tabContentElement) {
// tabContentElement.scrollTop = tabContentElement.scrollHeight;
// }
// }, 200);
// }
// }, 100));
// }
// }
// };
// function updateAppHeight() {
// const vh = window.innerHeight;
// document.documentElement.style.setProperty('--app-height', `${vh}px`);
// }
const adjustFooterPosition = (height) => {
console.log('调整底部位置', height)
const footer = document.querySelector('.el-footer');
@ -439,19 +339,19 @@ const adjustFooterPosition = (height) => {
body.style.overflow = 'hidden';
}, 200)
console.log(html.offsetHeight, 'html')
console.log(html.clientHeight, 'html')
console.log(html.scrollHeight, 'htmlScrollHeight')
console.log(body.clientHeight, 'body')
console.log(body.scrollHeight, 'bodyScrollHeight')
console.log(homePage.offsetHeight, 'homePage')
console.log(homePage.clientHeight, 'homePageClientHeight')
console.log(homePage.scrollHeight, 'homePageScrollHeight')
console.log(window.innerHeight, 'window.innerHeight')
console.log(window.visualViewport.height, 'window.visualViewport.height')
console.log(main.offsetHeight, 'main')
console.log(main.clientHeight, 'mainClientHeight')
console.log(main.scrollHeight, 'mainScrollHeight')
// console.log(html.offsetHeight, 'html')
// console.log(html.clientHeight, 'html')
// console.log(html.scrollHeight, 'htmlScrollHeight')
// console.log(body.clientHeight, 'body')
// console.log(body.scrollHeight, 'bodyScrollHeight')
// console.log(homePage.offsetHeight, 'homePage')
// console.log(homePage.clientHeight, 'homePageClientHeight')
// console.log(homePage.scrollHeight, 'homePageScrollHeight')
// console.log(window.innerHeight, 'window.innerHeight')
// console.log(window.visualViewport.height, 'window.visualViewport.height')
// console.log(main.offsetHeight, 'main')
// console.log(main.clientHeight, 'mainClientHeight')
// console.log(main.scrollHeight, 'mainScrollHeight')
};

Loading…
Cancel
Save