fix(ResearchReport): dynamically import print-js

This commit is contained in:
AnotiaWang
2025-02-24 22:54:52 +08:00
parent d27b131d1a
commit f8fa797518

View File

@ -1,5 +1,4 @@
<script setup lang="ts"> <script setup lang="ts">
import printJS from 'print-js'
import { marked } from 'marked' import { marked } from 'marked'
import { writeFinalReport } from '~/lib/deep-research' import { writeFinalReport } from '~/lib/deep-research'
import { import {
@ -34,6 +33,8 @@
loadingExportMarkdown.value, loadingExportMarkdown.value,
) )
let printJS: typeof import('print-js') | undefined
async function generateReport() { async function generateReport() {
loading.value = true loading.value = true
error.value = '' error.value = ''
@ -88,6 +89,10 @@
// Wait after title is changed // Wait after title is changed
await new Promise((r) => setTimeout(r, 100)) await new Promise((r) => setTimeout(r, 100))
if (!printJS) {
printJS = (await import('print-js')).default
}
printJS({ printJS({
printable: reportHtml.value, printable: reportHtml.value,
type: 'raw-html', type: 'raw-html',