index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <div class="drawer-wrap">
  3. <h3 class="drawer-title">{{ $t('le.layout.setting.title') }}</h3>
  4. <el-scrollbar class="drawer-content">
  5. <el-divider class="local-divider">
  6. <el-icon><SetUp /></el-icon>{{ $t('le.layout.setting.themeModeTitle') }}
  7. </el-divider>
  8. <div class="drawer-item">
  9. <span>{{ $t('le.layout.setting.themeColor') }}</span>
  10. <theme-picker @change="themeChange" />
  11. </div>
  12. <div class="drawer-item" @click.stop="">
  13. <span>{{ $t('le.layout.setting.themeDark') }}</span>
  14. <el-switch v-model="isDark" inline-prompt active-icon="Sunny" inactive-icon="Moon" @change="switchDark" />
  15. </div>
  16. <div class="drawer-item" @click.stop="">
  17. <span>{{ $t('le.layout.setting.themeGray') }}</span>
  18. <el-switch v-model="isGrey" inline-prompt @change="changeGreyOrWeak('grey', $event)" />
  19. </div>
  20. <div class="drawer-item" @click.stop="">
  21. <span>{{ $t('le.layout.setting.themeWeak') }}</span>
  22. <el-switch v-model="isWeak" inline-prompt @change="changeGreyOrWeak('weak', $event)" />
  23. </div>
  24. <div class="drawer-item">
  25. <span>{{ $t('le.layout.setting.sideDark') }}</span>
  26. <el-switch v-model="asideInverted" @change="setAsideTheme" />
  27. </div>
  28. <div class="drawer-item">
  29. <span>{{ $t('le.layout.setting.headDark') }}</span>
  30. <el-switch v-model="headerInverted" @change="setHeaderTheme" />
  31. </div>
  32. <div v-show="footer" class="drawer-item">
  33. <span>{{ $t('le.layout.setting.footDark') }}</span>
  34. <el-switch v-model="footerInverted" @change="setFooterTheme" />
  35. </div>
  36. <el-divider class="local-divider">
  37. <el-icon><Menu /></el-icon>{{ $t('le.layout.setting.layoutMode') }}
  38. </el-divider>
  39. <div class="layout-box">
  40. <el-tooltip effect="dark" :content="$t('le.layout.setting.layoutLeftMenuMode')" placement="top" :show-after="200">
  41. <div :class="['layout-item layout-left', { 'is-active': layout == 'left' }]" @click="setLayout('left')">
  42. <div class="layout-light"></div>
  43. <div class="layout-container">
  44. <div class="layout-dark"></div>
  45. <div class="layout-content"></div>
  46. </div>
  47. <el-icon v-if="layout == 'left'">
  48. <CircleCheckFilled />
  49. </el-icon>
  50. </div>
  51. </el-tooltip>
  52. <el-tooltip effect="dark" :content="$t('le.layout.setting.layoutLeftMenuBlendingMode')" placement="top" :show-after="200">
  53. <div :class="['layout-item layout-leftMix', { 'is-active': layout == 'leftMix' }]" @click="setLayout('leftMix')">
  54. <div class="layout-light"></div>
  55. <div class="layout-light light-2"></div>
  56. <div class="layout-container">
  57. <div class="layout-dark"></div>
  58. <div class="layout-content"></div>
  59. </div>
  60. <el-icon v-if="layout == 'leftMix'">
  61. <CircleCheckFilled />
  62. </el-icon>
  63. </div>
  64. </el-tooltip>
  65. <el-tooltip effect="dark" :content="$t('le.layout.setting.layoutTopMenuMode')" placement="top" :show-after="200">
  66. <div :class="['layout-item layout-top', { 'is-active': layout == 'top' }]" @click="setLayout('top')">
  67. <div class="layout-dark"></div>
  68. <div class="layout-content"></div>
  69. <el-icon v-if="layout == 'top'">
  70. <CircleCheckFilled />
  71. </el-icon>
  72. </div>
  73. </el-tooltip>
  74. <el-tooltip effect="dark" :content="$t('le.layout.setting.layoutTopMenuBlendingMode')" placement="top" :show-after="200">
  75. <div :class="['layout-item layout-topMix', { 'is-active': layout == 'topMix' }]" @click="setLayout('topMix')">
  76. <div class="layout-dark"></div>
  77. <div class="layout-container">
  78. <div class="layout-light"></div>
  79. <div class="layout-content"></div>
  80. </div>
  81. <el-icon v-if="layout == 'topMix'">
  82. <CircleCheckFilled />
  83. </el-icon>
  84. </div>
  85. </el-tooltip>
  86. </div>
  87. <el-divider class="local-divider">
  88. <el-icon><Operation /></el-icon>{{ $t('le.layout.setting.pageFunctions') }}
  89. </el-divider>
  90. <div class="drawer-item">
  91. <span>{{ $t('le.layout.setting.footerVisible') }}</span>
  92. <el-switch v-model="footer" />
  93. </div>
  94. <div class="drawer-item">
  95. <span>{{ $t('le.layout.setting.crumbVisible') }}</span>
  96. <el-switch v-model="breadcrumb" />
  97. </div>
  98. <div v-show="breadcrumb" class="drawer-item">
  99. <span>{{ $t('le.layout.setting.crumbIconVisible') }}</span>
  100. <el-switch v-model="breadcrumbIcon" />
  101. </div>
  102. <div class="drawer-item">
  103. <span>{{ $t('le.layout.setting.multipleTabsVisible') }}</span>
  104. <el-switch v-model="tagsView" />
  105. </div>
  106. <div class="drawer-item">
  107. <span>{{ $t('le.layout.setting.pageAnimate') }}</span>
  108. <el-switch v-model="animate" />
  109. </div>
  110. <div class="drawer-item">
  111. <span>{{ $t('le.layout.setting.pageAnimateMode') }}</span>
  112. <el-select v-model="animateMode" style="width: 100px">
  113. <el-option v-for="v of animateList" :key="v.value" :value="v.value" :label="$t(v.label)" />
  114. </el-select>
  115. </div>
  116. <el-divider class="local-divider">
  117. <el-icon><Setting /></el-icon>{{ $t('le.layout.setting.title') }}
  118. </el-divider>
  119. <div class="drawer-item">
  120. <el-button type="warning" style="width: 100%" @click="handle_resetTheme"> {{ $t('le.layout.setting.reset') }} </el-button>
  121. </div>
  122. </el-scrollbar>
  123. </div>
  124. </template>
  125. <script setup lang="ts">
  126. import { storeToRefs } from 'pinia'
  127. import { LayoutType } from '@/store/interface'
  128. import ThemePicker from '@/components/ThemePicker/index.vue'
  129. // import { useDark, useToggle } from '@vueuse/core'
  130. import { useTheme } from '@/hooks/useTheme'
  131. import useStore from '@/store'
  132. import { ElMessage } from 'element-plus'
  133. // const isDark = useDark()
  134. // const toggleDark = () => useToggle(isDark)
  135. const { setting } = useStore()
  136. const { switchDark, changeGreyOrWeak, setAsideTheme, setHeaderTheme, setFooterTheme, resetTheme } = useTheme()
  137. const handle_resetTheme = () => {
  138. resetTheme()
  139. ElMessage.success('le.message.resetSuccess')
  140. }
  141. const prefix = 'le.layout.setting.'
  142. const animateList = [
  143. {
  144. label: `${prefix}animate_fade`,
  145. value: 'fade'
  146. },
  147. {
  148. label: `${prefix}animate_fadeSlide`,
  149. value: 'fade-slide'
  150. },
  151. {
  152. label: `${prefix}animate_fadeBottom`,
  153. value: 'fade-bottom'
  154. },
  155. {
  156. label: `${prefix}animate_fadeScale`,
  157. value: 'fade-scale'
  158. },
  159. {
  160. label: `${prefix}animate_zoomFade`,
  161. value: 'zoom-fade'
  162. },
  163. {
  164. label: `${prefix}animate_zoomOut`,
  165. value: 'zoom-out'
  166. }
  167. ]
  168. const {
  169. isDark,
  170. isGrey,
  171. isWeak,
  172. layout,
  173. asideInverted,
  174. headerInverted,
  175. footerInverted,
  176. footer,
  177. breadcrumb,
  178. breadcrumbIcon,
  179. tagsView,
  180. animate,
  181. animateMode
  182. } = storeToRefs(setting)
  183. function themeChange(val: any) {
  184. setting.changeSetting('themeColor', val)
  185. }
  186. // 设置布局方式
  187. const setLayout = (val: LayoutType) => {
  188. setting.changeSetting('layout', val)
  189. setAsideTheme()
  190. }
  191. // watch(
  192. // () => state.tagsView,
  193. // value => {
  194. // setting.changeSetting('tagsView', value)
  195. // }
  196. // )
  197. </script>
  198. <style lang="scss" scoped>
  199. $header_height: 55px;
  200. .drawer-wrap {
  201. position: relative;
  202. display: flex;
  203. flex-direction: column;
  204. height: 100%;
  205. //padding: 0 24px 16px 24px;
  206. padding-bottom: 10px;
  207. font-size: 14px;
  208. line-height: 1.5;
  209. word-wrap: break-word;
  210. .drawer-title {
  211. padding: 16px 24px;
  212. //margin: 0 -24px;
  213. //padding: 16px 0;
  214. height: $header_height;
  215. font-size: 16px;
  216. border-bottom: 1px solid var(--el-border-color-lighter);
  217. }
  218. /*.drawer-content {
  219. height: calc(100% - $header_height);
  220. }*/
  221. .local-divider {
  222. margin: 24px;
  223. width: auto;
  224. .el-icon {
  225. position: relative;
  226. top: 2px;
  227. right: 5px;
  228. }
  229. :deep(.el-divider__text) {
  230. width: max-content;
  231. }
  232. }
  233. .drawer-item {
  234. display: flex;
  235. align-items: center;
  236. justify-content: space-between;
  237. color: var(--el-text-color-primary);
  238. font-size: 14px;
  239. padding: 4px 24px;
  240. }
  241. .layout-box {
  242. position: relative;
  243. display: flex;
  244. flex-wrap: wrap;
  245. justify-content: space-between;
  246. //padding: 12px 6px 0;
  247. padding: 4px 24px;
  248. .layout-item {
  249. position: relative;
  250. box-sizing: border-box;
  251. width: 100px;
  252. height: 70px;
  253. padding: 6px;
  254. cursor: pointer;
  255. border-radius: 5px;
  256. box-shadow: 0 0 5px 1px var(--el-border-color-dark);
  257. transition: all 0.2s;
  258. .layout-dark {
  259. background-color: var(--el-color-primary);
  260. border-radius: 3px;
  261. }
  262. .layout-light {
  263. background-color: var(--el-color-primary-light-5);
  264. border-radius: 3px;
  265. }
  266. .layout-content {
  267. background-color: var(--el-color-primary-light-8);
  268. //border: 1px dashed var(--el-color-primary);
  269. border: 1px solid var(--el-color-primary);
  270. border-radius: 3px;
  271. }
  272. .el-icon {
  273. position: absolute;
  274. right: 10px;
  275. bottom: 10px;
  276. color: var(--el-color-primary);
  277. transition: all 0.2s;
  278. }
  279. &:hover {
  280. box-shadow: 0 0 5px 1px var(--el-text-color-secondary);
  281. }
  282. }
  283. .is-active {
  284. box-shadow: 0 0 0 2px var(--el-color-primary) !important;
  285. }
  286. .layout-left {
  287. display: flex;
  288. justify-content: space-between;
  289. margin-bottom: 12px;
  290. .layout-light {
  291. width: 20%;
  292. }
  293. .layout-container {
  294. display: flex;
  295. flex-direction: column;
  296. justify-content: space-between;
  297. width: 72%;
  298. .layout-dark {
  299. height: 20%;
  300. }
  301. .layout-content {
  302. height: 67%;
  303. }
  304. }
  305. }
  306. .layout-leftMix {
  307. display: flex;
  308. justify-content: space-between;
  309. margin-bottom: 12px;
  310. .layout-light {
  311. width: 14%;
  312. &.light-2 {
  313. width: 17%;
  314. }
  315. }
  316. .layout-container {
  317. display: flex;
  318. flex-direction: column;
  319. justify-content: space-between;
  320. width: 55%;
  321. .layout-dark {
  322. height: 20%;
  323. }
  324. .layout-content {
  325. height: 67%;
  326. width: 100%;
  327. }
  328. }
  329. }
  330. .layout-top {
  331. display: flex;
  332. flex-direction: column;
  333. justify-content: space-between;
  334. //margin-bottom: 12px;
  335. .layout-dark {
  336. height: 20%;
  337. }
  338. .layout-content {
  339. height: 67%;
  340. }
  341. }
  342. .layout-topMix {
  343. display: flex;
  344. flex-direction: column;
  345. justify-content: space-between;
  346. //margin-bottom: 12px;
  347. .layout-dark {
  348. height: 22%;
  349. }
  350. .layout-container {
  351. display: flex;
  352. justify-content: space-between;
  353. height: 70%;
  354. .layout-light {
  355. width: 20%;
  356. }
  357. .layout-content {
  358. width: 70%;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. </style>