1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-24 07:39:41 +02:00

feat: Migrate to Nuxt 3 framework (#5184)

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
Hoa (Kyle) Trinh 2025-06-20 00:09:12 +07:00 committed by GitHub
parent 89ab7fac25
commit c24d532608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
403 changed files with 23959 additions and 19557 deletions

View file

@ -1,17 +1,10 @@
import { IncomingMessage } from "connect";
import { useDark } from "@vueuse/core";
import { useContext } from "@nuxtjs/composition-api";
import { useDark, useToggle } from "@vueuse/core";
export const useToggleDarkMode = () => {
const isDark = useDark();
const { $vuetify } = useContext();
const toggleDark = useToggle(isDark);
function toggleDark() {
isDark.value = !$vuetify.theme.dark;
$vuetify.theme.dark = !$vuetify.theme.dark;
}
return toggleDark;
return () => toggleDark();
};
export const useAsyncKey = function () {
@ -21,34 +14,13 @@ export const useAsyncKey = function () {
export const titleCase = function (str: string) {
return str
.split(" ")
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(" ");
};
export function detectServerBaseUrl(req?: IncomingMessage | null) {
if (!req || req === undefined) {
return "";
}
if (req.headers.referer) {
const url = new URL(req.headers.referer);
return `${url.protocol}//${url.host}`;
} else if (req.headers.host) {
// TODO Socket.encrypted doesn't exist. What is needed here?
// @ts-ignore See above
const protocol = req.socket.encrypted ? "https:" : "http:";
return `${protocol}//${req.headers.host}`;
} else if (req.socket.remoteAddress) {
// @ts-ignore See above
const protocol = req.socket.encrypted ? "https:" : "http:";
return `${protocol}//${req.socket.localAddress || ""}:${req.socket.localPort || ""}`;
}
return "";
}
export function uuid4() {
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) =>
(parseInt(c) ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (parseInt(c) / 4)))).toString(16)
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
(parseInt(c) ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (parseInt(c) / 4)))).toString(16),
);
}
@ -61,7 +33,8 @@ export function deepCopy<T>(obj: T): T {
if (obj === null) {
// null => null
rv = null;
} else {
}
else {
switch (Object.prototype.toString.call(obj)) {
case "[object Array]":
// It's an array, create a new array with
@ -81,7 +54,6 @@ export function deepCopy<T>(obj: T): T {
// Some other kind of object, deep-copy its
// properties into a new object
rv = Object.keys(obj).reduce(function (prev, key) {
// @ts-ignore This is hard to make type-safe
prev[key] = deepCopy(obj[key]);
return prev;
}, {});