Forráskód Böngészése

Merge branch 'master' of http://gogs.ioobot.com:6680/xy/online

xy 7 éve
szülő
commit
cb9736fe49
2 módosított fájl, 49 hozzáadás és 52 törlés
  1. 43 48
      src/components/app/App.jsx
  2. 6 4
      src/components/common/schema/Create.js

+ 43 - 48
src/components/app/App.jsx

@@ -42,17 +42,28 @@ class App extends Component {
         sessionStorage.setItem("language", "English");
         this.state = {
             menuLevel1: "graphql-service",
-            sideBar: "e-commerce",
+            sideBar: "ecommerce",
             collapsed: false,
             inlineCollapsed: false,
             locale: undefined,
             language: sessionStorage.getItem("language"),
-            visible: false,
-            userID: ''
-
+            visible: false
         };
     }
 
+    componentWillMount(){
+        console.log('window.location',window.location);
+        let urlList = window.location.pathname.split("/");
+        let urlListLength = urlList.length;
+        console.log('urlList',urlList,urlListLength);
+        if (urlListLength > 2) {
+            this.setState({menuLevel1:urlList[1]});
+            if(urlList[3] !== 'index'){
+                this.setState({sideBar:urlList[3]});
+            }
+        }
+    }
+
     onCollapse = (collapsed) => {
         // console.log(collapsed);
         this.setState({collapsed});
@@ -65,6 +76,12 @@ class App extends Component {
         });
     };
 
