From bad60a8ee52c5dc2b8836caab2ea66f49791972e Mon Sep 17 00:00:00 2001 From: gushen610140 Date: Fri, 30 Jan 2026 23:22:54 +0800 Subject: [PATCH] feat: add global theme --- eslint.config.js | 13 +++++ src/components/.gitkeep | 0 .../button/ChangeThemeDropdownButton.vue | 52 +++++++++++++++++++ src/hooks/globalThemeHook.ts | 51 ++++++++++++++++++ src/pages/index.vue | 12 +++-- src/style.css | 4 +- 6 files changed, 126 insertions(+), 6 deletions(-) delete mode 100644 src/components/.gitkeep create mode 100644 src/components/button/ChangeThemeDropdownButton.vue create mode 100644 src/hooks/globalThemeHook.ts diff --git a/eslint.config.js b/eslint.config.js index f092f77..409b9cb 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -24,6 +24,19 @@ export default typescriptEslint.config( "vue/singleline-html-element-content-newline": "off", "vue/max-attributes-per-line": "off", "vue/multi-word-component-names": "off", + "vue/html-self-closing": [ + "warn", + { + html: { + void: "always", + normal: "always", + component: "always", + }, + svg: "always", + math: "always", + }, + ], + "@typescript-eslint/no-unused-vars": "warn", }, }, ); diff --git a/src/components/.gitkeep b/src/components/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/button/ChangeThemeDropdownButton.vue b/src/components/button/ChangeThemeDropdownButton.vue new file mode 100644 index 0000000..739b35c --- /dev/null +++ b/src/components/button/ChangeThemeDropdownButton.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/src/hooks/globalThemeHook.ts b/src/hooks/globalThemeHook.ts new file mode 100644 index 0000000..81ad816 --- /dev/null +++ b/src/hooks/globalThemeHook.ts @@ -0,0 +1,51 @@ +enum GlobalTheme { + Light = "light", + Dark = "dark", + Cupcake = "cupcake", + Bumblebee = "bumblebee", + Emerald = "emerald", + Corporate = "corporate", + Synthwave = "synthwave", + Retro = "retro", + Cyberpunk = "cyberpunk", + Valentine = "valentine", + Halloween = "halloween", + Garden = "garden", + Forest = "forest", + Aqua = "aqua", + Lofi = "lofi", + Pastel = "pastel", + Fantasy = "fantasy", + Wireframe = "wireframe", + Black = "black", + Luxury = "luxury", + Dracula = "dracula", + Cmyk = "cmyk", + Autumn = "autumn", + Business = "business", + Acid = "acid", + Lemonade = "lemonade", + Night = "night", + Coffee = "coffee", + Winter = "winter", + Dim = "dim", + Nord = "nord", + Sunset = "sunset", + Caramellatte = "caramellatte", + Abyss = "abyss", + Silk = "silk", +} + +const optionalThemes = Object.values(GlobalTheme); + +const curGlobalTheme = ref(GlobalTheme.Light); + +function changeGlobalTheme(theme: GlobalTheme) { + curGlobalTheme.value = theme; +} + +export const useGlobalThemeHook = () => ({ + optionalThemes, + curGlobalTheme, + changeGlobalTheme, +}); diff --git a/src/pages/index.vue b/src/pages/index.vue index 1c10fdb..d15e7df 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -1,18 +1,20 @@ - + diff --git a/src/style.css b/src/style.css index 1e05665..427a37e 100644 --- a/src/style.css +++ b/src/style.css @@ -1,5 +1,7 @@ @import "tailwindcss"; -@plugin "daisyui"; +@plugin "daisyui" { + themes: all; +}; /* Custom Scrollbar Styles */ ::-webkit-scrollbar {