Commit e60e7e52 authored by mhw's avatar mhw

引用展开收缩

parent 25dc1fb3
......@@ -45,4 +45,7 @@ export default class KnowledgeManage {
static listForTree (sender, 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 {
white-space: nowrap;
text-overflow: ellipsis;
}
.el-message {
white-space: pre-line;
}
.omit_2 {
/*2行省略 */
text-overflow: -o-ellipsis-lastline;
......
......@@ -269,6 +269,7 @@
/* Break-point
--------------------------*/
.el-message {
white-space: pre-line;
min-width: 380px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
......
module.exports = {
baseUrl: 'http://192.168.83.215:8082/',
wsUrl: 'ws://127.0.0.1:7860/',
baseUrl: 'http://192.168.0.36:8082/',
wsUrl: 'ws://192.168.0.36:7860/',
projectName: '灵境大模型平台'
}
......@@ -189,13 +189,24 @@ const fetchUpload = function (url, params, isDefUrl = true) {
}
]
}).then(res => {
console.log(res);
console.log(res, res.data.msg);
if ((res.data && res.data.success) || res.data.code === 200) {
resolve(res.data);
} 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({
showClose: true,
message: res.data.errorMessage ? res.data.errorMessage : '数据请求失败'
message: res.data.errorMessage || res.data.msg ? res.data.errorMessage || msg : '数据请求失败'
});
}
}).catch(e => {
......
......@@ -4,8 +4,8 @@
<el-form-item label="上传知识库文件:" prop="filesArr">
<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">
<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="itemFile" v-for="(item,index) in files" :key="item.name">{{ item.name }}
<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"><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>
</div>
</el-form-item>
......@@ -14,7 +14,7 @@
</el-slider>
</el-form-item>
<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-form-item>
<el-form-item label="开启中文标题加强:">
......@@ -121,6 +121,8 @@ export default {
this.fullscreenLoading = false
this.$parent.onCancel(false)
}).catch(e => {
this.fullscreenLoading = false
this.getFiles()
reject(e);
});
}
......
<!-- 答案内容预览 -->
<template>
<vue-markdown :source="content" v-highlight class="markdown-body" :id="'myContainer'+index" >
</vue-markdown>
<vue-markdown :source="content" v-highlight class="markdown-body" :id="'myContainer'+index">
</vue-markdown>
</template>
<script>
......@@ -18,17 +18,17 @@ export default {
};
},
props: ['content', 'index', 'isSuccess'],
components: {VueMarkdown},
components: { VueMarkdown },
computed: {},
directives: {
highlight: {
// 指令的定义
// 指令的定义
inserted: function (el) {
let blocks = el.querySelectorAll('pre code');
blocks.forEach((block, index) => {
/** 代码高亮 */
/** 代码高亮 */
hljs.highlightBlock(block);
/** 手动添加一个hljs类名,防止不支持的语言背景变空白 */
block.classList.add('hljs');
......@@ -42,47 +42,86 @@ export default {
watch: {
'isSuccess' () {
if (this.isSuccess) {
let that = this
const anchorTags = document.querySelectorAll(`#myContainer${this.index} a`);
// 遍历并输出链接的 href 属性
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 => { });
}
});
});
this.preview(anchorTags)
}
}
},
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>
<style scoped>
.markdown-body{
background: none !important;
font-size: 14px !important;
.markdown-body {
background: none !important;
font-size: 14px !important;
}
.markdown-body pre{
background-color: #3b3d3f;
.markdown-body pre {
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>
......@@ -195,7 +195,7 @@ export default {
},
getKnowledgeList () {
let params = {}
KnowledgeManage.listForTree(this, params).then(res => {
KnowledgeManage.load(this, params).then(res => {
this.knowledgeList = res.data
}).catch(e => {
console.log(e);
......
......@@ -6,7 +6,7 @@ module.exports = {//
proxy: {
'/2api': {
/* 目标代理服务器地址 */
target: 'http://127.0.0.1:7861', //
target: 'http://192.168.0.36:7861', //
/* 允许跨域 */
changeOrigin: 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