index.vue 5.2 KB

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