bugfixing
This commit is contained in:
parent
4005ba9adc
commit
b041a54d68
@ -1,6 +1,6 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
|
|
||||||
<html lang="en" >
|
<html lang="en" data-theme="">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||||
|
|||||||
@ -5,10 +5,13 @@ import { serializeNonPOJOs } from "$lib/utils";
|
|||||||
export const handle = sequence(async ({ event, resolve }) => {
|
export const handle = sequence(async ({ event, resolve }) => {
|
||||||
|
|
||||||
// Use a ternary operator instead of the logical OR for better compatibility
|
// Use a ternary operator instead of the logical OR for better compatibility
|
||||||
const pbURL = import.meta.env.VITE_USEAST_POCKETBASE_URL; //isUS ? import.meta.env.VITE_USEAST_POCKETBASE_URL : import.meta.env.VITE_EU_POCKETBASE_URL;
|
const pbURL = import.meta.env.VITE_USEAST_POCKETBASE_URL;
|
||||||
const apiURL = import.meta.env.VITE_USEAST_API_URL; //isUS ? import.meta.env.VITE_USEAST_API_URL : import.meta.env.VITE_EU_API_URL;
|
const apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||||
const fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL; //isUS ? import.meta.env.VITE_USEAST_FASTIFY_URL : import.meta.env.VITE_EU_FASTIFY_URL;
|
const fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
|
||||||
const wsURL = import.meta.env.VITE_USEAST_WS_URL; //isUS ? import.meta.env.VITE_USEAST_WS_URL : import.meta.env.VITE_EU_WS_URL;
|
const wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||||
|
|
||||||
|
const themeMode = event?.cookies?.get("theme-mode");
|
||||||
|
|
||||||
|
|
||||||
event.locals = {
|
event.locals = {
|
||||||
pb: new PocketBase(pbURL),
|
pb: new PocketBase(pbURL),
|
||||||
@ -16,6 +19,7 @@ export const handle = sequence(async ({ event, resolve }) => {
|
|||||||
fastifyURL,
|
fastifyURL,
|
||||||
wsURL,
|
wsURL,
|
||||||
apiKey: import.meta.env.VITE_STOCKNEAR_API_KEY,
|
apiKey: import.meta.env.VITE_STOCKNEAR_API_KEY,
|
||||||
|
themeMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
const authCookie = event?.request?.headers?.get("cookie") || "";
|
const authCookie = event?.request?.headers?.get("cookie") || "";
|
||||||
@ -33,7 +37,9 @@ export const handle = sequence(async ({ event, resolve }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await resolve(event);
|
const response = await resolve(event, {
|
||||||
|
transformPageChunk: ({html}) => html.replace('data-theme=""', `data-theme="${themeMode}"`)
|
||||||
|
});
|
||||||
|
|
||||||
// Use a more compatible way to set the cookie
|
// Use a more compatible way to set the cookie
|
||||||
const cookieString = event?.locals?.pb?.authStore?.exportToCookie({
|
const cookieString = event?.locals?.pb?.authStore?.exportToCookie({
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
export const ssr = true;
|
|
||||||
|
|
||||||
|
|
||||||
export const load = ({ locals, cookies }) => {
|
export const load = ({ locals, cookies }) => {
|
||||||
const { user, isUSRegion, wsURL } = locals;
|
const { user, isUSRegion, wsURL, themeMode } = locals;
|
||||||
const themeMode = cookies.get("theme-mode") || "dark"; // Default to dark
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user: user || undefined,
|
user: user || undefined,
|
||||||
|
|||||||
@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
|
console.log(data?.themeMode, $mode)
|
||||||
let hideHeader = false;
|
let hideHeader = false;
|
||||||
BProgress.configure({
|
BProgress.configure({
|
||||||
showSpinner: false,
|
showSpinner: false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user