+    switchSidebar = (value) => {
+        this.setState({
+            sideBar:value,
+        });
+    };
+
     switchMenuLevel = (menuName, value) => {
         this.setState({
             [menuName]: value,
@@ -88,11 +105,9 @@ class App extends Component {
         let language = sessionStorage.getItem("language");
         // console.log('app language',language);
         let local = language === "中文" ? zhCN : undefined;
-        // console.log('app local',local);
         let changeLanguage = language === "中文" ? "English" : "中文";
-        // console.log('app changeLanguage',changeLanguage);
         let nowLanguage = language === "中文" ? 'zh' : 'en';
-        // console.log('app nowLanguage',nowLanguage);
+
         sessionStorage.setItem("language", changeLanguage);
         this.props.changeLanguage(nowLanguage);
         this.setState({
@@ -122,6 +137,7 @@ class App extends Component {
                             theme="dark"
                             mode="horizontal"
                             // defaultSelectedKeys={['graphql-service']}
+                            selectedKeys={[this.state.menuLevel1]}
                             style={{lineHeight: '64px'}}
                             onClick={(e) => this.switchMenu('menuLevel1', e)}
                         >
@@ -132,8 +148,8 @@ class App extends Component {
                                 <Link to="/wechat-service/trial-case/index"><FormattedMessage
                                     id="Wechat Service"/></Link>
                             </Menu.Item>
-                            <Menu.Item key="quantization-service">
-                                <Link to="/quant-service/"><FormattedMessage id="Quantization Service"/></Link>
+                            <Menu.Item key="quant-service">
+                                <Link to="/quant-service/trial-case/index"><FormattedMessage id="Quantization Service"/></Link>
                             </Menu.Item>
                         </Menu>
 
@@ -160,7 +176,7 @@ class App extends Component {
                                     >
                                         <GraphqlSidebar inlineCollapsed={this.state.inlineCollapsed}
                                                         sideBar={this.state.sideBar} switchMenu={this.switchMenu}
-                                                        userID={this.state.userID} showModal={this.showModal}/>
+                                                        showModal={this.showModal}/>
 
                                     </Sider>
                                 );
@@ -177,8 +193,8 @@ class App extends Component {
                                             theme="dark"
                                             mode="inline"
                                             inlineCollapsed={this.state.inlineCollapsed}
-                                            defaultSelectedKeys={['wechat']}
-                                            defaultOpenKeys={['trial-case']}
+                                            defaultSelectedKeys={['my-wechat']}
+                                            defaultOpenKeys={['my-create']}
                                             // openKeys={['cloud-function']}
                                             onClick={(e) => this.switchMenu('sideBar', e)}
                                             selectedKeys={[this.state.sideBar]}
@@ -191,19 +207,9 @@ class App extends Component {
                                                 position: 'fixed'
                                             }}
                                         >
-                                            {/*<SubMenu key="trial-case"*/}
-                                                     {/*title={<span><Icon type="appstore" theme="twoTone"/><span>Trial Case</span></span>}>*/}
-                                                {/*<Menu.Item key="wechat"><Link*/}
-                                                    {/*to="/wechat-service/trial-case/wechat case">wechat*/}
-                                                    {/*case</Link></Menu.Item>*/}
-                                            {/*</SubMenu>*/}
-
-                                            <SubMenu key="my-create"
-                                                     title={<span><Icon type="user"
-                                                                        theme="outlined"/><span>My Create</span></span>}>
-                                                <Menu.Item key="my wechat"><Link
-                                                    to="/wechat-service/my-create/my wechat">my
-                                                    wechat</Link></Menu.Item>
+                                            <SubMenu key="my-create" title={<span><Icon type="user" theme="outlined"/><span>My Create</span></span>}>
+                                                <Menu.Item key="my-wechat">
+                                                    <Link to="/wechat-service/my-create/my wechat">my wechat</Link></Menu.Item>
                                             </SubMenu>
 
                                             <Menu.Item key="instructions" >
@@ -215,7 +221,7 @@ class App extends Component {
                                         </Menu>
                                     </Sider>
                                 );
-                            case 'quantization-service':
+                            case 'quant-service':
                                 return (
                                     <Sider
                                         width={200}
@@ -242,19 +248,12 @@ class App extends Component {
                                                 position: 'fixed'
                                             }}
                                         >
-                                            <SubMenu key="trial-case"
-                                                     title={<span><Icon type="appstore" theme="twoTone"/><span>Case Show</span></span>}>
-                                                <Menu.Item key="quant-service"><Link to="/quant-service/">quant
-                                                    case</Link></Menu.Item>
+                                            <SubMenu key="trial-case" title={<span><Icon type="appstore" theme="twoTone"/><span>Case Show</span></span>}>
+                                                <Menu.Item key="quant-service">
+                                                    <Link to="/quant-service/trial-case/quant case">quant case</Link>
+                                                </Menu.Item>
                                             </SubMenu>
 
-                                            {/*<SubMenu key="my-create"*/}
-                                                     {/*title={<span><Icon type="user"*/}
-                                                                        {/*theme="outlined"/><span>My Create</span></span>}>*/}
-                                                {/*<Menu.Item key="my quant"><Link to="/quant-service/">my*/}
-                                                    {/*quant</Link></Menu.Item>*/}
-                                            {/*</SubMenu>*/}
-
                                             <Menu.Item key="instructions" >
                                                 <a href="https://ioobot-document.netlify.com/" title="instructions" target="instructions">
                                                     <Icon type="file-text" theme="twoTone" />
@@ -312,13 +311,13 @@ class App extends Component {
                                     >
                                         <GraphqlSidebar inlineCollapsed={this.state.inlineCollapsed}
                                                         sideBar={this.state.sideBar} switchMenu={this.switchMenu}
-                                                        userID={this.state.userID} showModal={this.showModal}/>
+                                                        showModal={this.showModal}/>
                                     </Sider>
                                 );
                         }
                     })()}
 
-                    <Create visible={visible} hideModal={this.hideModal}/>
+                    <Create visible={visible} hideModal={this.hideModal} switchSidebar={this.switchSidebar}/>
 
 
                     <LocaleProvider locale={locale}>
@@ -329,7 +328,7 @@ class App extends Component {
                                 <Route path="/graphql-service/trial-case/:case" component={TrialCase}/>
                                 <Route path="/graphql-service/my-create/:case" component={UserCreate}/>
                                 <Route path="/wechat-service/:sidebar/:case" component={WechatService}/>
-                                <Route path="/quant-service/" component={QuantService}/>
+                                <Route path="/quant-service/:sidebar/:case" component={QuantService}/>
                                 <Route path="/login" component={Login}/>
                                 <Redirect path="*" to="/"/>
                             </Switch>
@@ -348,7 +347,6 @@ class GraphqlSidebar extends Component {
         super(props);
         this.state = {
             userID: getCookie('user_id'),
-            show: false
         }
     }
 
@@ -368,9 +366,9 @@ class GraphqlSidebar extends Component {
                                 theme="dark"
                                 mode="inline"
                                 inlineCollapsed={this.props.inlineCollapsed}
-                                defaultSelectedKeys={['e-commerce']}
+                                defaultSelectedKeys={['ecommerce']}
                                 defaultOpenKeys={['trial-case', 'my-create']}
-                                // openKeys={['cloud-function']}
+                                // openKeys={['trial-case', 'my-create']}
                                 onClick={(e) => this.props.switchMenu('sideBar', e)}
                                 selectedKeys={[this.props.sideBar]}
                                 style={{
@@ -424,7 +422,7 @@ class GraphqlSidebar extends Component {
                                 </SubMenu>
 
                                 <Menu.Item key="instructions" >
-                                    <a href="https://ioobot-document.netlify.com/" title="instructions" target="instructions">
+                                    <a href="https://ioobot-document.netlify.com/" title="instructions" target="_blank" rel="noopener noreferrer">
                                         <Icon type="file-text" theme="twoTone" />
                                         <span>Instructions</span>
                                     </a>
@@ -438,7 +436,4 @@ class GraphqlSidebar extends Component {
             </Query>
         )
     }
-}
-
-// this.state.show ?
-// :''
+}

+ 6 - 4
src/components/common/schema/Create.js

@@ -41,6 +41,7 @@ class Create extends Component {
             schemaData: JSON.stringify([]),
             reference: ''
         };
+        let schemaName = this.state.schemaName;
 
         this.setState({
             confirmLoading: true,
@@ -49,7 +50,7 @@ class Create extends Component {
         create_schema({
             variables: {
                 ...varobj,
-                schemaName: this.state.schemaName
+                schemaName
             }
         });
         setTimeout(() => {
@@ -59,10 +60,11 @@ class Create extends Component {
             });
         }, 1000);
         this.props.hideModal();
+        this.props.switchSidebar(schemaName);
         this.props.history.push({
-            pathname: `/graphql-service/my-create/${this.state.schemaName}`,
+            pathname: `/graphql-service/my-create/${schemaName}`,
             state:{
-                schemaName:this.state.schemaName,
+                schemaName,
                 schemaID:varobj.id,
                 create: true
             }
@@ -91,7 +93,7 @@ class Create extends Component {
                                    visible={visible}
                                    onOk={() => this.handleOk(userID, create_schema)}
                                    confirmLoading={confirmLoading}
-                                   onCancel={() => this.props.hideModal()}
+                                   onCancel={() => {this.props.hideModal();}}
                             >
                                 <div>
                                     <p>schema name</p>