mirror of
https://github.com/DBNinjin/Ninjin.Web.v2.git
synced 2025-06-27 18:31:55 +00:00
Fix my lova logo and another elements
This commit is contained in:
parent
e1647c7aa5
commit
3255ef2d6e
@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import { page } from '$app/stores';
|
||||
let url = `ninjin.eu.org${$page.url.pathname == '/' ? '' : $page.url.pathname}`;
|
||||
let url = `https://ninjin.eu.org${$page.url.pathname == '/' ? '' : $page.url.pathname}`;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
|
@ -1 +0,0 @@
|
||||
// place files you want to import through the `$lib` alias in this folder.
|
25
src/lib/utils/cookies.js
Normal file
25
src/lib/utils/cookies.js
Normal file
@ -0,0 +1,25 @@
|
||||
// utils/cookies.js
|
||||
// @ts-ignore
|
||||
export function getCookie(name) {
|
||||
const value = `; ${document.cookie}`;
|
||||
const parts = value.split(`; ${name}=`);
|
||||
// @ts-ignore
|
||||
if (parts.length === 2) return parts.pop().split(';').shift();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export function setCookie(name, value, days) {
|
||||
let expires = '';
|
||||
if (days) {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
expires = `; expires=${date.toUTCString()}`;
|
||||
}
|
||||
document.cookie = `${name}=${value || ''}${expires}; path=/; SameSite=Strict`;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export function checkURL(url) {
|
||||
return window.location.href.includes(url);
|
||||
}
|
@ -1,22 +1,44 @@
|
||||
<script>
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
import { onMount } from 'svelte';
|
||||
import { getCookie, setCookie, checkURL } from '$lib/utils/cookies';
|
||||
import '$lib/assets/css/tailwind.css';
|
||||
import Header from '$lib/components/Layouts/Header.svelte';
|
||||
import Footer from '$lib/components/Layouts/Footer.svelte';
|
||||
import logoHeader from '$lib/assets/images/logo_header.png';
|
||||
import logoHeaderRevert from '$lib/assets/images/logo_header_revert.png';
|
||||
|
||||
let logo = logoHeader;
|
||||
if (data.revertNinjinLogo != 'false') {
|
||||
logo = logoHeaderRevert;
|
||||
}
|
||||
let isReverted = false;
|
||||
const cookieName = 'ninjin_af#eg@api/activate-revert-logo';
|
||||
|
||||
onMount(() => {
|
||||
// Vérifie si le cookie est déjà présent
|
||||
const cookieStatus = getCookie(cookieName);
|
||||
isReverted = cookieStatus === 'true';
|
||||
|
||||
// Si l'URL correspond à celle d'activation, mettre à jour le cookie
|
||||
if (checkURL('/api/activate-revert-logo')) {
|
||||
setCookie(cookieName, 'true', 30);
|
||||
isReverted = true;
|
||||
}
|
||||
|
||||
if (isReverted) {
|
||||
console.log('[Infos] Running a reverted logo version, EG is enabled');
|
||||
} else {
|
||||
console.log('[Infos] Running a normal logo version, EG is disabled');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<Header />
|
||||
<div class="container max-w-6xl mx-auto px-4">
|
||||
<main class="text-center mt-4 relative z-20">
|
||||
<img src={logo} alt="Ninjin Logo" class="w-full max-w-2xl mx-auto" draggable="false" />
|
||||
<img
|
||||
id="logo-header"
|
||||
src={isReverted ? logoHeaderRevert : logoHeader}
|
||||
alt="Ninjin Logo"
|
||||
class="w-full max-w-2xl mx-auto"
|
||||
draggable="false"
|
||||
/>
|
||||
|
||||
<section
|
||||
class="bg-[#192908] bg-opacity-70 border-4 border-black mx-10 my-4 p-6 rounded-lg shadow-lg hover:shadow-xl transition-shadow duration-300 ease-in-out"
|
||||
|
@ -25,10 +25,10 @@
|
||||
|
||||
if (isPC) {
|
||||
document.body.style.overflow = 'hidden';
|
||||
console.log('Running on a PC device, overflow is disabled');
|
||||
console.log('[Infos] Running on a PC device, overflow is disabled');
|
||||
} else {
|
||||
document.body.style.overflow = 'auto';
|
||||
console.log('Running on a mobile device, overflow is auto');
|
||||
console.log('[Infos] Running on a mobile device, overflow is auto');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
export function load({ cookies }) {
|
||||
const revertNinjinLogo = cookies.get('ninjin_af#eg@api/activate-revert-logo');
|
||||
|
||||
if (!revertNinjinLogo || revertNinjinLogo === 'false') {
|
||||
cookies.set('ninjin_af#eg@api/activate-revert-logo', 'true', {
|
||||
path: '/',
|
||||
httpOnly: false,
|
||||
sameSite: 'strict',
|
||||
maxAge: 60 * 60 * 24 * 30
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
revertNinjinLogo: revertNinjinLogo
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user