fix : correction de l'impression des absences + ajout d'un favicon
All checks were successful
Auto Tag Develop / tag (push) Successful in 5s

This commit is contained in:
2026-02-09 20:49:47 +01:00
parent 92d5fa55d0
commit 5be33abb03
6 changed files with 22 additions and 11 deletions

View File

@@ -4,9 +4,14 @@ import { useAuthStore } from '~/stores/auth'
export type AnyObject = Record<string, unknown>
export type BlobResponse = {
data: Blob
headers: Headers
}
export type ApiClient = {
get<T>(url: string, query?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
getBlob(url: string, query?: AnyObject, options?: ApiFetchOptions<'blob'>): Promise<Blob>
getBlob(url: string, query?: AnyObject, options?: ApiFetchOptions<'blob'>): Promise<BlobResponse>
post<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
put<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
patch<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
@@ -165,7 +170,9 @@ export const useApi = (): ApiClient => {
return request<T>('GET', url, { ...options, query })
},
getBlob(url: string, query: AnyObject = {}, options: ApiFetchOptions<'blob'> = {}) {
return client<Blob>(url, { ...options, method: 'GET', query, responseType: 'blob' })
return client
.raw(url, { ...options, method: 'GET', query, responseType: 'blob' })
.then((res) => ({ data: res._data as Blob, headers: res.headers }))
},
post<T>(url: string, body: AnyObject = {}, options: ApiFetchOptions<'json'> = {}) {
return request<T>('POST', url, { ...options, body })

View File

@@ -4,16 +4,17 @@ export const usePdfPrinter = () => {
const api = useApi()
const printPdf = async (url: string): Promise<void> => {
const blob = await api.getBlob(url);
const res = await api.getBlob(url);
const disposition = res.headers.get('content-disposition') || '';
const match = disposition.match(/filename="(.+?)"/i);
const filename = match?.[1] ?? 'document.pdf';
const pdfBlob = blob.type === 'application/pdf'
? blob
: new Blob([blob], { type: 'application/pdf' });
const pdfBlob = res.data.type === 'application/pdf'
? res.data
: new Blob([res.data], { type: 'application/pdf' });
const blobUrl = URL.createObjectURL(pdfBlob);
const filename = `test.pdf`;
const a = document.createElement('a');
a.href = blobUrl;
a.download = filename;

View File

@@ -63,7 +63,6 @@ const handleSubmit = async () => {
isSubmitting.value = true
try {
console.log(useRuntimeConfig().public.apiBase)
await auth.login(username.value, password.value)
await router.push('/')

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB