mirror of
https://github.com/zebrajr/ollama-webui.git
synced 2025-12-05 12:20:26 +01:00
Merge pull request #17502 from ShirasawaSama/patch-4
feat: Dynamically load jspdf and html2canvas-pro to improve first-screen loading speed (-980KB)
This commit is contained in:
commit
d88c6f81ee
|
|
@ -6,9 +6,6 @@
|
|||
import fileSaver from 'file-saver';
|
||||
const { saveAs } = fileSaver;
|
||||
|
||||
import jsPDF from 'jspdf';
|
||||
import html2canvas from 'html2canvas-pro';
|
||||
|
||||
import { downloadChatAsPDF } from '$lib/apis/utils';
|
||||
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
||||
|
||||
|
|
@ -75,6 +72,11 @@
|
|||
};
|
||||
|
||||
const downloadPdf = async () => {
|
||||
const [{ default: jsPDF }, { default: html2canvas }] = await Promise.all([
|
||||
import('jspdf'),
|
||||
import('html2canvas-pro')
|
||||
]);
|
||||
|
||||
if ($settings?.stylizedPdfExport ?? true) {
|
||||
showFullMessages = true;
|
||||
await tick();
|
||||
|
|
|
|||
|
|
@ -6,9 +6,6 @@
|
|||
import fileSaver from 'file-saver';
|
||||
const { saveAs } = fileSaver;
|
||||
|
||||
import jsPDF from 'jspdf';
|
||||
import html2canvas from 'html2canvas-pro';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
|
|
@ -91,6 +88,11 @@
|
|||
return;
|
||||
}
|
||||
|
||||
const [{ default: jsPDF }, { default: html2canvas }] = await Promise.all([
|
||||
import('jspdf'),
|
||||
import('html2canvas-pro')
|
||||
]);
|
||||
|
||||
if ($settings?.stylizedPdfExport ?? true) {
|
||||
showFullMessages = true;
|
||||
await tick();
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@
|
|||
import fileSaver from 'file-saver';
|
||||
const { saveAs } = fileSaver;
|
||||
|
||||
import jsPDF from 'jspdf';
|
||||
import html2canvas from 'html2canvas-pro';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
import { marked } from 'marked';
|
||||
|
|
@ -575,6 +572,11 @@ ${content}
|
|||
|
||||
const downloadPdf = async (note) => {
|
||||
try {
|
||||
const [{ default: jsPDF }, { default: html2canvas }] = await Promise.all([
|
||||
import('jspdf'),
|
||||
import('html2canvas-pro')
|
||||
]);
|
||||
|
||||
// Define a fixed virtual screen size
|
||||
const virtualWidth = 1024; // Fixed width (adjust as needed)
|
||||
const virtualHeight = 1400; // Fixed height (adjust as needed)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@
|
|||
|
||||
const { saveAs } = fileSaver;
|
||||
|
||||
import jsPDF from 'jspdf';
|
||||
import html2canvas from 'html2canvas-pro';
|
||||
|
||||
import dayjs from '$lib/dayjs';
|
||||
import duration from 'dayjs/plugin/duration';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
|
@ -137,6 +134,11 @@
|
|||
|
||||
const downloadPdf = async (note) => {
|
||||
try {
|
||||
const [{ default: jsPDF }, { default: html2canvas }] = await Promise.all([
|
||||
import('jspdf'),
|
||||
import('html2canvas-pro')
|
||||
]);
|
||||
|
||||
// Define a fixed virtual screen size
|
||||
const virtualWidth = 1024; // Fixed width (adjust as needed)
|
||||
const virtualHeight = 1400; // Fixed height (adjust as needed)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user