Przeglądaj źródła

fix -> 补充用户相关内容

Young 1 rok temu
rodzic
commit
36b671b24f

+ 9 - 7
src/components/Footer/index.js

@@ -5,19 +5,21 @@ import {withRouter} from "react-router-dom";
 
 class Footer extends PureComponent {
     render() {
-        const {copyright, domain, icp, title} = this.props.confing.toJS();
+        const {copyright, domain, icp, icpLink, title} = this.props.config.toJS();
         return (
             <Footers>
                 <div className='site-info'>
                     <div className='footertext'>
                         <p className='foo-logo'/>
-                        <p>项目托管于<a href={'https://www.aliyun.com/sale-season/2020/procurement-new-members?userCode=fzfxtn3t'}>阿里云</a></p>
+                        <p>项目托管于<a
+                            href={'https://www.aliyun.com/sale-season/2020/procurement-new-members?userCode=fzfxtn3t'}>阿里云</a>
+                        </p>
                         <p className='name'>
-                            <span>
-                                <a href={domain} rel="noopener noreferrer" target={'_blank'}>{copyright}</a>
-                            </span>
+                            <span><a href={domain} rel="noopener noreferrer" target={'_blank'}>{copyright}</a></span>
+                        </p>
+                        <p>
+                            <span><a href={icpLink} rel="noopener noreferrer" target="_blank">© 2020 {title} {icp}</a></span>
                         </p>
-                        <p>© 2020 {title} <a href="http://www.beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer">{icp}</a></p>
                     </div>
                 </div>
             </Footers>
@@ -27,7 +29,7 @@ class Footer extends PureComponent {
 
 const mapStateToProps = (state) => {
     return {
-        confing: state.getIn(['header', 'confing']),
+        config: state.getIn(['header', 'config']),
     }
 };
 

+ 5 - 5
src/components/Header/index.js

@@ -31,7 +31,7 @@ class Header extends PureComponent {
         // this.state.loading = true
         const {isVisible, value, open, isUser, menuList, loading} = this.state;
         const {category} = this.props;
-        const {title, domain} = this.props.confing.toJS();
+        const {title, domain} = this.props.config.toJS();
         const {name, introduction, avatar} = this.props.userInfo.toJS();
         if (title) document.title = title;
         return (
@@ -232,7 +232,7 @@ class Header extends PureComponent {
     componentDidMount() {
         this.props.getCategory();
         this.props.getUser();
-        this.props.getConfing();
+        this.props.getConfig();
         this.getMenu();
     }
 
@@ -359,7 +359,7 @@ class Header extends PureComponent {
 const mapStateToProps = (state) => {
     return {
         category: state.getIn(['header', 'category']),
-        confing: state.getIn(['header', 'confing']),
+        config: state.getIn(['header', 'config']),
         userInfo: state.getIn(['header', 'userInfo']),
     }
 };
@@ -372,8 +372,8 @@ const mapDispatchToProps = (dispatch) => {
         getUser() {
             dispatch(actionCreators.getUser());
         },
-        getConfing() {
-            dispatch(actionCreators.getConfing());
+        getConfig() {
+            dispatch(actionCreators.getConfig());
         }
     }
 };

+ 17 - 12
src/components/Header/store/actionCreators.js

@@ -20,23 +20,23 @@ export const getCategory = () => {
 
 export const getUser = () => {
     return (dispatch) => {
-        // axios.get('/auth/master/v1/get').then((res) => {
-        //     if (res.code === 0) {
-        //         dispatch({
-        //             type: constants.GET_USER,
-        //             data: fromJS(res.model)
-        //         });
-        //     }
-        // })
+        axios.get('/api/v1/user/master/simple').then((res) => {
+            if (res.code === 0) {
+                dispatch({
+                    type: constants.GET_USER,
+                    data: fromJS(res.data)
+                });
+            }
+        })
     }
 };
 
-export const getConfing = () => {
+export const getConfig = () => {
     return (dispatch) => {
         axios.get('/api/v1/config/list').then((res) => {
             if (res.code === 0) {
-                const {data} = res;
-                data.forEach(item => {
+                let data = {};
+                res.data.forEach(item => {
                     if (item.configKey === "name") {
                         data.title = item.configValue;
                     }
@@ -66,9 +66,14 @@ export const getConfing = () => {
                     if (item.configKey === "icp") {
                         data.icp = item.configValue;
                     }
+                    if (item.configKey === "icpLink") {
+                        data.icpLink = item.configValue
+                    }
                 });
+
+                console.log("获取配置内容:" + data.icpLink)
                 dispatch({
-                    type: constants.GET_CONFING,
+                    type: constants.GET_CONFIG,
                     data: fromJS(data)
                 });
             }

+ 1 - 1
src/components/Header/store/constants.js

@@ -1,3 +1,3 @@
 export const GET_CATEGORY = 'header/GET_CATEGORY';
 export const GET_USER = 'header/GET_USER';
-export const GET_CONFING = 'header/GET_CONFING';
+export const GET_CONFIG = 'header/GET_CONFIG';

+ 3 - 3
src/components/Header/store/reducer.js

@@ -4,7 +4,7 @@ import {fromJS} from 'immutable';
 const defaultState = fromJS({
     category: [],
     userInfo: {},
-    confing: {}
+    config: {}
 });
 
 //immutable对象的set方法,会结合之前的immutable对象的值和设置的值,返回一个全新的对象
@@ -18,9 +18,9 @@ export default (state = defaultState, action) => {
             return state.merge({
                 userInfo: action.data
             });
-        case constants.GET_CONFING:
+        case constants.GET_CONFIG:
             return state.merge({
-                confing: action.data
+                config: action.data
             });
         default:
             return state;