Minimal Viable Product + Refactor to pinia store + Fix PDF export
This commit is contained in:
@@ -1,13 +1,33 @@
|
||||
import { jsPDF } from "jspdf";
|
||||
|
||||
export function exportToPdf(element: HTMLElement, name: string) {
|
||||
const pdf = new jsPDF();
|
||||
// const pdf = new jsPDF({orientation: 'portrait', unit: 'mm', format: 'a4', precision: 1, hotfixes: ["px_scaling"]});
|
||||
|
||||
// pdf.html(element, {
|
||||
// callback: function (doc) {
|
||||
// doc.save(name);
|
||||
// },
|
||||
// margin: [0, 0, 0, 0],
|
||||
// autoPaging: 'text',
|
||||
// // width: 210,
|
||||
// // windowWidth: 2100,
|
||||
// html2canvas: {
|
||||
// allowTaint: true,
|
||||
// letterRendering: true,
|
||||
// logging: true,
|
||||
// // width: 210,
|
||||
// // windowWidth: 2100,
|
||||
// // scale: 0.2,
|
||||
// // scale: 210 / element.scrollWidth,
|
||||
// },
|
||||
// });
|
||||
|
||||
const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' });
|
||||
pdf.html(element, {
|
||||
callback: function (doc) {
|
||||
doc.save(name);
|
||||
},
|
||||
width: 210,
|
||||
windowWidth: element.scrollWidth,
|
||||
windowWidth: 1080,
|
||||
});
|
||||
}
|
||||
|
||||
5
resources/js/lib/pinia.ts
Normal file
5
resources/js/lib/pinia.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { createPinia } from 'pinia'
|
||||
|
||||
const pinia = createPinia()
|
||||
|
||||
export default pinia
|
||||
@@ -26,9 +26,13 @@ export async function httpApi<T>(url: string, options?: RequestInit, useFetchOpt
|
||||
...options,
|
||||
},
|
||||
useFetchOptions
|
||||
).json();
|
||||
);
|
||||
|
||||
if (!error.value && data.value) {
|
||||
if (data.value) {
|
||||
data.value = JSON.parse(data.value as string) as T;
|
||||
}
|
||||
|
||||
if (!error.value) {
|
||||
return { data: data.value, error: null };
|
||||
} else {
|
||||
return { data: data.value, error: error.value };
|
||||
|
||||
Reference in New Issue
Block a user