index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <script lang="ts" setup>
  2. import { watchEffect } from "vue"
  3. import { storeToRefs } from "pinia"
  4. import { useSettingsStore } from "@/store/modules/settings"
  5. import { useLayoutMode } from "@/hooks/useLayoutMode"
  6. import { resetConfigLayout } from "@/utils"
  7. import SelectLayoutMode from "./SelectLayoutMode.vue"
  8. import { Refresh } from "@element-plus/icons-vue"
  9. const { isLeft } = useLayoutMode()
  10. const settingsStore = useSettingsStore()
  11. /** 使用 storeToRefs 将提取的属性保持其响应性 */
  12. const {
  13. showTagsView,
  14. showLogo,
  15. fixedHeader,
  16. showFooter,
  17. showNotify,
  18. showThemeSwitch,
  19. showScreenfull,
  20. showSearchMenu,
  21. cacheTagsView,
  22. showWatermark,
  23. showGreyMode,
  24. showColorWeakness
  25. } = storeToRefs(settingsStore)
  26. /** 定义 switch 设置项 */
  27. const switchSettings = {
  28. 显示标签栏: showTagsView,
  29. "显示 Logo": showLogo,
  30. "固定 Header": fixedHeader,
  31. "显示页脚 Footer": showFooter,
  32. 显示消息通知: showNotify,
  33. 显示切换主题按钮: showThemeSwitch,
  34. 显示全屏按钮: showScreenfull,
  35. 显示搜索按钮: showSearchMenu,
  36. 是否缓存标签栏: cacheTagsView,
  37. 开启系统水印: showWatermark,
  38. 显示灰色模式: showGreyMode,
  39. 显示色弱模式: showColorWeakness
  40. }
  41. /** 非左侧模式时,Header 都是 fixed 布局 */
  42. watchEffect(() => {
  43. !isLeft.value && (fixedHeader.value = true)
  44. })
  45. </script>
  46. <template>
  47. <div class="setting-container">
  48. <h4>布局配置</h4>
  49. <SelectLayoutMode />
  50. <el-divider />
  51. <h4>功能配置</h4>
  52. <div class="setting-item" v-for="(settingValue, settingName, index) in switchSettings" :key="index">
  53. <span class="setting-name">{{ settingName }}</span>
  54. <el-switch v-model="settingValue.value" :disabled="!isLeft && settingName === '固定 Header'" />
  55. </div>
  56. <el-button type="danger" :icon="Refresh" @click="resetConfigLayout">重 置</el-button>
  57. </div>
  58. </template>
  59. <style lang="scss" scoped>
  60. @import "@/styles/mixins.scss";
  61. .setting-container {
  62. padding: 20px;
  63. .setting-item {
  64. font-size: 14px;
  65. color: var(--el-text-color-regular);
  66. padding: 5px 0;
  67. display: flex;
  68. justify-content: space-between;
  69. align-items: center;
  70. .setting-name {
  71. @extend %ellipsis;
  72. }
  73. }
  74. .el-button {
  75. margin-top: 40px;
  76. width: 100%;
  77. }
  78. }
  79. </style>