zwischenstand

This commit is contained in:
Martin Drechsel
2025-05-06 11:09:56 +02:00
parent 410a885d21
commit b729c8ebbe
40 changed files with 2252 additions and 376 deletions

View File

@ -1,21 +1,21 @@
import { H3Error } from 'h3';
import { H3Error } from "h3";
export const bytesToBase64DataUrlAsync = async (
bytes: Uint8Array,
type = 'application/octet-stream'
type = "application/octet-stream"
) => {
return await new Promise((resolve, reject) => {
const reader = Object.assign(new FileReader(), {
onload: () => resolve(reader.result),
onerror: () => reject(reader.error),
});
reader.readAsDataURL(new File([new Blob([bytes])], '', { type }));
reader.readAsDataURL(new File([new Blob([bytes])], "", { type }));
});
};
export const blobToImageAsync = (blob: Blob): Promise<HTMLImageElement> => {
return new Promise((resolve) => {
console.log('transform blob', blob);
console.log("transform blob", blob);
const url = URL.createObjectURL(blob);
let img = new Image();
img.onload = () => {
@ -34,7 +34,7 @@ export const deepToRaw = <T extends Record<string, any>>(sourceObj: T): T => {
if (isRef(input) || isReactive(input) || isProxy(input)) {
return objectIterator(toRaw(input));
}
if (input && typeof input === 'object') {
if (input && typeof input === "object") {
return Object.keys(input).reduce((acc, key) => {
acc[key as keyof typeof acc] = objectIterator(input[key]);
return acc;
@ -48,10 +48,9 @@ export const deepToRaw = <T extends Record<string, any>>(sourceObj: T): T => {
export const readableFileSize = (sizeInByte: number | string = 0) => {
if (!sizeInByte) {
return '0 KB';
return "0 KB";
}
const size =
typeof sizeInByte === 'string' ? parseInt(sizeInByte) : sizeInByte;
const size = typeof sizeInByte === "string" ? parseInt(sizeInByte) : sizeInByte;
const sizeInKb = size / 1024;
const sizeInMb = sizeInKb / 1024;
const sizeInGb = sizeInMb / 1024;
@ -64,20 +63,17 @@ export const readableFileSize = (sizeInByte: number | string = 0) => {
return `${sizeInKb.toFixed(2)} KB`;
};
import type { LocationQueryValue, RouteLocationRawI18n } from 'vue-router';
import type { LocationQueryValue, RouteLocationRawI18n } from "vue-router";
export const getSingleRouteParam = (
param: string | string[] | LocationQueryValue | LocationQueryValue[]
): string => {
const _param = Array.isArray(param) ? param.at(0) ?? '' : param ?? '';
const _param = Array.isArray(param) ? param.at(0) ?? "" : param ?? "";
//console.log('found param', _param, param);
return _param;
return decodeURIComponent(_param);
};
export const isRouteActive = (
to: RouteLocationRawI18n,
exact: boolean = false
) =>
export const isRouteActive = (to: RouteLocationRawI18n, exact: boolean = false) =>
computed(() => {
const found = useRouter()
.getRoutes()
@ -86,9 +82,7 @@ export const isRouteActive = (
return exact
? found?.name === useRouter().currentRoute.value.name
: found?.name === useRouter().currentRoute.value.name ||
found?.children.some(
(child) => child.name === useRouter().currentRoute.value.name
);
found?.children.some((child) => child.name === useRouter().currentRoute.value.name);
});
export const isKey = <T extends object>(x: T, k: PropertyKey): k is keyof T => {