index.vue 11 KB

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