|
@@ -394,7 +394,7 @@
|
|
|
></wOffice>
|
|
|
<relateFiles ref="relateFiles"></relateFiles>
|
|
|
<checkDialog ref="checkDialog"></checkDialog>
|
|
|
- <WebCrawlDialog :visible.sync="webUrlDialogVisible" @confirm="handleWebUrlConfirm"/>
|
|
|
+ <WebCrawlDialog :visible.sync="webUrlDialogVisible" :input-url.sync="webInputUrl" @confirm="handleWebUrlConfirm"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -512,6 +512,7 @@ export default {
|
|
|
ptotal: 0,
|
|
|
fileType: 1,
|
|
|
webUrlDialogVisible: false,
|
|
|
+ webInputUrl: '',
|
|
|
|
|
|
};
|
|
|
},
|
|
@@ -701,27 +702,10 @@ export default {
|
|
|
handleWebUrlConfirm(dataFromForm) {
|
|
|
if (!dataFromForm) return;
|
|
|
this.proVisible = true;
|
|
|
- // this.isLoading = true;
|
|
|
- // 直接 decode,不用判断前缀
|
|
|
- // let url = decodeURIComponent(dataFromForm.url);
|
|
|
-
|
|
|
- // const fileExtension = file.name.split(".").pop().toLowerCase();
|
|
|
-
|
|
|
- // if (!allowedExtensions.includes(fileExtension)) {
|
|
|
- // this.$message.error(`${this.lang.unsupFileformats}: ${file.name}`);
|
|
|
- // await new Promise((resolve) => setTimeout(resolve, 1000)); // 延迟1秒再跳过
|
|
|
- // continue; // 跳过不支持的文件
|
|
|
- // }
|
|
|
let uuid = uuidv4();
|
|
|
let formData = new FormData();
|
|
|
- // const timestamp = Date.now();
|
|
|
- // const baseName = file.name.slice(0, -(fileExtension.length + 1));
|
|
|
let string = [this.folderid, this.moFolderid].filter((id) => id);
|
|
|
formData.append("url", dataFromForm.url)
|
|
|
- // formData.append(
|
|
|
- // "file",
|
|
|
- // new File([file], `${baseName}${timestamp}.${fileExtension}`)
|
|
|
- // );
|
|
|
formData.append("collection_ids", JSON.stringify(string));
|
|
|
formData.append("id", uuid);
|
|
|
formData.append(
|
|
@@ -730,41 +714,20 @@ export default {
|
|
|
);
|
|
|
formData.append("ingestion_mode", "fast");
|
|
|
formData.append("run_with_orchestration", "false");
|
|
|
-
|
|
|
- // 获取html2md服务地址,优先从store取,没有则默认
|
|
|
+ debugger
|
|
|
const html2mdApi = process.env.VUE_APP_HTML2MD_API || 'http://localhost:7004';
|
|
|
const url = html2mdApi + '/file/knowledge-base/html-to-markdown';
|
|
|
const headers = {'Content-Type': 'multipart/form-data'};
|
|
|
this.ajax.post(url, formData, {headers})
|
|
|
.then(async (response) => {
|
|
|
- // if (this.loadingInstance) {
|
|
|
- // this.$nextTick(() => {
|
|
|
- // this.loadingInstance.close();
|
|
|
- // });
|
|
|
- // }
|
|
|
- console.log(response);
|
|
|
if (response && response.data && response.data.results) {
|
|
|
this.$message.success('文件上传成功');
|
|
|
- // 获取文件名和id
|
|
|
- // const fileName = response.data.results && response.data.results.filename ? response.data.results.filename : url;
|
|
|
const fileName = response.data.title;
|
|
|
const documentId = response.data.results && response.data.results.document_id;
|
|
|
-
|
|
|
- const status =
|
|
|
- response && response.status === 200
|
|
|
- ? "success"
|
|
|
- : "failed";
|
|
|
- const msg =
|
|
|
- response && response.status === 200
|
|
|
- ? "切片成功"
|
|
|
- : "切片失败";
|
|
|
- this.$message({
|
|
|
- message: msg,
|
|
|
- type: status == "success" ? status : "error",
|
|
|
- });
|
|
|
- // setTimeout(() => {
|
|
|
+ const status = response && response.status === 200 ? "success" : "failed";
|
|
|
+ const msg = response && response.status === 200 ? "切片成功" : "切片失败";
|
|
|
+ this.$message({ message: msg, type: status == "success" ? status : "error" });
|
|
|
this.getData();
|
|
|
- // }, 1000)
|
|
|
setTimeout(() => {
|
|
|
this.fileArray.forEach((e) => {
|
|
|
if (e.documentid === uuid) {
|
|
@@ -772,8 +735,6 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
}, 1000);
|
|
|
-
|
|
|
- // 调用 bindFileAndFolder
|
|
|
if (documentId) {
|
|
|
await this.bindFileAndFolder(
|
|
|
fileName,
|
|
@@ -783,9 +744,12 @@ export default {
|
|
|
this.moFolderid
|
|
|
);
|
|
|
}
|
|
|
+ // 受控组件写法,直接清空 input
|
|
|
+ this.webInputUrl = '';
|
|
|
} else {
|
|
|
this.$message.error(response && response.data && response.data.msg ? response.data.msg : '文件上传失败');
|
|
|
}
|
|
|
+ this.proVisible = false;
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
this.$message.error('服务器繁忙');
|
|
@@ -797,6 +761,7 @@ export default {
|
|
|
this.loadingInstance.close();
|
|
|
});
|
|
|
}
|
|
|
+ this.proVisible = false;
|
|
|
});
|
|
|
},
|
|
|
async bindFileAndFolder(name, docid, uid, folder_id, mofid = '') {
|