From 8e990f61d4a1790420f6eed542e09cb523b8a7a3 Mon Sep 17 00:00:00 2001 From: you Date: Mon, 23 Mar 2026 02:56:59 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20initState=20merges=20localStorage=20?= =?UTF-8?q?=E2=86=92=20export=20includes=20saved=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit State now loads: DEFAULTS → server config → localStorage. Admin saves locally, comes back later, opens customizer — sees their saved values, export includes everything. --- public/customize.js | 23 +++++++++++++---------- public/index.html | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/public/customize.js b/public/customize.js index 0b517d32..4f2f8cd0 100644 --- a/public/customize.js +++ b/public/customize.js @@ -189,18 +189,21 @@ function initState() { const cfg = window.SITE_CONFIG || {}; + // Merge: DEFAULTS → server config → localStorage saved values + var local = {}; + try { var s = localStorage.getItem('meshcore-user-theme'); if (s) local = JSON.parse(s); } catch {} state = { - branding: Object.assign({}, DEFAULTS.branding, cfg.branding || {}), - theme: Object.assign({}, DEFAULTS.theme, cfg.theme || {}), - themeDark: Object.assign({}, DEFAULTS.themeDark, cfg.themeDark || {}), - nodeColors: Object.assign({}, DEFAULTS.nodeColors, cfg.nodeColors || {}), - typeColors: Object.assign({}, DEFAULTS.typeColors, cfg.typeColors || {}), + branding: Object.assign({}, DEFAULTS.branding, cfg.branding || {}, local.branding || {}), + theme: Object.assign({}, DEFAULTS.theme, cfg.theme || {}, local.theme || {}), + themeDark: Object.assign({}, DEFAULTS.themeDark, cfg.themeDark || {}, local.themeDark || {}), + nodeColors: Object.assign({}, DEFAULTS.nodeColors, cfg.nodeColors || {}, local.nodeColors || {}), + typeColors: Object.assign({}, DEFAULTS.typeColors, cfg.typeColors || {}, local.typeColors || {}), home: { - heroTitle: (cfg.home && cfg.home.heroTitle) || DEFAULTS.home.heroTitle, - heroSubtitle: (cfg.home && cfg.home.heroSubtitle) || DEFAULTS.home.heroSubtitle, - steps: deepClone((cfg.home && cfg.home.steps) || DEFAULTS.home.steps), - checklist: deepClone((cfg.home && cfg.home.checklist) || DEFAULTS.home.checklist), - footerLinks: deepClone((cfg.home && cfg.home.footerLinks) || DEFAULTS.home.footerLinks) + heroTitle: (local.home && local.home.heroTitle) || (cfg.home && cfg.home.heroTitle) || DEFAULTS.home.heroTitle, + heroSubtitle: (local.home && local.home.heroSubtitle) || (cfg.home && cfg.home.heroSubtitle) || DEFAULTS.home.heroSubtitle, + steps: deepClone((local.home && local.home.steps) || (cfg.home && cfg.home.steps) || DEFAULTS.home.steps), + checklist: deepClone((local.home && local.home.checklist) || (cfg.home && cfg.home.checklist) || DEFAULTS.home.checklist), + footerLinks: deepClone((local.home && local.home.footerLinks) || (cfg.home && cfg.home.footerLinks) || DEFAULTS.home.footerLinks) } }; } diff --git a/public/index.html b/public/index.html index becd4370..f307c979 100644 --- a/public/index.html +++ b/public/index.html @@ -101,6 +101,6 @@ - +