theme change is ready

This commit is contained in:
RockYang
2024-04-27 13:13:28 +08:00
parent 5b16dc6ee7
commit 039d949523
20 changed files with 162 additions and 44 deletions

View File

@@ -1,10 +1,10 @@
<template>
<div class="admin-home" v-if="isLogin">
<admin-sidebar/>
<admin-sidebar v-model:theme="theme"/>
<div class="content-box" :class="{ 'content-collapse': sidebar.collapse }">
<admin-header/>
<admin-tags/>
<div class="content dark">
<admin-header v-model:theme="theme" @changeTheme="changeTheme"/>
<admin-tags v-model:theme="theme"/>
<div :class="'content '+theme" :style="{height:contentHeight+'px'}">
<router-view v-slot="{ Component }">
<transition name="move" mode="out-in">
<keep-alive :include="tags.nameList">
@@ -25,10 +25,13 @@ import AdminTags from "@/components/admin/AdminTags.vue";
import {useRouter} from "vue-router";
import {checkAdminSession} from "@/action/session";
import {ref} from "vue";
import {getAdminTheme, setAdminTheme} from "@/store/system";
const sidebar = useSidebarStore();
const tags = useTagsStore();
const isLogin = ref(false)
const contentHeight = window.innerHeight - 80
const theme = ref(getAdminTheme())
// 获取会话信息
const router = useRouter();
@@ -37,6 +40,16 @@ checkAdminSession().then(() => {
}).catch(() => {
router.replace('/admin/login')
})
const changeTheme = (value) => {
if (value) {
theme.value = 'dark'
} else {
theme.value = 'light'
}
setAdminTheme(theme.value)
}
</script>
<style scoped lang="stylus">