|
|
|
@ -37,6 +37,7 @@ import FileUploadDrag from '@/components/FileUploadDrag' |
|
|
|
|
import img01 from "@/assets/ai-test/img01.png" |
|
|
|
|
import img02 from "@/assets/ai-test/img02.png" |
|
|
|
|
import img03 from "@/assets/ai-test/img03.png" |
|
|
|
|
import mammoth from "mammoth"; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
name: 'Index', |
|
|
|
@ -71,12 +72,20 @@ export default { |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
/** 文件上传 **/ |
|
|
|
|
handleReferenceChange(file) { |
|
|
|
|
async handleReferenceChange(file) { |
|
|
|
|
this.checkState = true |
|
|
|
|
this.file = file |
|
|
|
|
const markdown = await this.convertDocxToMarkdown(file.raw); |
|
|
|
|
console.log(markdown); |
|
|
|
|
}, |
|
|
|
|
async convertDocxToMarkdown(file) { |
|
|
|
|
const result = await mammoth.extractRawText({ arrayBuffer: file }); |
|
|
|
|
// 这里可以添加额外的转换逻辑将纯文本转为Markdown |
|
|
|
|
return result.value; |
|
|
|
|
}, |
|
|
|
|
/** 页面跳转 **/ |
|
|
|
|
gotoPages() { |
|
|
|
|
|
|
|
|
|
this.$router.push({name: 'DocumentWritingDialog', params: {fileId: this.file.url,fileName: this.file.name}}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|