From 506ab5bf9f22d6ede6aa733690fbda1784e472c0 Mon Sep 17 00:00:00 2001 From: kudzu2019 <56812785+kudzu2019@users.noreply.github.com> Date: Mon, 11 Aug 2025 00:43:07 +0800 Subject: [PATCH 1/2] Update plugin.client.ts Set the path of the cookie to the root directory , path=/ --- src/runtime/plugin.client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/plugin.client.ts b/src/runtime/plugin.client.ts index ba09ef08..24db70f5 100644 --- a/src/runtime/plugin.client.ts +++ b/src/runtime/plugin.client.ts @@ -79,7 +79,8 @@ export default defineNuxtPlugin((nuxtApp) => { function setPreferenceToStorage(storageType: typeof storage, preference: string) { switch (storageType) { case 'cookie': - window.document.cookie = storageKey + '=' + preference + const oneYear = 60 * 60 * 24 * 365 + window.document.cookie = `${storageKey}=${preference}; max-age=${oneYear}; path=/`; break case 'sessionStorage': window.sessionStorage?.setItem(storageKey, preference) From 313b9b19a396e65e0331c65f76564f701ca8ce28 Mon Sep 17 00:00:00 2001 From: kudzu2019 <56812785+kudzu2019@users.noreply.github.com> Date: Mon, 11 Aug 2025 01:02:51 +0800 Subject: [PATCH 2/2] Update plugin.client.ts --- src/runtime/plugin.client.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/runtime/plugin.client.ts b/src/runtime/plugin.client.ts index 24db70f5..840ad2ce 100644 --- a/src/runtime/plugin.client.ts +++ b/src/runtime/plugin.client.ts @@ -79,8 +79,7 @@ export default defineNuxtPlugin((nuxtApp) => { function setPreferenceToStorage(storageType: typeof storage, preference: string) { switch (storageType) { case 'cookie': - const oneYear = 60 * 60 * 24 * 365 - window.document.cookie = `${storageKey}=${preference}; max-age=${oneYear}; path=/`; + window.document.cookie = `${storageKey}=${preference}; max-age=${60 * 60 * 24 * 365}; path=/` break case 'sessionStorage': window.sessionStorage?.setItem(storageKey, preference)