Commit 481f7e42 authored by mhw's avatar mhw

预览修改

parent 2276fb6b
......@@ -8,6 +8,9 @@ html, body {
font-family: Arial,"Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",sans-serif;
background-color: rgb(228,240,255);
}
div{
word-break:break-all
}
.omit {
/* 一行省略 */
overflow: hidden;
......
......@@ -18,9 +18,9 @@
</div>
<div class="video" v-if="['mp4', 'webm', 'ogg', 'ogv'].indexOf(fileType)>-1&&url">
<video controls style="width: 100%">
<source :src="item" type="video/mp4" />
<source :src="item" type="video/ogg" />
<source :src="item" type="video/webm" />
<source :src="url" type="video/mp4" />
<source :src="url" type="video/ogg" />
<source :src="url" type="video/webm" />
您的浏览器不支持 video 标签。
</video>
</div>
......@@ -57,6 +57,7 @@ export default {
props: ['url'],
computed: {
fileType () {
console.log(this.url);
return this.url.split('.').pop().toLowerCase();
}
},
......
......@@ -62,18 +62,12 @@ export default {
this.setDescribeStyle(aTag)
}
aTag.addEventListener('click', function (event) {
let url;
if (isFile) { // 判断可预览文件类型
// 阻止默认点击事件
event.preventDefault();
if (tagUrl.indexOf('https') !== -1) {
url = tagUrl.replace(/^https:\/\/[^/]+\//, `https://${window.location.hostname}:${window.location.port}/`);
} else {
url = tagUrl.replace(/^http:\/\/[^/]+\//, `http://${window.location.hostname}:${window.location.port}/`);
}
that.$dialog.show('文件预览', filePreview, {
area: ['100%', '100%']
}, { url }).then(res => {
}, {url: tagUrl }).then(res => {
}).catch(e => { });
}
......@@ -83,7 +77,6 @@ export default {
setDescribeStyle (aTag) {
let describeDom = aTag.parentNode.nextElementSibling
// 在当前元素前插入新的 HTML 内容
describeDom.insertAdjacentHTML('beforebegin', `
<button style="margin-bottom:10px" type="button" class="el-button el-button--primary el-button--mini is-round">
<span style="margin-right:5px">详情</span>
......@@ -120,7 +113,7 @@ export default {
.describe {
overflow: hidden;
transition: 0.5s all;
color: #007fff;
color: #000;
font-size: 14px;
background-color: #fff;
border-radius: 10px;
......
......@@ -140,18 +140,13 @@ export default {
},
onmessage (data) {
console.log(data);
let nowChat = this.myHistory[this.myHistory.length - 1]
if (this.chatForm.pattern === '通用智能问答') {
nowChat.answer += data
} else if (this.chatForm.pattern === '专业知识库问答') {
let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
temporary.forEach((item) => {
if (item.docs) {
item.docs = item.docs.map((item2) => {
return item2.replace('出处', '知识溯源')
})
}
this.modifyContent(item)// 修改返回内容
nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
nowChat.answer += item.answer || '\n' + item.docs
})
......@@ -159,13 +154,9 @@ export default {
} else if (this.chatForm.pattern === '文件对话') {
let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
temporary.forEach((item) => {
if (item.docs) {
item.docs = item.docs.map((item2) => {
return item2.replace('出处', '知识溯源')
})
}
this.modifyContent(item)// 修改返回内容
nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
nowChat.answer += item.answer || '\n' + item.docs
})
......@@ -175,6 +166,23 @@ export default {
this.$refs.contentBox.scrollTo(0, this.$refs.contentBox.scrollHeight)
})
},
modifyContent (item) { // 修改返回内容
if (item.docs) {
item.docs = item.docs.map((item2) => {
let tagUrl = item2.match(/\]\((.*?)\)/g)[0].slice(2, -1)
let url = ''
if (tagUrl.indexOf('https') !== -1) {
url = tagUrl.replace(/^https:\/\/[^/]+\//, `https://${window.location.hostname}:${window.location.port}/`);
item2 = item2.replace(/\]\((.*?)\)/g, `](${url})`)
} else {
url = tagUrl.replace(/^http:\/\/[^/]+\//, `http://${window.location.hostname}:${window.location.port}/`);
item2 = item2.replace(/\]\((.*?)\)/g, `](${url})`)
}
return item2.replace('出处', '知识溯源')
})
}
},
generateRandomString (length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment