index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="drawer-container">
  3. <div>
  4. <div class="setting-drawer-content">
  5. <div class="setting-drawer-title">
  6. <h3 class="drawer-title">主题风格设置</h3>
  7. </div>
  8. <div class="setting-drawer-block-checbox">
  9. <div class="setting-drawer-block-checbox-item" @click="handleTheme('theme-dark')">
  10. <img src="@/assets/images/dark.svg" alt="dark">
  11. <div v-if="sideTheme === 'theme-dark'" class="setting-drawer-block-checbox-selectIcon" style="display: block;">
  12. <i aria-label="图标: check" class="anticon anticon-check">
  13. <svg viewBox="64 64 896 896" data-icon="check" width="1em" height="1em" :fill="theme" aria-hidden="true"
  14. focusable="false" class="">
  15. <path
  16. d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"/>
  17. </svg>
  18. </i>
  19. </div>
  20. </div>
  21. <div class="setting-drawer-block-checbox-item" @click="handleTheme('theme-light')">
  22. <img src="@/assets/images/light.svg" alt="light">
  23. <div v-if="sideTheme === 'theme-light'" class="setting-drawer-block-checbox-selectIcon" style="display: block;">
  24. <i aria-label="图标: check" class="anticon anticon-check">
  25. <svg viewBox="64 64 896 896" data-icon="check" width="1em" height="1em" :fill="theme" aria-hidden="true"
  26. focusable="false" class="">
  27. <path
  28. d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"/>
  29. </svg>
  30. </i>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="drawer-item">
  35. <span>主题颜色</span>
  36. <theme-picker style="float: right;height: 26px;margin: -3px 8px 0 0;" @change="themeChange" />
  37. </div>
  38. </div>
  39. <el-divider/>
  40. <h3 class="drawer-title">系统布局配置</h3>
  41. <div class="drawer-item">
  42. <span>开启 Tags-Views</span>
  43. <el-switch v-model="tagsView" class="drawer-switch" />
  44. </div>
  45. <div class="drawer-item">
  46. <span>固定 Header</span>
  47. <el-switch v-model="fixedHeader" class="drawer-switch" />
  48. </div>
  49. <div class="drawer-item">
  50. <span>显示 Logo</span>
  51. <el-switch v-model="sidebarLogo" class="drawer-switch" />
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import ThemePicker from '@/components/ThemePicker'
  58. export default {
  59. components: { ThemePicker },
  60. data() {
  61. return {}
  62. },
  63. computed: {
  64. theme() {
  65. return this.$store.state.settings.theme
  66. },
  67. sideTheme() {
  68. return this.$store.state.settings.sideTheme
  69. },
  70. fixedHeader: {
  71. get() {
  72. return this.$store.state.settings.fixedHeader
  73. },
  74. set(val) {
  75. this.$store.dispatch('settings/changeSetting', {
  76. key: 'fixedHeader',
  77. value: val
  78. })
  79. }
  80. },
  81. tagsView: {
  82. get() {
  83. return this.$store.state.settings.tagsView
  84. },
  85. set(val) {
  86. this.$store.dispatch('settings/changeSetting', {
  87. key: 'tagsView',
  88. value: val
  89. })
  90. }
  91. },
  92. sidebarLogo: {
  93. get() {
  94. return this.$store.state.settings.sidebarLogo
  95. },
  96. set(val) {
  97. this.$store.dispatch('settings/changeSetting', {
  98. key: 'sidebarLogo',
  99. value: val
  100. })
  101. }
  102. },
  103. },
  104. methods: {
  105. themeChange(val) {
  106. this.$store.dispatch('settings/changeSetting', {
  107. key: 'theme',
  108. value: val
  109. })
  110. },
  111. handleTheme(val) {
  112. this.$store.dispatch('settings/changeSetting', {
  113. key: 'sideTheme',
  114. value: val
  115. })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .setting-drawer-content {
  122. .setting-drawer-title {
  123. margin-bottom: 12px;
  124. color: rgba(0, 0, 0, .85);
  125. font-size: 14px;
  126. line-height: 22px;
  127. font-weight: bold;
  128. }
  129. .setting-drawer-block-checbox {
  130. display: flex;
  131. justify-content: flex-start;
  132. align-items: center;
  133. margin-top: 10px;
  134. margin-bottom: 20px;
  135. .setting-drawer-block-checbox-item {
  136. position: relative;
  137. margin-right: 16px;
  138. border-radius: 2px;
  139. cursor: pointer;
  140. img {
  141. width: 48px;
  142. height: 48px;
  143. }
  144. .setting-drawer-block-checbox-selectIcon {
  145. position: absolute;
  146. top: 0;
  147. right: 0;
  148. width: 100%;
  149. height: 100%;
  150. padding-top: 15px;
  151. padding-left: 24px;
  152. color: #1890ff;
  153. font-weight: 700;
  154. font-size: 14px;
  155. }
  156. }
  157. }
  158. }
  159. .drawer-container {
  160. padding: 24px;
  161. font-size: 14px;
  162. line-height: 1.5;
  163. word-wrap: break-word;
  164. .drawer-title {
  165. margin-bottom: 12px;
  166. color: rgba(0, 0, 0, .85);
  167. font-size: 14px;
  168. line-height: 22px;
  169. }
  170. .drawer-item {
  171. color: rgba(0, 0, 0, .65);
  172. font-size: 14px;
  173. padding: 12px 0;
  174. }
  175. .drawer-switch {
  176. float: right
  177. }
  178. }
  179. </style>