|
|
@@ -4,51 +4,62 @@
|
|
|
<i class="sfont system-shezhi"></i>
|
|
|
</div>
|
|
|
<el-drawer v-model="drawer" title="系统设置" custom-class="herder_height">
|
|
|
- <el-divider>全局设置</el-divider>
|
|
|
- <el-form>
|
|
|
+ <el-collapse>
|
|
|
|
|
|
- <el-form-item label="侧边菜单栏背景色">
|
|
|
- <el-color-picker v-model="theme.menu.sideMenuBarBackgroundColor"/>
|
|
|
- </el-form-item>
|
|
|
+ <el-collapse-item title="菜单配置">
|
|
|
+ <el-form>
|
|
|
+ <el-form-item label="侧边菜单栏背景色">
|
|
|
+ <el-color-picker v-model="theme.menu.sideMenuBarBackgroundColor"/>
|
|
|
+ </el-form-item>
|
|
|
|
|
|
- <el-form-item label="侧边菜单文字颜色">
|
|
|
- <el-color-picker v-model="theme.menu.sideMenuTextColor"/>
|
|
|
- </el-form-item>
|
|
|
+ <el-form-item label="侧边菜单文字颜色">
|
|
|
+ <el-color-picker v-model="theme.menu.sideMenuTextColor"/>
|
|
|
+ </el-form-item>
|
|
|
|
|
|
- <el-form-item label="侧边菜单激活项背景色">
|
|
|
- <el-color-picker v-model="theme.menu.activateMenu"/>
|
|
|
- </el-form-item>
|
|
|
-
|
|
|
-
|
|
|
- </el-form>
|
|
|
+ <el-form-item label="侧边菜单激活项背景色">
|
|
|
+ <el-color-picker v-model="theme.menu.activateMenu"/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-collapse-item>
|
|
|
+ </el-collapse>
|
|
|
</el-drawer>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup name="Theme">
|
|
|
-import {clone} from '@/utils/clone'
|
|
|
-import store from '@/store'
|
|
|
+import {theme, themeStyle} from "@/theme";
|
|
|
+import {clone} from "@/utils/clone";
|
|
|
+
|
|
|
+const tabsHook = {
|
|
|
+ setItem: function (val) {
|
|
|
+ localStorage.setItem('theme', JSON.stringify(val))
|
|
|
+ },
|
|
|
+ getItem: function () {
|
|
|
+ return clone(JSON.parse(localStorage.getItem('theme') || '{}'))
|
|
|
+ },
|
|
|
+}
|
|
|
|
|
|
let drawer = $ref(false)
|
|
|
|
|
|
-let theme = $ref({
|
|
|
- menu: {
|
|
|
- // 侧边菜单激活项背景色
|
|
|
- activateMenu: '',
|
|
|
- // 侧边菜单文字颜色
|
|
|
- sideMenuBarBackgroundColor: '',
|
|
|
- // 侧边菜单栏背景色
|
|
|
- sideMenuTextColor: ''
|
|
|
+watch(() => theme.value, () => {
|
|
|
+ let tempStyle = {}
|
|
|
+ for (let key in theme.value) {
|
|
|
+ let item = theme.value[key]
|
|
|
+ if (typeof item === 'object') {
|
|
|
+ for (let key2 in item) {
|
|
|
+ tempStyle['--' + key2] = item[key2]
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tempStyle['--' + key] = item
|
|
|
+ }
|
|
|
}
|
|
|
-})
|
|
|
-
|
|
|
-watch(() => theme, () => {
|
|
|
- store.commit('app/setTheme', clone(theme))
|
|
|
-}, {deep: true})
|
|
|
+ themeStyle.value = tempStyle
|
|
|
+ tabsHook.setItem(theme.value)
|
|
|
+ console.log(localStorage.getItem('theme'))
|
|
|
+}, {deep: true, immediate: true})
|
|
|
|
|
|
onMounted(() => {
|
|
|
- console.log(store.state.app.theme)
|
|
|
- // theme = clone(store.state.app.theme)
|
|
|
+ theme.value = tabsHook.getItem()
|
|
|
})
|
|
|
|
|
|
</script>
|