Browse Source

fix -> 修改页面内容

Young 1 year ago
parent
commit
61b6fb0334

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

@@ -244,10 +244,10 @@ class Header extends PureComponent {
                 size: 10
             }
         }).then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 let Time = setTimeout(() => {
                     this.setState({
-                        menuList: res.models,
+                        menuList: res.data,
                         loading: true
                     });
                     clearTimeout(Time);
@@ -270,7 +270,7 @@ class Header extends PureComponent {
 
     login() {
         axios.get('/auth/github/v1/get').then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 openWindow(res.model.authorizeUrl, "绑定GitHub", 540, 540);
                 window.addEventListener("message", this.loginGithubHandel, false);
             }
@@ -290,7 +290,7 @@ class Header extends PureComponent {
                     htmlUrl: htmlUrl
                 }
             }).then((res) => {
-                if (res.success === 1) {
+                if (res.code === 0) {
                     setToken(res.model.token);
                     setAvatar(res.model.avatar);
                     this.setState({isUser: true});

+ 6 - 7
src/components/Header/store/actionCreators.js

@@ -11,8 +11,8 @@ const changeCategory = (data) => ({
 export const getCategory = () => {
     return (dispatch) => {
         axios.get('api/v1/category/list').then((res) => {
-            if (res.success === 1) {
-                dispatch(changeCategory(res.models));
+            if (res.code === 0) {
+                dispatch(changeCategory(res.data));
             }
         })
     }
@@ -21,7 +21,7 @@ export const getCategory = () => {
 export const getUser = () => {
     return (dispatch) => {
         // axios.get('/auth/master/v1/get').then((res) => {
-        //     if (res.success === 1) {
+        //     if (res.code === 0) {
         //         dispatch({
         //             type: constants.GET_USER,
         //             data: fromJS(res.model)
@@ -34,10 +34,9 @@ export const getUser = () => {
 export const getConfing = () => {
     return (dispatch) => {
         axios.get('api/v1/config/list').then((res) => {
-            if (res.success === 1) {
-                const {models} = res;
-                let data = {};
-                models.forEach(item => {
+            if (res.code === 0) {
+                const {data} = res;
+                data.forEach(item => {
                     if (item.configKey === "name") {
                         data.title = item.configValue;
                     }

+ 1 - 1
src/lib/auth.js

@@ -38,7 +38,7 @@ export function loginGithubHandel(e) {
                 htmlUrl: htmlUrl
             }
         }).then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 setToken(res.model.token);
                 setAvatar(res.model.avatar);
                 message.success('登录成功');

+ 2 - 2
src/pages/archives/index.js

@@ -105,9 +105,9 @@ class Archives extends PureComponent {
     getArchives() {
         this.setState({loading: true});
         axios.get('api/v1/post/archive/list').then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 this.setState({
-                    list: res.models,
+                    list: res.data,
                     loading: false
                 })
             }

+ 4 - 4
src/pages/article/components/Comments.js

@@ -139,7 +139,7 @@ class Comments extends PureComponent {
             url: '/comments/comments/v1/add',
             data: data
         }).then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 message.success('评论成功');
                 this.setState({
                     value: '',
@@ -154,7 +154,7 @@ class Comments extends PureComponent {
 
     login() {
         axios.get('/auth/github/v1/get').then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 openWindow(res.model.authorizeUrl, "绑定GitHub", 540, 540);
                 window.addEventListener("message", loginGithubHandel, false);
             }
@@ -169,9 +169,9 @@ class Comments extends PureComponent {
                 postsId: id
             }
         }).then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 this.setState({
-                    commentsList: res.models,
+                    commentsList: res.data,
                     pageInfo: res.pageInfo
                 })
             }

+ 8 - 5
src/pages/article/index.js

@@ -89,10 +89,10 @@ class Article extends PureComponent {
     }
 
     getDetail(id) {
-        axios.get('/posts/posts/v1/' + id).then((res) => {
-            if (res.success === 1) {
+        axios.get('/api/v1/post/' + id).then((res) => {
+            if (res.code === 0) {
                 this.setState({
-                    content: res.model
+                    content: res.data
                 })
             } else {
                 this.props.history.push('/404');
@@ -102,12 +102,15 @@ class Article extends PureComponent {
 
     getSocials() {
         axios.get('/social/social/v1/socials?code=reward').then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 this.setState({
-                    socialsList: res.models
+                    socialsList: res.data
                 })
             }
         });
+        this.setState({
+            socialsList: []
+        })
     }
 
     setSocials(socialsList) {

+ 1 - 1
src/pages/category/index.js

@@ -58,7 +58,7 @@ class Category extends PureComponent {
                 categoryId: id
             }
         }).then((res) => {
-            if (res.code === 1) {
+            if (res.code === 0) {
                 let current = res.data.current * res.data.size;
                 let total = res.data.total;
                 const data = res.data.records;

+ 17 - 17
src/pages/home/components/Banner.js

@@ -92,23 +92,23 @@ class Banner extends PureComponent {
     }
 
     componentDidMount() {
-        // axios.get('/social/social/v1/info').then((res) => {
-        //     if (res.success === 1) {
-        //         const {models} = res;
-        //         let array = [];
-        //         for (let i = 0; i < models.length; i++) {
-        //             array.push({
-        //                 show: false,
-        //                 icon: models[i].icon,
-        //                 content: models[i].content,
-        //                 showType: models[i].showType,
-        //             })
-        //         }
-        //         this.setState({
-        //             info: array
-        //         })
-        //     }
-        // });
+        axios.get('/api/v1/social/list').then((res) => {
+            if (res.code === 0) {
+                const {data} = res;
+                let array = [];
+                for (let i = 0; i < data.length; i++) {
+                    array.push({
+                        show: false,
+                        icon: data[i].icon,
+                        content: data[i].content,
+                        showType: data[i].showType,
+                    })
+                }
+                this.setState({
+                    info: array
+                })
+            }
+        });
     }
 }
 

+ 3 - 3
src/pages/home/components/List.js

@@ -142,12 +142,12 @@ const mapDispatch = (dispatch) => {
                     size: 10
                 }
             }).then((res) => {
-                if (res.code === 1) {
-                    let current = res.data.current * res.data.size;
+                if (res.code === 0) {
+                    let current = res.data.current;
                     let total = res.data.total;
                     let data = list(this.ListImg, res.data.records);
                     dispatch(setBlogList(data, current + 1, override));
-                    if (current > total) dispatch(setfinished());
+                    if ((current * res.data.size) > total) dispatch(setfinished());
                 }
             });
         },

+ 1 - 1
src/pages/home/store/actionCreators.js

@@ -15,7 +15,7 @@ export const getFeature = () => {
         //         size: 3
         //     }
         // }).then(function (res) {
-        //     if (res.success === 1) {
+        //     if (res.code === 0) {
         //         dispatch(setFeature(res.models));
         //     }
         // });

+ 1 - 1
src/pages/links/index.js

@@ -104,7 +104,7 @@ class Links extends PureComponent {
                     list: extra[i]
                 });
             }
-            if (res.success === 1) {
+            if (res.code === 0) {
                 this.setState({
                     list: arrar,
                     loading: false

+ 1 - 1
src/pages/search/index.js

@@ -47,7 +47,7 @@ class Search extends PureComponent {
                 keywords: key
             }
         }).then((res) => {
-            if (res.code === 1) {
+            if (res.code === 0) {
                 let current = res.data.current * res.data.size;
                 let total = res.data.total;
                 const data = res.data.records;

+ 2 - 2
src/pages/tags/index.js

@@ -71,9 +71,9 @@ class Tags extends PureComponent {
     getTags() {
         this.setState({loading: true});
         axios.get('/tags/tags-article-quantity/v1/list').then((res) => {
-            if (res.success === 1) {
+            if (res.code === 0) {
                 this.setState({
-                    list: res.models,
+                    list: res.data,
                     loading: false
                 })
             }

+ 1 - 1
src/pages/tags/list.js

@@ -58,7 +58,7 @@ class TagList extends PureComponent {
                 postsTagsId: id
             }
         }).then((res) => {
-            if (res.code === 1) {
+            if (res.code === 0) {
                 let current = res.data.current * res.data.size;
                 let total = res.data.total;
                 const data = res.data.records;