diff options
author | 2022-04-04 01:52:59 +0200 | |
---|---|---|
committer | 2022-04-04 01:52:59 +0200 | |
commit | 3e92b7f1e04a709df231fce22801b55619e8faab (patch) | |
tree | 55e09bfee391a02eff35eaf9ada784ae4b6193c2 /src | |
parent | e8594de7b45102b8bc1cfb82d0839e3722d9c4c2 (diff) | |
download | it-tools-3e92b7f1e04a709df231fce22801b55619e8faab.tar.gz it-tools-3e92b7f1e04a709df231fce22801b55619e8faab.tar.zst it-tools-3e92b7f1e04a709df231fce22801b55619e8faab.zip |
feat(style): dark mode
Diffstat (limited to 'src')
-rw-r--r-- | src/App.vue | 7 | ||||
-rw-r--r-- | src/layouts/base.layout.vue | 19 | ||||
-rw-r--r-- | src/stores/style.store.ts | 5 |
3 files changed, 25 insertions, 6 deletions
diff --git a/src/App.vue b/src/App.vue index abbb362..14139b3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,16 +5,21 @@ import { computed } from 'vue'; import { useRoute } from 'vue-router' import { + darkTheme, NConfigProvider, NGlobalStyle, } from 'naive-ui' +import { useStyleStore } from './stores/style.store'; const route = useRoute(); const layout = computed(() => route?.meta?.layout ?? layouts.base) +const styleStore = useStyleStore() + +const theme = computed(() => styleStore.isDarkTheme ? darkTheme : null) </script> <template> - <n-config-provider> + <n-config-provider :theme="theme"> <n-global-style /> <n-message-provider placement="bottom"> <component :is="layout"> diff --git a/src/layouts/base.layout.vue b/src/layouts/base.layout.vue index d7b0a90..e0994e1 100644 --- a/src/layouts/base.layout.vue +++ b/src/layouts/base.layout.vue @@ -2,13 +2,15 @@ import { NIcon } from 'naive-ui'; import { h, ref, type Component } from 'vue'; import { RouterLink, useRoute } from 'vue-router'; -import { User } from '@vicons/tabler' +import { LightModeFilled, DarkModeFilled } from '@vicons/material' import { tools } from '@/tools'; import SearchBar from '../components/SearchBar.vue'; +import { useStyleStore } from '@/stores/style.store'; const collapsed = ref(false) const activeKey = ref(null) const route = useRoute() +const styleStore = useStyleStore() const makeLabel = (text: string, to: string) => () => h(RouterLink, { to }, { default: () => text }) const makeIcon = (icon: Component) => () => h(NIcon, null, { default: () => h(icon) }) @@ -53,9 +55,16 @@ const menuOptions = tools.map(({ name, path, icon }) => ({ <div class="bar-wrapper"> <search-bar /> - <n-button secondary circle> - <n-icon size="large"> - <user /> + <n-button + circle + quaternary + @click="styleStore.isDarkTheme = !styleStore.isDarkTheme" + > + <n-icon size="large" v-if="styleStore.isDarkTheme"> + <LightModeFilled /> + </n-icon> + <n-icon size="large" v-else> + <DarkModeFilled /> </n-icon> </n-button> </div> @@ -76,7 +85,7 @@ const menuOptions = tools.map(({ name, path, icon }) => ({ } .content { - background-color: #f1f5f9; + // background-color: #f1f5f9; ::v-deep(.n-layout-scroll-container) { padding: 26px; } diff --git a/src/stores/style.store.ts b/src/stores/style.store.ts new file mode 100644 index 0000000..7c2099c --- /dev/null +++ b/src/stores/style.store.ts @@ -0,0 +1,5 @@ +import { defineStore } from 'pinia'; + +export const useStyleStore = defineStore('style', () => ({ + isDarkTheme: true, +})); |