From 21bccd866d249d7f5c7f0e031b8b622714de0680 Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期五, 23 五月 2025 16:54:50 +0800
Subject: [PATCH] 数据联调
---
src/layout/components/Settings/index.vue | 132 +++++++++++++------------------------------
1 files changed, 41 insertions(+), 91 deletions(-)
diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue
index a8c5132..679e4d9 100644
--- a/src/layout/components/Settings/index.vue
+++ b/src/layout/components/Settings/index.vue
@@ -38,35 +38,35 @@
<div class="drawer-item">
<span>寮�鍚� TopNav</span>
<span class="comp-style">
- <el-switch v-model="topNav" class="drawer-switch" />
+ <el-switch v-model="settingsStore.topNav" @change="topNavChange" class="drawer-switch" />
</span>
</div>
<div class="drawer-item">
<span>寮�鍚� Tags-Views</span>
<span class="comp-style">
- <el-switch v-model="tagsView" class="drawer-switch" />
+ <el-switch v-model="settingsStore.tagsView" class="drawer-switch" />
</span>
</div>
<div class="drawer-item">
<span>鍥哄畾 Header</span>
<span class="comp-style">
- <el-switch v-model="fixedHeader" class="drawer-switch" />
+ <el-switch v-model="settingsStore.fixedHeader" class="drawer-switch" />
</span>
</div>
<div class="drawer-item">
<span>鏄剧ず Logo</span>
<span class="comp-style">
- <el-switch v-model="sidebarLogo" class="drawer-switch" />
+ <el-switch v-model="settingsStore.sidebarLogo" class="drawer-switch" />
</span>
</div>
<div class="drawer-item">
<span>鍔ㄦ�佹爣棰�</span>
<span class="comp-style">
- <el-switch v-model="dynamicTitle" class="drawer-switch" />
+ <el-switch v-model="settingsStore.dynamicTitle" class="drawer-switch" />
</span>
</div>
@@ -80,91 +80,44 @@
<script setup>
import variables from '@/assets/styles/variables.module.scss'
-import originElementPlus from 'element-plus/theme-chalk/index.css'
import axios from 'axios'
import { ElLoading, ElMessage } from 'element-plus'
import { useDynamicTitle } from '@/utils/dynamicTitle'
+import useAppStore from '@/store/modules/app'
+import useSettingsStore from '@/store/modules/settings'
+import usePermissionStore from '@/store/modules/permission'
+import { handleThemeStyle } from '@/utils/theme'
-const { proxy } = getCurrentInstance();
-const store = useStore();
-const showSettings = ref(false);
-const theme = ref(store.state.settings.theme);
-const sideTheme = ref(store.state.settings.sideTheme);
-const storeSettings = computed(() => store.state.settings);
-const predefineColors = ref(["#409EFF", "#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585"]);
+const { proxy } = getCurrentInstance()
+const appStore = useAppStore()
+const settingsStore = useSettingsStore()
+const permissionStore = usePermissionStore()
+const showSettings = ref(false)
+const theme = ref(settingsStore.theme)
+const sideTheme = ref(settingsStore.sideTheme)
+const storeSettings = computed(() => settingsStore)
+const predefineColors = ref(["#409EFF", "#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585"])
/** 鏄惁闇�瑕乼opnav */
-const topNav = computed({
- get: () => storeSettings.value.topNav,
- set: (val) => {
- store.dispatch('settings/changeSetting', {
- key: 'topNav',
- value: val
- })
- if (!val) {
- store.commit("SET_SIDEBAR_ROUTERS", store.state.permission.defaultRoutes);
- }
+function topNavChange(val) {
+ if (!val) {
+ appStore.toggleSideBarHide(false)
+ permissionStore.setSidebarRouters(permissionStore.defaultRoutes)
}
-})
-/** 鏄惁闇�瑕乼agview */
-const tagsView = computed({
- get: () => storeSettings.value.tagsView,
- set: (val) => {
- store.dispatch('settings/changeSetting', {
- key: 'tagsView',
- value: val
- })
- }
-})
-/**鏄惁闇�瑕佸浐瀹氬ご閮� */
-const fixedHeader = computed({
- get: () => storeSettings.value.fixedHeader,
- set: (val) => {
- store.dispatch('settings/changeSetting', {
- key: 'fixedHeader',
- value: val
- })
- }
-})
-/**鏄惁闇�瑕佷晶杈规爮鐨刲ogo */
-const sidebarLogo = computed({
- get: () => storeSettings.value.sidebarLogo,
- set: (val) => {
- store.dispatch('settings/changeSetting', {
- key: 'sidebarLogo',
- value: val
- })
- }
-})
-/**鏄惁闇�瑕佷晶杈规爮鐨勫姩鎬佺綉椤电殑title */
-const dynamicTitle = computed({
- get: () => storeSettings.value.dynamicTitle,
- set: (val) => {
- store.dispatch('settings/changeSetting', {
- key: 'dynamicTitle',
- value: val
- })
- // 鍔ㄦ�佽缃綉椤垫爣棰�
- useDynamicTitle()
- }
-})
+}
function themeChange(val) {
- store.dispatch('settings/changeSetting', {
- key: 'theme',
- value: val
- })
- theme.value = val;
+ settingsStore.theme = val
+ handleThemeStyle(val)
}
+
function handleTheme(val) {
- store.dispatch('settings/changeSetting', {
- key: 'sideTheme',
- value: val
- })
- sideTheme.value = val;
+ settingsStore.sideTheme = val
+ sideTheme.value = val
}
+
function saveSetting() {
- proxy.$modal.loading("姝e湪淇濆瓨鍒版湰鍦帮紝璇风◢鍊�...");
+ proxy.$modal.loading("姝e湪淇濆瓨鍒版湰鍦帮紝璇风◢鍊�...")
let layoutSetting = {
"topNav": storeSettings.value.topNav,
"tagsView": storeSettings.value.tagsView,
@@ -173,34 +126,38 @@
"dynamicTitle": storeSettings.value.dynamicTitle,
"sideTheme": storeSettings.value.sideTheme,
"theme": storeSettings.value.theme
- };
- localStorage.setItem("layout-setting", JSON.stringify(layoutSetting));
+ }
+ localStorage.setItem("layout-setting", JSON.stringify(layoutSetting))
setTimeout(proxy.$modal.closeLoading(), 1000)
}
+
function resetSetting() {
- proxy.$modal.loading("姝e湪娓呴櫎璁剧疆缂撳瓨骞跺埛鏂帮紝璇风◢鍊�...");
+ proxy.$modal.loading("姝e湪娓呴櫎璁剧疆缂撳瓨骞跺埛鏂帮紝璇风◢鍊�...")
localStorage.removeItem("layout-setting")
setTimeout("window.location.reload()", 1000)
}
+
function openSetting() {
- showSettings.value = true;
+ showSettings.value = true
}
defineExpose({
- openSetting,
+ openSetting
})
</script>
<style lang='scss' scoped>
.setting-drawer-title {
margin-bottom: 12px;
- color: rgba(0, 0, 0, 0.85);
+ color: var(--el-text-color-primary, rgba(0, 0, 0, 0.85));
line-height: 22px;
font-weight: bold;
+
.drawer-title {
font-size: 14px;
}
}
+
.setting-drawer-block-checbox {
display: flex;
justify-content: flex-start;
@@ -219,13 +176,6 @@
height: 48px;
}
- .custom-img {
- width: 48px;
- height: 38px;
- border-radius: 5px;
- box-shadow: 1px 1px 2px #898484;
- }
-
.setting-drawer-block-checbox-selectIcon {
position: absolute;
top: 0;
@@ -242,7 +192,7 @@
}
.drawer-item {
- color: rgba(0, 0, 0, 0.65);
+ color: var(--el-text-color-regular, rgba(0, 0, 0, 0.65));
padding: 12px 0;
font-size: 14px;
--
Gitblit v1.9.3