refactor: update color modes handling
This commit is contained in:
+28
@@ -1,6 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<router-view />
|
<router-view />
|
||||||
</template>
|
</template>
|
||||||
|
<script>
|
||||||
|
import { onBeforeMount } from 'vue'
|
||||||
|
import { useStore } from 'vuex'
|
||||||
|
import { useColorModes } from '@coreui/vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const { isColorModeSet, setColorMode } = useColorModes(
|
||||||
|
'coreui-free-vue-admin-template-theme',
|
||||||
|
)
|
||||||
|
const store = useStore()
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
const urlParams = new URLSearchParams(window.location.href.split('?')[1])
|
||||||
|
if (urlParams.get('theme')) {
|
||||||
|
setColorMode(urlParams.get('theme'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isColorModeSet()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setColorMode(store.state.theme)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
// Import Main styles for this application
|
// Import Main styles for this application
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { useColorModes } from '@coreui/vue/'
|
import { useColorModes } from '@coreui/vue'
|
||||||
import AppBreadcrumb from './AppBreadcrumb'
|
import AppBreadcrumb from './AppBreadcrumb'
|
||||||
import AppHeaderDropdownAccnt from './AppHeaderDropdownAccnt'
|
import AppHeaderDropdownAccnt from './AppHeaderDropdownAccnt'
|
||||||
import { logo } from '@/assets/brand/logo'
|
import { logo } from '@/assets/brand/logo'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export default createStore({
|
|||||||
state: {
|
state: {
|
||||||
sidebarVisible: '',
|
sidebarVisible: '',
|
||||||
sidebarUnfoldable: false,
|
sidebarUnfoldable: false,
|
||||||
|
theme: 'light',
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
toggleSidebar(state) {
|
toggleSidebar(state) {
|
||||||
|
|||||||
@@ -386,12 +386,17 @@ export default {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.documentElement.addEventListener('ColorSchemeChange', () => {
|
document.documentElement.addEventListener('ColorSchemeChange', () => {
|
||||||
widgetChartRef1.value.chart.data.datasets[0].pointBackgroundColor =
|
if (widgetChartRef1.value) {
|
||||||
getStyle('--cui-primary')
|
widgetChartRef1.value.chart.data.datasets[0].pointBackgroundColor =
|
||||||
widgetChartRef2.value.chart.data.datasets[0].pointBackgroundColor =
|
getStyle('--cui-primary')
|
||||||
getStyle('--cui-info')
|
widgetChartRef1.value.chart.update()
|
||||||
widgetChartRef1.value.chart.update()
|
}
|
||||||
widgetChartRef2.value.chart.update()
|
|
||||||
|
if (widgetChartRef2.value) {
|
||||||
|
widgetChartRef2.value.chart.data.datasets[0].pointBackgroundColor =
|
||||||
|
getStyle('--cui-info')
|
||||||
|
widgetChartRef2.value.chart.update()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user