82 lines
2.2 KiB
Vue
Raw Normal View History

<script lang="ts" setup>
2023-07-06 13:02:52 +08:00
import { watchEffect } from "vue"
2023-06-14 18:14:47 +08:00
import { storeToRefs } from "pinia"
import { useSettingsStore } from "@/store/modules/settings"
2023-07-06 14:10:14 +08:00
import { resetConfigLayout } from "@/utils"
import { Refresh } from "@element-plus/icons-vue"
const settingsStore = useSettingsStore()
2023-06-14 18:14:47 +08:00
/** 使用 storeToRefs 将提取的属性保持其响应性 */
const {
2023-07-06 13:02:52 +08:00
layoutMode,
2023-06-14 18:14:47 +08:00
showTagsView,
2023-07-06 13:02:52 +08:00
showLogo,
2023-06-14 18:14:47 +08:00
fixedHeader,
showNotify,
showThemeSwitch,
showScreenfull,
2023-06-30 12:50:24 +08:00
cacheTagsView,
2023-06-14 18:14:47 +08:00
showGreyMode,
showColorWeakness
} = storeToRefs(settingsStore)
/** 定义 switch 设置项 */
const switchSettings = {
显示标签栏: showTagsView,
2023-07-06 13:02:52 +08:00
"显示 Logo": showLogo,
2023-06-14 18:14:47 +08:00
"固定 Header": fixedHeader,
显示消息通知: showNotify,
显示切换主题按钮: showThemeSwitch,
显示全屏按钮: showScreenfull,
2023-06-30 12:50:24 +08:00
是否缓存标签栏: cacheTagsView,
2023-06-14 18:14:47 +08:00
显示灰色模式: showGreyMode,
显示色弱模式: showColorWeakness
}
2023-07-06 13:02:52 +08:00
/** 非左侧模式时Header 都是 fixed 布局 */
watchEffect(() => {
layoutMode.value !== "left" && (fixedHeader.value = true)
})
</script>
<template>
2023-06-14 18:14:47 +08:00
<div class="setting-container">
2023-07-06 13:02:52 +08:00
<h4>布局配置</h4>
<el-radio-group v-model="layoutMode">
<el-radio label="left">左侧模式</el-radio>
<el-radio label="top">顶部模式开发中</el-radio>
<el-radio label="left-top">混合模式</el-radio>
</el-radio-group>
<h4>功能配置</h4>
2023-06-14 18:14:47 +08:00
<div class="setting-item" v-for="(settingValue, settingName, index) in switchSettings" :key="index">
<span class="setting-name">{{ settingName }}</span>
2023-07-06 13:02:52 +08:00
<el-switch v-model="settingValue.value" :disabled="layoutMode !== 'left' && settingName === '固定 Header'" />
</div>
2023-07-06 14:10:14 +08:00
<el-button type="danger" :icon="Refresh" @click="resetConfigLayout"> </el-button>
</div>
</template>
<style lang="scss" scoped>
2023-06-14 18:14:47 +08:00
@import "@/styles/mixins.scss";
.setting-container {
padding: 20px;
.setting-item {
font-size: 14px;
2023-07-06 13:02:52 +08:00
color: var(--el-text-color-regular);
padding: 5px 0;
2023-06-14 18:14:47 +08:00
display: flex;
justify-content: space-between;
align-items: center;
.setting-name {
@include ellipsis;
}
}
.el-button {
margin-top: 40px;
width: 100%;
}
}
</style>