diff --git a/pages/knowledge/index.vue b/pages/knowledge/index.vue
index b355dcd..9900e95 100644
--- a/pages/knowledge/index.vue
+++ b/pages/knowledge/index.vue
@@ -1,946 +1,1042 @@
-
-
-
-
-
-
- 您好,我是海信通途大模型
-
- 作为你的智能伙伴,我可以为你提供交通领域知识的答疑解惑。
-
- 你可以这样问我:
-
-
-
-
- {{ item.title }}
-
-
- {{ item.text }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 照片
-
-
-
- 视频
-
-
-
-
-
-
-
-
-
-
+
+ // this.isExpanded = !this.isExpanded;
+ },
+ clickContent() {
+ if (this.isExpanded) {
+ this.isExpanded = !this.isExpanded;
+ }
+ },
+ goToKnowledge() {
+ uni.navigateTo({
+ url: `/pages/home/detail?params=${encodeURIComponent(
+ JSON.stringify(item)
+ )}`,
+ });
+ },
+
+ // 选择图片
+ chooseImage() {
+ uni.chooseImage({
+ count: 6, //默认9
+ sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
+ sourceType: ["album"], //从相册选择
+ success: async (res) => {
+ console.log(res);
+ if (res.tempFilePaths && res.tempFilePaths.length) {
+ let str = "";
+ let jsonArr = [];
+ for (let i = 0; i < res.tempFilePaths.length; i++) {
+ const result = await this.uploadFilePromise(res.tempFilePaths[i]);
+ let json = JSON.parse(result);
+ str += ``;
+ jsonArr.push(json.result);
+ }
+
+ console.log(str);
+ if (this.id == 12121212) {
+ this.changeMsgList("0", str);
+ this.queryChat(jsonArr);
+ } else {
+ // this.addQuestion(str, "0");
+ // this.SSE(jsonArr, "0");
+ this.changeMsgList("0", str);
+ let j = jsonArr.join(',')
+ this.queryChat(j);
+ }
+ }
+ },
+ });
+ },
+ uploadFilePromise(url) {
+ return new Promise((resolve, reject) => {
+ let a = uni.uploadFile({
+ url: this.$.baseUrl + "/hiddenDanger/ftp/uploadFileToFtp", // 仅为示例,非真实的接口地址
+ filePath: url,
+ name: "file",
+ success: (res) => {
+ resolve(res.data);
+ },
+ });
+ });
+ },
+ },
+ // methods: {
+ // // 建立SSE长连接
+ // SSE(voiceText, answerId) {
+ // const ctrl = new AbortController();
+ // console.log(ctrl.signal);
+ // fetchEventSource($.chatUrl + "/chat", {
+ // method: "POST",
+ // headers: {
+ // "Content-Type": "application/json",
+ // Accept: ["text/event-stream", "application/json"],
+ // },
+ // body: JSON.stringify({
+ // voiceText,
+ // deptId: "3702000000",
+ // id: "37020017407",
+ // multiType: "",
+ // sceneFlag: "",
+ // stream: true,
+ // type: "0",
+ // userId: "admin1",
+ // }),
+ // signal: ctrl.signal,
+ // openWhenHidden: true,
+ // onopen: () => {},
+ // onmessage: (ev) => {
+ // console.log(ev);
+ // this.loading = true;
+ // const res = JSON.parse(ev.data);
+ // if (res?.code == 200 && res.result) {
+ // console.log(res.result.data.tabkey);
+ // console.log(res.result.data);
+ // this.tabkey = res.result.data.tabkey;
+ // if (this.tabkey - 1 != this.active) {
+ // this.active = this.tabkey - 1 > 0 ? this.tabkey - 1 : 0;
+ // }
+ // if (this.msgList.length == 0) {
+ // this.msgList = [
+ // {
+ // answerId,
+ // data: res.result.data.content,
+ // },
+ // ];
+ // } else {
+ // // debugger
+ // //回答
+ // if (this.msgList[this.msgList.length - 1].answerId == "1") {
+ // //最后一个是回答
+ // this.msgList[this.msgList.length - 1].data +=
+ // res.result.data.content;
+ // } else {
+ // //最后一个是问题
+ // this.msgList = [
+ // ...this.msgList,
+ // {
+ // answerId: "1",
+ // data: res.result.data.content,
+ // },
+ // ];
+ // }
+ // }
+
+ // // debugger
+
+ // this.scrollBottom();
+ // }
+ // },
+ // onclose: () => {
+ // console.log(1111);
+ // this.loading = false;
+
+ // if (this.isExpanded) {
+ // this.isExpanded = !this.isExpanded;
+ // }
+ // },
+ // onerror(error) {
+ // console.log("error", error);
+ // throw error;
+ // },
+ // });
+ // },
+
+ // async queryChat(voiceText) {
+
+ // // console.log(voiceText,"voiceText");
+ // this.loading = true;
+ // const [err, res] = await uni.request({
+ // // url: 'http://10.16.3.159:8777/api/local_doc_qa/local_doc_chat',
+ // url: $.chatUrl + "/chat",
+ // dataType: "json",
+ // method: "POST",
+ // // responseType: 'arraybuffer',
+ // headers: {
+ // // 'Accept': 'text/event-stream',
+ // "content-type": "application/json",
+ // },
+ // data: {
+ // voiceText,
+ // sceneFlag: "",
+ // sessionId: this.sessionId,
+ // id: this.id,
+ // multiType: "",
+ // userId: "admin1",
+ // deptId: "3702000000",
+ // type: '0',
+ // stream: false,
+ // // "user_id": "zzp",
+ // // "kb_ids": ["KBa80ea15e786241eca70a20f136f4e34c"],
+ // // "question": "隐患排查流程是什么",
+ // // "streaming": true,
+ // // "history": []
+ // },
+ // });
+ // if (res && res.data && res.data.code == 200) {
+ // // console.log('request success', res.data)
+ // const { result = {} } = res.data;
+ // const { data = {} } = result;
+ // if (data.tabkey - 1 != this.active) {
+ // this.active = data.tabkey - 1 > 0 ? data.tabkey - 1 : 0;
+ // }
+ // if (data.content) {
+ // this.changeMsgList(
+ // data.answerId || "1",
+ // data.content,
+ // data.answerOptions
+ // );
+ // }
+ // this.loading = false;
+ // if (this.isExpanded) {
+ // this.isExpanded = !this.isExpanded;
+ // }
+ // } else {
+ // if (err) {
+ // console.log("request fail", err.errMsg);
+ // }
+ // uni.showToast({
+ // title: "查询失败",
+ // icon: "error",
+ // duration: 2000,
+ // });
+ // }
+ // },
+ // // 输入框
+ // onKeyInput(event) {
+ // this.inputValue = event.detail.value;
+ // },
+ // addQuestion(q, answerId) {
+ // const newQuestion = {
+ // answerId,
+ // data: q,
+ // };
+ // this.msgList.push(newQuestion); // 将问题添加到消息列表
+ // // this.$store.commit('setMSg_List', this.msgList);
+ // this.scrollBottom();
+ // },
+ // scrollBottom() {
+ // this.$nextTick(() => {
+ // // const height =
+ // // this.$refs.scrollView &&
+ // // this.$refs.scrollView.$refs &&
+ // // this.$refs.scrollView.$refs.content
+ // // ? this.$refs.scrollView.$refs.content.scrollHeight
+ // // : 0;
+ // this.scrollTop = this.scrollTop + 1;
+ // });
+ // },
+ // // 发送
+ // handleSend(text) {
+ // if (!this.inputValue & !text) {
+ // uni.showToast({
+ // title: "请输入内容",
+ // icon: "closeempty",
+ // duration: 2000,
+ // });
+ // }
+ // if (text || this.inputValue) {
+ // // if (this.params.id == 12121212) {
+ // this.changeMsgList("0", this.inputValue || text);
+ // this.queryChat(this.inputValue || text);
+ // this.scrollBottom();
+ // // } else {
+ // // this.addQuestion(this.inputValue || text, "0");
+ // // this.SSE(this.inputValue || text, "0");
+ // // }
+ // this.inputValue = "";
+ // }
+ // },
+ // // 更新列表信息
+ // changeMsgList(answerId, data, answerOptions) {
+ // let id = 1;
+ // if (this.msgList.length > 0) {
+ // id = this.msgList[this.msgList.length - 1].id + 1;
+ // }
+ // if (answerId == "1") {
+ // // 后台返回来的消息
+ // let newdata = "";
+ // let index = 0;
+ // const timer = setInterval(() => {
+ // newdata = newdata += data[index];
+ // if (this.msgList?.filter((item) => item.id == id).length == 0) {
+ // this.msgList = [
+ // ...this.msgList,
+ // {
+ // id,
+ // answerId,
+ // data: newdata,
+ // // options: answerOptions // ['东南西北','东北','东南北','东南西北'] answerOptions
+ // },
+ // ];
+ // } else {
+ // this.msgList[this.msgList.length - 1].data = newdata;
+ // }
+ // index += 1;
+ // this.scrollBottom();
+ // if (newdata == data) {
+ // this.msgList[this.msgList.length - 1].options = answerOptions;
+ // clearInterval(timer);
+ // }
+ // }, 50);
+ // } else {
+ // this.msgList = [
+ // ...this.msgList,
+ // {
+ // id,
+ // answerId,
+ // data,
+ // },
+ // ];
+ // this.scrollBottom();
+ // }
+ // },
+
+ // handlePlus() {
+ // this.isExpanded = !this.isExpanded;
+ // },
+ // // 快捷回复
+ // handleBtn(text) {
+ // this.handleSend(text);
+ // },
+ // clickContent() {
+ // if (this.isExpanded) {
+ // this.isExpanded = !this.isExpanded;
+ // }
+ // },
+ // goToKnowledge() {
+ // uni.navigateTo({
+ // url: "/pages/home/knowledge",
+ // // url: `/pages/home/knowledge?params=${encodeURIComponent(JSON.stringify(this.$route.query.params))}`
+ // });
+ // },
+ // // 选择图片
+ // chooseImage() {
+ // uni.chooseImage({
+ // count: 6, //默认9
+ // sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
+ // sourceType: ["album"], //从相册选择
+ // success: async (res) => {
+ // console.log(res)
+ // if (res.tempFilePaths && res.tempFilePaths.length) {
+ // let str = "";
+ // let jsonArr = []
+ // for (let i = 0; i < res.tempFilePaths.length; i++) {
+ // const result = await this.uploadFilePromise(res.tempFilePaths[i]);
+ // let json = JSON.parse(result)
+ // str += ``;
+ // jsonArr.push(json.result)
+ // }
+
+ // console.log(str)
+ // if (this.id == 12121212) {
+ // this.changeMsgList("0", str);
+ // this.queryChat(jsonArr);
+ // } else {
+ // // this.addQuestion(str, "0");
+ // // this.SSE(jsonArr, "0");
+ // this.changeMsgList("0", str);
+ // this.queryChat(jsonArr);
+ // }
+ // }
+ // },
+ // });
+ // },
+ // uploadFilePromise(url) {
+ // return new Promise((resolve, reject) => {
+ // let a = uni.uploadFile({
+ // url: this.$.baseUrl + '/hiddenDanger/ftp/uploadFileToFtp', // 仅为示例,非真实的接口地址
+ // filePath: url,
+ // name: 'file',
+ // success: (res) => {
+ // resolve(res.data)
+ // }
+ // });
+ // })
+ // },
+ // },
+ };
+
+
+
\ No newline at end of file