新增侧边栏背景设置

This commit is contained in:
不做码农
2022-05-21 08:12:23 +08:00
parent 630960bf0c
commit 7086c5c336
3 changed files with 23 additions and 17 deletions
+17 -8
View File
@@ -4,18 +4,18 @@
<h3 class="drawer-title">{{ $t('layout.themeStyleSet') }}</h3>
</div>
<div class="setting-drawer-block-checbox">
<!-- <div class="setting-drawer-block-checbox-item" @click="handleTheme('theme-dark')">
<div class="item" @click="handleTheme('theme-dark')">
<img src="@/assets/images/dark.svg" alt="dark" />
<div v-if="sideTheme === 'theme-dark'" class="setting-drawer-block-checbox-selectIcon" style="display: block">
<el-icon><Check /></el-icon>
</div>
</div>
<div class="setting-drawer-block-checbox-item" @click="handleTheme('theme-light')">
<div class="item" @click="handleTheme('theme-light')">
<img src="@/assets/images/light.svg" alt="light" />
<div v-if="sideTheme === 'theme-light'" class="setting-drawer-block-checbox-selectIcon" style="display: block">
<el-icon><Check /></el-icon>
</div>
</div>-->
</div>
</div>
<div class="drawer-item">
<el-radio-group v-model="mode" size="small">
@@ -193,14 +193,23 @@ watch(
() => sideTheme,
(val) => {
const body = document.documentElement
if (val.value == 'theme-black') {
//body.setAttribute('data-theme', 'theme-black')
} else {
//body.setAttribute('data-theme', '')
body.setAttribute('data-theme', '')
},
{
immediate: true,
},
)
watch(
() => mode,
(val) => {
console.log(val.value)
if (val.value === 'dark') {
handleTheme('')
}
},
{
immediate: true,
deep: true,
},
)
/**
@@ -228,7 +237,7 @@ function handleTheme(val) {
sideTheme.value = val
const body = document.documentElement
if (val == 'theme-black') body.setAttribute('data-theme', 'theme-black')
else body.setAttribute('data-theme', '')
else body.removeAttribute('data-theme')
}
function saveSetting() {
proxy.$modal.loading('正在保存到本地,请稍候...')