Commit e60e7e52 authored by mhw's avatar mhw

引用展开收缩

parent 25dc1fb3
...@@ -45,4 +45,7 @@ export default class KnowledgeManage { ...@@ -45,4 +45,7 @@ export default class KnowledgeManage {
static listForTree (sender, params, axiosOption, httpOption) { static listForTree (sender, params, axiosOption, httpOption) {
return sender.doUrl('/admin/app/knowledgeManage/listForTree', 'post', params, axiosOption, httpOption); return sender.doUrl('/admin/app/knowledgeManage/listForTree', 'post', params, axiosOption, httpOption);
} }
static load (sender, params, axiosOption, httpOption) {
return sender.doUrl('/admin/app/knowledgeManage/load', 'post', params, axiosOption, httpOption);
}
} }
...@@ -14,7 +14,9 @@ html, body { ...@@ -14,7 +14,9 @@ html, body {
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.el-message {
white-space: pre-line;
}
.omit_2 { .omit_2 {
/*2行省略 */ /*2行省略 */
text-overflow: -o-ellipsis-lastline; text-overflow: -o-ellipsis-lastline;
......
...@@ -269,6 +269,7 @@ ...@@ -269,6 +269,7 @@
/* Break-point /* Break-point
--------------------------*/ --------------------------*/
.el-message { .el-message {
white-space: pre-line;
min-width: 380px; min-width: 380px;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
......
module.exports = { module.exports = {
baseUrl: 'http://192.168.83.215:8082/', baseUrl: 'http://192.168.0.36:8082/',
wsUrl: 'ws://127.0.0.1:7860/', wsUrl: 'ws://192.168.0.36:7860/',
projectName: '灵境大模型平台' projectName: '灵境大模型平台'
} }
...@@ -189,13 +189,24 @@ const fetchUpload = function (url, params, isDefUrl = true) { ...@@ -189,13 +189,24 @@ const fetchUpload = function (url, params, isDefUrl = true) {
} }
] ]
}).then(res => { }).then(res => {
console.log(res); console.log(res, res.data.msg);
if ((res.data && res.data.success) || res.data.code === 200) { if ((res.data && res.data.success) || res.data.code === 200) {
resolve(res.data); resolve(res.data);
} else { } else {
reject(res)
let failedFiles = res.data?.data?.failed_files
let msg = ''
if (failedFiles) {
for (const key in failedFiles) {
if (Object.hasOwnProperty.call(failedFiles, key)) {
const element = failedFiles[key];
msg += key + ':' + element + '\n'
}
}
}
showErrorMessage({ showErrorMessage({
showClose: true, showClose: true,
message: res.data.errorMessage ? res.data.errorMessage : '数据请求失败' message: res.data.errorMessage || res.data.msg ? res.data.errorMessage || msg : '数据请求失败'
}); });
} }
}).catch(e => { }).catch(e => {
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<el-form-item label="上传知识库文件:" prop="filesArr"> <el-form-item label="上传知识库文件:" prop="filesArr">
<el-button @click="clickUp" :size="defaultFormItemSize" type="primary">上传</el-button> <el-button @click="clickUp" :size="defaultFormItemSize" type="primary">上传</el-button>
<input style="display:none" ref="upFile" type="file" @change="fileinfo($event.target.files)" multiple accept=".html, .md, .json, .jsonl, .csv, .pdf, .png, .jpg, .jpeg, .bmp, .eml, .msg, .epub, .xlsx, .xls, .ipynb, .odt, .py, .rst, .rtf, .srt, .toml, .tsv, .docx, .doc, .xml, .ppt, .pptx, .txt, .htm"> <input style="display:none" ref="upFile" type="file" @change="fileinfo($event.target.files)" multiple accept=".html, .md, .json, .jsonl, .csv, .pdf, .png, .jpg, .jpeg, .bmp, .eml, .msg, .epub, .xlsx, .xls, .ipynb, .odt, .py, .rst, .rtf, .srt, .toml, .tsv, .docx, .doc, .xml, .ppt, .pptx, .txt, .htm">
<div class="el-upload__tip" ><i class="el-icon-document" style="color:#909399;margin-right:5px"></i>可上传HTML, MD, JSON, JSONL, CSV, PDF, PNG, JPG, JPEG, BMP, EML, MSG, EPUB, XLSX, XLSD, IPYNB, ODT, PY, RST, RTF, SRT, TOML, TSV, DOCX, DOC, XML, PPT, PPTX, TXT, HTM文件</div> <div class="el-upload__tip"> 可上传HTML, MD, JSON, JSONL, CSV, PDF, PNG, JPG, JPEG, BMP, EML, MSG, EPUB, XLSX, XLSD, IPYNB, ODT, PY, RST, RTF, SRT, TOML, TSV, DOCX, DOC, XML, PPT, PPTX, TXT, HTM文件</div>
<div class="itemFile" v-for="(item,index) in files" :key="item.name">{{ item.name }} <div class="itemFile" v-for="(item,index) in files" :key="item.name"><i class="el-icon-document" style="color:#909399;margin-right:5px"></i>{{ item.name }}
<i class="el-icon-circle-close" style="color:#0092FF;cursor: pointer;" @click="clearFile(index)"></i> <i class="el-icon-circle-close" style="color:#0092FF;cursor: pointer;" @click="clearFile(index)"></i>
</div> </div>
</el-form-item> </el-form-item>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</el-slider> </el-slider>
</el-form-item> </el-form-item>
<el-form-item label="相邻文本重合长度:"> <el-form-item label="相邻文本重合长度:">
<el-slider :min="0" :max="12" v-model="form.chunk_overlap" show-input> <el-slider :min="0" :max="250" v-model="form.chunk_overlap" show-input>
</el-slider> </el-slider>
</el-form-item> </el-form-item>
<el-form-item label="开启中文标题加强:"> <el-form-item label="开启中文标题加强:">
...@@ -121,6 +121,8 @@ export default { ...@@ -121,6 +121,8 @@ export default {
this.fullscreenLoading = false this.fullscreenLoading = false
this.$parent.onCancel(false) this.$parent.onCancel(false)
}).catch(e => { }).catch(e => {
this.fullscreenLoading = false
this.getFiles()
reject(e); reject(e);
}); });
} }
......
<!-- 答案内容预览 --> <!-- 答案内容预览 -->
<template> <template>
<vue-markdown :source="content" v-highlight class="markdown-body" :id="'myContainer'+index" > <vue-markdown :source="content" v-highlight class="markdown-body" :id="'myContainer'+index">
</vue-markdown> </vue-markdown>
</template> </template>
<script> <script>
...@@ -18,17 +18,17 @@ export default { ...@@ -18,17 +18,17 @@ export default {
}; };
}, },
props: ['content', 'index', 'isSuccess'], props: ['content', 'index', 'isSuccess'],
components: {VueMarkdown}, components: { VueMarkdown },
computed: {}, computed: {},
directives: { directives: {
highlight: { highlight: {
// 指令的定义 // 指令的定义
inserted: function (el) { inserted: function (el) {
let blocks = el.querySelectorAll('pre code'); let blocks = el.querySelectorAll('pre code');
blocks.forEach((block, index) => { blocks.forEach((block, index) => {
/** 代码高亮 */ /** 代码高亮 */
hljs.highlightBlock(block); hljs.highlightBlock(block);
/** 手动添加一个hljs类名,防止不支持的语言背景变空白 */ /** 手动添加一个hljs类名,防止不支持的语言背景变空白 */
block.classList.add('hljs'); block.classList.add('hljs');
...@@ -42,47 +42,86 @@ export default { ...@@ -42,47 +42,86 @@ export default {
watch: { watch: {
'isSuccess' () { 'isSuccess' () {
if (this.isSuccess) { if (this.isSuccess) {
let that = this
const anchorTags = document.querySelectorAll(`#myContainer${this.index} a`); const anchorTags = document.querySelectorAll(`#myContainer${this.index} a`);
// 遍历并输出链接的 href 属性 this.preview(anchorTags)
anchorTags.forEach((aTag) => {
aTag.addEventListener('click', function (event) {
let tagUrl = aTag.getAttribute('href')
let url;
// alert(aTag.getAttribute('href'))
if (['pdf', 'jpg', 'gif', 'jpeg', 'png', 'docx', 'doc', 'xlsx', 'xls', 'mp4', 'webm', 'ogg', 'ogv', 'txt'].indexOf(tagUrl.split('.').pop().toLowerCase()) !== -1) {
// 阻止默认点击事件
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 => {
}).catch(e => { });
}
});
});
} }
} }
}, },
methods: { methods: {
preview (anchorTags) {
let that = this
// 遍历并输出链接的 href 属性
anchorTags.forEach((aTag) => {
let tagUrl = aTag.getAttribute('href')
let isFile = ['pdf', 'jpg', 'gif', 'jpeg', 'png', 'docx', 'doc', 'xlsx', 'xls', 'mp4', 'webm', 'ogg', 'ogv', 'txt'].indexOf(tagUrl.split('.').pop().toLowerCase()) !== -1
if (isFile) {
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 => {
}).catch(e => { });
}
});
});
},
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>
<i class="el-icon-arrow-down"></i>
</button>
`);
describeDom.classList.add('describe')
let height = describeDom.scrollHeight
describeDom.setAttribute('style', `height:${height}px;`)
describeDom.previousElementSibling.addEventListener('click', function (event) {
if (height > 0 && (describeDom.style.height !== '0px' && describeDom.style.height !== '')) {
describeDom.setAttribute('style', 'height:0px;')
} else {
describeDom.setAttribute('style', `height:${height}px;`)
}
})
}
} }
} }
</script> </script>
<style scoped> <style scoped>
.markdown-body{ .markdown-body {
background: none !important; background: none !important;
font-size: 14px !important; font-size: 14px !important;
} }
.markdown-body pre{ .markdown-body pre {
background-color: #3b3d3f; background-color: #3b3d3f;
}
</style>
<style>
.describe {
overflow: hidden;
transition: 0.5s all;
color: #007fff;
font-size: 14px;
background-color: #fff;
border-radius: 10px;
padding: 0 20px 0 20px;
} }
</style> </style>
...@@ -195,7 +195,7 @@ export default { ...@@ -195,7 +195,7 @@ export default {
}, },
getKnowledgeList () { getKnowledgeList () {
let params = {} let params = {}
KnowledgeManage.listForTree(this, params).then(res => { KnowledgeManage.load(this, params).then(res => {
this.knowledgeList = res.data this.knowledgeList = res.data
}).catch(e => { }).catch(e => {
console.log(e); console.log(e);
......
...@@ -6,7 +6,7 @@ module.exports = {// ...@@ -6,7 +6,7 @@ module.exports = {//
proxy: { proxy: {
'/2api': { '/2api': {
/* 目标代理服务器地址 */ /* 目标代理服务器地址 */
target: 'http://127.0.0.1:7861', // target: 'http://192.168.0.36:7861', //
/* 允许跨域 */ /* 允许跨域 */
changeOrigin: true, changeOrigin: true,
ws: true, ws: true,
......
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