|
|
|
@ -8,7 +8,7 @@ |
|
|
|
|
<div class="ai-edit-left col m-r-large v-overflow-y" v-loading="generatedLoading" |
|
|
|
|
element-loading-text="请稍后,正文生成中..."> |
|
|
|
|
<div class="ai-show-btn show" @click="showPage = !showPage"><i class="el-icon-arrow-right"></i></div> |
|
|
|
|
<div class="ai-edit-content" v-html="generatedContent" v-if="!editorState"></div> |
|
|
|
|
<div class="ai-edit-content v-overflow-y" ref="generatedContent" v-html="generatedContent" v-if="!editorState"></div> |
|
|
|
|
<ckeditor :editor="editor" v-model="generatedEdit" :config="editorConfig" style="height:500px"/> |
|
|
|
|
<div class="v-edit-tool"> |
|
|
|
|
<div class="v-edit-tool-item down" @click="downLoadDoc"><i class="iconfont icon-down"></i></div> |
|
|
|
@ -97,6 +97,7 @@ |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div v-html="generatedEdit" class="v-export-box" ></div> |
|
|
|
|
</main> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
@ -105,8 +106,7 @@ |
|
|
|
|
import FileUpload from '@/components/FileUpload' |
|
|
|
|
import FileUpload1 from '@/components/FileUpload1' |
|
|
|
|
|
|
|
|
|
import htmlDocx from 'html-docx-js/dist/html-docx'; |
|
|
|
|
import FileSaver from 'file-saver'; |
|
|
|
|
import handleExportWord from "xh-htmlword"; |
|
|
|
|
|
|
|
|
|
import * as AiApi from '@/api/ai-api' |
|
|
|
|
|
|
|
|
@ -323,29 +323,17 @@ export default { |
|
|
|
|
methods: { |
|
|
|
|
downLoadDoc() { |
|
|
|
|
let doc = this.generatedContent.replace(/<[^>]*>/g, '') |
|
|
|
|
this.downloadTextAsFile(doc, this.form.title) |
|
|
|
|
this.downloadTextAsFile() |
|
|
|
|
}, |
|
|
|
|
refreshDoc() { |
|
|
|
|
this.generateDoc() |
|
|
|
|
}, |
|
|
|
|
downloadTextAsFile(text, fileName) { |
|
|
|
|
// 创建一个Blob对象,将文本内容转换为Blob |
|
|
|
|
var blob = new Blob([text], {type: 'application/msword;charset=utf-8'}); |
|
|
|
|
// 创建一个下载链接 |
|
|
|
|
var downloadLink = document.createElement('a'); |
|
|
|
|
downloadLink.href = URL.createObjectURL(blob); |
|
|
|
|
downloadLink.download = fileName; |
|
|
|
|
|
|
|
|
|
// 将下载链接添加到文档中(但不可见) |
|
|
|
|
document.body.appendChild(downloadLink); |
|
|
|
|
|
|
|
|
|
// 触发下载链接的点击事件 |
|
|
|
|
downloadLink.click(); |
|
|
|
|
|
|
|
|
|
// 从文档中移除下载链接 |
|
|
|
|
document.body.removeChild(downloadLink); |
|
|
|
|
// 释放Blob对象的URL |
|
|
|
|
URL.revokeObjectURL(downloadLink.href); |
|
|
|
|
downloadTextAsFile() { |
|
|
|
|
console.log("adsf",this.generatedEdit) |
|
|
|
|
handleExportWord({ |
|
|
|
|
dom: ".v-export-box", |
|
|
|
|
fileName: this.form.title?this.form.title:'公文', |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
/** 获取 模型列表 */ |
|
|
|
|
async getModellist() { |
|
|
|
@ -490,6 +478,7 @@ export default { |
|
|
|
|
|
|
|
|
|
// 处理正式内容 |
|
|
|
|
if (delta.content) { |
|
|
|
|
this.$nextTick(this.scrollToBottom('generatedContent')) |
|
|
|
|
if (this.thinkState) { |
|
|
|
|
this.endTime = new Date(); |
|
|
|
|
let deepTime = Math.abs(this.endTime.getTime() - this.startTime.getTime()); |
|
|
|
@ -501,7 +490,7 @@ export default { |
|
|
|
|
this.generatedContent += delta.content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.$nextTick(this.scrollToBottom); |
|
|
|
|
this.$nextTick(this.scrollToBottom(docCcontent)); |
|
|
|
|
} |
|
|
|
|
} catch (e) { |
|
|
|
|
console.warn("解析数据失败:", e); |
|
|
|
@ -546,8 +535,8 @@ export default { |
|
|
|
|
this.eventSource = null; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
scrollToBottom() { |
|
|
|
|
const container = this.$refs.docCcontent |
|
|
|
|
scrollToBottom(val) { |
|
|
|
|
const container = this.$refs[val] |
|
|
|
|
if (container) { |
|
|
|
|
container.scrollTop = container.scrollHeight; |
|
|
|
|
} |
|
|
|
|