From 5f1aba28b0df14e52316a21dcbee1fd2356bf5a1 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 8 May 2026 17:39:36 +0200 Subject: [PATCH] feat(frontend): unify theming on vanilla AD-Vue light/dark/ultra-dark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The legacy panel CSS (custom.min.css ported as legacy.css) tinted every non-primary button teal-green via .dark .ant-btn:not(.ant-btn-primary) overrides while AD-Vue 4's darkAlgorithm kept primary buttons blue — producing the mixed blue/green button look on dark mode. Drop legacy.css entirely and let AD-Vue 4's algorithms own the palette. Centralize antdThemeConfig in useTheme.js so every page resolves to the same source of truth (light = defaultAlgorithm, dark = darkAlgorithm, ultra-dark = darkAlgorithm + deeper colorBgBase/Layout/Container/ Elevated tokens). Each page's now imports the shared computed instead of defining its own copy. Drops the 67 KB legacy CSS chunk; per-page CSS bundles fall to ≤5.9 KB. Co-Authored-By: Claude Opus 4.7 --- frontend/src/composables/useTheme.js | 22 ++++++++++++++++++++ frontend/src/inbounds.js | 1 - frontend/src/index.js | 5 ----- frontend/src/login.js | 1 - frontend/src/pages/inbounds/InboundsPage.vue | 10 +++------ frontend/src/pages/index/IndexPage.vue | 8 +------ frontend/src/pages/login/LoginPage.vue | 16 ++++++-------- frontend/src/pages/settings/SettingsPage.vue | 10 +++------ frontend/src/pages/xray/XrayPage.vue | 18 +++------------- frontend/src/settings.js | 1 - frontend/src/styles/legacy.css | 1 - frontend/src/xray.js | 1 - 12 files changed, 38 insertions(+), 56 deletions(-) delete mode 100644 frontend/src/styles/legacy.css diff --git a/frontend/src/composables/useTheme.js b/frontend/src/composables/useTheme.js index e1005202..1d6ff2ce 100644 --- a/frontend/src/composables/useTheme.js +++ b/frontend/src/composables/useTheme.js @@ -1,4 +1,5 @@ import { reactive, computed, watchEffect } from 'vue'; +import { theme as antdTheme } from 'ant-design-vue'; // Single shared theme state. `import { theme } from '@/composables/useTheme.js'` // from any component to read/toggle. Boot side-effects (apply current @@ -24,6 +25,27 @@ export const theme = reactive({ export const currentTheme = computed(() => (theme.isDark ? 'dark' : 'light')); +// AD-Vue 4 theme config consumed by every page's . +// Three modes — light / dark / ultra-dark — all share AD-Vue's vanilla +// blue primary. Ultra-dark layers deeper background tokens on top of +// darkAlgorithm so layouts/cards/popups all darken together. +const ULTRA_DARK_TOKENS = { + colorBgBase: '#000', + colorBgLayout: '#000', + colorBgContainer: '#0a0a0a', + colorBgElevated: '#141414', +}; + +export const antdThemeConfig = computed(() => { + if (!theme.isDark) { + return { algorithm: antdTheme.defaultAlgorithm }; + } + return { + algorithm: antdTheme.darkAlgorithm, + token: theme.isUltra ? ULTRA_DARK_TOKENS : undefined, + }; +}); + export function toggleTheme() { theme.isDark = !theme.isDark; } diff --git a/frontend/src/inbounds.js b/frontend/src/inbounds.js index ba90f0ed..15b34d2e 100644 --- a/frontend/src/inbounds.js +++ b/frontend/src/inbounds.js @@ -1,7 +1,6 @@ import { createApp } from 'vue'; import Antd, { message } from 'ant-design-vue'; import 'ant-design-vue/dist/reset.css'; -import '@/styles/legacy.css'; import { setupAxios } from '@/api/axios-init.js'; import '@/composables/useTheme.js'; diff --git a/frontend/src/index.js b/frontend/src/index.js index b1712151..61d9dc12 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -1,11 +1,6 @@ import { createApp } from 'vue'; import Antd, { message } from 'ant-design-vue'; import 'ant-design-vue/dist/reset.css'; -// Legacy panel CSS — overrides AD-Vue defaults to match the -// pre-migration look (palette, dark mode contrast, tag colors, -// table/tooltip styling). Loaded after AD-Vue's reset so its -// rules win. -import '@/styles/legacy.css'; import { setupAxios } from '@/api/axios-init.js'; // Importing useTheme triggers the boot side-effect that applies the diff --git a/frontend/src/login.js b/frontend/src/login.js index 8ca1cc3d..ec90a9fb 100644 --- a/frontend/src/login.js +++ b/frontend/src/login.js @@ -1,7 +1,6 @@ import { createApp } from 'vue'; import Antd, { message } from 'ant-design-vue'; import 'ant-design-vue/dist/reset.css'; -import '@/styles/legacy.css'; import { setupAxios } from '@/api/axios-init.js'; // Importing this module triggers the boot side-effect that applies the diff --git a/frontend/src/pages/inbounds/InboundsPage.vue b/frontend/src/pages/inbounds/InboundsPage.vue index a5bb5ef1..6aab5ffb 100644 --- a/frontend/src/pages/inbounds/InboundsPage.vue +++ b/frontend/src/pages/inbounds/InboundsPage.vue @@ -1,7 +1,7 @@