index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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>开启 TopNav</span>
  43. <el-switch v-model="topNav" class="drawer-switch" />
  44. </div>
  45. <div class="drawer-item">
  46. <span>开启 Tags-Views</span>
  47. <el-switch v-model="tagsView" class="drawer-switch" />
  48. </div>
  49. <div class="drawer-item">
  50. <span>固定 Header</span>
  51. <el-switch v-model="fixedHeader" class="drawer-switch" />
  52. </div>
  53. <div class="drawer-item">
  54. <span>显示 Logo</span>
  55. <el-switch v-model="sidebarLogo" class="drawer-switch" />
  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. sideTheme() {
  72. return this.$store.state.settings.sideTheme
  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. topNav: {
  86. get() {
  87. return this.$store.state.settings.topNav
  88. },
  89. set(val) {
  90. this.$store.dispatch('settings/changeSetting', {
  91. key: 'topNav',
  92. value: val
  93. })
  94. if (!val) {
  95. this.$store.commit("SET_SIDEBAR_ROUTERS", this.$store.state.permission.defaultRoutes);
  96. }
  97. }
  98. },
  99. tagsView: {
  100. get() {
  101. return this.$store.state.settings.tagsView
  102. },
  103. set(val) {
  104. this.$store.dispatch('settings/changeSetting', {
  105. key: 'tagsView',
  106. value: val
  107. })
  108. }
  109. },
  110. sidebarLogo: {
  111. get() {
  112. return this.$store.state.settings.sidebarLogo
  113. },
  114. set(val) {
  115. this.$store.dispatch('settings/changeSetting', {
  116. key: 'sidebarLogo',
  117. value: val
  118. })
  119. }
  120. },
  121. },
  122. methods: {
  123. themeChange(val) {
  124. this.$store.dispatch('settings/changeSetting', {
  125. key: 'theme',
  126. value: val
  127. })
  128. },
  129. handleTheme(val) {
  130. this.$store.dispatch('settings/changeSetting', {
  131. key: 'sideTheme',
  132. value: val
  133. })
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .setting-drawer-content {
  140. .setting-drawer-title {
  141. margin-bottom: 12px;
  142. color: rgba(0, 0, 0, .85);
  143. font-size: 14px;
  144. line-height: 22px;
  145. font-weight: bold;
  146. }
  147. .setting-drawer-block-checbox {
  148. display: flex;
  149. justify-content: flex-start;
  150. align-items: center;
  151. margin-top: 10px;
  152. margin-bottom: 20px;
  153. .setting-drawer-block-checbox-item {
  154. position: relative;
  155. margin-right: 16px;
  156. border-radius: 2px;
  157. cursor: pointer;
  158. img {
  159. width: 48px;
  160. height: 48px;
  161. }
  162. .setting-drawer-block-checbox-selectIcon {
  163. position: absolute;
  164. top: 0;
  165. right: 0;
  166. width: 100%;
  167. height: 100%;
  168. padding-top: 15px;
  169. padding-left: 24px;
  170. color: #1890ff;
  171. font-weight: 700;
  172. font-size: 14px;
  173. }
  174. }
  175. }
  176. }
  177. .drawer-container {
  178. padding: 24px;
  179. font-size: 14px;
  180. line-height: 1.5;
  181. word-wrap: break-word;
  182. .drawer-title {
  183. margin-bottom: 12px;
  184. color: rgba(0, 0, 0, .85);
  185. font-size: 14px;
  186. line-height: 22px;
  187. }
  188. .drawer-item {
  189. color: rgba(0, 0, 0, .65);
  190. font-size: 14px;
  191. padding: 12px 0;
  192. }
  193. .drawer-switch {
  194. float: right
  195. }
  196. }
  197. </style>