@@ -7,15 +7,20 @@ import HashHandler from '../utils/HashHandler';
77import VariableList from '../components/VariableList' ;
88import SearchError from '../components/SearchError' ;
99import Loading from '../components/Loading' ;
10+ import Donate from "../components/Donate" ;
11+ import NoticeLinks from "../components/NoticeLinks" ;
12+ import Suggestion from "../components/Suggestion" ;
1013
1114export default class MainContainer extends React . Component {
1215 state = {
16+ isZH : false ,
1317 isError : false ,
1418 isSearchingVariable : false ,
1519 searchValue : SearchcodeModel . searchValue ,
1620 searchLang : SearchcodeModel . searchLang ,
1721 page : SearchcodeModel . page ,
18- variableList : SearchcodeModel . variableList
22+ variableList : SearchcodeModel . variableList ,
23+ suggestion : SearchcodeModel . suggestion
1924 }
2025
2126 constructor ( props ) {
@@ -40,12 +45,14 @@ export default class MainContainer extends React.Component {
4045
4146 handleSearchcodeModelUpdate = ( curr , prev , mutation ) => {
4247 this . setState ( {
48+ isZH : SearchcodeModel . isZH || this . state . isZH ,
4349 isError : this . checkError ( curr ) ,
4450 isSearchingVariable : ! mutation . variableList ,
4551 searchValue : SearchcodeModel . searchValue ,
4652 searchLang : SearchcodeModel . searchLang ,
4753 page : SearchcodeModel . page ,
48- variableList : SearchcodeModel . variableList
54+ variableList : SearchcodeModel . variableList ,
55+ suggestion : SearchcodeModel . suggestion
4956 } ) ;
5057 }
5158
@@ -76,24 +83,29 @@ export default class MainContainer extends React.Component {
7683 let page = this . state . page ;
7784 if ( val === this . state . searchValue ) {
7885 page += 1 ;
86+ } else {
87+ page = 0 ;
7988 }
8089 this . setState ( { searchValue : val , isSearchingVariable : true } ) ;
8190 SearchcodeModel . requestVariable ( val , page , lang || this . state . searchLang ) ;
8291 }
8392
84- renderDefault ( ) {
93+ renderSloganImage ( ) {
8594 if ( this . state . page > 0 || this . state . variableList . length ) { return '' ; }
86- return < div className = 'default ' > < img src = "images/twohardtings.jpg" /> </ div > ;
95+ return < div className = 'slogan-image ' > < img src = "images/twohardtings.jpg" /> </ div > ;
8796 }
8897
8998 render ( ) {
9099 return (
91100 < Container className = 'main' >
92101 < Title { ...this . state } />
93102 < SearchBar placeholder = 'AI 人工智能' { ...this . state } onSearch = { this . handleSearch } />
103+ < Suggestion { ...this . state } />
94104 { this . state . isSearchingVariable ? < Loading /> : ( this . state . isError ? < SearchError /> : '' ) }
95- { this . renderDefault ( ) }
105+ { this . renderSloganImage ( ) }
96106 < VariableList { ...this . state } />
107+ { this . state . variableList . length ? < Donate { ...this . state } /> : '' }
108+ < NoticeLinks />
97109 </ Container >
98110 )
99111 }
0 commit comments