Commit 49e4f5fee290fed4ca735e719a3acf33752fd5cd
1 parent
e36427d3
同步换肤功能;
Showing
5 changed files
with
213 additions
and
2 deletions
src/components/Common/PersonCenter/PersonCenter.js
| @@ -30,7 +30,7 @@ import OnlineUser from '@/assets/onlineUser.svg'; | @@ -30,7 +30,7 @@ import OnlineUser from '@/assets/onlineUser.svg'; | ||
| 30 | // import StaticEditTable from '@/components/Common/CommonTable'; | 30 | // import StaticEditTable from '@/components/Common/CommonTable'; |
| 31 | import * as commonServices from '@/services/services'; | 31 | import * as commonServices from '@/services/services'; |
| 32 | import commonConfig from '../../../utils/config'; | 32 | import commonConfig from '../../../utils/config'; |
| 33 | -// import SkinChangeModal from './SkinChangeModal'; | 33 | +import SkinChangeModal from './SkinChangeModal'; |
| 34 | import MenuSearchPopovor from './MenuSearchPopovor'; | 34 | import MenuSearchPopovor from './MenuSearchPopovor'; |
| 35 | import SwitchCompanyAndLanguage from './SwitchCompanyAndLanguage'; | 35 | import SwitchCompanyAndLanguage from './SwitchCompanyAndLanguage'; |
| 36 | 36 |
src/components/Common/PersonCenter/SkinChangeModal copy.js
0 → 100644
| 1 | +/* eslint-disable */ | ||
| 2 | +import React, { useEffect, useRef, useState } from "react"; | ||
| 3 | +import AntdDraggableModal from "@/components/Common/AntdDraggableModal"; | ||
| 4 | +import styles from "@/routes/indexPage.less"; | ||
| 5 | + | ||
| 6 | +const skinList = [ | ||
| 7 | + { | ||
| 8 | + name: "default", | ||
| 9 | + color1: "#383d41", | ||
| 10 | + color2: "#303538" | ||
| 11 | + }, | ||
| 12 | + { | ||
| 13 | + name: "color1", | ||
| 14 | + color1: "#6e5064", | ||
| 15 | + color2: "#b482a4" | ||
| 16 | + }, | ||
| 17 | + { | ||
| 18 | + name: "color2", | ||
| 19 | + color1: "#0010fc", | ||
| 20 | + color2: "#515bf3" | ||
| 21 | + }, | ||
| 22 | + { | ||
| 23 | + name: "color3", | ||
| 24 | + color1: "#433598", | ||
| 25 | + color2: "#7160d5" | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + name: "color4", | ||
| 29 | + color1: "#e1408e", | ||
| 30 | + color2: "#c56f98" | ||
| 31 | + }, | ||
| 32 | + { | ||
| 33 | + name: "color5", | ||
| 34 | + color1: "#f46b5f", | ||
| 35 | + color2: "#e69892" | ||
| 36 | + }, | ||
| 37 | + { | ||
| 38 | + name: "color6", | ||
| 39 | + color1: "#fa375c", | ||
| 40 | + color2: "#eb8498" | ||
| 41 | + }, | ||
| 42 | + { | ||
| 43 | + name: "color7", | ||
| 44 | + color1: "#6f41ed", | ||
| 45 | + color2: "#8b70d5" | ||
| 46 | + }, | ||
| 47 | + { | ||
| 48 | + name: "color8", | ||
| 49 | + color1: "#fd4138", | ||
| 50 | + color2: "#e3736e" | ||
| 51 | + } | ||
| 52 | +]; | ||
| 53 | + | ||
| 54 | +const SkinChangeModal = props => { | ||
| 55 | + const { skinChangeModalVisible, handleCancel } = props; | ||
| 56 | + const [currentSkin, setCurrentSkin] = useState( | ||
| 57 | + localStorage.getItem("xly-skin") || "default" | ||
| 58 | + ); | ||
| 59 | + const oldSkin = useRef(null); | ||
| 60 | + useEffect(() => { | ||
| 61 | + // getComputedStyle(oBody).getPropertyValue('--xly-login-header-logo') | ||
| 62 | + const oBody = document.querySelector("body"); | ||
| 63 | + oldSkin.current = oBody.getAttribute("data-skin"); | ||
| 64 | + }, []); | ||
| 65 | + | ||
| 66 | + const handleCancelSelf = () => { | ||
| 67 | + const oBody = document.querySelector("body"); | ||
| 68 | + oBody.setAttribute("data-skin", oldSkin.current); | ||
| 69 | + handleCancel(); | ||
| 70 | + }; | ||
| 71 | + | ||
| 72 | + const handleOk = () => { | ||
| 73 | + localStorage.setItem("xly-skin", currentSkin); | ||
| 74 | + handleCancel(); | ||
| 75 | + }; | ||
| 76 | + | ||
| 77 | + const handleChooseSkin = ({ name }) => { | ||
| 78 | + setCurrentSkin(name); | ||
| 79 | + const oBody = document.querySelector("body"); | ||
| 80 | + oBody.setAttribute("data-skin", name); | ||
| 81 | + }; | ||
| 82 | + | ||
| 83 | + return skinChangeModalVisible ? ( | ||
| 84 | + <AntdDraggableModal | ||
| 85 | + title={"主题肤色"} | ||
| 86 | + visible={skinChangeModalVisible} | ||
| 87 | + width={600} | ||
| 88 | + onOk={handleOk} | ||
| 89 | + onCancel={handleCancelSelf} | ||
| 90 | + > | ||
| 91 | + <div className={styles.skinChangeModal}> | ||
| 92 | + {skinList.map(item => { | ||
| 93 | + const { color1, color2, name } = item; | ||
| 94 | + return ( | ||
| 95 | + <div | ||
| 96 | + className="skinChangeOption" | ||
| 97 | + onClick={() => { | ||
| 98 | + handleChooseSkin(item); | ||
| 99 | + }} | ||
| 100 | + > | ||
| 101 | + <div className="skinChangeOptionLeft"> | ||
| 102 | + <div | ||
| 103 | + className="skinChangeOptionColor2" | ||
| 104 | + style={{ background: color2 }} | ||
| 105 | + /> | ||
| 106 | + </div> | ||
| 107 | + <div className="skinChangeOptionRight"> | ||
| 108 | + <div | ||
| 109 | + className="skinChangeOptionColor1" | ||
| 110 | + style={{ background: color1 }} | ||
| 111 | + /> | ||
| 112 | + {currentSkin === name ? ( | ||
| 113 | + <div className="skinChangeChecked">✓</div> | ||
| 114 | + ) : ( | ||
| 115 | + "" | ||
| 116 | + )} | ||
| 117 | + </div> | ||
| 118 | + </div> | ||
| 119 | + ); | ||
| 120 | + })} | ||
| 121 | + </div> | ||
| 122 | + </AntdDraggableModal> | ||
| 123 | + ) : ( | ||
| 124 | + "" | ||
| 125 | + ); | ||
| 126 | +}; | ||
| 127 | + | ||
| 128 | +export default SkinChangeModal; |
src/components/Common/PersonCenter/SkinChangeModal.js
| 1 | /* eslint-disable */ | 1 | /* eslint-disable */ |
| 2 | import React, { useEffect, useRef, useState } from "react"; | 2 | import React, { useEffect, useRef, useState } from "react"; |
| 3 | import AntdDraggableModal from "@/components/Common/AntdDraggableModal"; | 3 | import AntdDraggableModal from "@/components/Common/AntdDraggableModal"; |
| 4 | -import styles from "@/routes/IndexPage.less"; | 4 | +import styles from "@/routes/indexPage.less"; |
| 5 | 5 | ||
| 6 | const skinList = [ | 6 | const skinList = [ |
| 7 | { | 7 | { |
src/global.less
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | @import "./index.less"; | 2 | @import "./index.less"; |
| 3 | @import "./default.less"; | 3 | @import "./default.less"; |
| 4 | @import "./variable.less"; | 4 | @import "./variable.less"; |
| 5 | +@import "./skinchange.less"; | ||
| 5 | 6 | ||
| 6 | .ant-card-head { | 7 | .ant-card-head { |
| 7 | border-bottom: 1px solid #d9d9d9; | 8 | border-bottom: 1px solid #d9d9d9; |
src/skinchange.less
0 → 100644
| 1 | +:root { | ||
| 2 | + body[data-skin=default] { | ||
| 3 | + --xly-skin-header-color: #383d41; // 顶部导航栏背景色 | ||
| 4 | + --xly-skin-menu-color: #343848; // 左侧一级菜单背景色 | ||
| 5 | + --xly-skin-menu-span-color: #ccd6df; // 菜单字体色 | ||
| 6 | + --xly-skin-submenu-color: #303538; // 展开后二级菜单背景色 | ||
| 7 | + --xly-skin-active-color: #1890FF; // 激活色 | ||
| 8 | + --xly-skin-modal-bg-color: #646464; // modal弹窗header背景色 | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + body[data-skin=color1] { | ||
| 12 | + --xly-skin-header-color: #6e5064; | ||
| 13 | + --xly-skin-menu-color: #b482a4; | ||
| 14 | + --xly-skin-menu-span-color: #FFF; | ||
| 15 | + --xly-skin-submenu-color: #7c5a71; | ||
| 16 | + --xly-skin-active-color: #84c015; | ||
| 17 | + --xly-skin-modal-bg-color: #6e5064; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + body[data-skin=color2] { | ||
| 21 | + --xly-skin-header-color: #0010fc; | ||
| 22 | + --xly-skin-menu-color: #515bf3; | ||
| 23 | + --xly-skin-menu-span-color: #FFF; | ||
| 24 | + --xly-skin-submenu-color: #656ab3; | ||
| 25 | + --xly-skin-active-color: #dd8547; | ||
| 26 | + --xly-skin-modal-bg-color: #0010fc; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + body[data-skin=color3] { | ||
| 30 | + --xly-skin-header-color: #433598; | ||
| 31 | + --xly-skin-menu-color: #7160d5; | ||
| 32 | + --xly-skin-menu-span-color: #FFF; | ||
| 33 | + --xly-skin-submenu-color: #624fce; | ||
| 34 | + --xly-skin-active-color: #dd8547; | ||
| 35 | + --xly-skin-modal-bg-color: #433598; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + body[data-skin=color4] { | ||
| 39 | + --xly-skin-header-color: #e1408e; | ||
| 40 | + --xly-skin-menu-color: #c56f98; | ||
| 41 | + --xly-skin-menu-span-color: #FFF; | ||
| 42 | + --xly-skin-submenu-color: #cd5790; | ||
| 43 | + --xly-skin-active-color: #03bcff; | ||
| 44 | + --xly-skin-modal-bg-color: #e1408e; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + body[data-skin=color5] { | ||
| 48 | + --xly-skin-header-color: #f46b5f; | ||
| 49 | + --xly-skin-menu-color: #e69892; | ||
| 50 | + --xly-skin-menu-span-color: #FFF; | ||
| 51 | + --xly-skin-submenu-color: #c6655e; | ||
| 52 | + --xly-skin-active-color: #cdd32b; | ||
| 53 | + --xly-skin-modal-bg-color: #f46b5f; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + body[data-skin=color6] { | ||
| 57 | + --xly-skin-header-color: #fa375c; | ||
| 58 | + --xly-skin-menu-color: #eb8498; | ||
| 59 | + --xly-skin-menu-span-color: #FFF; | ||
| 60 | + --xly-skin-submenu-color: #cc576f; | ||
| 61 | + --xly-skin-active-color: #cdd32b; | ||
| 62 | + --xly-skin-modal-bg-color: #fa375c; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + body[data-skin=color7] { | ||
| 66 | + --xly-skin-header-color: #6f41ed; | ||
| 67 | + --xly-skin-menu-color: #8b70d5; | ||
| 68 | + --xly-skin-menu-span-color: #FFF; | ||
| 69 | + --xly-skin-submenu-color: rgb(76, 82, 169); | ||
| 70 | + --xly-skin-active-color: #cdd32b; | ||
| 71 | + --xly-skin-modal-bg-color: #6f41ed; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + body[data-skin=color8] { | ||
| 75 | + --xly-skin-header-color: #fd4138; | ||
| 76 | + --xly-skin-menu-color: #e3736e; | ||
| 77 | + --xly-skin-menu-span-color: #FFF; | ||
| 78 | + --xly-skin-submenu-color: #c3514b; | ||
| 79 | + --xly-skin-active-color: #cdd32b; | ||
| 80 | + --xly-skin-modal-bg-color: #fd4138; | ||
| 81 | + } | ||
| 82 | +} | ||
| 0 | \ No newline at end of file | 83 | \ No newline at end of file |